Skip to content

Commit

Permalink
Fixes issue #35. Add support for Facebook's onion address that can be…
Browse files Browse the repository at this point in the history
… used with Tor
  • Loading branch information
velazcod committed Nov 1, 2014
1 parent 276b059 commit 3acedc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,22 +230,26 @@ private void loadPreferences() {
String mode = mSharedPreferences.getString(FacebookPreferences.SITE_MODE,
FacebookPreferences.SITE_MODE_AUTO);

// TODO: time to fix this mess
// Force or detect the site mode to load
if (mode.equalsIgnoreCase(FacebookPreferences.SITE_MODE_MOBILE)) {
// Force the webview config to mobile
setupFacebookWebViewConfig(true, true, false, false);
setupFacebookWebViewConfig(true, true, false, false, false);
} else if (mode.equalsIgnoreCase(FacebookPreferences.SITE_MODE_DESKTOP)) {
// Force the webview config to desktop mode
setupFacebookWebViewConfig(true, false, false, false);
setupFacebookWebViewConfig(true, false, false, false, false);
} else if (mode.equalsIgnoreCase(FacebookPreferences.SITE_MODE_ZERO)) {
// Force the webview config to zero mode
setupFacebookWebViewConfig(false, true, false, true);
setupFacebookWebViewConfig(false, true, false, true, false);
} else if (mode.equalsIgnoreCase(FacebookPreferences.SITE_MODE_BASIC)) {
// Force the webview to load the Basic HTML Mobile site
setupFacebookWebViewConfig(true, true, true, false);
setupFacebookWebViewConfig(true, true, true, false, false);
} else if (mode.equalsIgnoreCase(FacebookPreferences.SITE_MODE_ONION)) {
// Force the webview to load Facebook via Tor (onion network)
setupFacebookWebViewConfig(true, true, false, false, true);
} else {
// Do not force, allow us to auto-detect what mode to use
setupFacebookWebViewConfig(false, true, false, false);
setupFacebookWebViewConfig(false, true, false, false, false);
}

// If we haven't shown the new menu drawer to the user, auto open it
Expand Down Expand Up @@ -273,13 +277,18 @@ private void loadPreferences() {
* @param facebookZero {@link boolean}
* whether or not to use Facebook Zero
*/
private void setupFacebookWebViewConfig(boolean force, boolean mobile, boolean facebookBasic, boolean facebookZero) {
// TODO: time to fix this mess
private void setupFacebookWebViewConfig(boolean force, boolean mobile, boolean facebookBasic,
boolean facebookZero, boolean facebookOnion) {
if (force && !mobile) {
// Force the desktop site to load
mDomainToUse = INIT_URL_DESKTOP;
} else if (facebookZero) {
// If Facebook zero is set, use that
mDomainToUse = INIT_URL_FACEBOOK_ZERO;
} else if (facebookOnion) {
// If the Onion domain is set, use that
mDomainToUse = INIT_URL_FACEBOOK_ONION;
} else {
// Otherwise, just load the mobile site for all devices
mDomainToUse = INIT_URL_MOBILE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public abstract class BaseFacebookWebViewActivity extends Activity implements
protected final static String INIT_URL_MOBILE = "https://m.facebook.com";
protected final static String INIT_URL_DESKTOP = "https://www.facebook.com";
protected final static String INIT_URL_FACEBOOK_ZERO = "https://0.facebook.com";
protected final static String INIT_URL_FACEBOOK_ONION = "https://facebookcorewwwi.onion";
protected final static String URL_PAGE_NOTIFICATIONS = "/notifications.php";
protected final static String URL_PAGE_MESSAGES = "/messages";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class FacebookPreferences extends PreferenceActivity {
public final static String SITE_MODE_DESKTOP = "desktop";
public final static String SITE_MODE_BASIC = "basic";
public final static String SITE_MODE_ZERO = "zero";
public final static String SITE_MODE_ONION = "onion";
public final static String ABOUT = "pref_about";

// Preferences
Expand Down
2 changes: 2 additions & 0 deletions Tinfoil-for-Facebook/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@
<item>Force desktop site</item>
<item>Force basic site</item>
<item>Facebook Zero</item>
<item>Facebook.onion</item>
</array>
<array name="prefs_mobile_site_list_values">
<item>auto</item>
<item>mobile</item>
<item>desktop</item>
<item>basic</item>
<item>zero</item>
<item>onion</item>
</array>

<string name="pref_about">About</string>
Expand Down

0 comments on commit 3acedc6

Please sign in to comment.