Permissions screen added

This commit is contained in:
Sathyanarayanan Gunasekaran 2011-06-04 02:12:06 +05:30
parent 3181d00c1d
commit 6af2989ab8
6 changed files with 256 additions and 10 deletions

View File

@ -27,7 +27,7 @@ provided guidance in the entire effort.
Adam Langley made the original valiant effort to port Tor to Android. Adam Langley made the original valiant effort to port Tor to Android.
Sathyanarayanan <gsathya.ceg@gmail.com> created a patch for the wizard Sathyanarayanan <me@gsathya.in> created a patch for the wizard
which updated the icon and link for the secure chat app info to point which updated the icon and link for the secure chat app info to point
to Gibberbot, and hopefully will continue to contribute useful patches. to Gibberbot, and hopefully will continue to contribute useful patches.

View File

@ -30,6 +30,7 @@
</activity> </activity>
<activity android:name=".LotsaText"/> <activity android:name=".LotsaText"/>
<activity android:name=".Permissions"/>
<activity android:name=".SettingsPreferences" android:label="@string/app_name"/> <activity android:name=".SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".AppManager" android:label="@string/app_name"/> <activity android:name=".AppManager" android:label="@string/app_name"/>
<activity android:name=".WizardActivity" android:label="@string/app_name"/> <activity android:name=".WizardActivity" android:label="@string/app_name"/>

View File

@ -0,0 +1,67 @@
<?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="@drawable/background">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relativeLayout1"
android:layout_gravity="center_horizontal">
<ImageView
android:src="@drawable/tor"
android:visibility="invisible"
android:id="@+id/orbot_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingLeft="20px" android:paddingRight="20px" >
</ImageView>
<TextView android:textSize="10pt"
android:layout_toRightOf="@id/orbot_image"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:id="@+id/WizardTextTitle"
android:layout_width="wrap_content"
android:fadingEdge="vertical"
android:text="TITLE"
android:textColor="#00ff00"
android:singleLine="true"
android:layout_centerInParent="true"
android:padding="20px">
</TextView>
</RelativeLayout>
<TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*" android:layout_height="fill_parent" android:layout_width="wrap_content">
<TableRow android:id="@+id/TableRow01" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ScrollView android:id="@+id/helpscrollview"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_span="3">
<LinearLayout android:layout_width="wrap_content" android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:padding="6px" android:id="@+id/WizardTextBody1" android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text"></TextView>
<Button android:layout_width="wrap_content" android:visibility="gone" android:layout_height="wrap_content" android:gravity="center" android:text="Grant Permission" android:id="@+id/grantPermissions" android:layout_gravity="center"></Button>
<TextView android:layout_width="wrap_content" android:visibility="gone" android:textColor="#ffffff" android:layout_height="wrap_content" android:background="#222222" android:textSize="8pt" android:padding="6px" android:id="@+id/WizardTextBody2" android:text="this is sample text this is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample textthis is sample text"></TextView>
</LinearLayout>
</ScrollView>
</TableRow>
<TableRow android:id="@+id/TableRow01" android:textColor="#00ff00" android:layout_width="fill_parent" android:layout_height="30px">
<Button android:text="Back" android:id="@+id/btnWizard1" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
<Button android:text="Next" android:id="@+id/btnWizard2" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</LinearLayout>

View File

@ -137,6 +137,9 @@
<string name="wizard_warning_msg">Simply installing Orbot will not automatically anonymize your mobile traffic.\nPlease follow the following steps to get started</string> <string name="wizard_warning_msg">Simply installing Orbot will not automatically anonymize your mobile traffic.\nPlease follow the following steps to get started</string>
<!-- Permissions screen --> <!-- Permissions screen -->
<string name="wizard_permissions_title">Permissions</string> <string name="wizard_permissions_title">Permissions</string>
<string name="wizard_permissions_root_msg1">Orbot has detected that you have root permissions enabled. To enable \'Transparent Proxying\', please grant superuser privileges to Orbot</string>
<string name="wizard_permissions_root_msg2">If you choose to continue without providing superuser privileges, make sure to use apps made to work with orbot</string>
<string name="wizard_permissions_msg">Orbot has detected that you do not have root permissions.\nTransparent Proxying is not possible without superuser privileges.\nMake sure to use apps that have been configured to work with Orbot</string>
</resources> </resources>

