productFlavors {
standard {
applicationId "com.stoutner.privacybrowser.standard"
- versionName "1.4-standard"
}
free {
applicationId "com.stoutner.privacybrowser.free"
- versionName "1.4-free"
}
}
}
public static boolean domStorageEnabled;
// homepage is public static so it can be accessed from SettingsFragment. It is also used in onCreate() and onOptionsItemSelected().
public static String homepage;
+ // swipeToRefresh is public static so it can be accessed from SettingsFragment. It is also used in onCreate().
+ public static SwipeRefreshLayout swipeToRefresh;
+ // swipeToRefreshEnabled is public static so it can be accessed from SettingsFragment. It is also used in onCreate().
+ public static boolean swipeToRefreshEnabled;
// drawerToggle is used in onCreate(), onPostCreate(), onConfigurationChanged(), onNewIntent(), and onNavigationItemSelected().
private ActionBarDrawerToggle drawerToggle;
final View adView = findViewById(R.id.adView);
// Implement swipe to refresh
- final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
+ swipeToRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
swipeToRefresh.setColorSchemeResources(R.color.blue);
swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
// Hide zoom controls.
mainWebView.getSettings().setDisplayZoomControls(false);
+
// Initialize the default preference values the first time the program is run.
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
// Set homepage initial status.
homepage = savedPreferences.getString("homepage", "https://www.duckduckgo.com");
+ // Set swipe to refresh initial status. The default is true.
+ swipeToRefreshEnabled = savedPreferences.getBoolean("swipe_to_refresh_enabled", true);
+ swipeToRefresh.setEnabled(swipeToRefreshEnabled);
+
+
// Get the intent information that started the app.
final Intent intent = getIntent();
//Everything else will be handled by CreateHomeScreenShortcut and the associated listeners below.
return true;
+ case R.id.refresh:
+ mainWebView.reload();
+
default:
return super.onOptionsItemSelected(menuItem);
}
MainWebViewActivity.homepage = sharedPreferences.getString("homepage", "https://www.duckduckgo.com");
return;
+ case "swipe_to_refresh_enabled":
+ // Set swipeToRefreshEnabled to the new state. The default is true.
+ MainWebViewActivity.swipeToRefreshEnabled = sharedPreferences.getBoolean("swipe_to_refresh_enabled", true);
+
+ // Update swipeRefreshLayout to match the new state.
+ MainWebViewActivity.swipeToRefresh.setEnabled(MainWebViewActivity.swipeToRefreshEnabled);
+
// If no match, do nothing.
default:
}
savedPreferences.registerOnSharedPreferenceChangeListener(preferencesListener);
}
+ // It is necessary to reregister the listener on every resume or it will randomly stop working for the user because apps can be paused and resumed at any time,
+ // even when they are in the foreground.
@Override
public void onResume() {
super.onResume();
android:title="@string/add_to_home_screen"
android:orderInCategory="80"
app:showAsAction="never" />
+
+ <item
+ android:id="@+id/refresh"
+ android:title="@string/refresh"
+ android:orderInCategory="90"
+ app:showAsAction="never" />
</menu>
<string name="clear_dom_storage">Clear DOM Storage</string>
<string name="share">Share</string>
<string name="add_to_home_screen">Add to Home Screen</string>
+ <string name="refresh">Refresh</string>
<!-- Create Home Screen Shortcut Alert Dialog. -->
<string name="shortcut_name">Shortcut name</string>
that allows websites to store larger and more complex types of information, like pictures, on your device.</string>
<string name="general_settings">General Settings</string>
<string name="homepage_preference">Homepage</string>
+ <string name="swipe_to_refresh_enabled">Swipe to refresh</string>
+ <string name="swipe_to_refresh_enabled_summary">Some websites don\'t work well if swipe to refresh is enabled.</string>
<!-- About Dialog. -->
<string name="about_privacy_browser">About Privacy Browser</string>
android:defaultValue="https://www.duckduckgo.com"
android:inputType="textUri"
android:singleLine="true" />
+
+ <SwitchPreference
+ android:key="swipe_to_refresh_enabled"
+ android:title="@string/swipe_to_refresh_enabled"
+ android:summary="@string/swipe_to_refresh_enabled_summary"
+ android:defaultValue="true" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file