X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FBookmarksDatabaseViewActivity.java;h=006af07a94c36b590ce86ee7b72d265774f3e5f0;hp=a61391db27c45f3bb21058346f1166d3c4583593;hb=012e5595c82d6e8d0b8a46f1ef18a02a56341182;hpb=9f551f25b53a30cca7b19b6e6bfc2d2520d9aa1b diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java index a61391db..006af07a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2017 Soren Stoutner . + * Copyright © 2016-2018 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -39,6 +39,7 @@ import android.support.v7.app.AppCompatDialogFragment; import android.support.v7.widget.Toolbar; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.AdapterView; import android.widget.EditText; import android.widget.ImageView; @@ -79,6 +80,11 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements @Override public void onCreate(Bundle savedInstanceState) { + // Disable screenshots if not allowed. + if (!MainWebViewActivity.allowScreenshots) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); + } + // Set the activity theme. if (MainWebViewActivity.darkTheme) { setTheme(R.style.PrivacyBrowserDark_SecondaryActivity); @@ -102,14 +108,14 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements // Remove the incorrect warning in Android Studio that `appBar` might be null. assert appBar != null; - // Display the `Spinner` and the back arrow in the `AppBar`. + // Display the spinner and the back arrow in the app bar. appBar.setCustomView(R.layout.bookmarks_databaseview_spinner); appBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_HOME_AS_UP); // Initialize the database handler. `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 `BookmarksDatabaseHelper`. bookmarksDatabaseHelper = new BookmarksDatabaseHelper(this, null, null, 0); - // Setup a `MatrixCursor` for "All Folders" and "Home Folder". + // Setup a matrix cursor for "All Folders" and "Home Folder". String[] matrixCursorColumnNames = {BookmarksDatabaseHelper._ID, BookmarksDatabaseHelper.BOOKMARK_NAME}; MatrixCursor matrixCursor = new MatrixCursor(matrixCursorColumnNames); matrixCursor.addRow(new Object[]{ALL_FOLDERS_DATABASE_ID, getString(R.string.all_folders)}); @@ -121,28 +127,26 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements // Combine `matrixCursor` and `foldersCursor`. MergeCursor foldersMergeCursor = new MergeCursor(new Cursor[]{matrixCursor, foldersCursor}); - // Create a `ResourceCursorAdapter` for the `Spinner` with `this` context. `0` specifies no flags.; + // Create a resource cursor adapter for the spinner. ResourceCursorAdapter foldersCursorAdapter = new ResourceCursorAdapter(this, R.layout.bookmarks_databaseview_spinner_item, foldersMergeCursor, 0) { @Override public void bindView(View view, Context context, Cursor cursor) { - // Get a handle for the `Spinner` item `TextView`. + // Get a handle for the spinner item text view. TextView spinnerItemTextView = view.findViewById(R.id.spinner_item_textview); - // Set the `TextView` to display the folder name. + // Set the text view to display the folder name. spinnerItemTextView.setText(cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME))); } }; - // Set the `ResourceCursorAdapter` drop drown view resource. + // Set the resource cursor adapter drop drown view resource. foldersCursorAdapter.setDropDownViewResource(R.layout.bookmarks_databaseview_spinner_dropdown_item); - // Get a handle for the folder `Spinner`. + // Get a handle for the folder spinner and set the adapter. Spinner folderSpinner = findViewById(R.id.bookmarks_databaseview_spinner); - - // Set the adapter for the folder `Spinner`. folderSpinner.setAdapter(foldersCursorAdapter); - // Handle clicks on the `Spinner` dropdown. + // Handle clicks on the spinner dropdown. folderSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { @@ -152,7 +156,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements // Store the current folder database ID. currentFolderDatabaseId = databaseId; - // Populate the bookmarks `ListView` based on the `Spinner` selection. + // Populate the bookmarks list view based on the spinner selection. switch (databaseId) { // Get a cursor with all the folders. case ALL_FOLDERS_DATABASE_ID: @@ -179,7 +183,7 @@ public class BookmarksDatabaseViewActivity extends AppCompatActivity implements currentFolderName = folderName; } - // Update the `ListView`. + // Update the list view. bookmarksCursorAdapter.changeCursor(bookmarksCursor); }