]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Add the ability to create and edit bookmark folders.
authorSoren Stoutner <soren@stoutner.com>
Fri, 15 Jul 2016 20:44:38 +0000 (13:44 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 15 Jul 2016 20:44:38 +0000 (13:44 -0700)
44 files changed:
.idea/dictionaries/soren.xml
app/src/main/AndroidManifest.xml
app/src/main/assets/about_licenses.html
app/src/main/assets/images/ic_create_new_folder.png [new file with mode: 0644]
app/src/main/assets/images/ic_folder.png [new file with mode: 0644]
app/src/main/assets/images/ic_folder_special.png [new file with mode: 0644]
app/src/main/java/com/stoutner/privacybrowser/BookmarksActivity.java
app/src/main/java/com/stoutner/privacybrowser/BookmarksDatabaseHandler.java
app/src/main/java/com/stoutner/privacybrowser/BookmarksDatabaseViewActivity.java [new file with mode: 0644]
app/src/main/java/com/stoutner/privacybrowser/CreateBookmark.java
app/src/main/java/com/stoutner/privacybrowser/CreateBookmarkFolder.java [new file with mode: 0644]
app/src/main/java/com/stoutner/privacybrowser/CreateHomeScreenShortcut.java
app/src/main/java/com/stoutner/privacybrowser/EditBookmark.java
app/src/main/java/com/stoutner/privacybrowser/EditBookmarkFolder.java [new file with mode: 0644]
app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java
app/src/main/java/com/stoutner/privacybrowser/MoveToFolder.java [new file with mode: 0644]
app/src/main/res/drawable-hdpi/folder_blue_bitmap.png [new file with mode: 0644]
app/src/main/res/drawable-mdpi/folder_blue_bitmap.png [new file with mode: 0644]
app/src/main/res/drawable-xhdpi/folder_blue_bitmap.png [new file with mode: 0644]
app/src/main/res/drawable-xxhdpi/folder_blue_bitmap.png [new file with mode: 0644]
app/src/main/res/drawable/back.xml
app/src/main/res/drawable/create_folder.xml [new file with mode: 0644]
app/src/main/res/drawable/edit.xml
app/src/main/res/drawable/exit.xml
app/src/main/res/drawable/folder.xml [new file with mode: 0644]
app/src/main/res/drawable/forward.xml
app/src/main/res/drawable/move_bookmark_down_disabled.xml
app/src/main/res/drawable/move_bookmark_down_enabled.xml
app/src/main/res/drawable/move_bookmark_up_disabled.xml
app/src/main/res/drawable/move_bookmark_up_enabled.xml
app/src/main/res/drawable/move_to_folder.xml [new file with mode: 0644]
app/src/main/res/layout/bookmarks_coordinatorlayout.xml
app/src/main/res/layout/bookmarks_database_view_coordinatorlayout.xml [new file with mode: 0644]
app/src/main/res/layout/bookmarks_database_view_linearlayout.xml [new file with mode: 0644]
app/src/main/res/layout/bookmarks_item_linearlayout.xml
app/src/main/res/layout/create_bookmark_dialog.xml
app/src/main/res/layout/create_bookmark_folder_dialog.xml [new file with mode: 0644]
app/src/main/res/layout/create_home_screen_shortcut_dialog.xml
app/src/main/res/layout/edit_bookmark_dialog.xml
app/src/main/res/layout/edit_bookmark_folder_dialog.xml [new file with mode: 0644]
app/src/main/res/menu/bookmarks_context_menu.xml
app/src/main/res/menu/bookmarks_options_menu.xml
app/src/main/res/values/colors.xml
app/src/main/res/values/strings.xml

index 2d91de1898e1707114668ce194a6139788486c19..f6e91ca9d0c663dfb9ddd0319ac3465cdf17f06b 100644 (file)
@@ -35,6 +35,8 @@
       <w>orbot</w>
       <w>panopticlick</w>
       <w>parentfolder</w>
+      <w>radiobutton</w>
+      <w>radiogroup</w>
       <w>redmine</w>
       <w>referer</w>
       <w>relativelayout</w>
index 17fb93abbc0c2bacfcb9bd30bbe9110b1070aac2..60d1f3aa8f2ba8f87bb2e9cd767226505bbc4fda 100644 (file)
@@ -28,7 +28,7 @@
     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
 
 
-    <!-- For API >= 23, app data is automatically backed up to Google cloud servers unless android:allowBackup="false" and android:fullBackupContent="false" is set. -->
+    <!-- For API >= 23, app data is automatically backed up to Google cloud servers unless `android:allowBackup="false"` and `android:fullBackupContent="false"` is set. -->
     <application
         android:label="@string/privacy_browser"
         android:icon="@mipmap/privacy_browser"
         android:allowBackup="false"
         android:fullBackupContent="false" >
 
-        <!-- If android:name="android.webkit.WebView.MetricsOptOut" is not "true" then WebViews will upload metrics to Google.
-          https://developer.android.com/reference/android/webkit/WebView.html -->
+        <!-- If `android:name="android.webkit.WebView.MetricsOptOut"` is not `true` then WebViews will upload metrics to Google.
+            https://developer.android.com/reference/android/webkit/WebView.html -->
         <meta-data
             android:name="android.webkit.WebView.MetricsOptOut"
             android:value="true" />
 
-        <!-- android:configChanges="orientation|screenSize" makes the activity not reload when the orientation changes, which preserves scroll location in the WebView.
-          android:launchMode="singleTask" makes the app launch in a new task instead of inside the task of the program that sends it an intent.
-          It also makes it reuse an existing Privacy Browser activity if available instead of launching a new one.
-          android:persistableMode="persistNever" removes Privacy Browser from the recents screen on a device reboot. -->
+        <!-- `android:configChanges="orientation|screenSize"` makes the activity not reload when the orientation changes, which preserves scroll location in the WebView.
+            `android:launchMode="singleTask"` makes the app launch in a new task instead of inside the task of the program that sends it an intent.
+            It also makes it reuse an existing Privacy Browser activity if available instead of launching a new one.
+            `android:persistableMode="persistNever"` removes Privacy Browser from the recents screen on a device reboot. -->
         <activity
             android:name=".MainWebViewActivity"
             android:label="@string/privacy_browser"
@@ -58,7 +58,7 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
 
-            <!-- android.intent.action.VIEW with the two data schemes enables processing of web intents. -->
+            <!-- `android.intent.action.VIEW` with the two data schemes enables processing of web intents. -->
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.BROWSABLE" />
         </activity>
 
 
-        <!-- android:configChanges="orientation|screenSize" makes the activity not reload when the orientation changes.
-          android:persistableMode="persistNever" removes Privacy Browser from the recents screen on a device reboot. -->
+        <!-- `android:configChanges="orientation|screenSize"` makes the activity not reload when the orientation changes.
+            `android:persistableMode="persistNever"` removes Privacy Browser from the recents screen on a device reboot. -->
         <activity
             android:name=".BookmarksActivity"
             android:label="@string/bookmarks"
             android:theme="@style/PrivacyBrowser.SecondaryActivity"
             android:parentActivityName=".MainWebViewActivity"
             android:configChanges="orientation|screenSize"
-            android:persistableMode="persistNever" >
-        </activity>
+            android:persistableMode="persistNever" />
+
+        <!-- `android:configChanges="orientation|screenSize"` makes the activity not reload when the orientation changes.
+            `android:persistableMode="persistNever"` removes Privacy Browser from the recents screen on a device reboot. -->
+        <activity
+            android:name=".BookmarksDatabaseViewActivity"
+            android:label="@string/bookmarks_database_view"
+            android:theme="@style/PrivacyBrowser.SecondaryActivity"
+            android:parentActivityName=".BookmarksActivity"
+            android:configChanges="orientation|screenSize"
+            android:persistableMode="persistNever" />
 
-        <!-- android:configChanges="orientation|screenSize" makes the activity not reload when the orientation changes.
-          android:persistableMode="persistNever" removes Privacy Browser from the recents screen on a device reboot. -->
+        <!-- `android:configChanges="orientation|screenSize"` makes the activity not reload when the orientation changes.
+            `android:persistableMode="persistNever"` removes Privacy Browser from the recents screen on a device reboot. -->
         <activity
             android:name=".SettingsActivity"
             android:label="@string/privacy_browser_settings"
             android:theme="@style/Settings"
             android:parentActivityName=".MainWebViewActivity"
             android:configChanges="orientation|screenSize"
-            android:persistableMode="persistNever" >
-        </activity>
+            android:persistableMode="persistNever" />
 
-        <!-- android:configChanges="orientation|screenSize" makes the activity not reload when the orientation changes.
-          android:persistableMode="persistNever" removes Privacy Browser from the recents screen on a device reboot. -->
+        <!-- `android:configChanges="orientation|screenSize"` makes the activity not reload when the orientation changes.
+            `android:persistableMode="persistNever"` removes Privacy Browser from the recents screen on a device reboot. -->
         <activity
             android:name=".GuideActivity"
             android:label="@string/privacy_browser_guide"
             android:theme="@style/PrivacyBrowser.SecondaryActivity"
             android:parentActivityName=".MainWebViewActivity"
             android:configChanges="orientation|screenSize"
-            android:persistableMode="persistNever" >
-        </activity>
+            android:persistableMode="persistNever" />
 
-        <!-- android:configChanges="orientation|screenSize" makes the activity not reload when the orientation changes.
-          android:persistableMode="persistNever" removes Privacy Browser from the recents screen on a device reboot. -->
+        <!-- `android:configChanges="orientation|screenSize"` makes the activity not reload when the orientation changes.
+            `android:persistableMode="persistNever"` removes Privacy Browser from the recents screen on a device reboot. -->
         <activity
             android:name=".AboutActivity"
             android:label="@string/about_privacy_browser"
             android:theme="@style/PrivacyBrowser.SecondaryActivity"
             android:parentActivityName=".MainWebViewActivity"
             android:configChanges="orientation|screenSize"
-            android:persistableMode="persistNever" >
-        </activity>
+            android:persistableMode="persistNever" />
     </application>
 </manifest>
index 63e7996643a3d24f0ee9c4c087c413730d854551..f09fbb4257b637e305ddc22c81098af40b2c5299 100644 (file)
         color: 0D4781;
     }
 
-    img.center {
+    img.icon {
         vertical-align: middle;
+        height: 32;
+        width: 32;
     }
 
     img.left {
     <img class="left" src="images/javascript_enabled.png" height="32" width="32">
     are derived from ic_security and ic_language. Modifications were made by Soren Stoutner in 2016.</p>
 
-<p><img class="center" src="images/ic_language.png" height="32" width="32"> ic_language.</p>
+<p><img class="icon" src="images/ic_language.png"> ic_language.</p>
 
-<p><img class="center" src="images/ic_home.png" height="32" width="32"> ic_home.</p>
+<p><img class="icon" src="images/ic_home.png"> ic_home.</p>
 
-<p><img class="center" src="images/ic_arrow_back.png" height="32" width="32"> ic_arrow_back.</p>
+<p><img class="icon" src="images/ic_arrow_back.png"> ic_arrow_back.</p>
 
-<p><img class="center" src="images/ic_arrow_forward.png" height="32" width="32"> ic_arrow_forward.</p>
+<p><img class="icon" src="images/ic_arrow_forward.png"> ic_arrow_forward.</p>
 
-<p><img class="center" src="images/ic_bookmark_border.png" height="32" width="32"> ic_bookmark_border.</p>
+<p><img class="icon" src="images/ic_bookmark_border.png"> ic_bookmark_border.</p>
 
-<p><img class="center" src="images/ic_file_download.png" height="32" width="32"> ic_file_download.</p>
+<p><img class="icon" src="images/ic_file_download.png"> ic_file_download.</p>
 
-<p><img class="center" src="images/ic_settings.png" height="32" width="32"> ic_settings.</p>
+<p><img class="icon" src="images/ic_settings.png"> ic_settings.</p>
 
-<p><img class="center" src="images/ic_import_contacts.png" height="32" width="32"> ic_import_contacts.</p>
+<p><img class="icon" src="images/ic_import_contacts.png"> ic_import_contacts.</p>
 
-<p><img class="center" src="images/ic_info_outline.png" height="32" width="32"> ic_info_outline.</p>
+<p><img class="icon" src="images/ic_info_outline.png"> ic_info_outline.</p>
 
-<p><img class="center" src="images/ic_exit_to_app.png" height="32" width="32"> ic_exit_to_app.</p>
+<p><img class="icon" src="images/ic_exit_to_app.png"> ic_exit_to_app.</p>
 
-<p><img class="center" src="images/ic_add.png" height="32" width="32"> ic_add.</p>
+<p><img class="icon" src="images/ic_add.png"> ic_add.</p>
 
-<p><img class="center" src="images/ic_vertical_align_top.png" height="32" width="32"> ic_vertical_align_top</p>
+<p><img class="icon" src="images/ic_vertical_align_top.png"> ic_vertical_align_top</p>
 
-<p><img class="center" src="images/ic_vertical_align_bottom.png" height="32" width="32"> ic_vertical_align_bottom</p>
+<p><img class="icon" src="images/ic_vertical_align_bottom.png"> ic_vertical_align_bottom</p>
 
-<p><img class="center" src="images/ic_edit.png" height="32" width="32"> ic_edit.</p>
+<p><img class="icon" src="images/ic_folder.png"> ic_folder</p>
 
-<p><img class="center" src="images/ic_delete.png" height="32" width="32"> ic_download.</p>
+<p><img class="icon" src="images/ic_create_new_folder.png"> ic_create_new_folder</p>
 
-<p><img class="center" src="images/ic_select_all.png" height="32" width="32"> ic_select_all</p>
+<p><img class="icon" src="images/ic_folder_special.png"> ic_folder_special</p>
+
+<p><img class="icon" src="images/ic_edit.png"> ic_edit.</p>
+
+<p><img class="icon" src="images/ic_delete.png"> ic_download.</p>
+
+<p><img class="icon" src="images/ic_select_all.png"> ic_select_all</p>
 <hr/>
 
 <h3>GNU General Public License</h3>
diff --git a/app/src/main/assets/images/ic_create_new_folder.png b/app/src/main/assets/images/ic_create_new_folder.png
new file mode 100644 (file)
index 0000000..db0234d
Binary files /dev/null and b/app/src/main/assets/images/ic_create_new_folder.png differ
diff --git a/app/src/main/assets/images/ic_folder.png b/app/src/main/assets/images/ic_folder.png
new file mode 100644 (file)
index 0000000..e1b3183
Binary files /dev/null and b/app/src/main/assets/images/ic_folder.png differ
diff --git a/app/src/main/assets/images/ic_folder_special.png b/app/src/main/assets/images/ic_folder_special.png
new file mode 100644 (file)
index 0000000..2eef308
Binary files /dev/null and b/app/src/main/assets/images/ic_folder_special.png differ
index 75a340211711d4f9fcb8f70d765fefacd3ac552d..ca004072a54ac11c68d78991849687a2e591b4c5 100644 (file)
@@ -22,15 +22,19 @@ package com.stoutner.privacybrowser;
 import android.app.Activity;
 import android.app.DialogFragment;
 import android.content.Context;
+import android.content.Intent;
 import android.database.Cursor;
+import android.database.DatabaseUtils;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.Typeface;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.support.design.widget.FloatingActionButton;
 import android.support.design.widget.Snackbar;
 import android.support.v4.app.NavUtils;
+import android.support.v4.content.ContextCompat;
 import android.support.v4.widget.CursorAdapter;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
@@ -47,11 +51,14 @@ import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.ListView;
+import android.widget.RadioButton;
 import android.widget.TextView;
 
 import java.io.ByteArrayOutputStream;
 
-public class BookmarksActivity extends AppCompatActivity implements CreateBookmark.CreateBookmarkListener, EditBookmark.EditBookmarkListener {
+public class BookmarksActivity extends AppCompatActivity implements CreateBookmark.CreateBookmarkListener,
+        CreateBookmarkFolder.CreateBookmarkFolderListener, EditBookmark.EditBookmarkListener,
+        EditBookmarkFolder.EditBookmarkFolderListener {
     // `bookmarksDatabaseHandler` is public static so it can be accessed from EditBookmark.  It is also used in `onCreate()`,
     // `onCreateBookmarkCreate()`, `updateBookmarksListView()`, and `updateBookmarksListViewExcept()`.
     public static BookmarksDatabaseHandler bookmarksDatabaseHandler;
@@ -60,34 +67,50 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
     // It is also used in `onCreate()`, `updateBookmarksListView()`, and `updateBookmarksListViewExcept()`.
     public static ListView bookmarksListView;
 
+    // `currentFolder` is used in `onCreate`, `onOptionsItemSelected()`, `onCreateBookmarkCreate`, `onCreateBookmarkFolderCreate`, and `onEditBookmarkSave`.
+    private String currentFolder;
+
     // `contextualActionMode` is used in `onCreate()` and `onEditBookmarkSave()`.
     private ActionMode contextualActionMode;
 
     // `selectedBookmarkPosition` is used in `onCreate()` and `onEditBookarkSave()`.
     private int selectedBookmarkPosition;
 
+    // `appBar` is used in `onCreate()` and `updateBookmarksListView()`.
+    private ActionBar appBar;
+
+    // `bookmarksCursor` is used in `onCreate()`, `updateBookmarksListView()`, and `updateBookmarksListViewExcept()`.
+    private Cursor bookmarksCursor;
+
+    // `oldFolderName` is used in `onCreate()` and `onEditBookmarkFolderSave()`.
+    private String oldFolderNameString;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.bookmarks_coordinatorlayout);
 
-        // We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21.
+        // We need to use the `SupportActionBar` from `android.support.v7.app.ActionBar` until the minimum API is >= 21.
         final Toolbar bookmarksAppBar = (Toolbar) findViewById(R.id.bookmarks_toolbar);
         setSupportActionBar(bookmarksAppBar);
 
-        // Display the home arrow on supportAppBar.
-        final ActionBar appBar = getSupportActionBar();
+        // Display the home arrow on `SupportActionBar`.
+        appBar = getSupportActionBar();
         assert appBar != null;// This assert removes the incorrect warning in Android Studio on the following line that appBar might be null.
         appBar.setDisplayHomeAsUpEnabled(true);
 
+
         // Initialize the database handler and the ListView.
         // `this` specifies the context.  The two `null`s do not specify the database name or a `CursorFactory`.
-        // The `0` is to specify a database version, but that is set instead using a constant in BookmarksDatabaseHandler.
+        // The `0` is to specify a database version, but that is set instead using a constant in `BookmarksDatabaseHandler`.
         bookmarksDatabaseHandler = new BookmarksDatabaseHandler(this, null, null, 0);
         bookmarksListView = (ListView) findViewById(R.id.bookmarks_listview);
 
+        // Set currentFolder to the home folder, which is null in the database.
+        currentFolder = "";
+
         // Display the bookmarks in the ListView.
-        updateBookmarksListView();
+        updateBookmarksListView(currentFolder);
 
         // Set a listener so that tapping a list item loads the URL.  We need to store the activity
         // in a variable so that we can return to the parent activity after loading the URL.
@@ -98,12 +121,28 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                 // Convert the id from long to int to match the format of the bookmarks database.
                 int databaseID = (int) id;
 
-                // Get the bookmark URL and assign it to formattedUrlString.
-                MainWebViewActivity.formattedUrlString = bookmarksDatabaseHandler.getBookmarkURL(databaseID);
+                // Get the bookmark `Cursor` and move it to the first row.
+                Cursor bookmarkCursor = bookmarksDatabaseHandler.getBookmarkCursor(databaseID);
+                bookmarkCursor.moveToFirst();
+
+                // If the bookmark is a folder load its contents into the ListView.
+                if (bookmarkCursor.getInt(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.IS_FOLDER)) == 1) {
+                    // Update `currentFolder`.
+                    currentFolder = bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_NAME));
+
+                    // Reload the ListView with `currentFolder`.
+                    updateBookmarksListView(currentFolder);
+                } else {  // Load the URL into `mainWebView`.
+                    // Get the bookmark URL and assign it to formattedUrlString.
+                    MainWebViewActivity.formattedUrlString = bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_URL));
+
+                    //  Load formattedUrlString and return to the main activity.
+                    MainWebViewActivity.mainWebView.loadUrl(MainWebViewActivity.formattedUrlString);
+                    NavUtils.navigateUpFromSameTask(bookmarksActivity);
+                }
 
