From c8b11d2b76391db47bdd6d5289e2668147cf177a Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Fri, 12 Apr 2024 14:30:17 -0700 Subject: [PATCH] First wrong button text in View Headers in night theme. https://redmine.stoutner.com/issues/1191 --- .../BookmarksDatabaseViewActivity.kt | 7 ++-- .../activities/LogcatActivity.kt | 14 +++---- .../activities/ViewHeadersActivity.kt | 21 +++------- .../res/color/button_background_selector.xml | 6 +-- .../main/res/color/button_text_selector.xml | 6 +-- .../main/res/color/checked_text_selector.xml | 6 +-- .../main/res/color/yellow_icon_selector.xml | 6 +-- app/src/main/res/layout/url_app_bar.xml | 2 +- .../view_headers_appbar_custom_view.xml | 42 +++++-------------- .../res/layout/view_headers_bottom_appbar.xml | 4 +- .../res/layout/view_headers_top_appbar.xml | 4 +- build.gradle | 2 +- 12 files changed, 45 insertions(+), 75 deletions(-) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt index b9f161e8..9804e5f5 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/BookmarksDatabaseViewActivity.kt @@ -1,7 +1,7 @@ /* * Copyright 2016-2024 Soren Stoutner . * - * This file is part of Privacy Browser Android . + * This file is part of Privacy Browser Android . * * Privacy Browser Android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -104,9 +104,8 @@ class BookmarksDatabaseViewActivity : AppCompatActivity(), EditBookmarkDatabaseV val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false) // Disable screenshots if not allowed. - if (!allowScreenshots) { + if (!allowScreenshots) window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) - } // Run the default commands. super.onCreate(savedInstanceState) @@ -129,7 +128,7 @@ class BookmarksDatabaseViewActivity : AppCompatActivity(), EditBookmarkDatabaseV setContentView(R.layout.bookmarks_databaseview_top_appbar) } - // Get a handle for the toolbar. + // Get handles for the views. val toolbar = findViewById(R.id.bookmarks_databaseview_toolbar) bookmarksListView = findViewById(R.id.bookmarks_databaseview_listview) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt index 214ebf21..a0e5ad8a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.kt @@ -246,7 +246,7 @@ class LogcatActivity : AppCompatActivity() { override fun onOptionsItemSelected(menuItem: MenuItem): Boolean { // Run the commands that correlate to the selected menu item. - return when (menuItem.itemId) { + when (menuItem.itemId) { R.id.search -> { // Search was selected. // Set the minimum height of the search linear layout to match the toolbar. searchLinearLayout.minimumHeight = toolbar.height @@ -273,7 +273,7 @@ class LogcatActivity : AppCompatActivity() { logcatWebView.resumeTimers() // Consume the event. - true + return true } R.id.copy -> { // Copy was selected. @@ -291,7 +291,7 @@ class LogcatActivity : AppCompatActivity() { Snackbar.make(logcatWebView, R.string.logcat_copied, Snackbar.LENGTH_SHORT).show() // Consume the event. - true + return true } R.id.save -> { // Save was selected. @@ -299,7 +299,7 @@ class LogcatActivity : AppCompatActivity() { saveLogcatActivityResultLauncher.launch(getString(R.string.privacy_browser_logcat_txt, BuildConfig.VERSION_NAME)) // Consume the event. - true + return true } R.id.clear -> { // Clear was selected. @@ -317,12 +317,12 @@ class LogcatActivity : AppCompatActivity() { } // Consume the event. - true + return true } - else -> { // The home button was pushed. + else -> { // The home button was selected. // Do not consume the event. The system will process the home command. - super.onOptionsItemSelected(menuItem) + return super.onOptionsItemSelected(menuItem) } } } diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt index 8a0cc653..8e72b596 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/ViewHeadersActivity.kt @@ -46,7 +46,6 @@ import androidx.appcompat.app.ActionBar import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.constraintlayout.widget.ConstraintLayout -import androidx.core.app.NavUtils import androidx.lifecycle.ViewModelProvider import androidx.preference.PreferenceManager import androidx.swiperefreshlayout.widget.SwipeRefreshLayout @@ -152,9 +151,8 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false) // Disable screenshots if not allowed. - if (!allowScreenshots) { + if (!allowScreenshots) window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) - } // Run the default commands. super.onCreate(savedInstanceState) @@ -167,11 +165,10 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener val userAgent = intent.getStringExtra(USER_AGENT)!! // Set the content view. - if (bottomAppBar) { + if (bottomAppBar) setContentView(R.layout.view_headers_bottom_appbar) - } else { + else setContentView(R.layout.view_headers_top_appbar) - } // Get a handle for the toolbar. val toolbar = findViewById(R.id.toolbar) @@ -186,7 +183,7 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener actionBar.setCustomView(R.layout.view_headers_appbar_custom_view) // Instruct the action bar to display a custom layout. - actionBar.displayOptions = ActionBar.DISPLAY_SHOW_CUSTOM + actionBar.displayOptions = ActionBar.DISPLAY_SHOW_CUSTOM or ActionBar.DISPLAY_HOME_AS_UP // Get handles for the views. urlEditText = findViewById(R.id.url_edittext) @@ -427,7 +424,7 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener } override fun onOptionsItemSelected(menuItem: MenuItem): Boolean { - // Run the appropriate commands. + // Run the commands that correlate to the selected menu item. when (menuItem.itemId) { R.id.copy_headers -> { // Copy the headers. // Get the headers string. @@ -502,18 +499,12 @@ class ViewHeadersActivity: AppCompatActivity(), UntrustedSslCertificateListener } else -> { // The home button was selected. - // Run the parents class on return. + // Do not consume the event. The system will process the home command. return super.onOptionsItemSelected(menuItem) } } } - // This method must be named `goBack()` and must have a View argument to match the default back arrow in the app bar or a crash occurs. - fun goBack(@Suppress("UNUSED_PARAMETER") view: View) { - // Go home. - NavUtils.navigateUpFromSameTask(this) - } - private fun getHeadersString(): String { // Initialize a headers string builder. val headersStringBuilder = StringBuilder() diff --git a/app/src/main/res/color/button_background_selector.xml b/app/src/main/res/color/button_background_selector.xml index a21d2724..dbb36f95 100644 --- a/app/src/main/res/color/button_background_selector.xml +++ b/app/src/main/res/color/button_background_selector.xml @@ -1,9 +1,9 @@ - - + - - - - - - + android:layout_width="match_parent" + android:hint="@string/url" + android:imeOptions="actionGo" + android:inputType="textUri" + android:selectAllOnFocus="true" + tools:ignore="Autofill" /> diff --git a/app/src/main/res/layout/view_headers_bottom_appbar.xml b/app/src/main/res/layout/view_headers_bottom_appbar.xml index 0219c09a..7dbab777 100644 --- a/app/src/main/res/layout/view_headers_bottom_appbar.xml +++ b/app/src/main/res/layout/view_headers_bottom_appbar.xml @@ -100,7 +100,7 @@ android:text="@string/ciphers" android:onClick="showCiphers" app:backgroundTint="@color/button_background_selector" - android:textColor="@color/button_text_selector" + android:textColor="@color/white" tools:ignore="ButtonStyle" /> diff --git a/app/src/main/res/layout/view_headers_top_appbar.xml b/app/src/main/res/layout/view_headers_top_appbar.xml index 588ff6b7..34207a5b 100644 --- a/app/src/main/res/layout/view_headers_top_appbar.xml +++ b/app/src/main/res/layout/view_headers_top_appbar.xml @@ -122,7 +122,7 @@ android:text="@string/ciphers" android:onClick="showCiphers" app:backgroundTint="@color/button_background_selector" - android:textColor="@color/button_text_selector" + android:textColor="@color/white" tools:ignore="ButtonStyle" /> diff --git a/build.gradle b/build.gradle index c390d1f0..8573ba5c 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.3.1' + classpath 'com.android.tools.build:gradle:8.3.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20" // NOTE: Do not place your application dependencies here; they belong -- 2.43.0