fixed OrbotRequiredDialogActivity not finishing, orbot install dialog style

This commit is contained in:
Adithya Abraham Philip
2015-07-03 09:27:46 +05:30
parent 89f017aa9c
commit aca106e808
8 changed files with 112 additions and 44 deletions

View File

@@ -149,22 +149,30 @@ public class OrbotHelper {
* @param fragmentActivity
* @return true if Tor is not enabled or Tor is enabled and Orbot is installed and running, else false
*/
public static boolean putOrbotInRequiredState(int middleButton, final Runnable middleButtonRunnable,
public static boolean putOrbotInRequiredState(final int middleButton,
final Runnable middleButtonRunnable,
final Runnable dialogDismissRunnable,
Preferences.ProxyPrefs proxyPrefs,
FragmentActivity fragmentActivity) {
Handler ignoreTorHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// every message received by this handler will mean the middle button was pressed
middleButtonRunnable.run();
}
};
if (!proxyPrefs.torEnabled) {
return true;
}
if (!OrbotHelper.isOrbotInstalled(fragmentActivity)) {
Handler ignoreTorHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case SupportInstallDialogFragment.MESSAGE_MIDDLE_CLICKED:
middleButtonRunnable.run();
break;
case SupportInstallDialogFragment.MESSAGE_DIALOG_DISMISSED:
dialogDismissRunnable.run();
break;
}
}
};
OrbotHelper.getInstallDialogFragmentWithThirdButton(
new Messenger(ignoreTorHandler),
@@ -174,6 +182,20 @@ public class OrbotHelper {
return false;
} else if (!OrbotHelper.isOrbotRunning()) {
Handler ignoreTorHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case OrbotStartDialogFragment.MESSAGE_MIDDLE_BUTTON:
middleButtonRunnable.run();
break;
case OrbotStartDialogFragment.MESSAGE_DIALOG_DISMISSED:
dialogDismissRunnable.run();
break;
}
}
};
OrbotHelper.getOrbotStartDialogFragment(new Messenger(ignoreTorHandler),
middleButton)
.show(fragmentActivity.getSupportFragmentManager(), "OrbotHelperOrbotStartDialog");
@@ -183,4 +205,18 @@ public class OrbotHelper {
return true;
}
}
public static boolean putOrbotInRequiredState(final int middleButton,
final Runnable middleButtonRunnable,
Preferences.ProxyPrefs proxyPrefs,
FragmentActivity fragmentActivity) {
Runnable emptyRunnable = new Runnable() {
@Override
public void run() {
}
};
return putOrbotInRequiredState(middleButton, middleButtonRunnable, emptyRunnable,
proxyPrefs, fragmentActivity);
}
}