-                //  Load formattedUrlString and return to the main activity.
-                MainWebViewActivity.mainWebView.loadUrl(MainWebViewActivity.formattedUrlString);
-                NavUtils.navigateUpFromSameTask(bookmarksActivity);
+                // Close the `Cursor`.
+                bookmarkCursor.close();
             }
         });
 
@@ -125,7 +164,14 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
             public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                 // Inflate the menu for the contextual app bar and set the title.
                 getMenuInflater().inflate(R.menu.bookmarks_context_menu, menu);
-                mode.setTitle(R.string.bookmarks);
+
+                // Set the title.
+                if (currentFolder.isEmpty()) {
+                    // Use `R.string.bookmarks` if we are in the home folder.
+                    mode.setTitle(R.string.bookmarks);
+                } else {  // Use the current folder name as the title.
+                    mode.setTitle(currentFolder);
+                }
 
                 // Get a handle for MenuItems we need to selectively disable.
                 moveBookmarkUpMenuItem = menu.findItem(R.id.move_bookmark_up);
@@ -202,12 +248,14 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                 // `numberOfBookmarks` is used in `R.id.move_bookmark_up_enabled`, `R.id.move_bookmark_down_enabled`, and `R.id.context_menu_select_all_bookmarks`.
                 int numberOfBookmarks;
 
-                // `selectedBookmarkLongArray` is used in `R.id.move_bookmark_up` and `R.id.move_bookmark_down`.
+                // `selectedBookmarkLongArray` is used in `R.id.move_bookmark_up`, `R.id.move_bookmark_down`, and `R.id.edit_bookmark`.
                 long[]selectedBookmarkLongArray;
-                // `selectedBookmarkDatabaseId` is used in `R.id.move_bookmark_up` and `R.id.move_bookmark_down`.
+                // `selectedBookmarkDatabaseId` is used in `R.id.move_bookmark_up`, `R.id.move_bookmark_down`, and `R.id.edit_bookmark`.
                 int selectedBookmarkDatabaseId;
                 // `selectedBookmarkNewPosition` is used in `R.id.move_bookmark_up` and `R.id.move_bookmark_down`.
                 int selectedBookmarkNewPosition;
+                // `bookmarkPositionSparseBooleanArray` is used in `R.id.edit_bookmark` and `R.id.delete_bookmark`.
+                SparseBooleanArray bookmarkPositionSparseBooleanArray;
 
                 switch (menuItemId) {
                     case R.id.move_bookmark_up:
@@ -238,7 +286,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                         }
 
                         // Refresh the ListView.
-                        updateBookmarksListView();
+                        updateBookmarksListView(currentFolder);
 
                         // Select the previously selected bookmark in the new location.
                         bookmarksListView.setItemChecked(selectedBookmarkNewPosition, true);
@@ -275,7 +323,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                         }
 
                         // Refresh the ListView.
-                        updateBookmarksListView();
+                        updateBookmarksListView(currentFolder);
 
                         // Select the previously selected bookmark in the new location.
                         bookmarksListView.setItemChecked(selectedBookmarkNewPosition, true);
@@ -284,22 +332,44 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                         break;
 
                     case R.id.edit_bookmark:
+                        // Get a handle for `contextualActionMode` so we can close it when `editBookmarkDialog` is finished.
+                        contextualActionMode = mode;
+
                         // Get a handle for `selectedBookmarkPosition` so we can scroll to it after refreshing the ListView.
-                        SparseBooleanArray bookmarkPositionSparseBooleanArray = bookmarksListView.getCheckedItemPositions();
+                        bookmarkPositionSparseBooleanArray = bookmarksListView.getCheckedItemPositions();
                         selectedBookmarkPosition = bookmarkPositionSparseBooleanArray.keyAt(0);
 
-                        // Get a handle for `contextualActionMode` so we can close it when `editBookmarkDialog` is finished.
-                        contextualActionMode = mode;
+                        // Move to the selected database ID and find out if it is a folder.
+                        bookmarksCursor.moveToPosition(selectedBookmarkPosition);
+                        boolean isFolder = (bookmarksCursor.getInt(bookmarksCursor.getColumnIndex(BookmarksDatabaseHandler.IS_FOLDER)) == 1);
 
-                        // Show the `EditBookmark` `AlertDialog` and name the instance `@string/edit_bookmark`.
-                        DialogFragment editBookmarkDialog = new EditBookmark();
-                        editBookmarkDialog.show(getFragmentManager(), "@string/edit_bookmark");
+                        if (isFolder) {
+                            // Save the current folder name.
+                            oldFolderNameString = bookmarksCursor.getString(bookmarksCursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_NAME));
+
+                            // Show the `EditBookmarkFolder` `AlertDialog` and name the instance `@string/edit_folder`.
+                            DialogFragment editFolderDialog = new EditBookmarkFolder();
+                            editFolderDialog.show(getFragmentManager(), getResources().getString(R.string.edit_folder));
+                        } else {
+                            // Show the `EditBookmark` `AlertDialog` and name the instance `@string/edit_bookmark`.
+                            DialogFragment editBookmarkDialog = new EditBookmark();
+                            editBookmarkDialog.show(getFragmentManager(), getResources().getString(R.string.edit_bookmark));
+                        }
                         break;
 
                     case R.id.delete_bookmark:
                         // Get an array of the selected rows.
                         final long[] selectedBookmarksLongArray = bookmarksListView.getCheckedItemIds();
 
+                        // Get a handle for `selectedBookmarkPosition` so we can scroll to it after refreshing the ListView.
+                        bookmarkPositionSparseBooleanArray = bookmarksListView.getCheckedItemPositions();
+                        selectedBookmarkPosition = bookmarkPositionSparseBooleanArray.keyAt(0);
+
+                        updateBookmarksListViewExcept(selectedBookmarksLongArray, currentFolder);
+
+                        // Scroll to where the deleted bookmark was located.
+                        bookmarksListView.setSelection(selectedBookmarkPosition);
+
                         String snackbarMessage;
 
                         // Determine how many items are in the array and prepare an appropriate Snackbar message.
@@ -309,8 +379,6 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                             snackbarMessage = selectedBookmarksLongArray.length + " " + getString(R.string.bookmarks_deleted);
                         }
 
-                        updateBookmarksListViewExcept(selectedBookmarksLongArray);
-
                         // Show a SnackBar.
                         Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), snackbarMessage, Snackbar.LENGTH_LONG)
                                 .setAction(R.string.undo, new View.OnClickListener() {
@@ -326,7 +394,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                                             // The user pushed the "Undo" button.
                                             case Snackbar.Callback.DISMISS_EVENT_ACTION:
                                                 // Refresh the ListView to show the rows again.
-                                                updateBookmarksListView();
+                                                updateBookmarksListView(currentFolder);
 
                                                 break;
 
@@ -376,7 +444,7 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
             public void onClick(View view) {
                 // Show the `CreateBookmark` `AlertDialog` and name the instance `@string/create_bookmark`.
                 DialogFragment createBookmarkDialog = new CreateBookmark();
-                createBookmarkDialog.show(getFragmentManager(), "@string/create_bookmark");
+                createBookmarkDialog.show(getFragmentManager(), getResources().getString(R.string.create_bookmark));
             }
         });
     }
@@ -402,7 +470,21 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
 
         switch (menuItemId) {
             case android.R.id.home:
-                NavUtils.navigateUpFromSameTask(this);
+                // Exit BookmarksActivity if currently at the home folder.
+                if (currentFolder.isEmpty()) {
+                    NavUtils.navigateUpFromSameTask(this);
+                } else {  // Navigate up one folder.
+                    // Place the former parent folder in `currentFolder`.
+                    currentFolder = bookmarksDatabaseHandler.getParentFolder(currentFolder);
+
+                    updateBookmarksListView(currentFolder);
+                }
+                break;
+
+            case R.id.create_folder:
+                // Show the `CreateBookmarkFolder` `AlertDialog` and name the instance `@string/create_folder`.
+                DialogFragment createBookmarkFolderDialog = new CreateBookmarkFolder();
+                createBookmarkFolderDialog.show(getFragmentManager(), getResources().getString(R.string.create_folder));
                 break;
 
             case R.id.options_menu_select_all_bookmarks:
@@ -412,21 +494,27 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                     bookmarksListView.setItemChecked(i, true);
                 }
                 break;
+
+            case R.id.bookmarks_database_view:
+                // Launch `BookmarksDatabaseViewActivity`.
+                Intent bookmarksDatabaseViewIntent = new Intent(this, BookmarksDatabaseViewActivity.class);
+                startActivity(bookmarksDatabaseViewIntent);
+                break;
         }
         return true;
     }
 
     @Override
-    public void onCreateBookmarkCancel(DialogFragment createBookmarkDialogFragment) {
+    public void onCancelCreateBookmark(DialogFragment dialogFragment) {
         // Do nothing because the user selected `Cancel`.
     }
 
     @Override
-    public void onCreateBookmarkCreate(DialogFragment createBookmarkDialogFragment) {
+    public void onCreateBookmark(DialogFragment dialogFragment) {
         // Get the `EditText`s from the `createBookmarkDialogFragment` and extract the strings.
-        EditText createBookmarkNameEditText = (EditText) createBookmarkDialogFragment.getDialog().findViewById(R.id.create_bookmark_name_edittext);
+        EditText createBookmarkNameEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.create_bookmark_name_edittext);
         String bookmarkNameString = createBookmarkNameEditText.getText().toString();
-        EditText createBookmarkUrlEditText = (EditText) createBookmarkDialogFragment.getDialog().findViewById(R.id.create_bookmark_url_edittext);
+        EditText createBookmarkUrlEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.create_bookmark_url_edittext);
         String bookmarkUrlString = createBookmarkUrlEditText.getText().toString();
 
         // Convert the favoriteIcon Bitmap to a byte array.  `0` is for lossless compression (the only option for a PNG).
@@ -438,63 +526,175 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
         int newBookmarkDisplayOrder = bookmarksListView.getCount();
 
         // Create the bookmark.
-        bookmarksDatabaseHandler.createBookmark(bookmarkNameString, bookmarkUrlString, newBookmarkDisplayOrder, favoriteIconByteArray);
+        bookmarksDatabaseHandler.createBookmark(bookmarkNameString, bookmarkUrlString, newBookmarkDisplayOrder, currentFolder, favoriteIconByteArray);
 
         // Refresh the ListView.  `setSelection` scrolls to the bottom of the list.
-        updateBookmarksListView();
-        bookmarksListView.setSelection(bookmarksListView.getCount());
+        updateBookmarksListView(currentFolder);
+        bookmarksListView.setSelection(newBookmarkDisplayOrder);
     }
 
     @Override
-    public void onEditBookmarkCancel(DialogFragment editBookmarkDialogFragment) {
+    public void onCancelCreateBookmarkFolder(DialogFragment dialogFragment) {
         // Do nothing because the user selected `Cancel`.
     }
 
     @Override
-    public void onEditBookmarkSave(DialogFragment editBookmarkDialogFragment) {
-        // Get the `EditText`s from the `editBookmarkDialogFragment` and extract the strings.
-        EditText editBookmarkNameEditText = (EditText) editBookmarkDialogFragment.getDialog().findViewById(R.id.edit_bookmark_name_edittext);
-        String bookmarkNameString = editBookmarkNameEditText.getText().toString();
-        EditText editBookmarkUrlEditText = (EditText) editBookmarkDialogFragment.getDialog().findViewById(R.id.edit_bookmark_url_edittext);
-        String bookmarkUrlString = editBookmarkUrlEditText.getText().toString();
+    public void onCreateBookmarkFolder(DialogFragment dialogFragment) {
+        // Get `create_folder_name_edit_text` and extract the string.
+        EditText createFolderNameEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.create_folder_name_edittext);
+        String folderNameString = createFolderNameEditText.getText().toString();
+
+        // Check to see if the folder already exists.
+        Cursor bookmarkFolderCursor = bookmarksDatabaseHandler.getFolderCursor(folderNameString);
+        int existingFoldersWithNewName = bookmarkFolderCursor.getCount();
+        bookmarkFolderCursor.close();
+        if (folderNameString.isEmpty() || (existingFoldersWithNewName > 0)) {
+            String cannotCreateFolder = getResources().getString(R.string.cannot_create_folder) + " \"" + folderNameString + "\"";
+            Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), cannotCreateFolder, Snackbar.LENGTH_INDEFINITE).show();
+        } else {  // Create the folder.
+            // Get the new folder icon.
+            RadioButton defaultFolderIconRadioButton = (RadioButton) dialogFragment.getDialog().findViewById(R.id.create_folder_default_icon_radiobuttion);
+            Bitmap folderIconBitmap;
+            if (defaultFolderIconRadioButton.isChecked()) {
+                // Get the default folder icon drawable and convert it to a `Bitmap`.  `this` specifies the current context.
+                Drawable folderIconDrawable = ContextCompat.getDrawable(this, R.drawable.folder_blue_bitmap);
+                BitmapDrawable folderIconBitmapDrawable = (BitmapDrawable) folderIconDrawable;
+                folderIconBitmap = folderIconBitmapDrawable.getBitmap();
+            } else {
+                folderIconBitmap = MainWebViewActivity.favoriteIcon;
+            }
 
-        CheckBox useNewFavoriteIconBitmap = (CheckBox) editBookmarkDialogFragment.getDialog().findViewById(R.id.edit_bookmark_use_new_favorite_icon_checkbox);
-        byte[] favoriteIconByteArray;
+            // Convert the folder `Bitmap` to a byte array.  `0` is for lossless compression (the only option for a PNG).
+            ByteArrayOutputStream folderIconByteArrayOutputStream = new ByteArrayOutputStream();
+            folderIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, folderIconByteArrayOutputStream);
+            byte[] folderIconByteArray = folderIconByteArrayOutputStream.toByteArray();
+
+            // Move all the bookmarks down one in the display order.
+            for (int i = 0; i < bookmarksListView.getCount(); i++) {
+                int databaseId = (int) bookmarksListView.getItemIdAtPosition(i);
+                bookmarksDatabaseHandler.updateBookmarkDisplayOrder(databaseId, i + 1);
+            }
 
