]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/fragments/DomainSettingsFragment.java
Reload `DomainSettingsFragment` on rotate. Implements https://redmine.stoutner.com...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / fragments / DomainSettingsFragment.java
index dbd8bb9b9975bc10f079c7b08dd9390442c2dd5d..b47dec32c2e0d575a7448f0abd14d99a4cd5176d 100644 (file)
@@ -50,8 +50,8 @@ public class DomainSettingsFragment extends Fragment {
     // `DATABASE_ID` is used by activities calling this fragment.
     public static final String DATABASE_ID = "database_id";
 
-    // `databaseId` is used in `onCreate()` and `onCreateView()`.
-    private int databaseId;
+    // `databaseId` is public statis so it can be accessed from `DomainsActivity`. It is also used in `onCreate()` and `onCreateView()`.
+    public static int databaseId;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -65,8 +65,8 @@ public class DomainSettingsFragment extends Fragment {
     @SuppressWarnings("deprecation")
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        // Inflate `domain_settings`.  `false` does not attach it to the root `container`.
-        View domainSettingsView = inflater.inflate(R.layout.domain_settings, container, false);
+        // Inflate `domain_settings_fragment`.  `false` does not attach it to the root `container`.
+        View domainSettingsView = inflater.inflate(R.layout.domain_settings_fragment, container, false);
 
         // Get a handle for the `Context`.
         Context context = getContext();
@@ -91,9 +91,8 @@ public class DomainSettingsFragment extends Fragment {
         final ImageView displayWebpageImagesImageView = (ImageView) domainSettingsView.findViewById(R.id.domain_settings_display_webpage_images_imageview);
         Spinner displayWebpageImagesSpinner = (Spinner) domainSettingsView.findViewById(R.id.domain_settings_display_webpage_images_spinner);
 
-        // Initialize the database handler.  `this` specifies the context.  The two `nulls` do not specify the database name or a `CursorFactory`.
-        // The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`.
-        DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(getContext(), null, null, 0);
+        // Initialize the database handler.  The two `nulls` do not specify the database name or a `CursorFactory`.  The `0` specifies the database version, but that is ignored and set instead using a constant in `DomainsDatabaseHelper`.
+        DomainsDatabaseHelper domainsDatabaseHelper = new DomainsDatabaseHelper(context, null, null, 0);
 
         // Get the database `Cursor` for this ID and move it to the first row.
         Cursor domainCursor = domainsDatabaseHelper.getCursorForId(databaseId);
@@ -253,8 +252,8 @@ public class DomainSettingsFragment extends Fragment {
         WebView bareWebView = (WebView) bareWebViewLayout.findViewById(R.id.bare_webview);
         final String webViewDefaultUserAgentString = bareWebView.getSettings().getUserAgentString();
 
-        // Get a handle for the shared preference.  `this` references the current context.
-        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+        // Get a handle for the shared preference.
+        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
 
         // Store the default user agent string values.
         final String defaultUserAgentString = sharedPreferences.getString("user_agent", "PrivacyBrowser/1.0");