View File

@ -2,6 +2,7 @@ package org.torproject.android;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -24,13 +25,10 @@ public class LotsaText extends Activity implements TorConstants{
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
if (step == -1)
{
setContentView(R.layout.scrollingtext_buttons_view); setContentView(R.layout.scrollingtext_buttons_view);
stepOne(); stepOne();
}
} }
@Override @Override
@ -52,7 +50,6 @@ public class LotsaText extends Activity implements TorConstants{
*/ */
private void stepOne() { private void stepOne() {
step++;
//setContentView(R.layout.scrollingtext_buttons_view); //setContentView(R.layout.scrollingtext_buttons_view);
String title = context.getString(R.string.wizard_title); String title = context.getString(R.string.wizard_title);
@ -82,7 +79,7 @@ public class LotsaText extends Activity implements TorConstants{
} }
private void stepTwo() { private void stepTwo() {
step++; step=0;
setContentView(R.layout.scrollingtext_buttons_view); setContentView(R.layout.scrollingtext_buttons_view);
String title = context.getString(R.string.wizard_warning_title); String title = context.getString(R.string.wizard_warning_title);
@ -114,9 +111,11 @@ public class LotsaText extends Activity implements TorConstants{
@Override @Override
public void onClick(View v) { public void onClick(View v) {
//stepThree(); startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
} }
}); });
} }
} }

View File

@ -0,0 +1,176 @@
package org.torproject.android;
import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceUtils;
import org.torproject.android.service.TorTransProxy;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class Permissions extends Activity implements TorConstants {
private Context context;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
context = this;
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_permissions);
stepThree();
}
@Override
protected void onResume() {
super.onResume();
}
private void stepThree(){
boolean hasRoot = TorServiceUtils.checkRootAccess();
if (hasRoot)
{
try {
int resp = TorTransProxy.testOwnerModule(context);
if (resp < 0)
{
hasRoot = false;
Toast.makeText(context, "ERROR: IPTables OWNER module not available", Toast.LENGTH_LONG).show();
Log.i(TorService.TAG,"ERROR: IPTables OWNER module not available");
}
} catch (Exception e) {
hasRoot = false;
Log.d(TorService.TAG,"ERROR: IPTables OWNER module not available",e);
}
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Editor pEdit = prefs.edit();
pEdit.putBoolean("has_root",hasRoot);
pEdit.commit();
if (hasRoot)
{
Toast.makeText(context, "Has Root", Toast.LENGTH_SHORT).show();
stepFourRoot();
}
else
{
Toast.makeText(context, "Unable to get root access", Toast.LENGTH_LONG).show();
stepFour();
}
}
private void stepFourRoot(){
String title = context.getString(R.string.wizard_permissions_title);
String msg1 = context.getString(R.string.wizard_permissions_root_msg1);
String msg2 = context.getString(R.string.wizard_permissions_root_msg2);
TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
txtTitle.setText(title);
TextView txtBody1 = ((TextView)findViewById(R.id.WizardTextBody1));
txtBody1.setText(msg1);
TextView txtBody2 = ((TextView)findViewById(R.id.WizardTextBody2));
txtBody2.setText(msg2);
txtBody2.setVisibility(TextView.VISIBLE);
Button grantPermissions = ((Button)findViewById(R.id.grantPermissions));
grantPermissions.setVisibility(Button.VISIBLE);
Button back = ((Button)findViewById(R.id.btnWizard1));
Button next = ((Button)findViewById(R.id.btnWizard2));
grantPermissions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Check and Install iptables
}
});
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
}
});
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Tips Screen
}
});
}
private void stepFour(){
String title = context.getString(R.string.wizard_permissions_title);
String msg = context.getString(R.string.wizard_permissions_msg);
TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
txtTitle.setText(title);
TextView txtBody = ((TextView)findViewById(R.id.WizardTextBody));
txtBody.setText(msg);
Button btn1 = ((Button)findViewById(R.id.btnWizard1));
Button btn2 = ((Button)findViewById(R.id.btnWizard2));
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(new Intent(getBaseContext(), LotsaText.class), 1);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Tips Screen
}
});
}
}