+            // Create the folder, placing it at the top of the ListView
+            bookmarksDatabaseHandler.createFolder(folderNameString, 0, currentFolder, folderIconByteArray);
+
+            // Refresh the ListView.
+            updateBookmarksListView(currentFolder);
+        }
+    }
+
+    @Override
+    public void onCancelEditBookmark(DialogFragment dialogFragment) {
+        // Do nothing because the user selected `Cancel`.
+    }
+
+    @Override
+    public void onSaveEditBookmark(DialogFragment dialogFragment) {
         // Get a long array with the the databaseId of the selected bookmark and convert it to an `int`.
         long[] selectedBookmarksLongArray = bookmarksListView.getCheckedItemIds();
         int selectedBookmarkDatabaseId = (int) selectedBookmarksLongArray[0];
 
-        if (useNewFavoriteIconBitmap.isChecked()) {
-            // Get the new favorite icon from the Dialog and convert it into a Bitmap.
-            ImageView newFavoriteIconImageView = (ImageView) editBookmarkDialogFragment.getDialog().findViewById(R.id.edit_bookmark_new_favorite_icon);
-            Drawable favoriteIconDrawable = newFavoriteIconImageView.getDrawable();
-            Bitmap favoriteIconBitmap = ((BitmapDrawable) favoriteIconDrawable).getBitmap();
+        // Get the `EditText`s from the `editBookmarkDialogFragment` and extract the strings.
+        EditText editBookmarkNameEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.edit_bookmark_name_edittext);
+        String bookmarkNameString = editBookmarkNameEditText.getText().toString();
+        EditText editBookmarkUrlEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.edit_bookmark_url_edittext);
+        String bookmarkUrlString = editBookmarkUrlEditText.getText().toString();
 
-            // Convert the new `favoriteIconBitmap` into a Byte Array.
-            ByteArrayOutputStream favoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
-            favoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, favoriteIconByteArrayOutputStream);
-            favoriteIconByteArray = favoriteIconByteArrayOutputStream.toByteArray();
+        // Get `edit_bookmark_current_icon_radiobutton`.
+        RadioButton currentBookmarkIconRadioButton = (RadioButton) dialogFragment.getDialog().findViewById(R.id.edit_bookmark_current_icon_radiobutton);
 
-            //  Update the bookmark and the favorite icon.
-            bookmarksDatabaseHandler.updateBookmark(selectedBookmarkDatabaseId, bookmarkNameString, bookmarkUrlString, favoriteIconByteArray);
-        } else {  // Update the bookmark without changing the favorite icon.
+        if (currentBookmarkIconRadioButton.isChecked()) {  // Update the bookmark without changing the favorite icon.
             bookmarksDatabaseHandler.updateBookmark(selectedBookmarkDatabaseId, bookmarkNameString, bookmarkUrlString);
+        } else {  // Update the bookmark and the favorite icon.
+            // Get the new favorite icon from the `Dialog` and convert it into a `Bitmap`.
+            ImageView newFavoriteIconImageView = (ImageView) dialogFragment.getDialog().findViewById(R.id.edit_bookmark_web_page_favorite_icon);
+            Drawable newFavoriteIconDrawable = newFavoriteIconImageView.getDrawable();
+            Bitmap newFavoriteIconBitmap = ((BitmapDrawable) newFavoriteIconDrawable).getBitmap();
+
+            // Convert `newFavoriteIconBitmap` into a Byte Array.
+            ByteArrayOutputStream newFavoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
+            newFavoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, newFavoriteIconByteArrayOutputStream);
+            byte[] newFavoriteIconByteArray = newFavoriteIconByteArrayOutputStream.toByteArray();
+
+            //  Update the bookmark and the favorite icon.
+            bookmarksDatabaseHandler.updateBookmark(selectedBookmarkDatabaseId, bookmarkNameString, bookmarkUrlString, newFavoriteIconByteArray);
         }
 
         // Close the contextual action mode.
         contextualActionMode.finish();
 
-        // Refresh the `ListView`.  `setSelection` scrolls to that position.
-        updateBookmarksListView();
+        // Refresh the `ListView`.  `setSelection` scrolls to the position of the bookmark that was edited.
+        updateBookmarksListView(currentFolder);
         bookmarksListView.setSelection(selectedBookmarkPosition);
     }
 
-    private void updateBookmarksListView() {
-        // Get a Cursor with the current contents of the bookmarks database.
-        final Cursor bookmarksCursor = bookmarksDatabaseHandler.getAllBookmarksCursor();
+    @Override
+    public void onCancelEditBookmarkFolder(DialogFragment dialogFragment) {
+        // Do nothing because the user selected `Cancel`.
+    }
+
+    @Override
+    public void onSaveEditBookmarkFolder(DialogFragment dialogFragment) {
+        // Get the new folder name.
+        EditText editFolderNameEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.edit_folder_name_edittext);
+        String newFolderNameString = editFolderNameEditText.getText().toString();
+
+        // Check to see if the new folder name is unique.
+        Cursor bookmarkFolderCursor = bookmarksDatabaseHandler.getFolderCursor(newFolderNameString);
+        int existingFoldersWithNewName = bookmarkFolderCursor.getCount();
+        bookmarkFolderCursor.close();
+        if ( ((existingFoldersWithNewName == 0) || newFolderNameString.equals(oldFolderNameString)) && !newFolderNameString.isEmpty()) {
+            // Get a long array with the the databaseId of the selected folder and convert it to an `int`.
+            long[] selectedFolderLongArray = bookmarksListView.getCheckedItemIds();
+            int selectedFolderDatabaseId = (int) selectedFolderLongArray[0];
+
+            // Get the `RadioButtons` from the `Dialog`.
+            RadioButton currentFolderIconRadioButton = (RadioButton) dialogFragment.getDialog().findViewById(R.id.edit_folder_current_icon_radiobutton);
+            RadioButton defaultFolderIconRadioButton = (RadioButton) dialogFragment.getDialog().findViewById(R.id.edit_folder_default_icon_radiobutton);
+            Bitmap folderIconBitmap;
+
+            // Prepare the favorite icon.
+            if (currentFolderIconRadioButton.isChecked()) {
+                // Update the folder name if it has changed.
+                if (!newFolderNameString.equals(oldFolderNameString)) {
+                    bookmarksDatabaseHandler.updateFolder(selectedFolderDatabaseId, oldFolderNameString, newFolderNameString);
+
+                    // Refresh the `ListView`.  `setSelection` scrolls to the position of the folder that was edited.
+                    updateBookmarksListView(currentFolder);
+                    bookmarksListView.setSelection(selectedBookmarkPosition);
+                }
+            } else {  // Prepare the new favorite icon.
+                if (defaultFolderIconRadioButton.isChecked()) {
+                    // Get the default folder icon drawable and convert it to a `Bitmap`.  `this` specifies the current context.
+                    Drawable folderIconDrawable = ContextCompat.getDrawable(this, R.drawable.folder_blue_bitmap);
+                    BitmapDrawable folderIconBitmapDrawable = (BitmapDrawable) folderIconDrawable;
+                    folderIconBitmap = folderIconBitmapDrawable.getBitmap();
+                } else {  // Use the web page favorite icon.
+                    folderIconBitmap = MainWebViewActivity.favoriteIcon;
+                }
+
+                // Convert the folder `Bitmap` to a byte array.  `0` is for lossless compression (the only option for a PNG).
+                ByteArrayOutputStream folderIconByteArrayOutputStream = new ByteArrayOutputStream();
+                folderIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, folderIconByteArrayOutputStream);
+                byte[] folderIconByteArray = folderIconByteArrayOutputStream.toByteArray();
+
+                bookmarksDatabaseHandler.updateFolder(selectedFolderDatabaseId, oldFolderNameString, newFolderNameString, folderIconByteArray);
+
+                // Refresh the `ListView`.  `setSelection` scrolls to the position of the folder that was edited.
+                updateBookmarksListView(currentFolder);
+                bookmarksListView.setSelection(selectedBookmarkPosition);
+            }
+        } else {  // Don't edit the folder because the new name is not unique.
+            String cannot_rename_folder = getResources().getString(R.string.cannot_rename_folder) + " \"" + newFolderNameString + "\"";
+            Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), cannot_rename_folder, Snackbar.LENGTH_INDEFINITE).show();
+        }
+    }
+
+    private void updateBookmarksListView(String folderName) {
+        // Get a `Cursor` with the current contents of the bookmarks database.
+        bookmarksCursor = bookmarksDatabaseHandler.getAllBookmarksCursorByDisplayOrder(folderName);
 
-        // Setup bookmarksCursorAdapter with `this` context.  The `false` disables autoRequery.
+        // Setup `bookmarksCursorAdapter` with `this` context.  The `false` disables autoRequery.
         CursorAdapter bookmarksCursorAdapter = new CursorAdapter(this, bookmarksCursor, false) {
             @Override
             public View newView(Context context, Cursor cursor, ViewGroup parent) {
@@ -518,20 +718,34 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                 // Get the bookmark name from the cursor and display it in `bookmarkNameTextView`.
                 String bookmarkNameString = cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_NAME));
                 TextView bookmarkNameTextView = (TextView) view.findViewById(R.id.bookmark_name);
-                assert bookmarkNameTextView != null;  // This assert removes the warning that bookmarkNameTextView might be null.
                 bookmarkNameTextView.setText(bookmarkNameString);
+
+                // Make the font bold for folders.
+                if (cursor.getInt(cursor.getColumnIndex(BookmarksDatabaseHandler.IS_FOLDER)) == 1) {
+                    // The first argument is `null` because we don't want to chage the font.
+                    bookmarkNameTextView.setTypeface(null, Typeface.BOLD);
+                } else {  // Reset the font to default.
+                    bookmarkNameTextView.setTypeface(Typeface.DEFAULT);
+                }
             }
         };
 
         // Update the ListView.
         bookmarksListView.setAdapter(bookmarksCursorAdapter);
+
+        // Set the AppBar title.
+        if (currentFolder.isEmpty()) {
+            appBar.setTitle(R.string.bookmarks);
+        } else {
+            appBar.setTitle(currentFolder);
+        }
     }
 
-    private void updateBookmarksListViewExcept(long[] exceptIdLongArray) {
-        // Get a Cursor with the current contents of the bookmarks database except for the specified database IDs.
-        final Cursor bookmarksCursor = bookmarksDatabaseHandler.getBookmarksCursorExcept(exceptIdLongArray);
+    private void updateBookmarksListViewExcept(long[] exceptIdLongArray, String folderName) {
+        // Get a `Cursor` with the current contents of the bookmarks database except for the specified database IDs.
+        bookmarksCursor = bookmarksDatabaseHandler.getBookmarksCursorExcept(exceptIdLongArray, folderName);
 
-        // Setup bookmarksCursorAdapter with `this` context.  The `false` disables autoRequery.
+        // Setup `bookmarksCursorAdapter` with `this` context.  The `false` disables autoRequery.
         CursorAdapter bookmarksCursorAdapter = new CursorAdapter(this, bookmarksCursor, false) {
             @Override
             public View newView(Context context, Cursor cursor, ViewGroup parent) {
@@ -555,8 +769,15 @@ public class BookmarksActivity extends AppCompatActivity implements CreateBookma
                 // Get the bookmark name from the cursor and display it in `bookmarkNameTextView`.
                 String bookmarkNameString = cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_NAME));
                 TextView bookmarkNameTextView = (TextView) view.findViewById(R.id.bookmark_name);
-                assert bookmarkNameTextView != null;  // This assert removes the warning that bookmarkNameTextView might be null.
                 bookmarkNameTextView.setText(bookmarkNameString);
+
+                // Make the font bold for folders.
+                if (cursor.getInt(cursor.getColumnIndex(BookmarksDatabaseHandler.IS_FOLDER)) == 1) {
+                    // The first argument is `null` because we don't want to chage the font.
+                    bookmarkNameTextView.setTypeface(null, Typeface.BOLD);
+                } else {  // Reset the font to default.
+                    bookmarkNameTextView.setTypeface(Typeface.DEFAULT);
+                }
             }
         };
 
index 5a5a025a16aae46bb03fd25cc23bf67c81df9d77..bc17bc7dba7c4d4c068a36d08dca8f8f41efbb4d 100644 (file)
@@ -22,8 +22,10 @@ package com.stoutner.privacybrowser;
 import android.content.ContentValues;
 import android.content.Context;
 import android.database.Cursor;
