// `ignorePinnedSslCertificateForDomain` is used in `onCreate()`, `onSslMismatchProceed()`, and `applyDomainSettings()`.
private boolean ignorePinnedSslCertificate;
+ // `orbotStatusBroadcastReciever` is used in `onCreate()` and `onDestroy()`.
+ private BroadcastReceiver orbotStatusBroadcastReceiver;
+
// `waitingForOrbot` is used in `onCreate()`, `onResume()`, and `applyAppSettings()`.
private boolean waitingForOrbot;
waitingForOrbot = false;
// Create an Orbot status `BroadcastReceiver`.
- BroadcastReceiver orbotStatusBroadcastReceiver = new BroadcastReceiver() {
+ orbotStatusBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Store the content of the status message in `orbotStatus`.
// Replace the header that `WebView` creates for `X-Requested-With` with a null value. The default value is the application ID (com.stoutner.privacybrowser.standard).
customHeaders.put("X-Requested-With", "");
- // Initialize the default preference values the first time the program is run. `this` is the context. `false` keeps this command from resetting any current preferences back to default.
+ // Initialize the default preference values the first time the program is run. `false` keeps this command from resetting any current preferences back to default.
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
// Get the intent that started the app.
@Override
public void onPause() {
+ // Run the default commands.
super.onPause();
// Pause `mainWebView`.
}
}
+ @Override
+ public void onDestroy() {
+ // Unregister the Orbot status broadcast receiver.
+ this.unregisterReceiver(orbotStatusBroadcastReceiver);
+
+ // Run the default commands.
+ super.onDestroy();
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
package com.stoutner.privacybrowser.activities;
import android.os.Bundle;
-import android.preference.PreferenceFragment;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;
// Run the default commands.
super.onCreate(savedInstanceState);
- // Display SettingsFragment.
- PreferenceFragment settingsFragment = new SettingsFragment();
- getFragmentManager().beginTransaction().replace(android.R.id.content, settingsFragment).commit();
+ // Display the settings fragment.
+ getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
}
}