X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;ds=sidebyside;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FLogcatActivity.java;h=de0b873d8afa276757553de795f286c3bf3ed16c;hb=74655c0cd0ba72c80ac6c48df55bc3d2f5280ad2;hp=c38181a60239d81e190b1274ba8e94422ac73de8;hpb=5d3cafb4a4fbb2bf851d36f973cc1e8b23ecebab;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java index c38181a6..de0b873d 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/LogcatActivity.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019 Soren Stoutner . + * Copyright © 2019-2020 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -27,13 +27,16 @@ import android.content.ClipboardManager; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.media.MediaScannerConnection; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import android.view.WindowManager; import android.widget.EditText; import android.widget.TextView; @@ -41,7 +44,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; // The AndroidX toolbar must be used until the minimum API is >= 21. +import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; @@ -74,8 +77,7 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo // Get a handle for the shared preferences. SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - // Get the theme and screenshot preferences. - boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); + // Get the screenshot preference. boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); // Disable screenshots if not allowed. @@ -83,12 +85,8 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); } - // Set the activity theme. - if (darkTheme) { - setTheme(R.style.PrivacyBrowserDark_SecondaryActivity); - } else { - setTheme(R.style.PrivacyBrowserLight_SecondaryActivity); - } + // Set the theme. + setTheme(R.style.PrivacyBrowser); // Run the default commands. super.onCreate(savedInstanceState); @@ -96,7 +94,7 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo // Set the content view. setContentView(R.layout.logcat_coordinatorlayout); - // The AndroidX toolbar must be used until the minimum API is >= 21. + // Set the toolbar as the action bar. Toolbar toolbar = findViewById(R.id.logcat_toolbar); setSupportActionBar(toolbar); @@ -116,14 +114,28 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo new GetLogcat(this).execute(); }); - // Set the swipe to refresh color according to the theme. - if (darkTheme) { - swipeRefreshLayout.setColorSchemeResources(R.color.blue_600); - swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.gray_800); + // Get the current theme status. + int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + + // Set the refresh color scheme according to the theme. + if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) { + swipeRefreshLayout.setColorSchemeResources(R.color.blue_500); } else { swipeRefreshLayout.setColorSchemeResources(R.color.blue_700); } + // Initialize a color background typed value. + TypedValue colorBackgroundTypedValue = new TypedValue(); + + // Get the color background from the theme. + getTheme().resolveAttribute(android.R.attr.colorBackground, colorBackgroundTypedValue, true); + + // Get the color background int from the typed value. + int colorBackgroundInt = colorBackgroundTypedValue.data; + + // Set the swipe refresh background color. + swipeRefreshLayout.setProgressBackgroundColorSchemeColor(colorBackgroundInt); + // Get the logcat. new GetLogcat(this).execute(); } @@ -335,8 +347,9 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo // Remove the lint warning below that the save dialog might be null. assert saveDialog != null; - // Get a handle for the file name edit text. + // Get a handle for the dialog views. EditText fileNameEditText = saveDialog.findViewById(R.id.file_name_edittext); + TextView fileExistsWarningTextView = saveDialog.findViewById(R.id.file_exists_warning_textview); // Instantiate the file name helper. FileNameHelper fileNameHelper = new FileNameHelper(); @@ -351,6 +364,12 @@ public class LogcatActivity extends AppCompatActivity implements SaveLogcatDialo // Set the file name path as the text of the file name edit text. fileNameEditText.setText(fileNamePath); + + // Move the cursor to the end of the file name edit text. + fileNameEditText.setSelection(fileNamePath.length()); + + // Hide the file exists warning. + fileExistsWarningTextView.setVisibility(View.GONE); } } }