}
@Override
- public void onSaveBookmark(DialogFragment dialogFragment, int selectedBookmarkDatabaseId, Bitmap favoriteIconBitmap) {
+ public void onSaveBookmark(DialogFragment dialogFragment, int selectedBookmarkDatabaseId, @NonNull Bitmap favoriteIconBitmap) {
// Get the dialog from the dialog fragment.
Dialog dialog = dialogFragment.getDialog();
private int savedTabPosition;
private String savedProxyMode;
- // Define the class views.
- private AppBarLayout appBarLayout;
- private TabLayout tabLayout;
- private ViewPager webViewPager;
-
// Define the class variables.
@SuppressWarnings("rawtypes")
AsyncTask populateBlocklists;
private String saveWebpageUrl;
private String saveWebpageFilePath;
+ // Declare the class views.
+ private DrawerLayout drawerLayout;
+ private AppBarLayout appBarLayout;
+ private TabLayout tabLayout;
+ private ViewPager webViewPager;
+
@Override
// Remove the warning about needing to override `performClick()` when using an `OnTouchListener` with `WebView`.
@SuppressLint("ClickableViewAccessibility")
setContentView(R.layout.main_framelayout);
// Get handles for the views.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
+ drawerLayout = findViewById(R.id.drawerlayout);
appBarLayout = findViewById(R.id.appbar_layout);
Toolbar toolbar = findViewById(R.id.toolbar);
tabLayout = findViewById(R.id.tablayout);
loadUrl(currentWebView, url);
}
- // Get a handle for the drawer layout.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
-
// Close the navigation drawer if it is open.
if (drawerLayout.isDrawerVisible(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
// Update the bookmarks drawer if returning from the Bookmarks activity.
if (restartFromBookmarksActivity) {
- // Get a handle for the drawer layout.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
-
// Close the bookmarks drawer.
drawerLayout.closeDrawer(GravityCompat.END);
return true;
case R.id.bookmarks:
- // Get a handle for the drawer layout.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
-
// Open the bookmarks drawer.
drawerLayout.openDrawer(GravityCompat.END);
break;
}
- // Get a handle for the drawer layout.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
-
// Close the navigation drawer.
drawerLayout.closeDrawer(GravityCompat.START);
return true;
bookmarksCursorAdapter.changeCursor(bookmarksCursor);
}
- // Override `onBackPressed` to handle the navigation drawer and and the WebViews.
+ // Override `onBackPressed()` to handle the navigation drawer and and the WebViews.
@Override
public void onBackPressed() {
- // Get a handle for the drawer layout.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
-
+ // Check the different options for processing `back`.
if (drawerLayout.isDrawerVisible(GravityCompat.START)) { // The navigation drawer is open.
// Close the navigation drawer.
drawerLayout.closeDrawer(GravityCompat.START);
} else if (drawerLayout.isDrawerVisible(GravityCompat.END)){ // The bookmarks drawer is open.
- if (currentBookmarksFolder.isEmpty()) { // The home folder is displayed.
- // close the bookmarks drawer.
- drawerLayout.closeDrawer(GravityCompat.END);
- } else { // A subfolder is displayed.
- // Place the former parent folder in `currentFolder`.
- currentBookmarksFolder = bookmarksDatabaseHelper.getParentFolderName(currentBookmarksFolder);
-
- // Load the new folder.
- loadBookmarksFolder();
- }
+ // close the bookmarks drawer.
+ drawerLayout.closeDrawer(GravityCompat.END);
} else if (displayingFullScreenVideo) { // A full screen video is shown.
// Get a handle for the layouts.
FrameLayout rootFrameLayout = findViewById(R.id.root_framelayout);
this.registerReceiver(orbotStatusBroadcastReceiver, new IntentFilter("org.torproject.android.intent.action.STATUS"));
// Get handles for views that need to be modified.
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
NavigationView navigationView = findViewById(R.id.navigationview);
SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swiperefreshlayout);
ListView bookmarksListView = findViewById(R.id.bookmarks_drawer_listview);
System.exit(0);
}
+ public void bookmarksBack(View view) {
+ if (currentBookmarksFolder.isEmpty()) { // The home folder is displayed.
+ // close the bookmarks drawer.
+ drawerLayout.closeDrawer(GravityCompat.END);
+ } else { // A subfolder is displayed.
+ // Place the former parent folder in `currentFolder`.
+ currentBookmarksFolder = bookmarksDatabaseHelper.getParentFolderName(currentBookmarksFolder);
+
+ // Load the new folder.
+ loadBookmarksFolder();
+ }
+ }
+
private void setCurrentWebView(int pageNumber) {
// Get handles for the URL views.
RelativeLayout urlRelativeLayout = findViewById(R.id.url_relativelayout);
// Get handles for the activity views.
FrameLayout rootFrameLayout = findViewById(R.id.root_framelayout);
- DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
RelativeLayout mainContentRelativeLayout = findViewById(R.id.main_content_relativelayout);
ActionBar actionBar = appCompatDelegate.getSupportActionBar();
LinearLayout tabsLinearLayout = findViewById(R.id.tabs_linearlayout);
<!-- `android:layout_width="400dp"` keeps the bookmarks drawer from filling the whole screen on a tablet. -->
<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bookmarks_framelayout"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="400dp"
android:layout_gravity="end" >
android:orientation="vertical"
android:background="?android:attr/colorBackground" >
- <TextView
- android:id="@+id/bookmarks_title_textview"
+ <!-- A compound drawable doesn't work well because only the image view should execute the `onClick()`. -->
+ <LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
- android:textStyle="bold"
- android:textSize="20sp"
- android:textColor="?android:attr/textColorPrimary"
- android:layout_margin="10dp" />
+ android:orientation="horizontal"
+ tools:ignore="UseCompoundDrawables" >
+
+ <ImageView
+ android:layout_height="match_parent"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:paddingStart="15dp"
+ android:paddingEnd="15dp"
+ android:src="@drawable/back"
+ android:background="?attr/selectableItemBackground"
+ android:onClick="bookmarksBack"
+ android:contentDescription="@string/back"
+ app:tint="?android:attr/textColorPrimary" />
+
+ <TextView
+ android:id="@+id/bookmarks_title_textview"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:textStyle="bold"
+ android:textSize="20sp"
+ android:textColor="?android:attr/textColorPrimary"
+ android:layout_margin="10dp" />
+ </LinearLayout>
<ListView
android:id="@+id/bookmarks_drawer_listview"
along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>. -->
<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bookmarks_framelayout"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:layout_gravity="end" >
+ android:layout_gravity="end">
<LinearLayout
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?android:attr/colorBackground" >
- <TextView
- android:id="@+id/bookmarks_title_textview"
+ <!-- A compound drawable doesn't work well because only the image view should execute the `onClick()`. -->
+ <LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
- android:textStyle="bold"
- android:textSize="20sp"
- android:textColor="?android:attr/textColorPrimary"
- android:layout_margin="10dp" />
+ android:orientation="horizontal"
+ tools:ignore="UseCompoundDrawables" >
+
+ <ImageView
+ android:layout_height="match_parent"
+ android:layout_width="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:paddingStart="15dp"
+ android:paddingEnd="15dp"
+ android:src="@drawable/back"
+ android:background="?attr/selectableItemBackground"
+ android:onClick="bookmarksBack"
+ android:contentDescription="@string/back"
+ app:tint="?android:attr/textColorPrimary" />
+
+ <TextView
+ android:id="@+id/bookmarks_title_textview"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:textStyle="bold"
+ android:textSize="20sp"
+ android:textColor="?android:attr/textColorPrimary"
+ android:layout_margin="10dp" />
+ </LinearLayout>
<ListView
android:id="@+id/bookmarks_drawer_listview"
android:layout_marginEnd="4dp"
android:text="@string/zero_of_zero" />
+ <!-- `android:background="?attr/selectableItemBackground"` adds a ripple animation on touch. -->
<ImageView
android:id="@+id/find_previous"
android:src="@drawable/previous"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_gravity="center_vertical"
- android:tint="?attr/findOnPageIconTintColor"
+ android:background="?attr/selectableItemBackground"
android:contentDescription="@string/previous"
- android:onClick="findPreviousOnPage" />
+ android:onClick="findPreviousOnPage"
+ app:tint="?attr/findOnPageIconTintColor" />
+ <!-- `android:background="?attr/selectableItemBackground"` adds a ripple animation on touch. -->
<ImageView
android:id="@+id/find_next"
android:src="@drawable/next"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:layout_gravity="center_vertical"
- android:tint="?attr/findOnPageIconTintColor"
+ android:background="?attr/selectableItemBackground"
android:contentDescription="@string/next"
- android:onClick="findNextOnPage" />
+ android:onClick="findNextOnPage"
+ app:tint="?attr/findOnPageIconTintColor" />
+ <!-- `android:background="?attr/selectableItemBackground"` adds a ripple animation on touch. -->
<ImageView
android:id="@+id/close_find"
android:src="@drawable/close_day"
android:layout_marginStart="4dp"
android:layout_marginEnd="8dp"
android:layout_gravity="center_vertical"
- android:tint="?attr/findOnPageIconTintColor"
+ android:background="?attr/selectableItemBackground"
android:contentDescription="@string/close"
- android:onClick="closeFindOnPage" />
+ android:onClick="closeFindOnPage"
+ app:tint="?attr/findOnPageIconTintColor" />
</LinearLayout>
<!-- The tab linear layout. It sets the background to the right of the add tab button. It is initially `visibility="gone"` so it doesn't display while the blocklists are loading. -->
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:src="@drawable/close_day"
- android:tint="?attr/addTabIconTintColor"
android:background="?attr/selectableItemBackground"
android:onClick="closeTab"
- android:contentDescription="@string/close_tab" />
+ android:contentDescription="@string/close_tab"
+ app:tint="?attr/addTabIconTintColor" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:src="@drawable/add"
- android:tint="?attr/addTabIconTintColor"
android:background="?attr/selectableItemBackground"
android:onClick="addTab"
- android:contentDescription="@string/add_tab" />
+ android:contentDescription="@string/add_tab"
+ app:tint="?attr/addTabIconTintColor" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>