+import android.database.DatabaseUtils;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
+import android.provider.ContactsContract;
 
 public class BookmarksDatabaseHandler extends SQLiteOpenHelper {
     private static final int SCHEMA_VERSION = 1;
@@ -62,21 +64,41 @@ public class BookmarksDatabaseHandler extends SQLiteOpenHelper {
         // Code for upgrading the database will be added here when the schema version > 1.
     }
 
-    public void createBookmark(String bookmarkName, String bookmarkURL, int displayOrder, byte[] favoriteIcon) {
+    public void createBookmark(String bookmarkName, String bookmarkURL, int displayOrder, String parentFolder, byte[] favoriteIcon) {
         ContentValues bookmarkContentValues = new ContentValues();
 
         // ID is created automatically.
         bookmarkContentValues.put(DISPLAY_ORDER, displayOrder);
         bookmarkContentValues.put(BOOKMARK_NAME, bookmarkName);
         bookmarkContentValues.put(BOOKMARK_URL, bookmarkURL);
-        bookmarkContentValues.put(PARENT_FOLDER, "");
+        bookmarkContentValues.put(PARENT_FOLDER, parentFolder);
         bookmarkContentValues.put(IS_FOLDER, false);
         bookmarkContentValues.put(FAVORITE_ICON, favoriteIcon);
 
         // Get a writable database handle.
         SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
 
-        // The second argument is "null", which makes it so that completely null rows cannot be created.  Not a problem in our case.
+        // The second argument is `null`, which makes it so that completely null rows cannot be created.  Not a problem in our case.
+        bookmarksDatabase.insert(BOOKMARKS_TABLE, null, bookmarkContentValues);
+
+        // Close the database handle.
+        bookmarksDatabase.close();
+    }
+
+    public void createFolder(String folderName, int displayOrder, String parentFolder, byte[] favoriteIcon) {
+        ContentValues bookmarkContentValues = new ContentValues();
+
+        // ID is created automatically.
+        bookmarkContentValues.put(DISPLAY_ORDER, displayOrder);
+        bookmarkContentValues.put(BOOKMARK_NAME, folderName);
+        bookmarkContentValues.put(PARENT_FOLDER, parentFolder);
+        bookmarkContentValues.put(IS_FOLDER, true);
+        bookmarkContentValues.put(FAVORITE_ICON, favoriteIcon);
+
+        // Get a writable database handle.
+        SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+        // The second argument is `null`, which makes it so that completely null rows cannot be created.  Not a problem in our case.
         bookmarksDatabase.insert(BOOKMARKS_TABLE, null, bookmarkContentValues);
 
         // Close the database handle.
@@ -87,38 +109,54 @@ public class BookmarksDatabaseHandler extends SQLiteOpenHelper {
         // Get a readable database handle.
         SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
 
-        // Prepare the SQL statement to get the cursor for `databaseId`
+        // Prepare the SQL statement to get the `Cursor` for `databaseId`
         final String GET_ONE_BOOKMARK = "Select * FROM " + BOOKMARKS_TABLE +
                 " WHERE " + _ID + " = " + databaseId;
 
-        // Return the results as a `Cursor`.  The second argument is `null` because there are no selectionArgs.
+        // Return the results as a `Cursor`.  The second argument is `null` because there are no `selectionArgs`.
         // We can't close the `Cursor` because we need to use it in the parent activity.
         return bookmarksDatabase.rawQuery(GET_ONE_BOOKMARK, null);
     }
 
-    public Cursor getBookmarksCursorExcept(long[] exceptIdLongArray) {
+    public Cursor getFolderCursor(String folderName) {
         // Get a readable database handle.
         SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
 
-        // Prepare a string that contains the comma-separated list of IDs not to get.
-        String doNotGetIdsString = "";
-        // Extract the array to `doNotGetIdsString`.
-        for (long databaseIdLong : exceptIdLongArray) {
-            // If this is the first number, only add the number.
-            if (doNotGetIdsString.isEmpty()) {
-                doNotGetIdsString = String.valueOf(databaseIdLong);
-            } else {  // If there already is a number in the string, place a `,` before the number.
-                doNotGetIdsString = doNotGetIdsString + "," + databaseIdLong;
-            }
-        }
+        // SQL escape `folderName`.
+        folderName = DatabaseUtils.sqlEscapeString(folderName);
 
-        // Prepare the SQL statement to select all items except those with the specified IDs.
-        final String GET_All_BOOKMARKS_EXCEPT_SPECIFIED = "Select * FROM " + BOOKMARKS_TABLE +
-                " WHERE " + _ID + " NOT IN (" + doNotGetIdsString + ") ORDER BY " + DISPLAY_ORDER + " ASC";
+        // Prepare the SQL statement to get the `Cursor` for the folder.
+        final String GET_FOLDER = "Select * FROM " + BOOKMARKS_TABLE +
+                " WHERE " + BOOKMARK_NAME + " = " + folderName +
+                " AND " + IS_FOLDER + " = " + 1;
 
-        // Return the results as a `Cursor`.  The second argument is `null` because there are no selectionArgs.
+        // Return the results as a `Cursor`.  The second argument is `null` because there are no `selectionArgs`.
         // We can't close the `Cursor` because we need to use it in the parent activity.
-        return bookmarksDatabase.rawQuery(GET_All_BOOKMARKS_EXCEPT_SPECIFIED, null);
+        return bookmarksDatabase.rawQuery(GET_FOLDER, null);
+    }
+
+    public String getParentFolder(String currentFolder) {
+        // Get a readable database handle.
+        SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
+
+        // SQL escape `currentFolder`.
+        currentFolder = DatabaseUtils.sqlEscapeString(currentFolder);
+
+        // Prepare the SQL statement to get the parent folder.
+        final String GET_PARENT_FOLDER = "Select * FROM " + BOOKMARKS_TABLE +
+                " WHERE " + IS_FOLDER + " = " + 1 + " AND " + BOOKMARK_NAME + " = " + currentFolder;
+
+        // The second argument is `null` because there are no `selectionArgs`.
+        Cursor bookmarkCursor = bookmarksDatabase.rawQuery(GET_PARENT_FOLDER, null);
+        bookmarkCursor.moveToFirst();
+
+        // Store the name of the parent folder.
+        String parentFolder = bookmarkCursor.getString(bookmarkCursor.getColumnIndex(PARENT_FOLDER));
+
+        // Close the `Cursor`.
+        bookmarkCursor.close();
+
+        return parentFolder;
     }
 
     public Cursor getAllBookmarksCursor() {
@@ -126,35 +164,55 @@ public class BookmarksDatabaseHandler extends SQLiteOpenHelper {
         SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
 
         // Get everything in the BOOKMARKS_TABLE.
-        final String GET_ALL_BOOKMARKS = "Select * FROM " + BOOKMARKS_TABLE + " ORDER BY " + DISPLAY_ORDER + " ASC";
+        final String GET_ALL_BOOKMARKS = "Select * FROM " + BOOKMARKS_TABLE;
 
         // Return the results as a Cursor.  The second argument is `null` because there are no selectionArgs.
         // We can't close the Cursor because we need to use it in the parent activity.
         return bookmarksDatabase.rawQuery(GET_ALL_BOOKMARKS, null);
     }
 
-    public String getBookmarkURL(int databaseId) {
+    public Cursor getAllBookmarksCursorByDisplayOrder(String folderName) {
         // Get a readable database handle.
         SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
 
-        // Prepare the SQL statement to get the row for the selected databaseId.
-        final String GET_BOOKMARK_URL = "Select * FROM " + BOOKMARKS_TABLE +
-                " WHERE " + _ID + " = " + databaseId;
+        // SQL escape `folderName`.
+        folderName = DatabaseUtils.sqlEscapeString(folderName);
 
-        // Save the results as Cursor and move it to the first (only) row.  The second argument is "null" because there are no selectionArgs.
-        Cursor bookmarksCursor = bookmarksDatabase.rawQuery(GET_BOOKMARK_URL, null);
-        bookmarksCursor.moveToFirst();
+        // Get everything in the BOOKMARKS_TABLE.
+        final String GET_ALL_BOOKMARKS = "Select * FROM " + BOOKMARKS_TABLE +
+                " WHERE " + PARENT_FOLDER + " = " + folderName + " ORDER BY " + DISPLAY_ORDER + " ASC";
 
-        // Get the int that identifies the "BOOKMARK_URL" column and save the string as bookmarkURL.
-        int urlColumnInt = bookmarksCursor.getColumnIndex(BOOKMARK_URL);
-        String bookmarkURLString = bookmarksCursor.getString(urlColumnInt);
+        // Return the results as a Cursor.  The second argument is `null` because there are no selectionArgs.
+        // We can't close the Cursor because we need to use it in the parent activity.
+        return bookmarksDatabase.rawQuery(GET_ALL_BOOKMARKS, null);
+    }
 
-        // Close the Cursor and the database handle.
-        bookmarksCursor.close();
-        bookmarksDatabase.close();
+    public Cursor getBookmarksCursorExcept(long[] exceptIdLongArray, String folderName) {
+        // Get a readable database handle.
+        SQLiteDatabase bookmarksDatabase = this.getReadableDatabase();
 
-        // Return the bookmarkURLString.
-        return bookmarkURLString;
+        // Prepare a string that contains the comma-separated list of IDs not to get.
+        String doNotGetIdsString = "";
+        // Extract the array to `doNotGetIdsString`.
+        for (long databaseIdLong : exceptIdLongArray) {
+            // If this is the first number, only add the number.
+            if (doNotGetIdsString.isEmpty()) {
+                doNotGetIdsString = String.valueOf(databaseIdLong);
+            } else {  // If there already is a number in the string, place a `,` before the number.
+                doNotGetIdsString = doNotGetIdsString + "," + databaseIdLong;
+            }
+        }
+
+        // SQL escape `folderName`.
+        folderName = DatabaseUtils.sqlEscapeString(folderName);
+
+        // Prepare the SQL statement to select all items except those with the specified IDs.
+        final String GET_All_BOOKMARKS_EXCEPT_SPECIFIED = "Select * FROM " + BOOKMARKS_TABLE +
+                " WHERE " + PARENT_FOLDER + " = " + folderName + " AND " + _ID + " NOT IN (" + doNotGetIdsString + ") ORDER BY " + DISPLAY_ORDER + " ASC";
+
+        // Return the results as a `Cursor`.  The second argument is `null` because there are no selectionArgs.
+        // We can't close the `Cursor` because we need to use it in the parent activity.
+        return bookmarksDatabase.rawQuery(GET_All_BOOKMARKS_EXCEPT_SPECIFIED, null);
     }
 
     public void updateBookmark(int databaseId, String bookmarkName, String bookmarkUrl) {
@@ -167,7 +225,7 @@ public class BookmarksDatabaseHandler extends SQLiteOpenHelper {
         // Get a writable database handle.
         SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
 
-        // Update the database.  The last argument is `null` because there are no `whereArgs`.
+        // Update the bookmark.  The last argument is `null` because there are no `whereArgs`.
         bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, _ID + " = " + databaseId, null);
 
         // Close the database handle.
@@ -185,13 +243,70 @@ public class BookmarksDatabaseHandler extends SQLiteOpenHelper {
         // Get a writable database handle.
         SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
 
-        // Update the database.  The last argument is `null` because there are no `whereArgs`.
+        // Update the bookmark.  The last argument is `null` because there are no `whereArgs`.
         bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, _ID + " = " + databaseId, null);
 
         // Close the database handle.
         bookmarksDatabase.close();
     }
 
+    public void updateFolder(int databaseId, String oldFolderName, String newFolderName) {
+        // Get a writable database handle.
+        SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+        // Update the folder first.  Store the updated values in `folderContentValues`.
+        ContentValues folderContentValues = new ContentValues();
+
+        folderContentValues.put(BOOKMARK_NAME, newFolderName);
+
+        // Run the update on the folder.  The last argument is `null` because there are no `whereArgs`.
+        bookmarksDatabase.update(BOOKMARKS_TABLE, folderContentValues, _ID + " = " + databaseId, null);
+
+
+        // Update the bookmarks inside the folder with the new parent folder name.
+        ContentValues bookmarkContentValues = new ContentValues();
+
+        bookmarkContentValues.put(PARENT_FOLDER, newFolderName);
+
+        // SQL escape `oldFolderName`.
+        oldFolderName = DatabaseUtils.sqlEscapeString(oldFolderName);
+
+        // Run the update on the bookmarks.  The last argument is `null` because there are no `whereArgs`.
+        bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, PARENT_FOLDER + " = " + oldFolderName, null);
+
+        // Close the database handle.
+        bookmarksDatabase.close();
+    }
+
+    public void updateFolder(int databaseId, String oldFolderName, String newFolderName, byte[] folderIcon) {
+        // Get a writable database handle.
+        SQLiteDatabase bookmarksDatabase = this.getWritableDatabase();
+
+        // Update the folder first.  Store the updated values in `folderContentValues`.
+        ContentValues folderContentValues = new ContentValues();
+
+        folderContentValues.put(BOOKMARK_NAME, newFolderName);
+        folderContentValues.put(FAVORITE_ICON, folderIcon);
+
+        // Run the update on the folder.  The last argument is `null` because there are no `whereArgs`.
+        bookmarksDatabase.update(BOOKMARKS_TABLE, folderContentValues, _ID + " = " + databaseId, null);
+
+
+        // Update the bookmarks inside the folder with the new parent folder name.
+        ContentValues bookmarkContentValues = new ContentValues();
+
+        bookmarkContentValues.put(PARENT_FOLDER, newFolderName);
+
+        // SQL escape `oldFolderName`.
+        oldFolderName = DatabaseUtils.sqlEscapeString(oldFolderName);
+
+        // Run the update on the bookmarks.  The last argument is `null` because there are no `whereArgs`.
+        bookmarksDatabase.update(BOOKMARKS_TABLE, bookmarkContentValues, PARENT_FOLDER + " = " + oldFolderName, null);
+
+        // Close the database handle.
+        bookmarksDatabase.close();
+    }
+
     public void updateBookmarkDisplayOrder(int databaseId, int displayOrder) {
         // Store the updated values in `bookmarkContentValues`.
         ContentValues bookmarkContentValues = new ContentValues();
diff --git a/app/src/main/java/com/stoutner/privacybrowser/BookmarksDatabaseViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/BookmarksDatabaseViewActivity.java
new file mode 100644 (file)
index 0000000..00bad90
--- /dev/null
@@ -0,0 +1,144 @@
+/**
+ * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.support.v4.content.ContextCompat;
+import android.support.v4.widget.CursorAdapter;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class BookmarksDatabaseViewActivity extends AppCompatActivity {
+    // `bookmarksDatabaseHandler` is used in `onCreate()` and `updateBookmarksListView()`.
+    BookmarksDatabaseHandler bookmarksDatabaseHandler;
+
+    // `bookmarksListView` is used in `onCreate()` and `updateBookmarksListView()`.
+    ListView bookmarksListView;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.bookmarks_database_view_coordinatorlayout);
+
+        // We need to use the `SupportActionBar` from `android.support.v7.app.ActionBar` until the minimum API is >= 21.
+        final Toolbar bookmarksDatabaseViewAppBar = (Toolbar) findViewById(R.id.bookmarks_database_view_toolbar);
+        setSupportActionBar(bookmarksDatabaseViewAppBar);
+
+        // Display the home arrow on `SupportActionBar`.
+        final ActionBar appBar = getSupportActionBar();
+        assert appBar != null;  // This assert removes the incorrect warning in Android Studio on the following line that appBar might be null.
+        appBar.setDisplayHomeAsUpEnabled(true);
+
+        // Initialize the database handler and the ListView.
+        // `this` specifies the context.  The two `null`s do not specify the database name or a `CursorFactory`.
+        // The `0` is to specify a database version, but that is set instead using a constant in `BookmarksDatabaseHandler`.
+        bookmarksDatabaseHandler = new BookmarksDatabaseHandler(this, null, null, 0);
+        bookmarksListView = (ListView) findViewById(R.id.bookmarks_database_view_listview);
+
+        // Display the bookmarks in the ListView.
+        updateBookmarksListView();
+
+    }
+
+    private void updateBookmarksListView() {
+        // Get a `Cursor` with the current contents of the bookmarks database.
+        final Cursor bookmarksCursor = bookmarksDatabaseHandler.getAllBookmarksCursor();
+
+        // Setup `bookmarksCursorAdapter` with `this` context.  The `false` disables autoRequery.
+        CursorAdapter bookmarksCursorAdapter = new CursorAdapter(this, bookmarksCursor, false) {
+            @Override
+            public View newView(Context context, Cursor cursor, ViewGroup parent) {
+                // Inflate the individual item layout.  `false` does not attach it to the root.
+                return getLayoutInflater().inflate(R.layout.bookmarks_database_view_linearlayout, parent, false);
+            }
+
+            @Override
+            public void bindView(View view, Context context, Cursor cursor) {
+                boolean isFolder = (cursor.getInt(cursor.getColumnIndex(BookmarksDatabaseHandler.IS_FOLDER)) == 1);
+
+                // Get the database ID from the `Cursor` and display it in `bookmarkDatabaseIdTextView`.
+                int bookmarkDatabaseId = cursor.getInt(cursor.getColumnIndex(BookmarksDatabaseHandler._ID));
+                TextView bookmarkDatabaseIdTextView = (TextView) view.findViewById(R.id.bookmarks_database_view_database_id);
+                bookmarkDatabaseIdTextView.setText(String.valueOf(bookmarkDatabaseId));
+
+                // Get the favorite icon byte array from the `Cursor`.
+                byte[] favoriteIconByteArray = cursor.getBlob(cursor.getColumnIndex(BookmarksDatabaseHandler.FAVORITE_ICON));
+                // Convert the byte array to a `Bitmap` beginning at the beginning at the first byte and ending at the last.
+                Bitmap favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.length);
+                // Display the bitmap in `bookmarkFavoriteIcon`.
+                ImageView bookmarkFavoriteIcon = (ImageView) view.findViewById(R.id.bookmarks_database_view_favorite_icon);
+                bookmarkFavoriteIcon.setImageBitmap(favoriteIconBitmap);
+
+                // Get the bookmark name from the `Cursor` and display it in `bookmarkNameTextView`.
+                String bookmarkNameString = cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_NAME));
+                TextView bookmarkNameTextView = (TextView) view.findViewById(R.id.bookmarks_database_view_bookmark_name);
+                bookmarkNameTextView.setText(bookmarkNameString);
+                // Make the font bold for folders.
+                if (isFolder) {
+                    // The first argument is `null` because we don't want to chage the font.
+                    bookmarkNameTextView.setTypeface(null, Typeface.BOLD);
+                } else {  // Reset the font to default.
+                    bookmarkNameTextView.setTypeface(Typeface.DEFAULT);
+                }
+
+                // Get the display order from the `Cursor` and display it in `bookmarkDisplayOrderTextView`.
+                int bookmarkDisplayOrder = cursor.getInt(cursor.getColumnIndex(BookmarksDatabaseHandler.DISPLAY_ORDER));
+                TextView bookmarkDisplayOrderTextView = (TextView) view.findViewById(R.id.bookmarks_database_view_display_order);
+                bookmarkDisplayOrderTextView.setText(String.valueOf(bookmarkDisplayOrder));
+
+                // Get the parent folder from the `Cursor` and display it in `bookmarkParentFolder`.
+                String bookmarkParentFolder = cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHandler.PARENT_FOLDER));
+                TextView bookmarkParentFolderTextView = (TextView) view.findViewById(R.id.bookmarks_database_view_parent_folder);
+                // Make the folder name gray if it is the home folder.
+                if (bookmarkParentFolder.isEmpty()) {
+                    bookmarkParentFolderTextView.setText(R.string.home_folder);
+                    bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.grey));
+                } else {
+                    bookmarkParentFolderTextView.setText(bookmarkParentFolder);
+                    bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.black));
+                }
+
+                // Get the bookmark URL form the `Cursor` and display it in `bookmarkUrlTextView`.
+                String bookmarkUrlString = cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_URL));
+                TextView bookmarkUrlTextView = (TextView) view.findViewById(R.id.bookmarks_database_view_bookmark_url);
+                bookmarkUrlTextView.setText(bookmarkUrlString);
+                if (isFolder) {
+                    bookmarkUrlTextView.setVisibility(View.GONE);
+                } else {
+                    bookmarkUrlTextView.setVisibility(View.VISIBLE);
+                }
+            }
+        };
+
+        // Update the ListView.
+        bookmarksListView.setAdapter(bookmarksCursorAdapter);
+    }
+}
\ No newline at end of file
index c5acd03591754b5912851b5719d17e0181086265..b779709c4e35248919594e66a6ccbdf2fed15a35 100644 (file)
@@ -36,9 +36,9 @@ import android.widget.EditText;
 public class CreateBookmark extends DialogFragment {
     // The public interface is used to send information back to the parent activity.
     public interface CreateBookmarkListener {
-        void onCreateBookmarkCancel(DialogFragment createBookmarkDialogFragment);
+        void onCancelCreateBookmark(DialogFragment dialogFragment);
 
-        void onCreateBookmarkCreate(DialogFragment createBookmarkDialogFragment);
+        void onCreateBookmark(DialogFragment dialogFragment);
     }
 
     // `createBookmarkListener` is used in `onAttach()` and `onCreateDialog()`
@@ -48,7 +48,7 @@ public class CreateBookmark extends DialogFragment {
     public void onAttach(Activity parentActivity) {
         super.onAttach(parentActivity);
 
-        // Get a handle for `CreateBookmarkListener` from the `parentActivity`.
+        // Get a handle for `CreateBookmarkListener` from `parentActivity`.
         try {
             createBookmarkListener = (CreateBookmarkListener) parentActivity;
         } catch(ClassCastException exception) {
@@ -62,51 +62,51 @@ public class CreateBookmark extends DialogFragment {
         Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), MainWebViewActivity.favoriteIcon);
 
         // Use `AlertDialog.Builder` to create the `AlertDialog`.  The style formats the color of the button text.
-        AlertDialog.Builder createBookmarkDialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
-        createBookmarkDialogBuilder.setTitle(R.string.create_bookmark);
-        createBookmarkDialogBuilder.setIcon(favoriteIconDrawable);
-        // The parent view is `null` because it will be assigned by `AlertDialog`.
-        createBookmarkDialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.create_bookmark_dialog, null));
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
+        dialogBuilder.setTitle(R.string.create_bookmark);
+        dialogBuilder.setIcon(favoriteIconDrawable);
+        // The parent view is `null` because it will be assigned by the `AlertDialog`.
+        dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.create_bookmark_dialog, null));
 
         // Set an `onClick()` listener for the negative button.
-        createBookmarkDialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+        dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
                 // Return the `DialogFragment` to the parent activity on cancel.
-                createBookmarkListener.onCreateBookmarkCancel(CreateBookmark.this);
+                createBookmarkListener.onCancelCreateBookmark(CreateBookmark.this);
             }
         });
 
         // Set an `onClick()` listener for the positive button.
-        createBookmarkDialogBuilder.setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
+        dialogBuilder.setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
                 // Return the `DialogFragment` to the parent activity on create.
-                createBookmarkListener.onCreateBookmarkCreate(CreateBookmark.this);
+                createBookmarkListener.onCreateBookmark(CreateBookmark.this);
             }
         });
 
 
         // Create an `AlertDialog` from the `AlertDialog.Builder`.
-        final AlertDialog createBookmarkDialog = createBookmarkDialogBuilder.create();
+        final AlertDialog alertDialog = dialogBuilder.create();
 
         // Show the keyboard when the `Dialog` is displayed on the screen.
-        createBookmarkDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+        alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
 
         // We need to show the `AlertDialog` before we can call `setOnKeyListener()` below.
-        createBookmarkDialog.show();
+        alertDialog.show();
 
         // Allow the `enter` key on the keyboard to create the bookmark from `create_bookmark_name_edittext`.
-        EditText createBookmarkNameEditText = (EditText) createBookmarkDialog.findViewById(R.id.create_bookmark_name_edittext);
-        assert createBookmarkNameEditText != null;  // Remove the warning below that createBookmarkNameEditText might be null.
+        EditText createBookmarkNameEditText = (EditText) alertDialog.findViewById(R.id.create_bookmark_name_edittext);
+        assert createBookmarkNameEditText != null;  // Remove the warning below that `createBookmarkNameEditText` might be `null`.
         createBookmarkNameEditText.setOnKeyListener(new View.OnKeyListener() {
             public boolean onKey(View v, int keyCode, KeyEvent event) {
-                // If the event is a key-down on the `enter` button, select the PositiveButton `Create`.
+                // If the event is a key-down on the `enter` button, select the `PositiveButton` `Create`.
                 if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
-                    // Trigger `createBookmarkListener` and return the DialogFragment to the parent activity.
-                    createBookmarkListener.onCreateBookmarkCreate(CreateBookmark.this);
+                    // Trigger `createBookmarkListener` and return the `DialogFragment` to the parent activity.
+                    createBookmarkListener.onCreateBookmark(CreateBookmark.this);
                     // Manually dismiss the `AlertDialog`.
-                    createBookmarkDialog.dismiss();
+                    alertDialog.dismiss();
                     // Consume the event.
                     return true;
                 } else {  // If any other key was pressed, do not consume the event.
@@ -116,8 +116,8 @@ public class CreateBookmark extends DialogFragment {
         });
 
         // Set the formattedUrlString as the initial text of `create_bookmark_url_edittext`.
-        EditText createBookmarkUrlEditText = (EditText) createBookmarkDialog.findViewById(R.id.create_bookmark_url_edittext);
-        assert createBookmarkUrlEditText != null;// Remove the warning below that `createBookmarkUrlEditText` might be null.
+        EditText createBookmarkUrlEditText = (EditText) alertDialog.findViewById(R.id.create_bookmark_url_edittext);
+        assert createBookmarkUrlEditText != null;// Remove the warning below that `createBookmarkUrlEditText` might be `null`.
         createBookmarkUrlEditText.setText(MainWebViewActivity.formattedUrlString);
 
         // Allow the `enter` key on the keyboard to create the bookmark from `create_bookmark_url_edittext`.
@@ -126,9 +126,9 @@ public class CreateBookmark extends DialogFragment {
                 // If the event is a key-down on the "enter" button, select the PositiveButton "Create".
                 if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                     // Trigger `createBookmarkListener` and return the DialogFragment to the parent activity.
-                    createBookmarkListener.onCreateBookmarkCreate(CreateBookmark.this);
+                    createBookmarkListener.onCreateBookmark(CreateBookmark.this);
                     // Manually dismiss the `AlertDialog`.
-                    createBookmarkDialog.dismiss();
+                    alertDialog.dismiss();
                     // Consume the event.
                     return true;
                 } else { // If any other key was pressed, do not consume the event.
@@ -138,6 +138,6 @@ public class CreateBookmark extends DialogFragment {
         });
 
         // `onCreateDialog()` requires the return of an `AlertDialog`.
-        return createBookmarkDialog;
+        return alertDialog;
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/stoutner/privacybrowser/CreateBookmarkFolder.java b/app/src/main/java/com/stoutner/privacybrowser/CreateBookmarkFolder.java
new file mode 100644 (file)
index 0000000..0847ce3
--- /dev/null
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.os.Bundle;
+// If we don't use `android.support.v7.app.AlertDialog` instead of `android.app.AlertDialog` then the dialog will be covered by the keyboard.
+import android.support.v7.app.AlertDialog;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.ImageView;
+
+public class CreateBookmarkFolder extends DialogFragment {
+    // The public interface is used to send information back to the parent activity.
+    public interface CreateBookmarkFolderListener {
+        void onCancelCreateBookmarkFolder(DialogFragment dialogFragment);
+
+        void onCreateBookmarkFolder(DialogFragment dialogFragment);
+    }
+
+    // `createBookmarkFolderListener` is used in `onAttach()` and `onCreateDialog`.
+    private CreateBookmarkFolderListener createBookmarkFolderListener;
+
+    public void onAttach(Activity parentActivity) {
+        super.onAttach(parentActivity);
+
+        // Get a handle for `createBookmarkFolderListener` from `parentActivity`.
+        try {
+            createBookmarkFolderListener = (CreateBookmarkFolderListener) parentActivity;
+        } catch(ClassCastException exception) {
+            throw new ClassCastException(parentActivity.toString() + " must implement CreateBookmarkFolderListener.");
+        }
+    }
+
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+        // Use `AlertDialog.Builder` to create the `AlertDialog`.  The style formats the color of the button text.
+        final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
+        dialogBuilder.setTitle(R.string.create_folder);
+        // The parent view is `null` because it will be assigned by the `AlertDialog`.
+        dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.create_bookmark_folder_dialog, null));
+
+        // Set an `onClick()` listener for the negative button.
+        dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                // Return the `DialogFragment` to the parent activity on cancel.
+                createBookmarkFolderListener.onCancelCreateBookmarkFolder(CreateBookmarkFolder.this);
+            }
+        });
+
+        // Set an `onClick()` listener fo the positive button.
+        dialogBuilder.setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                // Return the `DialogFragment` to the parent activity on create.
+                createBookmarkFolderListener.onCreateBookmarkFolder(CreateBookmarkFolder.this);
+            }
+        });
+
+
+        // Create an `AlertDialog` from the `AlertDialog.Builder`.
+        final AlertDialog alertDialog = dialogBuilder.create();
+
+        // Show the keyboard when the `Dialog` is displayed on the screen.
+        alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+
+        // We need to show the `AlertDialog` before we can call `setOnKeyListener()` below.
+        alertDialog.show();
+
+        // Allow the `enter` key on the keyboard to create the folder from `create_folder_name_edittext`.
+        EditText createFolderNameEditText = (EditText) alertDialog.findViewById(R.id.create_folder_name_edittext);
+        assert createFolderNameEditText != null;  // Remove the warning below that `createFolderNameEditText` might be `null`.
+        createFolderNameEditText.setOnKeyListener(new View.OnKeyListener() {
+            public boolean onKey(View v, int keyCode, KeyEvent event) {
+                // If the event is a key-down on the `enter` key, select the `PositiveButton` `Create`.
+                if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
+                    // Trigger `createBookmarkFolderListener` and return the `DialogFragment` to the parent activity.
+                    createBookmarkFolderListener.onCreateBookmarkFolder(CreateBookmarkFolder.this);
+                    // Manually dismiss the `AlertDialog`.
+                    alertDialog.dismiss();
+                    // Consume the event.
+                    return true;
+                } else {  // If any other key was pressed do not consume the event.
+                    return false;
+                }
+            }
+        });
+
+        // Display the current favorite icon.
+        ImageView webPageIconImageView = (ImageView) alertDialog.findViewById(R.id.create_folder_web_page_icon);
+        assert webPageIconImageView != null;  // Remove the warning that `webPageIconImageView` may be null.
+        webPageIconImageView.setImageBitmap(MainWebViewActivity.favoriteIcon);
+
+        // `onCreateDialog()` requires the return of an `AlertDialog`.
+        return alertDialog;
+    }
+}
\ No newline at end of file
index 71e84ab3dc9576a9837d33008294c29c4c1d0aa5..4a6b2fa7317768f04872dea018c60562f03fb0a1 100644 (file)
@@ -37,9 +37,9 @@ import android.widget.EditText;
 public class CreateHomeScreenShortcut extends DialogFragment {
     // The public interface is used to send information back to the parent activity.
     public interface CreateHomeScreenSchortcutListener {
-        void onCreateHomeScreenShortcutCancel(DialogFragment dialogFragment);
+        void onCancelCreateHomeScreenShortcut(DialogFragment dialogFragment);
 
-        void onCreateHomeScreenShortcutCreate(DialogFragment dialogFragment);
+        void onCreateHomeScreenShortcut(DialogFragment dialogFragment);
     }
 
     //createHomeScreenShortcutListener is used in onAttach and and onCreateDialog.
@@ -64,50 +64,50 @@ public class CreateHomeScreenShortcut extends DialogFragment {
         LayoutInflater customDialogInflater = getActivity().getLayoutInflater();
 
         // Use AlertDialog.Builder to create the AlertDialog.  The style formats the color of the button text.
-        AlertDialog.Builder createHomeScreenShorcutDialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
-        createHomeScreenShorcutDialogBuilder.setTitle(R.string.create_shortcut);
-        createHomeScreenShorcutDialogBuilder.setIcon(favoriteIconDrawable);
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
+        dialogBuilder.setTitle(R.string.create_shortcut);
+        dialogBuilder.setIcon(favoriteIconDrawable);
         // The parent view is "null" because it will be assigned by AlertDialog.
-        createHomeScreenShorcutDialogBuilder.setView(customDialogInflater.inflate(R.layout.create_home_screen_shortcut_dialog, null));
+        dialogBuilder.setView(customDialogInflater.inflate(R.layout.create_home_screen_shortcut_dialog, null));
 
         // Set an onClick listener on the negative button.
-        createHomeScreenShorcutDialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+        dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
-                createHomeScreenShortcutListener.onCreateHomeScreenShortcutCancel(CreateHomeScreenShortcut.this);
+                createHomeScreenShortcutListener.onCancelCreateHomeScreenShortcut(CreateHomeScreenShortcut.this);
             }
         });
 
         // Set an onClick listener on the positive button.
-        createHomeScreenShorcutDialogBuilder.setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
+        dialogBuilder.setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
-                createHomeScreenShortcutListener.onCreateHomeScreenShortcutCreate(CreateHomeScreenShortcut.this);
+                createHomeScreenShortcutListener.onCreateHomeScreenShortcut(CreateHomeScreenShortcut.this);
             }
         });
 
 
         // Create an AlertDialog from the AlertDialogBuilder.
-        final AlertDialog createHomeScreenShortcutAlertDialog = createHomeScreenShorcutDialogBuilder.create();
+        final AlertDialog alertDialog = dialogBuilder.create();
 
         // Show the keyboard when the Dialog is displayed on the screen.
-        createHomeScreenShortcutAlertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+        alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
 
         // We need to show the AlertDialog before we can call setOnKeyListener() below.
-        createHomeScreenShortcutAlertDialog.show();
+        alertDialog.show();
 
         // Allow the "enter" key on the keyboard to create the shortcut.
-        EditText shortcutNameEditText = (EditText) createHomeScreenShortcutAlertDialog.findViewById(R.id.shortcut_name_edittext);
+        EditText shortcutNameEditText = (EditText) alertDialog.findViewById(R.id.shortcut_name_edittext);
         assert shortcutNameEditText != null;  // Remove the warning below that shortcutNameEditText might be null.
         shortcutNameEditText.setOnKeyListener(new View.OnKeyListener() {
             public boolean onKey(View v, int keyCode, KeyEvent event) {
                 // If the event is a key-down on the "enter" button, select the PositiveButton "Create".
                 if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                     // Trigger the create listener.
-                    createHomeScreenShortcutListener.onCreateHomeScreenShortcutCreate(CreateHomeScreenShortcut.this);
+                    createHomeScreenShortcutListener.onCreateHomeScreenShortcut(CreateHomeScreenShortcut.this);
 
-                    // Manually dismiss the AlertDialog.
-                    createHomeScreenShortcutAlertDialog.dismiss();
+                    // Manually dismiss `alertDialog`.
+                    alertDialog.dismiss();
 
                     // Consume the event.
                     return true;
@@ -118,6 +118,6 @@ public class CreateHomeScreenShortcut extends DialogFragment {
         });
 
         // onCreateDialog requires the return of an AlertDialog.
-        return createHomeScreenShortcutAlertDialog;
+        return alertDialog;
     }
 }
\ No newline at end of file
index 8eee58d65d621a524643d86045f749cbc98087d3..8343ace2ff3818dd3afb149604de1698a45459b3 100644 (file)
@@ -40,9 +40,9 @@ import android.widget.ImageView;
 public class EditBookmark extends DialogFragment {
     // The public interface is used to send information back to the parent activity.
     public interface EditBookmarkListener {
-        void onEditBookmarkCancel(DialogFragment editBookmarkDialogFragment);
+        void onCancelEditBookmark(DialogFragment dialogFragment);
 
-        void onEditBookmarkSave(DialogFragment editBookmarkDialogFragment);
+        void onSaveEditBookmark(DialogFragment dialogFragment);
     }
 
     // `editBookmarkListener` is used in `onAttach()` and `onCreateDialog()`
@@ -51,7 +51,7 @@ public class EditBookmark extends DialogFragment {
     public void onAttach(Activity parentActivity) {
         super.onAttach(parentActivity);
 
-        // Get a handle for `EditBookmarkListener` from the `parentActivity`.
+        // Get a handle for `EditBookmarkListener` from `parentActivity`.
         try {
             editBookmarkListener = (EditBookmarkListener) parentActivity;
         } catch(ClassCastException exception) {
@@ -62,62 +62,63 @@ public class EditBookmark extends DialogFragment {
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         // Get a long array with the the databaseId of the selected bookmark and convert it to an `int`.
-        long[] selectedBookmarksLongArray = BookmarksActivity.bookmarksListView.getCheckedItemIds();
-        int selectedBookmarkDatabaseId = (int) selectedBookmarksLongArray[0];
+        long[] selectedBookmarkLongArray = BookmarksActivity.bookmarksListView.getCheckedItemIds();
+        int selectedBookmarkDatabaseId = (int) selectedBookmarkLongArray[0];
 
         // Get a `Cursor` with the specified bookmark and move it to the first position.
         Cursor bookmarkCursor = BookmarksActivity.bookmarksDatabaseHandler.getBookmarkCursor(selectedBookmarkDatabaseId);
         bookmarkCursor.moveToFirst();
 
-        // Get the favorite icon byte array from the `Cursor`.
-        byte[] favoriteIconByteArray = bookmarkCursor.getBlob(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.FAVORITE_ICON));
-        // Convert the byte array to a `Bitmap` beginning at the first byte and ending at the last.
-        Bitmap favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.length);
-        // Convert the `Bitmap` to a `Drawable`.
-        Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), favoriteIconBitmap);
-
         // Use `AlertDialog.Builder` to create the `AlertDialog`.  The style formats the color of the button text.
-        AlertDialog.Builder editBookmarkDialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
-        editBookmarkDialogBuilder.setTitle(R.string.edit_bookmark);
-        editBookmarkDialogBuilder.setIcon(favoriteIconDrawable);
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
+        dialogBuilder.setTitle(R.string.edit_bookmark);
         // The parent view is `null` because it will be assigned by `AlertDialog`.
-        editBookmarkDialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.edit_bookmark_dialog, null));
+        dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.edit_bookmark_dialog, null));
 
         // Set an `onClick()` listener for the negative button.
-        editBookmarkDialogBuilder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() {
+        dialogBuilder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
                 // Return the `DialogFragment` to the parent activity on cancel.
-                editBookmarkListener.onEditBookmarkCancel(EditBookmark.this);
+                editBookmarkListener.onCancelEditBookmark(EditBookmark.this);
             }
         });
 
         // Set the `onClick()` listener fo the positive button.
-        editBookmarkDialogBuilder.setPositiveButton(R.string.save, new Dialog.OnClickListener() {
+        dialogBuilder.setPositiveButton(R.string.save, new Dialog.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
                 // Return the `DialogFragment` to the parent activity on save.
-                editBookmarkListener.onEditBookmarkSave(EditBookmark.this);
+                editBookmarkListener.onSaveEditBookmark(EditBookmark.this);
             }
         });
 
 
         // Create an `AlertDialog` from the `AlertDialog.Builder`.
-        final AlertDialog editBookmarkDialog = editBookmarkDialogBuilder.create();
+        final AlertDialog alertDialog = dialogBuilder.create();
 
         // Show the keyboard when the `Dialog` is displayed on the screen.
-        editBookmarkDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+        alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
 
-        // We need to show the `AlertDialog` before we can call `setOnKeyListener()` below.
-        editBookmarkDialog.show();
+        // We need to show the `AlertDialog` before we can modify items in the layout.
+        alertDialog.show();
 
-        // Get a `Drawable` of the favorite icon from `mainWebView` and display it in `edit_bookmark_new_favorite_icon`.
-        ImageView newFavoriteIcon = (ImageView) editBookmarkDialog.findViewById(R.id.edit_bookmark_new_favorite_icon);
-        assert newFavoriteIcon != null;  // Remove the warning below that `newFavoriteIcon` might be null.
-        newFavoriteIcon.setImageBitmap(MainWebViewActivity.favoriteIcon);
+        // Get the current favorite icon byte array from the `Cursor`.
+        byte[] currentIconByteArray = bookmarkCursor.getBlob(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.FAVORITE_ICON));
+        // Convert the byte array to a `Bitmap` beginning at the first byte and ending at the last.
+        Bitmap currentIconBitmap = BitmapFactory.decodeByteArray(currentIconByteArray, 0, currentIconByteArray.length);
+        // Display `currentIconBitmap` in `edit_bookmark_current_icon`.
+        ImageView currentIconImageView = (ImageView) alertDialog.findViewById(R.id.edit_bookmark_current_icon);
+        assert currentIconImageView != null;  // Remove the warning below that `currentIconImageView` might be null;
+        currentIconImageView.setImageBitmap(currentIconBitmap);
+
+        // Get a `Bitmap` of the favorite icon from `MainWebViewActivity` and display it in `edit_bookmark_web_page_favorite_icon`.
+        ImageView newFavoriteIconImageView = (ImageView) alertDialog.findViewById(R.id.edit_bookmark_web_page_favorite_icon);
+        assert newFavoriteIconImageView != null;  // Remove the warning below that `newFavoriteIcon` might be null.
+        newFavoriteIconImageView.setImageBitmap(MainWebViewActivity.favoriteIcon);
 
         // Load the text for `edit_bookmark_name_edittext`.
-        EditText bookmarkNameEditText = (EditText) editBookmarkDialog.findViewById(R.id.edit_bookmark_name_edittext);
+        EditText bookmarkNameEditText = (EditText) alertDialog.findViewById(R.id.edit_bookmark_name_edittext);
         assert bookmarkNameEditText != null;  // Remove the warning below that `bookmarkNameEditText` might be null.
         bookmarkNameEditText.setText(bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_NAME)));
 
@@ -127,9 +128,9 @@ public class EditBookmark extends DialogFragment {
                 // If the event is a key-down on the "enter" button, select the PositiveButton `Save`.
                 if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                     // Trigger `editBookmarkListener` and return the DialogFragment to the parent activity.
-                    editBookmarkListener.onEditBookmarkSave(EditBookmark.this);
-                    // Manually dismiss the `AlertDialog`.
-                    editBookmarkDialog.dismiss();
+                    editBookmarkListener.onSaveEditBookmark(EditBookmark.this);
+                    // Manually dismiss `alertDialog`.
+                    alertDialog.dismiss();
                     // Consume the event.
                     return true;
                 } else {  // If any other key was pressed, do not consume the event.
@@ -138,8 +139,8 @@ public class EditBookmark extends DialogFragment {
             }
         });
 
-        // Load the text for `create_bookmark_url_edittext`.
-        EditText bookmarkUrlEditText = (EditText) editBookmarkDialog.findViewById(R.id.edit_bookmark_url_edittext);
+        // Load the text for `edit_bookmark_url_edittext`.
+        EditText bookmarkUrlEditText = (EditText) alertDialog.findViewById(R.id.edit_bookmark_url_edittext);
         assert bookmarkUrlEditText != null;// Remove the warning below that `bookmarkUrlEditText` might be null.
         bookmarkUrlEditText.setText(bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_URL)));
 
@@ -149,9 +150,9 @@ public class EditBookmark extends DialogFragment {
                 // If the event is a key-down on the `enter` button, select the PositiveButton `Save`.
                 if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                     // Trigger `editBookmarkListener` and return the DialogFragment to the parent activity.
-                    editBookmarkListener.onEditBookmarkSave(EditBookmark.this);
+                    editBookmarkListener.onSaveEditBookmark(EditBookmark.this);
                     // Manually dismiss the `AlertDialog`.
-                    editBookmarkDialog.dismiss();
+                    alertDialog.dismiss();
                     // Consume the event.
                     return true;
                 } else { // If any other key was pressed, do not consume the event.
@@ -161,6 +162,6 @@ public class EditBookmark extends DialogFragment {
         });
 
         // `onCreateDialog` requires the return of an `AlertDialog`.
-        return editBookmarkDialog;
+        return alertDialog;
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/stoutner/privacybrowser/EditBookmarkFolder.java b/app/src/main/java/com/stoutner/privacybrowser/EditBookmarkFolder.java
new file mode 100644 (file)
index 0000000..c27b963
--- /dev/null
@@ -0,0 +1,143 @@
+/**
+ * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.Bundle;
+// If we don't use `android.support.v7.app.AlertDialog` instead of `android.app.AlertDialog` then the dialog will be covered by the keyboard.
+import android.support.v7.app.AlertDialog;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.ImageView;
+
+public class EditBookmarkFolder extends DialogFragment {
+    // The public interface is used to send information back to the parent activity.
+    public interface EditBookmarkFolderListener {
+        void onCancelEditBookmarkFolder(DialogFragment dialogFragment);
+
+        void onSaveEditBookmarkFolder(DialogFragment dialogFragment);
+    }
+
+    // `editFolderListener` is used in `onAttach()` and `onCreateDialog`.
+    private EditBookmarkFolderListener editBookmarkFolderListener;
+
+    public void onAttach(Activity parentActivity) {
+        super.onAttach(parentActivity);
+
+        // Get a handle for `EditFolderListener` from `parentActivity`.
+        try {
+            editBookmarkFolderListener = (EditBookmarkFolderListener) parentActivity;
+        } catch(ClassCastException exception) {
+            throw new ClassCastException(parentActivity.toString() + " must implement EditBookmarkFolderListener.");
+        }
+    }
+
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+        // Get a long array with the the databaseId of the selected bookmark and convert it to an `int`.
+        long[] selectedBookmarkLongArray = BookmarksActivity.bookmarksListView.getCheckedItemIds();
+        int selectedBookmarkDatabaseId = (int) selectedBookmarkLongArray[0];
+
+        // Get a `Cursor` with the specified bookmark and move it to the first position.
+        Cursor bookmarkCursor = BookmarksActivity.bookmarksDatabaseHandler.getBookmarkCursor(selectedBookmarkDatabaseId);
+        bookmarkCursor.moveToFirst();
+
+        // Use `AlertDialog.Builder` to create the `AlertDialog`.  The style formats the color of the button text.
+        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.LightAlertDialog);
+        dialogBuilder.setTitle(R.string.edit_folder);
+        // The parent view is `null` because it will be assigned by `AlertDialog`.
+        dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.edit_bookmark_folder_dialog, null));
+
+        // Set an `onClick()` listener for the negative button.
+        dialogBuilder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                // Return the `DialogFragment` to the parent activity on cancel.
+                editBookmarkFolderListener.onCancelEditBookmarkFolder(EditBookmarkFolder.this);
+            }
+        });
+
+        // Set the `onClick()` listener fo the positive button.
+        dialogBuilder.setPositiveButton(R.string.save, new Dialog.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                // Return the `DialogFragment` to the parent activity on save.
+                editBookmarkFolderListener.onSaveEditBookmarkFolder(EditBookmarkFolder.this);
+            }
+        });
+
+
+        // Create an `AlertDialog` from the `AlertDialog.Builder`.
+        final AlertDialog alertDialog = dialogBuilder.create();
+
+        // Show the keyboard when the `Dialog` is displayed on the screen.
+        alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+
+        // We need to show the `AlertDialog` before we can modify items in the layout.
+        alertDialog.show();
+
+        // Get the current favorite icon byte array from the `Cursor`.
+        byte[] currentIconByteArray = bookmarkCursor.getBlob(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.FAVORITE_ICON));
+        // Convert the byte array to a `Bitmap` beginning at the first byte and ending at the last.
+        Bitmap currentIconBitmap = BitmapFactory.decodeByteArray(currentIconByteArray, 0, currentIconByteArray.length);
+        // Display `currentIconBitmap` in `edit_folder_current_icon`.
+        ImageView currentIconImageView = (ImageView) alertDialog.findViewById(R.id.edit_folder_current_icon);
+        assert currentIconImageView != null;  // Remove the warning below that `currentIconImageView` might be null.
+        currentIconImageView.setImageBitmap(currentIconBitmap);
+
+        // Get a `Bitmap` of the favorite icon from `MainWebViewActivity` and display it in `edit_folder_web_page_favorite_icon`.
+        ImageView webPageFavoriteIcon = (ImageView) alertDialog.findViewById(R.id.edit_folder_web_page_favorite_icon);
+        assert webPageFavoriteIcon != null;  // Remove the warning below that `webPageFavoriteIcon` might be null.
+        webPageFavoriteIcon.setImageBitmap(MainWebViewActivity.favoriteIcon);
+
+        // Load the text for `edit_folder_name_edittext`.
+        EditText folderNameEditText = (EditText) alertDialog.findViewById(R.id.edit_folder_name_edittext);
+        assert folderNameEditText != null;  // Remove the warning below that `bookmarkNameEditText` might be null.
+        folderNameEditText.setText(bookmarkCursor.getString(bookmarkCursor.getColumnIndex(BookmarksDatabaseHandler.BOOKMARK_NAME)));
+
+        // Allow the `enter` key on the keyboard to save the bookmark from `edit_bookmark_name_edittext`.
+        folderNameEditText.setOnKeyListener(new View.OnKeyListener() {
+            public boolean onKey(View v, int keyCode, KeyEvent event) {
+                // If the event is a key-down on the "enter" button, select the PositiveButton `Save`.
+                if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
+                    // Trigger `editBookmarkListener` and return the DialogFragment to the parent activity.
+                    editBookmarkFolderListener.onSaveEditBookmarkFolder(EditBookmarkFolder.this);
+                    // Manually dismiss the `AlertDialog`.
+                    alertDialog.dismiss();
+                    // Consume the event.
+                    return true;
+                } else {  // If any other key was pressed, do not consume the event.
+                    return false;
+                }
+            }
+        });
+
+        // `onCreateDialog` requires the return of an `AlertDialog`.
+        return alertDialog;
+    }
+}
\ No newline at end of file
index e59168fe0519bafa3248031b73604a420a72a87f..f10c2e45f561d0640f50fc92c22b4e4addbdcfac 100644 (file)
@@ -65,7 +65,7 @@ import java.net.URLEncoder;
 
 // We need to use AppCompatActivity from android.support.v7.app.AppCompatActivity to have access to the SupportActionBar until the minimum API is >= 21.
 public class MainWebViewActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, CreateHomeScreenShortcut.CreateHomeScreenSchortcutListener {
-    // `favoriteIcon` is public static so it can be accessed from `CreateHomeScreenShortcut`, `BookmarksActivity`, and `EditBookmark`.
+    // `favoriteIcon` is public static so it can be accessed from `CreateHomeScreenShortcut`, `BookmarksActivity`, `CreateBookmark`, `CreateBookmarkFolder`, and `EditBookmark`.
     // It is also used in `onCreate()` and `onCreateHomeScreenShortcutCreate()`.
     public static Bitmap favoriteIcon;
 
@@ -629,7 +629,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             case R.id.addToHomescreen:
                 // Show the CreateHomeScreenShortcut AlertDialog and name this instance "@string/create_shortcut".
                 DialogFragment createHomeScreenShortcutDialogFragment = new CreateHomeScreenShortcut();
-                createHomeScreenShortcutDialogFragment.show(getFragmentManager(), "@string/create_shortcut");
+                createHomeScreenShortcutDialogFragment.show(getFragmentManager(), getResources().getString(R.string.create_shortcut));
 
                 //Everything else will be handled by CreateHomeScreenShortcut and the associated listeners below.
                 return true;
@@ -684,19 +684,19 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 break;
 
             case R.id.settings:
-                // Launch SettingsActivity.
+                // Launch `SettingsActivity`.
                 Intent settingsIntent = new Intent(this, SettingsActivity.class);
                 startActivity(settingsIntent);
                 break;
 
             case R.id.guide:
-                // Launch GuideActivity.
+                // Launch `GuideActivity`.
                 Intent guideIntent = new Intent(this, GuideActivity.class);
                 startActivity(guideIntent);
                 break;
 
             case R.id.about:
-                // Launch AboutActivity.
+                // Launch `AboutActivity`.
                 Intent aboutIntent = new Intent(this, AboutActivity.class);
                 startActivity(aboutIntent);
                 break;
@@ -765,12 +765,12 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
     }
 
     @Override
-    public void onCreateHomeScreenShortcutCancel(DialogFragment dialogFragment) {
+    public void onCancelCreateHomeScreenShortcut(DialogFragment dialogFragment) {
         // Do nothing because the user selected "Cancel".
     }
 
     @Override
-    public void onCreateHomeScreenShortcutCreate(DialogFragment dialogFragment) {
+    public void onCreateHomeScreenShortcut(DialogFragment dialogFragment) {
         // Get shortcutNameEditText from the alert dialog.
         EditText shortcutNameEditText = (EditText) dialogFragment.getDialog().findViewById(R.id.shortcut_name_edittext);
 
diff --git a/app/src/main/java/com/stoutner/privacybrowser/MoveToFolder.java b/app/src/main/java/com/stoutner/privacybrowser/MoveToFolder.java
new file mode 100644 (file)
index 0000000..2ae2cc6
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+ *
+ * Privacy Browser is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privacy Browser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser;
+
+import android.app.DialogFragment;
+
+public class MoveToFolder extends DialogFragment {
+}
diff --git a/app/src/main/res/drawable-hdpi/folder_blue_bitmap.png b/app/src/main/res/drawable-hdpi/folder_blue_bitmap.png
new file mode 100644 (file)
index 0000000..0b5f491
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/folder_blue_bitmap.png differ
diff --git a/app/src/main/res/drawable-mdpi/folder_blue_bitmap.png b/app/src/main/res/drawable-mdpi/folder_blue_bitmap.png
new file mode 100644 (file)
index 0000000..2e8e77d
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/folder_blue_bitmap.png differ
diff --git a/app/src/main/res/drawable-xhdpi/folder_blue_bitmap.png b/app/src/main/res/drawable-xhdpi/folder_blue_bitmap.png
new file mode 100644 (file)
index 0000000..ab7a308
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/folder_blue_bitmap.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/folder_blue_bitmap.png b/app/src/main/res/drawable-xxhdpi/folder_blue_bitmap.png
new file mode 100644 (file)
index 0000000..8c1be73
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/folder_blue_bitmap.png differ
index e69b5ad5096bc5619761d455fa7f46ba2d36867a..a49efd8b44cc4ec17a5fcceb159b5b2c2cc0a766 100644 (file)
@@ -3,11 +3,11 @@
 
 <vector
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:autoMirrored="true"
     android:height="24dp"
     android:width="24dp"
     android:viewportHeight="24.0"
-    android:viewportWidth="24.0" >
+    android:viewportWidth="24.0"
+    android:autoMirrored="true" >
 
     <path
         android:fillColor="#FF000000"
diff --git a/app/src/main/res/drawable/create_folder.xml b/app/src/main/res/drawable/create_folder.xml
new file mode 100644 (file)
index 0000000..0ac318e
--- /dev/null
@@ -0,0 +1,15 @@
+<!-- create_folder.xml comes from the Android Material icon set, where it is called ic_create_new_folder.
+  It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>. -->
+
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0"
+    android:autoMirrored="true" >
+
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M20,6h-8l-2,-2L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM19,14h-3v3h-2v-3h-3v-2h3L14,9h2v3h3v2z"/>
+</vector>
index d516488129fae5120f99d390495b4d8a750f0a38..89a86c32df286ec3cfc8b2f0cb7e8388bca34978 100644 (file)
@@ -3,11 +3,11 @@
 
 <vector
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:autoMirrored="true"
     android:height="24dp"
     android:width="24dp"
     android:viewportHeight="24.0"
-    android:viewportWidth="24.0" >
+    android:viewportWidth="24.0"
+    android:autoMirrored="true" >
 
     <path
         android:fillColor="#FFFFFFFF"
index 89d4faffa704d83a0b6b1b1198ef28cc1432ec65..e46ccccaa44c91be326d4bcda48efaf23484cf7d 100644 (file)
@@ -3,11 +3,11 @@
 
 <vector
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:autoMirrored="true"
     android:height="24dp"
     android:width="24dp"
     android:viewportHeight="24.0"
-    android:viewportWidth="24.0" >
+    android:viewportWidth="24.0"
+    android:autoMirrored="true" >
 
     <path
         android:fillColor="#FF000000"
diff --git a/app/src/main/res/drawable/folder.xml b/app/src/main/res/drawable/folder.xml
new file mode 100644 (file)
index 0000000..a6d3d31
--- /dev/null
@@ -0,0 +1,14 @@
+<!-- folder.xml comes from the Android Material icon set, where it is called ic_folder.
+  It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>. -->
+
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0" >
+
+    <path
+        android:fillColor="#FF9E9E9E"
+        android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>
+</vector>
index e8ccd370fdb901c074e1a8b554ed70bb88a3a105..dfa9e066b96ce0d30e2c3a73ff7968d3eeffa46c 100644 (file)
@@ -3,11 +3,11 @@
 
 <vector
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:autoMirrored="true"
     android:height="24dp"
     android:width="24dp"
     android:viewportHeight="24.0"
-    android:viewportWidth="24.0" >
+    android:viewportWidth="24.0"
+    android:autoMirrored="true" >
 
     <path
         android:fillColor="#FF000000"
index 674fcda7f6fe234cd8a0934d43bfd397568e9287..6934feb5286bd7777928e1a8eb6b7d1d76f208a4 100644 (file)
@@ -1,4 +1,4 @@
-<!-- move_bookmark_down_enabled.xmlbled.xml comes from the Android Material icon set, where it is called ic_vertical_align_bottom.
+<!-- move_bookmark_down_disabled.xml comes from the Android Material icon set, where it is called ic_vertical_align_bottom.
   It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>. -->
 
 <vector
index 90b5ae1b3eeda92a5bb32d780ab234f86386059c..b7a2423ece42638153c110460dabdf6a45b28e5c 100644 (file)
@@ -1,4 +1,4 @@
-<!-- move_bookmark_down_enabled.xmlbled.xml comes from the Android Material icon set, where it is called ic_vertical_align_bottom.
+<!-- move_bookmark_down_enabled.xml comes from the Android Material icon set, where it is called ic_vertical_align_bottom.
   It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>. -->
 
 <vector
index c38ad46c374600f2a342f6efb8fa8c135d85608d..4ead123aa821216887cf918d4552e69e4373e993 100644 (file)
@@ -1,4 +1,4 @@
-<!-- move_bookmark_up_enabled.xmlbled.xml comes from the Android Material icon set, where it is called ic_vertical_align_top.
+<!-- move_bookmark_up_disabled.xml comes from the Android Material icon set, where it is called ic_vertical_align_top.
   It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>. -->
 
 <vector
index 06c837d52b84d8fefdc6902e91e0ba3e535b9cda..20a40515464168ba39f17314272a5dcb41215bdb 100644 (file)
@@ -1,4 +1,4 @@
-<!-- move_bookmark_up_enabled_enabled.xml comes from the Android Material icon set, where it is called ic_vertical_align_top.
+<!-- move_bookmark_up_enabled.xml comes from the Android Material icon set, where it is called ic_vertical_align_top.
   It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>. -->
 
 <vector
diff --git a/app/src/main/res/drawable/move_to_folder.xml b/app/src/main/res/drawable/move_to_folder.xml
new file mode 100644 (file)
index 0000000..9b912bb
--- /dev/null
@@ -0,0 +1,15 @@
+<!-- move_to_folder.xml comes from the Android Material icon set, where it is called ic_folder_special.
+  It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>. -->
+
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:autoMirrored="true"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0" >
+
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM17.94,17L15,15.28 12.06,17l0.78,-3.33 -2.59,-2.24 3.41,-0.29L15,8l1.34,3.14 3.41,0.29 -2.59,2.24 0.78,3.33z"/>
+</vector>
index 783a19bc0257b200fe8e11a5c466999cfec63611..4ebdaaa5a729ce834d83c51026052bf37b5afffb 100644 (file)
@@ -18,9 +18,9 @@
   You should have received a copy of the GNU General Public License
   along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
 
-<!-- android:fitsSystemWindows="true" moves the AppBar below the status bar.
-  When it is specified the theme should include <item name="android:windowTranslucentStatus">true</item>
-  to make the status bar a transparent, darkened overlay. -->
+<!-- `android:fitsSystemWindows="true"` moves the AppBar below the status bar.
+    When it is specified the theme should include `<item name="android:windowTranslucentStatus">true</item>`
+    to make the status bar a transparent, darkened overlay. -->
 <android.support.design.widget.CoordinatorLayout
     android:id="@+id/bookmarks_coordinatorlayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
@@ -29,7 +29,7 @@
     android:layout_width="match_parent"
     android:fitsSystemWindows="true" >
 
-    <!-- the LinearLayout with orientation="vertical" moves the content below the AppBarLayout. -->
+    <!-- the `LinearLayout` with `orientation="vertical"` moves the content below the `AppBarLayout`. -->
     <LinearLayout
         android:layout_height="match_parent"
         android:layout_width="match_parent"
@@ -51,9 +51,9 @@
                 app:popupTheme="@style/LightPopupOverlay" />
         </android.support.design.widget.AppBarLayout>
 
-        <!-- android:choiceMode="multipleChoiceModal" allows the contextual action menu to select more than one item at a time.
-            android:dividerHeight must be specified with android:divider or the height will be 0dp.
-            In our case we want the height to be 0dp. -->
+        <!-- `android:choiceMode="multipleChoiceModal"` allows the contextual action menu to select more than one item at a time.
+            `android:dividerHeight` must be specified with `android:divider` or the height will be `0dp`.
+            In our case we want the height to be `0dp`. -->
         <ListView
             android:id="@+id/bookmarks_listview"
             android:layout_height="match_parent"
diff --git a/app/src/main/res/layout/bookmarks_database_view_coordinatorlayout.xml b/app/src/main/res/layout/bookmarks_database_view_coordinatorlayout.xml
new file mode 100644 (file)
index 0000000..2db0281
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+
+  Privacy Browser is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  Privacy Browser is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<!-- `android:fitsSystemWindows="true"` moves the AppBar below the status bar.
+    When it is specified the theme should include `<item name="android:windowTranslucentStatus">true</item>`
+    to make the status bar a transparent, darkened overlay. -->
+<android.support.design.widget.CoordinatorLayout
+    android:id="@+id/bookmarks_database_view_coordinatorlayout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_height="match_parent"
+    android:layout_width="match_parent"
+    android:fitsSystemWindows="true" >
+
+    <!-- the `LinearLayout` with `orientation="vertical"` moves the content below the `AppBarLayout`. -->
+    <LinearLayout
+        android:layout_height="match_parent"
+        android:layout_width="match_parent"
+        android:orientation="vertical" >
+
+        <android.support.design.widget.AppBarLayout
+            android:id="@+id/bookmarks_database_view_appbarlayout"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:theme="@style/AppBarOverlay" >
+
+            <android.support.v7.widget.Toolbar
+                android:id="@+id/bookmarks_database_view_toolbar"
+                android:layout_height="wrap_content"
+                android:layout_width="match_parent"
+                android:background="@color/blue"
+                android:theme="@style/DarkAppBar"
+                app:popupTheme="@style/LightPopupOverlay" />
+        </android.support.design.widget.AppBarLayout>
+
+        <ListView
+            android:id="@+id/bookmarks_database_view_listview"
+            android:layout_height="match_parent"
+            android:layout_width="match_parent" />
+    </LinearLayout>
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/bookmarks_database_view_linearlayout.xml b/app/src/main/res/layout/bookmarks_database_view_linearlayout.xml
new file mode 100644 (file)
index 0000000..f1949e8
--- /dev/null
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+
+  Privacy Browser is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  Privacy Browser is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<LinearLayout
+    android:id="@+id/bookmarks_database_view_item_linearlayout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent"
+    android:orientation="vertical" >
+
+    <!-- First row. -->
+    <LinearLayout
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_marginTop="10dp"
+        android:layout_marginStart="10dp"
+        android:layout_marginEnd="10dp"
+        android:orientation="horizontal" >
+
+        <TextView
+            android:id="@+id/bookmarks_database_view_database_id"
+            android:layout_height="wrap_content"
+            android:layout_width="50dp"
+            android:layout_marginEnd="10dp"
+            android:gravity="end"
+            android:textColor="@color/grey"
+            android:textSize="22sp" />
+
+        <ImageView
+            android:id="@+id/bookmarks_database_view_favorite_icon"
+            android:layout_width="30dp"
+            android:layout_height="30dp"
+            android:layout_gravity="center_vertical"
+            android:layout_marginEnd="10dp"
+            tools:ignore="ContentDescription" />
+
+        <TextView
+            android:id='@+id/bookmarks_database_view_bookmark_name'
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:textColor="@color/black"
+            android:textSize="22sp"
+            android:singleLine="true" />
+    </LinearLayout>
+
+    <!-- Second row. -->
+    <LinearLayout
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content"
+        android:layout_marginStart="10dp"
+        android:layout_marginEnd="10dp"
+        android:orientation="horizontal" >
+
+        <TextView
+            android:id="@+id/bookmarks_database_view_display_order"
+            android:layout_height="wrap_content"
+            android:layout_width="50dp"
+            android:layout_marginEnd="10dp"
+            android:gravity="end"
+            android:textColor="@color/black"
+            android:textSize="22sp" />
+
+        <ImageView
+            android:layout_height="30dp"
+            android:layout_width="30dp"
+            android:layout_gravity="center_vertical"
+            android:layout_marginEnd="10dp"
+            android:src="@drawable/folder"
+            tools:ignore="ContentDescription" />
+
+        <TextView
+            android:id="@+id/bookmarks_database_view_parent_folder"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:textColor="@color/black"
+            android:textSize="22sp"
+            android:textStyle="italic"
+            android:singleLine="true" />
+    </LinearLayout>
+
+    <!-- Third row. -->
+    <TextView
+        android:id="@+id/bookmarks_database_view_bookmark_url"
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content"
+        android:layout_marginBottom="10dp"
+        android:layout_marginStart="13dp"
+        android:layout_marginEnd="10dp"
+        android:textColor="@color/black"
+        android:textSize="22sp"
+        android:singleLine="true" />
+</LinearLayout>
\ No newline at end of file
index 408844fe7e82ba4444c9dbc9e535722dc928fc23..cbb120381fa05ba9531b75512f7cdbe3cb94508b 100644 (file)
 <LinearLayout
     android:id="@+id/bookmarks_item_linearlayout"
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_height="wrap_content"
     android:layout_width="match_parent"
     android:orientation="horizontal"
-    android:background="@drawable/bookmarks_list_selector"
-    xmlns:tools="http://schemas.android.com/tools">
+    android:background="@drawable/bookmarks_list_selector" >
 
     <ImageView
         android:id="@+id/bookmark_favorite_icon"
index 48e7cc79dd66e80be2ce6cd92cd94e4841a9334a..49670020e869f31a4401d13d92e467468aabf449 100644 (file)
         android:layout_marginTop="12dp"
         android:layout_marginBottom="6dp"
         android:layout_marginStart="4dp"
-        android:layout_marginEnd="4dp">
+        android:layout_marginEnd="4dp" >
 
         <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
-            `android:inputType="textUri"` disables spell check in the EditText.
-            `android:singleLine="true"` is not needed in a Dialog.-->
+            `android:inputType="textUri"` disables spell check in the EditText. -->
         <android.support.design.widget.TextInputEditText
             android:id="@+id/create_bookmark_name_edittext"
             android:layout_height="wrap_content"
@@ -55,8 +54,7 @@
         android:layout_marginEnd="4dp" >
 
         <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
-            `android:inputType="textUri"` disables spell check in the EditText.
-            `android:singleLine="true"` is not needed in a Dialog.-->
+            `android:inputType="textUri"` disables spell check in the EditText.-->
         <EditText
             android:id="@+id/create_bookmark_url_edittext"
             android:layout_height="wrap_content"
diff --git a/app/src/main/res/layout/create_bookmark_folder_dialog.xml b/app/src/main/res/layout/create_bookmark_folder_dialog.xml
new file mode 100644 (file)
index 0000000..58bb405
--- /dev/null
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+
+  Privacy Browser is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  Privacy Browser is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent"
+    android:orientation="vertical" >
+
+    <!-- The icon selection rows. -->
+    <LinearLayout
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:orientation="horizontal">
+
+        <!-- The column displaying the icons. -->
+        <LinearLayout
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:orientation="vertical" >
+
+            <ImageView
+                android:id="@+id/create_folder_default_icon"
+                android:layout_height="30dp"
+                android:layout_width="30dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginBottom="6dp"
+                android:layout_marginStart="8dp"
+                android:layout_marginEnd="8dp"
+                android:layout_gravity="center_vertical"
+                android:src="@drawable/folder_blue_bitmap"
+                tools:ignore="ContentDescription" />
+
+            <ImageView
+                android:id="@+id/create_folder_web_page_icon"
+                android:layout_height="30dp"
+                android:layout_width="30dp"
+                android:layout_marginTop="6dp"
+                android:layout_marginBottom="6dp"
+                android:layout_marginStart="8dp"
+                android:layout_marginEnd="8dp"
+                android:layout_gravity="center_vertical"
+                tools:ignore="ContentDescription" />
+        </LinearLayout>
+
+        <!-- The column with the `RadioGroup`. -->
+        <RadioGroup
+            android:id="@+id/create_folder_radiogroup"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:checkedButton="@+id/create_folder_default_icon_radiobuttion">
+
+            <RadioButton
+                android:id="@id/create_folder_default_icon_radiobuttion"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="12dp"
+                android:layout_marginBottom="9dp"
+                android:text="@string/default_folder_icon"
+                android:textSize="18sp" />
+
+            <RadioButton
+                android:id="@+id/create_folder_web_page_icon_radiobuttion"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/web_page_favorite_icon"
+                android:textSize="18sp" />
+        </RadioGroup>
+    </LinearLayout>
+
+    <!-- `android.support.design.widget.TextInputLayout` makes the `android:hint` float above the `EditText`. -->
+    <android.support.design.widget.TextInputLayout
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_marginTop="6dp"
+        android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp" >
+
+        <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
+            `android:inputType="textUri"` disables spell check in the EditText. -->
+        <android.support.design.widget.TextInputEditText
+            android:id="@+id/create_folder_name_edittext"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:hint="@string/folder_name"
+            android:imeOptions="actionGo"
+            android:inputType="textUri" />
+    </android.support.design.widget.TextInputLayout>
+
+    <TextView
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:gravity="center_horizontal"
+        android:text="@string/folder_names_must_be_unique" />
+</LinearLayout>
\ No newline at end of file
index 5e9241112ee3752eda2bc09e51d9470ab1008b28..11469afff08a6ece5ab0e212da65976c87c83c61 100644 (file)
   You should have received a copy of the GNU General Public License
   along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
 
-<RelativeLayout
-    android:id="@+id/create_home_screen_shortcut_dialog_relativelayout"
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_height="wrap_content"
-    android:layout_width="match_parent" >
-
-    <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
-        `android:inputType="textUri"` disables spell check in the EditText.
-        `android:singleLine="true"` is not needed in a Dialog.
-        We can't use `android:imeOptions=flagNoExtractUi"` because it disables tapping to select in landscape orientation on small devices.-->
-    <EditText
-        android:id="@+id/shortcut_name_edittext"
+    android:layout_width="match_parent"
+    android:orientation="vertical" >
+
+    <android.support.design.widget.TextInputLayout
         android:layout_height="wrap_content"
         android:layout_width="match_parent"
         android:layout_marginTop="16dp"
-        android:layout_marginLeft="4dp"
-        android:layout_marginRight="4dp"
-        android:layout_marginBottom="16dp"
-        android:hint="@string/shortcut_name"
-        android:imeOptions="actionGo"
-        android:inputType="textUri" />
-</RelativeLayout>
\ No newline at end of file
+        android:layout_marginBottom="10dp"
+        android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp" >
+
+        <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
+            `android:inputType="textUri"` disables spell check in the EditText.
+            We can't use `android:imeOptions=flagNoExtractUi"` because it disables tapping to select in landscape orientation on small devices.-->
+        <android.support.design.widget.TextInputEditText
+            android:id="@+id/shortcut_name_edittext"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:hint="@string/shortcut_name"
+            android:imeOptions="actionGo"
+            android:inputType="textUri" />
+    </android.support.design.widget.TextInputLayout>
+</LinearLayout>
\ No newline at end of file
index 1768ca08f8470414af2e39302da729df33644703..7bb2e454d4ffe7bb1e4b13940ba6c9341179579b 100644 (file)
 
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical"
-    android:paddingStart="4dp"
-    android:paddingEnd="4dp" >
+    android:orientation="vertical">
 
+    <!-- The icon selection rows. -->
     <LinearLayout
         android:layout_height="wrap_content"
         android:layout_width="match_parent"
-        android:orientation="horizontal"
-        android:paddingTop="12dp"
-        android:paddingBottom="4dp"
-        android:paddingStart="20dp"
-        android:paddingEnd="0dp" >
-
-        <ImageView
-            android:id="@+id/edit_bookmark_new_favorite_icon"
-            android:layout_width="32dp"
-            android:layout_height="32dp"
-            android:contentDescription="@string/new_favorite_icon" />
-
-        <TextView
+        android:orientation="horizontal">
+
+        <!-- The column displaying the icons. -->
+        <LinearLayout
             android:layout_height="wrap_content"
             android:layout_width="wrap_content"
-            android:text="@string/use_new_icon"
-            android:textColor="@color/black"
-            android:textSize="20sp"
-            android:paddingStart="8dp"
-            android:paddingEnd="4dp" />
-
-        <CheckBox
-            android:id="@+id/edit_bookmark_use_new_favorite_icon_checkbox"
+            android:layout_marginStart="16dp"
+            android:layout_marginEnd="10dp"
+            android:orientation="vertical" >
+
+            <ImageView
+                android:id="@+id/edit_bookmark_current_icon"
+                android:layout_width="30dp"
+                android:layout_height="30dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginBottom="6dp"
+                android:layout_gravity="center_vertical"
+                tools:ignore="ContentDescription" />
+
+            <ImageView
+                android:id="@+id/edit_bookmark_web_page_favorite_icon"
+                android:layout_width="30dp"
+                android:layout_height="30dp"
+                android:layout_marginTop="6dp"
+                android:layout_marginBottom="6dp"
+                tools:ignore="ContentDescription" />
+        </LinearLayout>
+
+        <!-- The column with the `RadioGroup`. -->
+        <RadioGroup
             android:layout_height="wrap_content"
-            android:layout_width="wrap_content" />
+            android:layout_width="match_parent"
+            android:checkedButton="@+id/edit_bookmark_current_icon_radiobutton" >
+
+            <RadioButton
+                android:id="@id/edit_bookmark_current_icon_radiobutton"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_marginTop="12dp"
+                android:layout_marginBottom="4dp"
+                android:text="@string/current_bookmark_icon"
+                android:textSize="18sp" />
+
+            <RadioButton
+                android:id="@+id/edit_bookmark_web_page_favorite_icon_radiobutton"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_marginTop="5dp"
+                android:text="@string/web_page_favorite_icon"
+                android:textSize="18sp" />
+        </RadioGroup>
     </LinearLayout>
 
     <!-- `android.support.design.widget.TextInputLayout` makes the `android:hint` float above the `EditText`. -->
@@ -61,7 +87,9 @@
         android:layout_height="wrap_content"
         android:layout_width="match_parent"
         android:layout_marginTop="12dp"
-        android:layout_marginBottom="6dp" >
+        android:layout_marginBottom="6dp"
+        android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp" >
 
         <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
             `android:inputType="textUri"` disables spell check in the EditText.
         android:layout_height="wrap_content"
         android:layout_width="match_parent"
         android:layout_marginTop="6dp"
-        android:layout_marginBottom="12dp" >
+        android:layout_marginBottom="12dp"
+        android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp" >
 
         <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
             `android:inputType="textUri"` disables spell check in the EditText.
diff --git a/app/src/main/res/layout/edit_bookmark_folder_dialog.xml b/app/src/main/res/layout/edit_bookmark_folder_dialog.xml
new file mode 100644 (file)
index 0000000..2286cbd
--- /dev/null
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
+
+  Privacy Browser is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  Privacy Browser is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent"
+    android:orientation="vertical" >
+
+    <!-- The icon selection rows. -->
+    <LinearLayout
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:orientation="horizontal">
+
+        <!-- The column displaying the icons. -->
+        <LinearLayout
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:orientation="vertical"
+            android:layout_marginStart="16dp"
+            android:layout_marginEnd="10dp" >
+
+            <ImageView
+                android:id="@+id/edit_folder_current_icon"
+                android:layout_height="30dp"
+                android:layout_width="30dp"
+                android:layout_marginTop="12dp"
+                android:layout_marginBottom="6dp"
+                android:layout_gravity="center_vertical"
+                tools:ignore="ContentDescription" />
+
+            <ImageView
+                android:id="@+id/edit_folder_default_icon"
+                android:layout_height="30dp"
+                android:layout_width="30dp"
+                android:layout_marginTop="6dp"
+                android:layout_marginBottom="6dp"
+                android:layout_gravity="center_vertical"
+                android:src="@drawable/folder_blue_bitmap"
+                tools:ignore="ContentDescription" />
+
+            <ImageView
+                android:id="@+id/edit_folder_web_page_favorite_icon"
+                android:layout_height="30dp"
+                android:layout_width="30dp"
+                android:layout_marginTop="6dp"
+                android:layout_marginBottom="12dp"
+                android:layout_gravity="center_vertical"
+                tools:ignore="ContentDescription" />
+        </LinearLayout>
+
+        <!-- The column with the `RadioGroup`. -->
+        <RadioGroup
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:checkedButton="@+id/edit_folder_current_icon_radiobutton">
+
+            <RadioButton
+                android:id="@id/edit_folder_current_icon_radiobutton"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_marginTop="12dp"
+                android:layout_marginBottom="4dp"
+                android:text="@string/current_folder_icon"
+                android:textSize="18sp"/>
+
+            <RadioButton
+                android:id="@+id/edit_folder_default_icon_radiobutton"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:layout_marginBottom="4dp"
+                android:text="@string/default_folder_icon"
+                android:textSize="18sp" />
+
+            <RadioButton
+                android:id="@+id/edit_folder_web_page_icon_radiobutton"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:text="@string/web_page_favorite_icon"
+                android:textSize="18sp" />
+        </RadioGroup>
+    </LinearLayout>
+
+    <!-- `android.support.design.widget.TextInputLayout` makes the `android:hint` float above the `EditText`. -->
+    <android.support.design.widget.TextInputLayout
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_marginTop="6dp"
+        android:layout_marginBottom="12dp"
+        android:layout_marginStart="4dp"
+        android:layout_marginEnd="4dp" >
+
+        <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
+            `android:inputType="textUri"` disables spell check in the EditText. -->
+        <android.support.design.widget.TextInputEditText
+            android:id="@+id/edit_folder_name_edittext"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:hint="@string/folder_name"
+            android:imeOptions="actionGo"
+            android:inputType="textUri" />
+    </android.support.design.widget.TextInputLayout>
+
+    <TextView
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:gravity="center_horizontal"
+        android:text="@string/folder_names_must_be_unique" />
+</LinearLayout>
\ No newline at end of file
index ba1139ee3a1e22a4c5d02b420dd885f94b4d5c37..1f880e39625d15b837af3a8e6af6105be63bac9e 100644 (file)
         android:icon="@drawable/move_bookmark_down_enabled"
         app:showAsAction="ifRoom" />
 
+    <item
+        android:id="@+id/move_to_folder"
+        android:title="@string/move_to_folder"
+        android:orderInCategory="30"
+        android:icon="@drawable/move_to_folder"
+        app:showAsAction="ifRoom" />
+
     <item
         android:id="@+id/edit_bookmark"
         android:title="@string/edit"
-        android:orderInCategory="30"
+        android:orderInCategory="40"
         android:icon="@drawable/edit"
         app:showAsAction="ifRoom" />
 
     <item
         android:id="@+id/delete_bookmark"
         android:title="@string/delete"
-        android:orderInCategory="40"
+        android:orderInCategory="50"
         android:icon="@drawable/delete"
         app:showAsAction="ifRoom" />
 
     <item
         android:id="@+id/context_menu_select_all_bookmarks"
         android:title="@string/select_all"
-        android:orderInCategory="50"
+        android:orderInCategory="60"
         android:icon="@drawable/select_all"
         app:showAsAction="ifRoom" />
 </menu>
\ No newline at end of file
index 856594ce3810d24120f4fb7c84b4aebe87ed4464..41b7b86f644a52a4a1509ac74f84aa791bb13283 100644 (file)
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
+    <item
+        android:id="@+id/create_folder"
+        android:title="@string/create_folder"
+        android:orderInCategory="10"
+        android:icon="@drawable/create_folder"
+        app:showAsAction="ifRoom" />
+
     <item
         android:id="@+id/options_menu_select_all_bookmarks"
         android:title="@string/select_all"
-        android:orderInCategory="10"
+        android:orderInCategory="20"
         android:icon="@drawable/select_all"
         app:showAsAction="ifRoom" />
+
+    <item
+        android:id="@+id/bookmarks_database_view"
+        android:title="@string/database_view"
+        android:orderInCategory="30"
+        app:showAsAction="never" />
 </menu>
\ No newline at end of file
index 02fa590facd0ecb63fc2e97e9fe6ec81892b0403..598c51b790b6ec7f44c6267c48170dcec179dc25 100644 (file)
     <color name="black">#FF000000</color>
     <color name="blue">#FF1976D2</color>
     <color name="dark_blue">#FF0D47A1</color>
-    <color name="blue_gray">#FF607d8b</color>
+    <color name="blue_gray">#FF607D8B</color>
+    <color name="grey">#FF9E9E9E</color>
     <color name="green">#FF64DD17</color>
     <color name="light_blue">#FFBBDEFB</color>
+    <color name="medium_light_blue">#FF42A5F5</color>
     <color name="red">#FFD50000</color>
     <color name="white">#FFFFFFFF</color>
     <color name="yellow">#FFFFD600</color>
index a4a030e0c3a781c59b1ed51b50b675a4156dcaea..42396d5919dd7a826f4cbe56943c64124a8e9e63 100644 (file)
     <string name="create">Create</string>
 
     <!-- Bookmarks. -->
+    <string name="database_view">Database View</string>
     <string name="create_bookmark">Create bookmark</string>
+    <string name="create_folder">Create folder</string>
+    <string name="current_folder_icon">Current folder icon</string>
+    <string name="default_folder_icon">Default folder icon</string>
+    <string name="web_page_favorite_icon">Web page favorite icon</string>
+    <string name="folder_name">Folder name</string>
+    <string name="folder_names_must_be_unique">Folder names must be unique</string>
+    <string name="cannot_create_folder">Cannot create the folder because the name is not unique:</string>
+    <string name="cannot_rename_folder">Cannot rename the folder because the new name is not unique:</string>
     <string name="edit_bookmark">Edit bookmark</string>
+    <string name="edit_folder">Edit folder</string>
+    <string name="move_to_folder">Move to Folder</string>
     <string name="save">Save</string>
     <string name="bookmark_name">Bookmark name</string>
     <string name="bookmark_url">Bookmark URL</string>
-    <string name="new_favorite_icon">New favorite icon</string>
-    <string name="use_new_icon">Use new icon</string>
+    <string name="current_bookmark_icon">Current bookmark icon</string>
 
     <!-- Bookmarks Contextual App Bar. -->
     <string name="selected">Selected</string>
     <string name="move_up">Move Up</string>
-    <string name="move_down">Move down</string>
+    <string name="move_down">Move Down</string>
     <string name="edit">Edit</string>
     <string name="delete">Delete</string>
     <string name="select_all">Select All</string>
     <string name="bookmarks_deleted">Bookmarks Deleted</string>
     <string name="undo">Undo</string>
 
+    <!-- Bookmarks Database View. -->
+    <string name="bookmarks_database_view">Bookmarks Database View</string>
+    <string name="home_folder">Home folder</string>
+
     <!-- Guide. -->
     <string name="privacy_browser_guide">Privacy Browser Guide</string>
     <string name="overview">Overview</string>