]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java
Bump the target API to 32 (Android 12L). https://redmine.stoutner.com/issues/828
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / BookmarksDatabaseViewActivity.java
index 86ebfbaa93993888cf2887a1f4fbfbc4d3bfc383..dbfda387903de7d0fc0a9c40b42467fb8a16249b 100644 (file)
@@ -153,11 +153,11 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
         actionBar.setCustomView(R.layout.spinner);
         actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_HOME_AS_UP);
 
-        // Initialize the database handler.  The `0` is to specify a database version, but that is set instead using a constant in `BookmarksDatabaseHelper`.
-        bookmarksDatabaseHelper = new BookmarksDatabaseHelper(this, null, null, 0);
+        // Initialize the database handler.
+        bookmarksDatabaseHelper = new BookmarksDatabaseHelper(this);
 
         // Setup a matrix cursor for "All Folders" and "Home Folder".
-        String[] matrixCursorColumnNames = {BookmarksDatabaseHelper._ID, BookmarksDatabaseHelper.BOOKMARK_NAME};
+        String[] matrixCursorColumnNames = {BookmarksDatabaseHelper.ID, BookmarksDatabaseHelper.BOOKMARK_NAME};
         MatrixCursor matrixCursor = new MatrixCursor(matrixCursorColumnNames);
         matrixCursor.addRow(new Object[]{ALL_FOLDERS_DATABASE_ID, getString(R.string.all_folders)});
         matrixCursor.addRow(new Object[]{HOME_FOLDER_DATABASE_ID, getString(R.string.home_folder)});
@@ -296,7 +296,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
                 boolean isFolder = (cursor.getInt(cursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.IS_FOLDER)) == 1);
 
                 // Get the database ID from the `Cursor` and display it in `bookmarkDatabaseIdTextView`.
-                int bookmarkDatabaseId = cursor.getInt(cursor.getColumnIndexOrThrow(BookmarksDatabaseHelper._ID));
+                int bookmarkDatabaseId = cursor.getInt(cursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.ID));
                 TextView bookmarkDatabaseIdTextView = view.findViewById(R.id.bookmarks_databaseview_database_id);
                 bookmarkDatabaseIdTextView.setText(String.valueOf(bookmarkDatabaseId));
 
@@ -472,7 +472,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
                             // Get the position of the folder in the bookmarks cursor.
                             while ((folderPosition < 0) && (bookmarksCursor.getPosition() < bookmarksCursor.getCount())) {
                                 // Check if the folder database ID matches the bookmark database ID.
-                                if (folderDatabaseId == bookmarksCursor.getInt(bookmarksCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper._ID))) {
+                                if (folderDatabaseId == bookmarksCursor.getInt(bookmarksCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.ID))) {
                                     // Get the folder position.
                                     folderPosition = bookmarksCursor.getPosition();
 
@@ -613,19 +613,12 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
         // Inflate the menu.
         getMenuInflater().inflate(R.menu.bookmarks_databaseview_options_menu, menu);
 
-        // Get the current theme status.
-        int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
         // Get a handle for the sort menu item.
         MenuItem sortMenuItem = menu.findItem(R.id.sort);
 
         // Change the sort menu item icon if the listview is sorted by display order, which restores the state after a restart.
         if (sortByDisplayOrder) {
-            if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                sortMenuItem.setIcon(R.drawable.sort_selected_day);
-            } else {
-                sortMenuItem.setIcon(R.drawable.sort_selected_night);
-            }
+            sortMenuItem.setIcon(R.drawable.sort_selected);
         }
 
         // Success.
@@ -648,27 +641,16 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
             // Get a handle for the bookmarks list view.
             ListView bookmarksListView = findViewById(R.id.bookmarks_databaseview_listview);
 
-            // Get the current theme status.
-            int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-
             // Update the icon and display a snackbar.
             if (sortByDisplayOrder) {  // Sort by display order.
-                // Update the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                    menuItem.setIcon(R.drawable.sort_selected_day);
-                } else {
-                    menuItem.setIcon(R.drawable.sort_selected_night);
-                }
+                // Update the icon.
+                menuItem.setIcon(R.drawable.sort_selected);
 
                 // Display a Snackbar indicating the current sort type.
                 Snackbar.make(bookmarksListView, R.string.sorted_by_display_order, Snackbar.LENGTH_SHORT).show();
             } else {  // Sort by database id.
-                // Update the icon according to the theme.
-                if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) {
-                    menuItem.setIcon(R.drawable.sort_day);
-                } else {
-                    menuItem.setIcon(R.drawable.sort_night);
-                }
+                // Update the icon.
+                menuItem.setIcon(R.drawable.sort);
 
                 // Display a Snackbar indicating the current sort type.
                 Snackbar.make(bookmarksListView, R.string.sorted_by_database_id, Snackbar.LENGTH_SHORT).show();
@@ -772,7 +754,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
 
         while (folderCursor.getPosition() < folderCursor.getCount()) {
             // Get the bookmark database ID.
-            int bookmarkId = folderCursor.getInt(folderCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper._ID));
+            int bookmarkId = folderCursor.getInt(folderCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.ID));
 
             // Move the bookmarks cursor to the first position.
             bookmarksCursor.moveToFirst();
@@ -783,7 +765,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements
             // Get the position of this bookmark in the bookmarks cursor.
             while ((bookmarkPosition < 0) && (bookmarksCursor.getPosition() < bookmarksCursor.getCount())) {
                 // Check if the bookmark IDs match.
-                if (bookmarkId == bookmarksCursor.getInt(bookmarksCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper._ID))) {
+                if (bookmarkId == bookmarksCursor.getInt(bookmarksCursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.ID))) {
                     // Get the bookmark position.
                     bookmarkPosition = bookmarksCursor.getPosition();