new wizard interface nearly complete
This commit is contained in:
parent
a2d41e4f79
commit
a85f5b9552
|
@ -1,272 +0,0 @@
|
|||
/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
package org.torproject.android;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, TorConstants {
|
||||
|
||||
private static TorifiedApp[] apps = null;
|
||||
|
||||
private ListView listApps;
|
||||
|
||||
private AppManager mAppManager;
|
||||
|
||||
|
||||
private boolean appsLoaded = false;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.setContentView(R.layout.layout_apps);
|
||||
|
||||
mAppManager = this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
listApps = (ListView)findViewById(R.id.applistview);
|
||||
|
||||
if (!appsLoaded)
|
||||
loadApps();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void loadApps ()
|
||||
{
|
||||
resetApps(this);
|
||||
final TorifiedApp[] apps = getApps(this);
|
||||
|
||||
Arrays.sort(apps, new Comparator<TorifiedApp>() {
|
||||
public int compare(TorifiedApp o1, TorifiedApp o2) {
|
||||
if (o1.isTorified() == o2.isTorified()) return o1.getName().compareTo(o2.getName());
|
||||
if (o1.isTorified()) return -1;
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
final LayoutInflater inflater = getLayoutInflater();
|
||||
|
||||
final ListAdapter adapter = new ArrayAdapter<TorifiedApp>(this,R.layout.layout_apps_item,R.id.itemtext,apps) {
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ListEntry entry;
|
||||
if (convertView == null) {
|
||||
// Inflate a new view
|
||||
convertView = inflater.inflate(R.layout.layout_apps_item, parent, false);
|
||||
entry = new ListEntry();
|
||||
entry.icon = (ImageView) convertView.findViewById(R.id.itemicon);
|
||||
entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
|
||||
entry.text = (TextView) convertView.findViewById(R.id.itemtext);
|
||||
|
||||
entry.text.setOnClickListener(mAppManager);
|
||||
entry.text.setOnClickListener(mAppManager);
|
||||
|
||||
convertView.setTag(entry);
|
||||
|
||||
entry.box.setOnCheckedChangeListener(mAppManager);
|
||||
} else {
|
||||
// Convert an existing view
|
||||
entry = (ListEntry) convertView.getTag();
|
||||
}
|
||||
|
||||
|
||||
final TorifiedApp app = apps[position];
|
||||
|
||||
|
||||
entry.icon.setImageDrawable(app.getIcon());
|
||||
entry.text.setText(app.getName());
|
||||
|
||||
final CheckBox box = entry.box;
|
||||
box.setTag(app);
|
||||
box.setChecked(app.isTorified());
|
||||
|
||||
entry.text.setTag(box);
|
||||
entry.icon.setTag(box);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
};
|
||||
|
||||
listApps.setAdapter(adapter);
|
||||
|
||||
appsLoaded = true;
|
||||
|
||||
}
|
||||
|
||||
private static class ListEntry {
|
||||
private CheckBox box;
|
||||
private TextView text;
|
||||
private ImageView icon;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onStop()
|
||||
*/
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
}
|
||||
|
||||
public static TorifiedApp[] getApps (Context context)
|
||||
{
|
||||
if (apps == null)
|
||||
resetApps(context);
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
public static TorifiedApp[] resetApps (Context context)
|
||||
{
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
|
||||
String[] tordApps;
|
||||
|
||||
StringTokenizer st = new StringTokenizer(tordAppString,"|");
|
||||
tordApps = new String[st.countTokens()];
|
||||
int tordIdx = 0;
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
tordApps[tordIdx++] = st.nextToken();
|
||||
}
|
||||
|
||||
Arrays.sort(tordApps);
|
||||
|
||||
//else load the apps up
|
||||
PackageManager pMgr = context.getPackageManager();
|
||||
|
||||
List<ApplicationInfo> lAppInfo = pMgr.getInstalledApplications(0);
|
||||
|
||||
Iterator<ApplicationInfo> itAppInfo = lAppInfo.iterator();
|
||||
|
||||
apps = new TorifiedApp[lAppInfo.size()];
|
||||
|
||||
ApplicationInfo aInfo = null;
|
||||
|
||||
int appIdx = 0;
|
||||
|
||||
while (itAppInfo.hasNext())
|
||||
{
|
||||
aInfo = itAppInfo.next();
|
||||
|
||||
apps[appIdx] = new TorifiedApp();
|
||||
|
||||
apps[appIdx].setEnabled(aInfo.enabled);
|
||||
apps[appIdx].setUid(aInfo.uid);
|
||||
apps[appIdx].setUsername(pMgr.getNameForUid(apps[appIdx].getUid()));
|
||||
apps[appIdx].setProcname(aInfo.processName);
|
||||
apps[appIdx].setName(pMgr.getApplicationLabel(aInfo).toString());
|
||||
apps[appIdx].setIcon(pMgr.getApplicationIcon(aInfo));
|
||||
|
||||
// check if this application is allowed
|
||||
if (Arrays.binarySearch(tordApps, apps[appIdx].getUsername()) >= 0) {
|
||||
apps[appIdx].setTorified(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
apps[appIdx].setTorified(false);
|
||||
}
|
||||
|
||||
appIdx++;
|
||||
}
|
||||
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
|
||||
public void saveAppSettings (Context context)
|
||||
{
|
||||
if (apps == null)
|
||||
return;
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
// final SharedPreferences prefs = context.getSharedPreferences(PREFS_KEY, 0);
|
||||
|
||||
StringBuilder tordApps = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < apps.length; i++)
|
||||
{
|
||||
if (apps[i].isTorified())
|
||||
{
|
||||
tordApps.append(apps[i].getUsername());
|
||||
tordApps.append("|");
|
||||
}
|
||||
}
|
||||
|
||||
Editor edit = prefs.edit();
|
||||
edit.putString(PREFS_KEY_TORIFIED, tordApps.toString());
|
||||
edit.commit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called an application is check/unchecked
|
||||
*/
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
final TorifiedApp app = (TorifiedApp) buttonView.getTag();
|
||||
if (app != null) {
|
||||
app.setTorified(isChecked);
|
||||
}
|
||||
|
||||
saveAppSettings(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
CheckBox cbox = (CheckBox)v.getTag();
|
||||
|
||||
final TorifiedApp app = (TorifiedApp)cbox.getTag();
|
||||
if (app != null) {
|
||||
app.setTorified(!app.isTorified());
|
||||
cbox.setChecked(app.isTorified());
|
||||
}
|
||||
|
||||
saveAppSettings(this);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
package org.torproject.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ConfigureTransProxy extends Activity implements TorConstants {
|
||||
|
||||
private Context context;
|
||||
private int flag = 0;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
context = this;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
|
||||
super.onStart();
|
||||
setContentView(R.layout.layout_wizard_root);
|
||||
|
||||
stepSix();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void stepSix(){
|
||||
|
||||
String title = context.getString(R.string.wizard_transproxy_title);
|
||||
TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
|
||||
txtTitle.setText(title);
|
||||
|
||||
Button back = ((Button)findViewById(R.id.btnWizard1));
|
||||
Button next = ((Button)findViewById(R.id.btnWizard2));
|
||||
next.setEnabled(false);
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
|
||||
}
|
||||
});
|
||||
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
//Dirty flag variable - improve logic
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if( flag == 1 )
|
||||
context.startActivity(new Intent(context, AppManager.class));
|
||||
|
||||
else
|
||||
showWizardFinal();
|
||||
}
|
||||
});
|
||||
|
||||
RadioGroup mRadioGroup = (RadioGroup)findViewById(R.id.radioGroup);
|
||||
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener (){
|
||||
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId){
|
||||
Button next = ((Button)findViewById(R.id.btnWizard2));
|
||||
next.setEnabled(true);
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
showWizardFinal();
|
||||
}
|
||||
});
|
||||
|
||||
RadioButton rb0 = (RadioButton)findViewById(R.id.radio0);
|
||||
RadioButton rb1 = (RadioButton)findViewById(R.id.radio1);
|
||||
RadioButton rb2 = (RadioButton)findViewById(R.id.radio2);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
pEdit.putBoolean(PREF_TRANSPARENT, rb0.isChecked());
|
||||
pEdit.putBoolean(PREF_TRANSPARENT_ALL, rb0.isChecked());
|
||||
pEdit.commit();
|
||||
|
||||
if(rb0.isChecked())
|
||||
{
|
||||
pEdit.putString("radiobutton","rb0");
|
||||
pEdit.commit();
|
||||
}
|
||||
|
||||
else if(rb1.isChecked())
|
||||
{
|
||||
flag = 1;
|
||||
|
||||
pEdit.putBoolean(PREF_TRANSPARENT, true);
|
||||
pEdit.putBoolean(PREF_TRANSPARENT_ALL, false);
|
||||
pEdit.putString("radiobutton","rb1");
|
||||
pEdit.commit();
|
||||
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
context.startActivity(new Intent(context, AppManager.class));
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(rb2.isChecked())
|
||||
{
|
||||
pEdit.putString("radiobutton", "rb2");
|
||||
pEdit.commit();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showWizardFinal ()
|
||||
{
|
||||
String title = null;
|
||||
String msg = null;
|
||||
|
||||
|
||||
title = context.getString(R.string.wizard_final);
|
||||
msg = context.getString(R.string.wizard_final_msg);
|
||||
|
||||
DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
context.startActivity(new Intent(context, Orbot.class));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setIcon(R.drawable.icon)
|
||||
.setTitle(title)
|
||||
.setPositiveButton(R.string.button_close, ocListener)
|
||||
.setMessage(msg)
|
||||
.show();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
package org.torproject.android;
|
||||
|
||||
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.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class LotsaText 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.scrollingtext_buttons_view);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
boolean wizardScreen1 = prefs.getBoolean("wizardscreen1",true);
|
||||
if(wizardScreen1)
|
||||
stepOne();
|
||||
else
|
||||
stepTwo();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void stepOne() {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
pEdit.putBoolean("wizardscreen1",true);
|
||||
pEdit.commit();
|
||||
|
||||
String title = context.getString(R.string.wizard_title);
|
||||
String msg = context.getString(R.string.wizard_title_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));
|
||||
ImageView img = (ImageView) findViewById(R.id.orbot_image);
|
||||
|
||||
btn1.setVisibility(Button.INVISIBLE);
|
||||
img.setImageResource(R.drawable.tor);
|
||||
|
||||
btn2.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
stepTwo();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void stepTwo() {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
pEdit.putBoolean("wizardscreen1",false);
|
||||
pEdit.commit();
|
||||
|
||||
setContentView(R.layout.scrollingtext_buttons_view);
|
||||
String title = context.getString(R.string.wizard_warning_title);
|
||||
String msg = context.getString(R.string.wizard_warning_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));
|
||||
ImageView img = (ImageView) findViewById(R.id.orbot_image);
|
||||
|
||||
btn1.setVisibility(Button.VISIBLE);
|
||||
img.setImageResource(R.drawable.warning);
|
||||
|
||||
btn1.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
stepOne();
|
||||
}
|
||||
});
|
||||
|
||||
btn2.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -14,6 +14,9 @@ import java.util.StringTokenizer;
|
|||
import org.torproject.android.service.ITorService;
|
||||
import org.torproject.android.service.ITorServiceCallback;
|
||||
import org.torproject.android.service.TorServiceConstants;
|
||||
import org.torproject.android.settings.ProcessSettingsAsyncTask;
|
||||
import org.torproject.android.settings.SettingsPreferences;
|
||||
import org.torproject.android.wizard.LotsaText;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -59,7 +62,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
private MenuItem mItemOnOff = null; //the menu item which we toggle based on Orbot state
|
||||
|
||||
/* Some tracking bits */
|
||||
private int torStatus = STATUS_READY; //latest status reported from the tor service
|
||||
private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
|
||||
// this is a value we get passed back from the TorService
|
||||
|
||||
/* Tor Service interaction */
|
||||
|
@ -175,7 +178,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
{
|
||||
|
||||
}
|
||||
else if (mService.getStatus() == STATUS_READY)
|
||||
else if (mService.getStatus() == TorServiceConstants.STATUS_OFF)
|
||||
{
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_stop);
|
||||
|
@ -573,7 +576,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
if (imgStatus != null)
|
||||
{
|
||||
|
||||
if (torStatus == STATUS_ON)
|
||||
if (torStatus == TorServiceConstants.STATUS_ON)
|
||||
{
|
||||
imgStatus.setImageResource(R.drawable.toron);
|
||||
|
||||
|
@ -584,7 +587,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
|
||||
lblStatus.setText(lblMsg);
|
||||
|
||||
if (torServiceMsg.length() > 0)
|
||||
if (torServiceMsg != null && torServiceMsg.length() > 0)
|
||||
showAlert("Update", torServiceMsg, false);
|
||||
|
||||
boolean showFirstTime = prefs.getBoolean("connect_first_time",true);
|
||||
|
@ -607,7 +610,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
|
||||
|
||||
}
|
||||
else if (torStatus == STATUS_CONNECTING)
|
||||
else if (torStatus == TorServiceConstants.STATUS_CONNECTING)
|
||||
{
|
||||
|
||||
imgStatus.setImageResource(R.drawable.torstarting);
|
||||
|
@ -619,18 +622,6 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
mItemOnOff.setTitle(R.string.menu_stop);
|
||||
|
||||
}
|
||||
else if (torStatus == STATUS_OFF)
|
||||
{
|
||||
imgStatus.setImageResource(R.drawable.toroff);
|
||||
|
||||
|
||||
hideProgressDialog();
|
||||
|
||||
lblStatus.setText(getString(R.string.status_shutting_down));
|
||||
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
@ -704,34 +695,30 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
public boolean onLongClick(View view) {
|
||||
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
|
||||
if (mService != null && mService.getStatus() == TorServiceConstants.STATUS_OFF)
|
||||
{
|
||||
|
||||
if (mService == null)
|
||||
{
|
||||
|
||||
}
|
||||
else if (mService.getStatus() == STATUS_READY)
|
||||
{
|
||||
|
||||
createProgressDialog(getString(R.string.status_starting_up));
|
||||
|
||||
startTor();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
stopTor();
|
||||
|
||||
}
|
||||
createProgressDialog(getString(R.string.status_starting_up));
|
||||
|
||||
startTor();
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
Log.d(TAG,"error onclick",e);
|
||||
|
||||
stopTor();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.d(TAG,"error onclick",e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -775,13 +762,21 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
|
|||
// this is what takes messages or values from the callback threads or other non-mainUI threads
|
||||
//and passes them back into the main UI thread for display to the user
|
||||
private Handler mHandler = new Handler() {
|
||||
|
||||
private String lastServiceMsg = null;
|
||||
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case TorServiceConstants.STATUS_MSG:
|
||||
|
||||
String torServiceMsg = (String)msg.getData().getString(HANDLER_TOR_MSG);
|
||||
|
||||
updateStatus(torServiceMsg);
|
||||
if (lastServiceMsg == null || !lastServiceMsg.equals(torServiceMsg))
|
||||
{
|
||||
updateStatus(torServiceMsg);
|
||||
|
||||
lastServiceMsg = torServiceMsg;
|
||||
}
|
||||
|
||||
break;
|
||||
case TorServiceConstants.LOG_MSG:
|
||||
|
|
|
@ -1,229 +0,0 @@
|
|||
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.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
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();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
pEdit.putBoolean("has_root",hasRoot);
|
||||
pEdit.commit();
|
||||
|
||||
if (hasRoot)
|
||||
{
|
||||
stepFourRoot();
|
||||
}
|
||||
else
|
||||
{
|
||||
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));
|
||||
next.setEnabled(false);
|
||||
|
||||
CheckBox consent = (CheckBox)findViewById(R.id.checkBox);
|
||||
consent.setVisibility(CheckBox.VISIBLE);
|
||||
|
||||
consent.setOnCheckedChangeListener(new OnCheckedChangeListener (){
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
|
||||
pEdit.putBoolean(PREF_TRANSPARENT, !isChecked);
|
||||
pEdit.putBoolean(PREF_TRANSPARENT_ALL, !isChecked);
|
||||
|
||||
pEdit.commit();
|
||||
|
||||
Button next = ((Button)findViewById(R.id.btnWizard2));
|
||||
if(isChecked)
|
||||
next.setEnabled(true);
|
||||
else
|
||||
next.setEnabled(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
grantPermissions.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//Check and Install iptables - TorTransProxy.testOwnerModule(this)
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean hasRoot = prefs.getBoolean("has_root",false);
|
||||
|
||||
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");
|
||||
stepFour();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
hasRoot = false;
|
||||
Log.d(TorService.TAG,"ERROR: IPTables OWNER module not available",e);
|
||||
}
|
||||
}
|
||||
|
||||
startActivityForResult(new Intent(getBaseContext(), ConfigureTransProxy.class), 1);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
startActivityForResult(new Intent(getBaseContext(), TipsAndTricks.class), 1);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void stepFour(){
|
||||
|
||||
Toast.makeText(context, "NON ROOT FUNC", Toast.LENGTH_SHORT).show();
|
||||
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.WizardTextBody1));
|
||||
txtBody.setText(msg);
|
||||
|
||||
Button btn1 = ((Button)findViewById(R.id.btnWizard1));
|
||||
Button btn2 = ((Button)findViewById(R.id.btnWizard2));
|
||||
btn2.setEnabled(true);
|
||||
|
||||
|
||||
TextView txtBody2 = ((TextView)findViewById(R.id.WizardTextBody2));
|
||||
txtBody2.setVisibility(TextView.GONE);
|
||||
|
||||
Button grantPermissions = ((Button)findViewById(R.id.grantPermissions));
|
||||
grantPermissions.setVisibility(Button.GONE);
|
||||
|
||||
|
||||
CheckBox consent = (CheckBox)findViewById(R.id.checkBox);
|
||||
consent.setVisibility(CheckBox.GONE);
|
||||
|
||||
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) {
|
||||
startActivityForResult(new Intent(getBaseContext(), TipsAndTricks.class), 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package org.torproject.android;
|
||||
|
||||
import org.torproject.android.service.ITorService;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.RemoteException;
|
||||
|
||||
public class ProcessSettingsAsyncTask extends AsyncTask<ITorService, Integer, Long>
|
||||
{
|
||||
|
||||
|
||||
@Override
|
||||
protected Long doInBackground(ITorService... torService) {
|
||||
|
||||
try {
|
||||
torService[0].processSettings();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 100L;
|
||||
}
|
||||
|
||||
protected void onProgressUpdate(Integer... progress) {
|
||||
|
||||
}
|
||||
|
||||
protected void onPostExecute(Long result) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
package org.torproject.android;
|
||||
|
||||
import org.torproject.android.service.TorServiceUtils;
|
||||
import org.torproject.android.service.TorTransProxy;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceCategory;
|
||||
|
||||
|
||||
public class SettingsPreferences
|
||||
extends PreferenceActivity implements OnPreferenceClickListener {
|
||||
|
||||
private CheckBoxPreference prefCBTransProxy = null;
|
||||
private CheckBoxPreference prefcBTransProxyAll = null;
|
||||
private Preference prefTransProxyApps = null;
|
||||
private CheckBoxPreference prefHiddenServices = null;
|
||||
|
||||
private boolean hasRoot = false;
|
||||
|
||||
|
||||
private final static int HIDDEN_SERVICE_PREF_IDX = 6;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if (prefs.contains("has_root"))
|
||||
{
|
||||
hasRoot = prefs.getBoolean("has_root",false);
|
||||
}
|
||||
else
|
||||
{
|
||||
hasRoot = TorServiceUtils.checkRootAccess();
|
||||
Editor pEdit = prefs.edit();
|
||||
pEdit.putBoolean("has_root",hasRoot);
|
||||
pEdit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
|
||||
super.onResume();
|
||||
|
||||
|
||||
int transProxyGroupIdx = 1;
|
||||
|
||||
if (!hasRoot)
|
||||
{
|
||||
getPreferenceScreen().getPreference(transProxyGroupIdx).setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(0));
|
||||
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(1);
|
||||
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(transProxyGroupIdx)).getPreference(2);
|
||||
|
||||
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
|
||||
|
||||
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
|
||||
|
||||
prefCBTransProxy.setOnPreferenceClickListener(this);
|
||||
prefcBTransProxyAll.setOnPreferenceClickListener(this);
|
||||
prefTransProxyApps.setOnPreferenceClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
prefHiddenServices = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(0));
|
||||
prefHiddenServices.setOnPreferenceClickListener(this);
|
||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
|
||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onStop()
|
||||
*/
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
//Log.d(getClass().getName(),"Exiting Preferences");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
|
||||
setResult(1010);
|
||||
|
||||
if (preference == prefTransProxyApps)
|
||||
{
|
||||
startActivity(new Intent(this, AppManager.class));
|
||||
|
||||
}
|
||||
else if (preference == prefHiddenServices)
|
||||
{
|
||||
|
||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(1).setEnabled(prefHiddenServices.isChecked());
|
||||
((PreferenceCategory)this.getPreferenceScreen().getPreference(HIDDEN_SERVICE_PREF_IDX)).getPreference(2).setEnabled(prefHiddenServices.isChecked());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
|
||||
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked()));
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
package org.torproject.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TipsAndTricks 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_tips);
|
||||
|
||||
stepFive();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void stepFive(){
|
||||
|
||||
String title = context.getString(R.string.wizard_tips_title);
|
||||
TextView txtTitle = ((TextView)findViewById(R.id.WizardTextTitle));
|
||||
txtTitle.setText(title);
|
||||
|
||||
Button btn1 = (Button)findViewById(R.id.WizardRootButtonInstallGibberbot);
|
||||
|
||||
btn1.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
String url = context.getString(R.string.gibberbot_apk_url);
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Button btn2 = (Button)findViewById(R.id.WizardRootButtonInstallFirefox);
|
||||
|
||||
btn2.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
String url = context.getString(R.string.firefox_apk_url);
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Button btn3 = (Button)findViewById(R.id.WizardRootButtonInstallProxyMob);
|
||||
|
||||
btn3.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
String url = context.getString(R.string.proxymob_url);
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
}
|
||||
});
|
||||
|
||||
Button back = ((Button)findViewById(R.id.btnWizard1));
|
||||
Button next = ((Button)findViewById(R.id.btnWizard2));
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
startActivityForResult(new Intent(getBaseContext(), Permissions.class), 1);
|
||||
}
|
||||
});
|
||||
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showWizardFinal();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showWizardFinal ()
|
||||
{
|
||||
String title = null;
|
||||
String msg = null;
|
||||
|
||||
|
||||
title = context.getString(R.string.wizard_final);
|
||||
msg = context.getString(R.string.wizard_final_msg);
|
||||
|
||||
DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
context.startActivity(new Intent(context, Orbot.class));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setIcon(R.drawable.icon)
|
||||
.setTitle(title)
|
||||
.setPositiveButton(R.string.button_close, ocListener)
|
||||
.setMessage(msg)
|
||||
.show();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -16,11 +16,6 @@ public interface TorConstants {
|
|||
//path to check Tor against
|
||||
public final static String URL_TOR_CHECK = "https://check.torproject.org";
|
||||
|
||||
public final static int STATUS_OFF = -1;
|
||||
public final static int STATUS_READY = 0;
|
||||
public final static int STATUS_ON = 1;
|
||||
public final static int STATUS_CONNECTING = 2;
|
||||
|
||||
|
||||
public final static String NEWLINE = "\n";
|
||||
|
||||
|
@ -45,6 +40,8 @@ public interface TorConstants {
|
|||
public final static String PREF_TRANSPARENT = "pref_transparent";
|
||||
public final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
|
||||
|
||||
public final static String PREF_HAS_ROOT = "has_root";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
package org.torproject.android;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class TorifiedApp {
|
||||
|
||||
private boolean enabled;
|
||||
private int uid;
|
||||
private String username;
|
||||
private String procname;
|
||||
private String name;
|
||||
private Drawable icon;
|
||||
|
||||
private boolean torified = false;
|
||||
|
||||
/**
|
||||
* @return the torified
|
||||
*/
|
||||
public boolean isTorified() {
|
||||
return torified;
|
||||
}
|
||||
/**
|
||||
* @param torified the torified to set
|
||||
*/
|
||||
public void setTorified(boolean torified) {
|
||||
this.torified = torified;
|
||||
}
|
||||
private int[] enabledPorts;
|
||||
|
||||
/**
|
||||
* @return the enabledPorts
|
||||
*/
|
||||
public int[] getEnabledPorts() {
|
||||
return enabledPorts;
|
||||
}
|
||||
/**
|
||||
* @param enabledPorts the enabledPorts to set
|
||||
*/
|
||||
public void setEnabledPorts(int[] enabledPorts) {
|
||||
this.enabledPorts = enabledPorts;
|
||||
}
|
||||
/**
|
||||
* @return the enabled
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
/**
|
||||
* @param enabled the enabled to set
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
/**
|
||||
* @return the uid
|
||||
*/
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
/**
|
||||
* @param uid the uid to set
|
||||
*/
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
/**
|
||||
* @param username the username to set
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
/**
|
||||
* @return the procname
|
||||
*/
|
||||
public String getProcname() {
|
||||
return procname;
|
||||
}
|
||||
/**
|
||||
* @param procname the procname to set
|
||||
*/
|
||||
public void setProcname(String procname) {
|
||||
this.procname = procname;
|
||||
}
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(Drawable icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
|
@ -1,425 +0,0 @@
|
|||
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.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class WizardHelper implements TorConstants {
|
||||
|
||||
private Context context;
|
||||
private AlertDialog currentDialog;
|
||||
|
||||
public WizardHelper (Context context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
public void showWizard ()
|
||||
{
|
||||
showWizardStep1();
|
||||
}
|
||||
|
||||
public void showWizardStep1()
|
||||
{
|
||||
|
||||
|
||||
String title = context.getString(R.string.wizard_title);
|
||||
|
||||
LayoutInflater li = LayoutInflater.from(context);
|
||||
View view = li.inflate(R.layout.layout_wizard_welcome, null);
|
||||
|
||||
|
||||
showCustomDialog(title, view,context.getString(R.string.btn_next),null,new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
|
||||
if (which == DialogInterface.BUTTON_NEUTRAL)
|
||||
{
|
||||
|
||||
showWizardStep2();
|
||||
}
|
||||
/*
|
||||
else if (which == DialogInterface.BUTTON_POSITIVE)
|
||||
{
|
||||
showAbout();
|
||||
}*/
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showWizardStep2()
|
||||
{
|
||||
|
||||
|
||||
String title = context.getString(R.string.wizard_permissions_stock);
|
||||
|
||||
LayoutInflater li = LayoutInflater.from(context);
|
||||
View view = li.inflate(R.layout.layout_wizard_stock, null);
|
||||
|
||||
Button btn1 = (Button)view.findViewById(R.id.WizardRootButtonEnable);
|
||||
|
||||
btn1.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
currentDialog.dismiss();
|
||||
showWizardStep2Root();
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(context, "Unable to get root access", Toast.LENGTH_LONG).show();
|
||||
view.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CheckBox cb1 = (CheckBox)view.findViewById(R.id.CheckBoxConsent);
|
||||
|
||||
cb1.setOnCheckedChangeListener(new OnCheckedChangeListener (){
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
|
||||
currentDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setEnabled(isChecked);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
pEdit.putBoolean("has_root",false);
|
||||
pEdit.commit();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
showCustomDialog(title, view,context.getString(R.string.btn_next),context.getString(R.string.btn_back),new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
|
||||
if (which == DialogInterface.BUTTON_NEUTRAL)
|
||||
{
|
||||
showWizardTipsAndTricks();
|
||||
}
|
||||
else if (which == DialogInterface.BUTTON_POSITIVE)
|
||||
{
|
||||
showWizardStep1();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
currentDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setEnabled(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void showWizardStep2Root()
|
||||
{
|
||||
|
||||
String title = null;
|
||||
String msg = null;
|
||||
|
||||
|
||||
|
||||
title = context.getString(R.string.wizard_permissions_root);
|
||||
msg = context.getString(R.string.wizard_premissions_msg_root);
|
||||
|
||||
|
||||
|
||||
showDialog(title, msg,context.getString(R.string.btn_next),context.getString(R.string.btn_back),new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
|
||||
if (which == DialogInterface.BUTTON_NEUTRAL)
|
||||
{
|
||||
showWizardRootConfigureTorification();
|
||||
}
|
||||
else if (which == DialogInterface.BUTTON_POSITIVE)
|
||||
{
|
||||
showWizardStep1();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void showWizardTipsAndTricks()
|
||||
{
|
||||
|
||||
String title = context.getString(R.string.wizard_tips_tricks);
|
||||
|
||||
LayoutInflater li = LayoutInflater.from(context);
|
||||
View view = li.inflate(R.layout.layout_wizard_tips, null);
|
||||
|
||||
Button btn1 = (Button)view.findViewById(R.id.WizardRootButtonInstallGibberbot);
|
||||
|
||||
btn1.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
String url = context.getString(R.string.otrchat_apk_url);
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Button btn2 = (Button)view.findViewById(R.id.WizardRootButtonInstallFirefox);
|
||||
|
||||
btn2.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
String url = context.getString(R.string.orweb_apk_url);
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Button btn3 = (Button)view.findViewById(R.id.WizardRootButtonInstallProxyMob);
|
||||
|
||||
btn3.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
showProxyHelp();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
showCustomDialog(title, view,context.getString(R.string.btn_next),context.getString(R.string.btn_back),new DialogInterface.OnClickListener() {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
|
||||
if (which == DialogInterface.BUTTON_NEUTRAL)
|
||||
{
|
||||
showWizardFinal();
|
||||
|
||||
}
|
||||
else if (which == DialogInterface.BUTTON_POSITIVE)
|
||||
{
|
||||
showWizardStep2();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showWizardRootConfigureTorification()
|
||||
{
|
||||
/*
|
||||
LayoutInflater li = LayoutInflater.from(context);
|
||||
View view = li.inflate(R.layout.layout_wizard_root, null);
|
||||
|
||||
CheckBox cb1 = (CheckBox)view.findViewById(R.id.WizardRootCheckBox01);
|
||||
Button btn1 = (Button)view.findViewById(R.id.WizardRootButton01);
|
||||
|
||||
cb1.setOnCheckedChangeListener(new OnCheckedChangeListener (){
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
|
||||
pEdit.putBoolean(PREF_TRANSPARENT, isChecked);
|
||||
pEdit.putBoolean(PREF_TRANSPARENT_ALL, isChecked);
|
||||
|
||||
pEdit.commit();
|
||||
|
||||
//Button btn1 = (Button)buttonView.getParent().findViewById(R.id.WizardRootButton01);
|
||||
//btn1.setEnabled(!isChecked);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
btn1.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
Editor pEdit = prefs.edit();
|
||||
pEdit.putBoolean(PREF_TRANSPARENT, true);
|
||||
pEdit.putBoolean(PREF_TRANSPARENT_ALL, false);
|
||||
pEdit.commit();
|
||||
|
||||
context.startActivity(new Intent(context, AppManager.class));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
showCustomDialog(context.getString(R.string.wizard_configure),view,context.getString(R.string.btn_next),context.getString(R.string.btn_back),new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
dialog.dismiss();
|
||||
|
||||
if (which == DialogInterface.BUTTON_NEUTRAL)
|
||||
{
|
||||
showWizardTipsAndTricks();
|
||||
|
||||
}
|
||||
else if (which == DialogInterface.BUTTON_POSITIVE)
|
||||
{
|
||||
showWizardStep2();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void showWizardFinal ()
|
||||
{
|
||||
String title = null;
|
||||
String msg = null;
|
||||
|
||||
|
||||
title = context.getString(R.string.wizard_final);
|
||||
msg = context.getString(R.string.wizard_final_msg);
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setIcon(R.drawable.icon)
|
||||
.setTitle(title)
|
||||
.setPositiveButton(R.string.button_close, null)
|
||||
.setMessage(msg)
|
||||
.show();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void showDialog (String title, String msg, String button1, String button2, DialogInterface.OnClickListener ocListener)
|
||||
{
|
||||
|
||||
// dialog.setContentView(R.layout.custom_dialog);
|
||||
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context)
|
||||
.setIcon(R.drawable.icon)
|
||||
.setTitle(title)
|
||||
.setMessage(msg)
|
||||
.setNeutralButton(button1, ocListener)
|
||||
.setPositiveButton(button2, ocListener);
|
||||
|
||||
|
||||
currentDialog = builder.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showCustomDialog (String title, View view, String button1, String button2, DialogInterface.OnClickListener ocListener)
|
||||
{
|
||||
|
||||
currentDialog = new AlertDialog.Builder(context)
|
||||
.setIcon(R.drawable.icon)
|
||||
.setTitle(title)
|
||||
.setView(view)
|
||||
.setNeutralButton(button1, ocListener)
|
||||
.setPositiveButton(button2, ocListener)
|
||||
.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void showProxyHelp ()
|
||||
{
|
||||
|
||||
LayoutInflater li = LayoutInflater.from(context);
|
||||
View view = li.inflate(R.layout.layout_wizard_proxy_help, null);
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(context.getString(R.string.wizard_proxy_help_info))
|
||||
.setView(view)
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue