Skip to content

Commit

Permalink
target api 17 to give nice styling on ICS devices, new background
Browse files Browse the repository at this point in the history
pattern, swap nasty toggle button for check box, added code to
enabled/disable boot receiver to save it running all the time.
  • Loading branch information
scottyab committed Jun 6, 2013
1 parent f5925df commit 03e2063
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 119 deletions.
36 changes: 26 additions & 10 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eslack.rootadb"
android:versionCode="2"
android:versionName="1.1">
<uses-sdk android:minSdkVersion="4" />
package="org.eslack.rootadb"
android:versionCode="3"
android:versionName="1.1" >

<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name="RootAdb"
android:label="@string/app_name">

<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name" >
<activity
android:name="RootAdb"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SettingsActivity" android:label="RootAdb settings" />
<receiver android:name=".BootReceiver">
<activity
android:name=".SettingsActivity"
android:label="RootAdb settings" />

<receiver
android:name=".BootReceiver"
android:enabled="false" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>

</manifest>
Binary file added res/drawable-nodpi/knitting250px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions res/drawable/knitting_gradident.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
android:src="@drawable/knitting250px"
android:tileMode="repeat" />
</item>
<item>
<shape>
<gradient
android:angle="270"
android:endColor="#2C000000"
android:startColor="#B3000000" />
</shape>
<shape>
<gradient
android:angle="270"
android:centerColor="#000000"
android:centerY="0.1"
android:endColor="#c8c8c8"
android:startColor="#000000" />
</shape>
</item>

</layer-list>
68 changes: 32 additions & 36 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffffff"
android:padding="15dp"
>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/knitting_gradident"
android:orientation="vertical"
android:padding="15dp" >

<LinearLayout
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="2dp" >

<ToggleButton
android:id="@+id/togglebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOn="insecure adb"
android:textOff="secure adb"
android:onClick="onToggleClicked"/>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onToggleClicked" />
</LinearLayout>

</LinearLayout>
<ScrollView
android:id="@+id/widget48"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000" >

<ScrollView
android:id="@+id/widget48"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff000000">
<TextView
android:id="@+id/outputView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:padding="2dp"
android:textColor="#ffffffff" >
</TextView>
</ScrollView>

<TextView android:id="@+id/outputView"
android:padding="2dp"
android:background="#ff000000"
android:textColor="#ffffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>

</ScrollView>

</LinearLayout>
</LinearLayout>
6 changes: 5 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">RootAdb</string>
</resources>
<string name="button_on">secure adb</string>
<string name="button_off">insecure adb</string>

</resources>
86 changes: 49 additions & 37 deletions src/org/eslack/rootadb/RootAdb.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
/*
rootadb
(c) 2013 Pau Oliva Fora <pof[at]eslack[dot]org>
*/
*/
package org.eslack.rootadb;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;

import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

public class RootAdb extends Activity {

private TextView outputView;
private Handler handler = new Handler();
private ToggleButton toggle;

private Context context;
private Utils mUtils;
private Utils mUtils;
private CheckBox check;

/** Called when the activity is first created. */
@Override
Expand All @@ -34,37 +30,52 @@ public void onCreate(Bundle savedInstanceState) {

mUtils = new Utils(getApplicationContext());

outputView = (TextView)findViewById(R.id.outputView);
initViews();
}

@Override
protected void onStart() {
super.onStart();
updateUi(isAdbRoot());
}

private void initViews() {
outputView = (TextView) findViewById(R.id.outputView);

toggle = (ToggleButton) findViewById(R.id.togglebutton);
check = (CheckBox) findViewById(R.id.checkBox1);

toggle.setClickable(false);
check.setClickable(false);

toggle.setChecked(isAdbRoot());
updateUi(isAdbRoot());

toggle.setClickable(true);
check.setClickable(true);
}

private void updateUi(boolean rootadbEnabled) {
check.setText(rootadbEnabled ? R.string.button_on : R.string.button_off);
check.setChecked(rootadbEnabled);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, 0, 0, "Settings");
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
startActivity(new Intent(this, SettingsActivity.class));
return true;
}
return false;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, 0, 0, "Settings");
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
startActivity(new Intent(this, SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}

public void onToggleClicked(View view) {
toggle.setClickable(false);
boolean on = ((ToggleButton) view).isChecked();
check.setClickable(false);

boolean on = ((CheckBox) view).isChecked();

if (on) {
output("\nrestarting adb daemon with root privileges\n");
Expand All @@ -78,17 +89,18 @@ public void onToggleClicked(View view) {
public void run() {
mUtils.doTheMeat();
isAdbRoot();
toggle.setClickable(true);
check.setClickable(true);
}
});
thread.start();

}
}

private void output(final String str) {
Runnable proc = new Runnable() {
public void run() {
if (str!=null) outputView.append(str);
if (str != null)
outputView.append(str);
}
};
handler.post(proc);
Expand Down
50 changes: 39 additions & 11 deletions src/org/eslack/rootadb/SettingsActivity.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
/*
rootadb
(c) 2013 Pau Oliva Fora <pof[at]eslack[dot]org>
*/
*/
package org.eslack.rootadb;

import org.eslack.rootadb.Utils;

import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;

public class SettingsActivity extends PreferenceActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}

}

private CheckBoxPreference mStartOnBootPreference;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);

mStartOnBootPreference = (CheckBoxPreference) getPreferenceScreen()
.findPreference("start_onboot");

// toggle BootReceiver on/off
mStartOnBootPreference
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

@Override
public boolean onPreferenceChange(Preference preference,
Object newValue) {

if (newValue instanceof Boolean) {
if ((Boolean) newValue) {
Utils.enableReceiver(getApplicationContext(),
BootReceiver.class);
} else {
Utils.disableReceiver(getApplicationContext(),
BootReceiver.class);
}
return true;
}
return false;
}
});

}

}
Loading

0 comments on commit 03e2063

Please sign in to comment.