From be6b7ff89993de4eff1eb2499f7537ab74a6d8c8 Mon Sep 17 00:00:00 2001 From: Adithya Abraham Philip Date: Wed, 8 Jul 2015 06:31:34 +0530 Subject: shifted proxy checking to ImportKeysListCloudLoader --- .../keychain/util/orbot/OrbotHelper.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java index 9d97ba305..9eb92f92f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java @@ -130,6 +130,13 @@ public class OrbotHelper { return intent; } + /** + * checks preferences to see if Orbot is required, and if yes, if it is installed and running + * + * @param context used to retrieve preferences + * @return false if Tor is selected proxy and Orbot is not installed or running, true + * otherwise + */ public static boolean isOrbotInRequiredState(Context context) { Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(context).getProxyPrefs(); if (!proxyPrefs.torEnabled) { @@ -219,4 +226,27 @@ public class OrbotHelper { return putOrbotInRequiredState(middleButton, middleButtonRunnable, emptyRunnable, proxyPrefs, fragmentActivity); } + + /** + * generates a standard Orbot install/enable dialog if necessary, based on proxy settings in + * preferences + * + * @param ignoreTorRunnable run when the "Ignore Tor" button is pressed + * @param fragmentActivity used to start the activ + * @return + */ + public static boolean putOrbotInRequiredState(Runnable ignoreTorRunnable, + FragmentActivity fragmentActivity) { + return putOrbotInRequiredState(R.string.orbot_ignore_tor, ignoreTorRunnable, + Preferences.getPreferences(fragmentActivity).getProxyPrefs(), fragmentActivity); + } + + public static boolean putOrbotInRequiredState(Runnable ignoreTorRunnable, + Runnable dismissDialogRunnable, + FragmentActivity fragmentActivity) { + return putOrbotInRequiredState(R.string.orbot_ignore_tor, ignoreTorRunnable, + dismissDialogRunnable, + Preferences.getPreferences(fragmentActivity).getProxyPrefs(), + fragmentActivity); + } } -- cgit v1.2.3