mirror of
https://github.com/nextcloud/android.git
synced 2024-12-23 01:00:26 +03:00
Fix activity foreground text colour for >=API21.
Share expiration date picker now has buttons that are the primary colour. Theme change is now done in BaseActivity and ThemedPreferenceActivity. This should help any activities in the back stack show the correct theme. Fixed style issues on firstrun and authenticator activities. Signed-off-by: Daniel Bailey <daniel.bailey@grappleIT.co.uk>
This commit is contained in:
parent
8aaf29a7c3
commit
f5aa60bae9
14 changed files with 188 additions and 23 deletions
|
@ -80,7 +80,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
|||
setSlideshowSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
|
||||
|
||||
Button loginButton = findViewById(R.id.login);
|
||||
loginButton.setBackgroundColor(getResources().getColor(R.color.bg_default));
|
||||
loginButton.setBackgroundColor(getResources().getColor(R.color.login_btn_tint));
|
||||
loginButton.setTextColor(getResources().getColor(R.color.primary));
|
||||
|
||||
loginButton.setOnClickListener(v -> {
|
||||
|
|
|
@ -410,7 +410,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
new Handler().postDelayed(() -> DisplayUtils.createSnackbar(mLoginWebView,
|
||||
R.string.fallback_weblogin_text,
|
||||
Snackbar.LENGTH_INDEFINITE)
|
||||
.setActionTextColor(getResources().getColor(R.color.fg_inverse))
|
||||
.setActionTextColor(getResources().getColor(R.color.themed_fg))
|
||||
.setBackgroundTint(getResources().getColor(R.color.themed_bg))
|
||||
.setTextColor(getResources().getColor(R.color.themed_fg))
|
||||
.setAction(R.string.fallback_weblogin_back, v -> {
|
||||
mLoginWebView.setVisibility(View.INVISIBLE);
|
||||
webViewLoginMethod = false;
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
@ -76,12 +77,15 @@ public class ThemeableSwitchPreference extends SwitchPreference {
|
|||
if(thumbColorStateList == null && trackColorStateList == null) {
|
||||
int color = ThemeUtils.primaryAccentColor(getContext());
|
||||
int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color));
|
||||
int trackColorUnchecked = getContext().getResources().getColor(R.color.switch_track_color_unchecked);
|
||||
thumbColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{color, Color.WHITE});
|
||||
trackColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{trackColor, Color.parseColor("#4D000000")});
|
||||
new int[][]{new int[]{android.R.attr.state_checked},
|
||||
new int[]{}},
|
||||
new int[]{trackColor, trackColorUnchecked});
|
||||
// new int[]{trackColor, Color.parseColor("#4D000000")});
|
||||
}
|
||||
|
||||
// setting the thumb color
|
||||
|
|
|
@ -6,12 +6,14 @@ import android.accounts.AccountManagerCallback;
|
|||
import android.accounts.AccountManagerFuture;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
@ -19,12 +21,13 @@ import com.owncloud.android.lib.resources.status.OCCapability;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* Base activity with common behaviour for activities dealing with ownCloud {@link Account}s .
|
||||
*/
|
||||
public abstract class BaseActivity extends AppCompatActivity implements Injectable {
|
||||
public abstract class BaseActivity extends AppCompatActivity implements Injectable, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private static final String TAG = BaseActivity.class.getSimpleName();
|
||||
|
||||
/**
|
||||
|
@ -52,12 +55,53 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
*/
|
||||
private FileDataStorageManager mStorageManager;
|
||||
|
||||
/**
|
||||
* Tracks whether the activity should be recreate()'d after a theme change
|
||||
*/
|
||||
private boolean mThemeChangePending;
|
||||
private boolean mPaused;
|
||||
|
||||
@Inject UserAccountManager accountManager;
|
||||
@Inject SharedPreferences sharedPreferences;
|
||||
|
||||
public UserAccountManager getUserAccountManager() {
|
||||
return accountManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mPaused = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mPaused = false;
|
||||
|
||||
if(mThemeChangePending) {
|
||||
// getDelegate().applyDayNight();
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
@ -85,6 +129,19 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
Log_OC.v(TAG, "onRestart() end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) {
|
||||
if (!getString(R.string.prefs_key_theme).equals(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(mPaused) {
|
||||
mThemeChangePending = true;
|
||||
return;
|
||||
}
|
||||
recreate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets and validates the ownCloud {@link Account} associated to the Activity.
|
||||
*
|
||||
|
|
|
@ -95,7 +95,7 @@ import androidx.core.content.res.ResourcesCompat;
|
|||
*
|
||||
* It proxies the necessary calls via {@link androidx.appcompat.app.AppCompatDelegate} to be used with AppCompat.
|
||||
*/
|
||||
public class SettingsActivity extends PreferenceActivity
|
||||
public class SettingsActivity extends ThemedPreferenceActivity
|
||||
implements StorageMigration.StorageMigrationProgressListener, LoadingVersionNumberTask.VersionDevInterface,
|
||||
Injectable {
|
||||
|
||||
|
@ -697,8 +697,7 @@ public class SettingsActivity extends PreferenceActivity
|
|||
getString(R.string.prefs_value_theme_dark) : getString(R.string.prefs_value_theme_light));
|
||||
themePref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
MainApp.setAppTheme((Boolean) newValue);
|
||||
getDelegate().applyDayNight();
|
||||
recreate();
|
||||
// recreate();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Daniel Bailey
|
||||
* Copyright (C) 2019 Daniel Bailey
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ThemedPreferenceActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
/**
|
||||
* Tracks whether the activity should be recreate()'d after a theme change
|
||||
*/
|
||||
private boolean mThemeChangePending;
|
||||
private boolean mPaused;
|
||||
|
||||
@Inject SharedPreferences sharedPreferences;
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mPaused = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mPaused = false;
|
||||
|
||||
if(mThemeChangePending) {
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) {
|
||||
if(mPaused) {
|
||||
mThemeChangePending = true;
|
||||
return;
|
||||
}
|
||||
|
||||
recreate();
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ import com.owncloud.android.R;
|
|||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
|
@ -140,6 +141,11 @@ public class ExpirationDatePickerDialogFragment
|
|||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
dialog.getButton(DatePickerDialog.BUTTON_NEUTRAL).setTextColor(ThemeUtils.primaryColor(getContext()));
|
||||
dialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(ThemeUtils.primaryColor(getContext()));
|
||||
dialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(ThemeUtils.primaryColor(getContext()));
|
||||
|
||||
// Prevent days in the past may be chosen
|
||||
DatePicker picker = dialog.getDatePicker();
|
||||
picker.setMinDate(tomorrowInMillis - 1000);
|
||||
|
|
|
@ -509,7 +509,7 @@ public final class ThemeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
editText.setHintTextColor(color);
|
||||
// editText.setHintTextColor(color);
|
||||
editText.setTextColor(color);
|
||||
editText.setHighlightColor(context.getResources().getColor(R.color.fg_contrast));
|
||||
setEditTextCursorColor(editText, color);
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
android:layout_gravity="start"
|
||||
android:layout_weight="1"
|
||||
android:fitsSystemWindows="true"
|
||||
android:background="@color/bg_default"
|
||||
android:theme="@style/NavigationView_ItemTextAppearance"
|
||||
app:headerLayout="@layout/drawer_header"
|
||||
app:menu="@menu/drawer_menu"
|
||||
app:theme="@style/NavigationView_ItemTextAppearance">
|
||||
app:menu="@menu/drawer_menu">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/drawer_quota"
|
||||
|
|
|
@ -77,5 +77,6 @@
|
|||
<!--<color name="background_material_light">#555555</color>-->
|
||||
<color name="drawer_menu_icon">#ffffff</color>
|
||||
<color name="bg_fallback_highlight">#737373</color>
|
||||
<color name="switch_track_color_unchecked">#B3FFFFFF</color>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -19,11 +19,16 @@
|
|||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- General ownCloud app style -->
|
||||
<style name="Theme.ownCloud" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<item name="android:textColorSecondary">@color/secondaryTextColor</item>
|
||||
<item name="colorSecondary">@color/secondaryTextColor</item>
|
||||
<item name="android:datePickerDialogTheme">@style/FallbackDatePickerDialogTheme</item>
|
||||
</style>
|
||||
|
||||
<style name="FallbackThemingTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<item name="android:datePickerDialogTheme">@style/FallbackDatePickerDialogTheme</item>
|
||||
<item name="android:textColor">@color/textColor</item>
|
||||
<item name="android:textColorSecondary">@color/secondaryTextColor</item>
|
||||
<item name="colorSecondary">@color/secondaryTextColor</item>
|
||||
</style>
|
||||
|
||||
<style name="FallbackDatePickerDialogTheme" parent="Theme.MaterialComponents.DayNight.Dialog.Alert">
|
||||
|
@ -60,4 +65,9 @@
|
|||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:colorBackground">@color/bg_default</item>
|
||||
</style>
|
||||
|
||||
<style name="Nextcloud.EditText.Login" parent="ThemeOverlay.MaterialComponents.TextInputEditText">
|
||||
<item name="colorControlNormal">@color/login_text_color</item>
|
||||
<item name="colorControlActivated">@color/login_text_color</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -82,9 +82,10 @@
|
|||
<!--<color name="background_material_light">#ef4</color>-->
|
||||
<color name="drawer_menu_icon">#757575</color>
|
||||
<color name="bg_fallback_highlight">#616161</color>
|
||||
<color name="switch_track_color_unchecked">#4D000000</color>
|
||||
|
||||
<!-- Excluded from future app dark theme -->
|
||||
<color name="themed_fg">#FFFFFF</color>
|
||||
<color name="themed_fg_inverse">#000000</color>
|
||||
|
||||
<color name="themed_bg">#222222</color>
|
||||
</resources>
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
<item name="android:alertDialogTheme">@style/ownCloud.AlertDialog</item>
|
||||
<item name="searchViewStyle">@style/ownCloud.SearchView</item>
|
||||
<item name="android:textColor">@color/textColor</item>
|
||||
<item name="colorSecondary">@color/textColor</item>
|
||||
<item name="android:textColorSecondary">@color/secondaryTextColor</item>
|
||||
<item name="colorSecondary">@color/secondaryTextColor</item>
|
||||
<item name="android:textColorHint">@color/secondaryTextColor</item>
|
||||
</style>
|
||||
|
||||
<style name="FallbackThemingTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
|
@ -43,6 +45,7 @@
|
|||
<item name="android:alertDialogTheme">@style/FallbackTheming.Dialog</item>
|
||||
<item name="dialogTheme">@style/FallbackTheming.Dialog</item>
|
||||
<item name="android:windowBackground">@color/bg_default</item>
|
||||
<item name="android:textColorSecondary">@color/secondaryTextColor</item>
|
||||
</style>
|
||||
|
||||
<style name="FallbackDatePickerDialogTheme" parent="Theme.MaterialComponents.DayNight.Dialog.Alert">
|
||||
|
@ -139,7 +142,7 @@
|
|||
|
||||
<style name="OutlineLogindButton" parent="Widget.MaterialComponents.Button.OutlinedButton">
|
||||
<item name="colorAccent">@color/transparent</item>
|
||||
<item name="android:textColor">@color/textColor</item>
|
||||
<item name="android:textColor">@color/fg_inverse</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="strokeColor">@color/login_btn_stroke</item>
|
||||
</style>
|
||||
|
@ -150,8 +153,8 @@
|
|||
</style>
|
||||
|
||||
<style name="Button.Login" parent="Button">
|
||||
<item name="colorButtonNormal">@color/textColor</item>
|
||||
<item name="colorAccent">@color/textColor</item>
|
||||
<item name="colorButtonNormal">@color/login_btn_tint</item>
|
||||
<item name="colorAccent">@color/login_btn_tint</item>
|
||||
<item name="android:textColor">@color/primary_dark</item>
|
||||
</style>
|
||||
|
||||
|
@ -166,7 +169,7 @@
|
|||
</style>
|
||||
|
||||
<style name="Button.Borderless.Login" parent="Widget.MaterialComponents.Button.TextButton">
|
||||
<item name="android:textColor">@color/textColor</item>
|
||||
<item name="android:textColor">@color/fg_inverse</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
</style>
|
||||
|
||||
|
@ -192,6 +195,7 @@
|
|||
<!-- Launch screen -->
|
||||
<style name="Theme.ownCloud.Launcher">
|
||||
<item name="android:windowBackground">@drawable/launch_screen</item>
|
||||
<item name="android:textColorHint">@color/secondaryTextColor</item>
|
||||
</style>
|
||||
|
||||
<!-- Progress bar -->
|
||||
|
@ -238,8 +242,8 @@
|
|||
<item name="android:listDivider">@color/transparent</item>
|
||||
|
||||
<!-- TODO are these two necessary -->
|
||||
<item name="android:textColor">@color/textColor</item>
|
||||
<item name="android:color">@color/textColor</item>
|
||||
<!-- <item name="android:textColor">@color/textColor</item>-->
|
||||
<!-- <item name="android:color">@color/textColor</item>-->
|
||||
</style>
|
||||
|
||||
<style name="PassCodeStyle">
|
||||
|
@ -268,8 +272,8 @@
|
|||
<style name="NextcloudTextAppearanceMedium" parent="@style/TextAppearance.AppCompat.Medium">
|
||||
</style>
|
||||
|
||||
<style name="TextInputLayout" parent="Base.Widget.MaterialComponents.TextInputEditText"></style>
|
||||
|
||||
<style name="TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
|
||||
</style>
|
||||
<style name="Nextcloud.EditText.Login" parent="ThemeOverlay.MaterialComponents.TextInputEditText">
|
||||
<item name="colorControlNormal">@color/login_text_color</item>
|
||||
<item name="colorControlActivated">@color/login_text_color</item>
|
||||
|
@ -315,5 +319,7 @@
|
|||
<item name="android:scaleType">fitCenter</item>
|
||||
<item name="android:layout_gravity">center_vertical</item>
|
||||
</style>
|
||||
|
||||
<style name="SwitchPreference" parent="Widget.AppCompat.CompoundButton.Switch">
|
||||
<item name="android:colorForeground">@color/fg_default</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
android:defaultValue="@string/prefs_value_theme_light"
|
||||
android:key="@string/prefs_key_theme"
|
||||
android:summary="%s"
|
||||
android:title="@string/prefs_theme_title" />
|
||||
android:title="@string/prefs_theme_title"
|
||||
android:theme="@style/SwitchPreference"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/drawer_synced_folders"
|
||||
|
|
Loading…
Reference in a new issue