<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>The following icons are unchanged except for layout information like color and size. Some of them have been renamed to match their use in the code. The original icons and names are shown below.</p>
+
<p><img class="icon" src="images/ic_language.png"> ic_language.</p>
<p><img class="icon" src="images/ic_home.png"> ic_home.</p>
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.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
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).
+ // Convert the favoriteIcon Bitmap to a byte array.
ByteArrayOutputStream favoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
+ // `0` is for lossless compression (the only option for a PNG).
MainWebViewActivity.favoriteIcon.compress(Bitmap.CompressFormat.PNG, 0, favoriteIconByteArrayOutputStream);
byte[] favoriteIconByteArray = favoriteIconByteArrayOutputStream.toByteArray();
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.
+ // Get the new folder icon `Bitmap`.
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);
+ // Get the default folder icon `ImageView` from the `Dialog` and convert it to a `Bitmap`.
+ ImageView folderIconImageView = (ImageView) dialogFragment.getDialog().findViewById(R.id.create_folder_default_icon);
+ Drawable folderIconDrawable = folderIconImageView.getDrawable();
BitmapDrawable folderIconBitmapDrawable = (BitmapDrawable) folderIconDrawable;
folderIconBitmap = folderIconBitmapDrawable.getBitmap();
- } else {
+ } else { // Assign `favoriteIcon` from the `WebView`.
folderIconBitmap = MainWebViewActivity.favoriteIcon;
}
- // Convert the folder `Bitmap` to a byte array. `0` is for lossless compression (the only option for a PNG).
+ // Convert `folderIconBitmap` 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();
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.
+ } else { // Update the bookmark using the `WebView` favorite icon.
ByteArrayOutputStream newFavoriteIconByteArrayOutputStream = new ByteArrayOutputStream();
- newFavoriteIconBitmap.compress(Bitmap.CompressFormat.PNG, 0, newFavoriteIconByteArrayOutputStream);
+ MainWebViewActivity.favoriteIcon.compress(Bitmap.CompressFormat.PNG, 0, newFavoriteIconByteArrayOutputStream);
byte[] newFavoriteIconByteArray = newFavoriteIconByteArrayOutputStream.toByteArray();
// Update the bookmark and the favorite icon.
// 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.
+ // Check if the favorite icon has changed.
if (currentFolderIconRadioButton.isChecked()) {
- // Update the folder name if it has changed.
+ // Update the folder name if it has changed without modifying the favorite icon.
if (!newFolderNameString.equals(oldFolderNameString)) {
bookmarksDatabaseHandler.updateFolder(selectedFolderDatabaseId, oldFolderNameString, newFolderNameString);
updateBookmarksListView(currentFolder);
bookmarksListView.setSelection(selectedBookmarkPosition);
}
- } else { // Prepare the new favorite icon.
+ } else { // Update the folder icon.
+ // Get the new folder icon `Bitmap`.
+ 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);
+ // Get the default folder icon `ImageView` from the `Drawable` and convert it to a `Bitmap`.
+ ImageView folderIconImageView = (ImageView) dialogFragment.getDialog().findViewById(R.id.edit_folder_default_icon);
+ Drawable folderIconDrawable = folderIconImageView.getDrawable();
BitmapDrawable folderIconBitmapDrawable = (BitmapDrawable) folderIconDrawable;
folderIconBitmap = folderIconBitmapDrawable.getBitmap();
- } else { // Use the web page favorite icon.
+ } else { // Get the web page icon `ImageView` from the `Dialog`.
folderIconBitmap = MainWebViewActivity.favoriteIcon;
}
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
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;
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);
+ ImageView webPageFavoriteIconImageView = (ImageView) alertDialog.findViewById(R.id.edit_folder_web_page_favorite_icon);
+ assert webPageFavoriteIconImageView != null; // Remove the warning below that `webPageFavoriteIcon` might be null.
+ webPageFavoriteIconImageView.setImageBitmap(MainWebViewActivity.favoriteIcon);
// Load the text for `edit_folder_name_edittext`.
EditText folderNameEditText = (EditText) alertDialog.findViewById(R.id.edit_folder_name_edittext);
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
+import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SwipeRefreshLayout;
// Load the initial website.
mainWebView.loadUrl(formattedUrlString);
+ // Load the default favorite icon if it is null.
+ if (favoriteIcon == null) {
+ // We have to use `ContextCompat` until API >= 21.
+ Drawable favoriteIconDrawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.world);
+ BitmapDrawable favoriteIconBitmapDrawable = (BitmapDrawable) favoriteIconDrawable;
+ favoriteIcon = favoriteIconBitmapDrawable.getBitmap();
+ }
+
// Initialize AdView for the free flavor and request an ad. If this is not the free flavor BannerAd.requestAd() does nothing.
adView = findViewById(R.id.adView);
BannerAd.requestAd(adView);
+++ /dev/null
-<!-- folder_dark_blue.xml.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="#FF0D47A1"
- 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>
--- /dev/null
+<!-- folder_dark_blue.xml.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="#FF0D47A1"
+ 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>
+++ /dev/null
-<!-- world.xml is part of the Android Material icon set, where it is named ic_language.
- It is released under the CC-BY license <https://creativecommons.org/licenses/by/4.0/>.
- Changes to fill color and size were made by Soren Stoutner <soren@stoutner.com> in 2016. -->
-
-<vector
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:height="26dp"
- android:width="26dp"
- android:viewportHeight="24.0"
- android:viewportWidth="24.0" >
-
- <path
- android:fillColor="#FF9E9E9E"
- android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zm6.93,6h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.91 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2H4.26zm0.82,2h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zm2.95,-8H5.08c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14H9.66c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zm0.25,5.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z" />
-</vector>
\ No newline at end of file