diff options
9 files changed, 26 insertions, 43 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 132beb6ce..58d344eae 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -70,20 +70,17 @@ <activity android:name=".ui.archivedcards.ArchivedCardsActvitiy" android:label="@string/archived_cards" - android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" /> <activity android:name=".ui.archivedboards.ArchivedBoardsActvitiy" android:label="@string/archived_boards" - android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" /> <activity android:name=".ui.card.EditActivity" android:label="@string/edit" - android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" /> <activity android:name=".ui.attachments.AttachmentsActivity" @@ -94,19 +91,16 @@ <activity android:name=".ui.settings.SettingsActivity" android:label="@string/simple_settings" - android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" /> <activity android:name=".ui.ImportAccountActivity" - android:label="@string/app_name" - android:theme="@style/AppTheme" /> + android:label="@string/app_name" /> <activity android:name=".ui.preparecreate.PrepareCreateActivity" android:description="@string/add_a_new_card_using_the_button" - android:label="@string/add_card" - android:theme="@style/AppTheme"> + android:label="@string/add_card" > <intent-filter> <action android:name="android.intent.action.SEND" /> @@ -118,13 +112,11 @@ <activity android:name=".ui.about.AboutActivity" android:label="@string/about" - android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" /> <activity android:name=".ui.PushNotificationActivity" - android:label="@string/app_name" - android:theme="@style/AppTheme"> + android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/Application.java b/app/src/main/java/it/niedermann/nextcloud/deck/Application.java index cdf65f7d5..e4e139d52 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/Application.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/Application.java @@ -66,7 +66,7 @@ public class Application extends android.app.Application { if (Application.isBrandingEnabled(context)) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); DeckLog.log("--- Read: shared_preference_theme_main"); - return sharedPreferences.getInt(context.getString(R.string.shared_preference_theme_main), context.getApplicationContext().getResources().getColor(R.color.primary)); + return sharedPreferences.getInt(context.getString(R.string.shared_preference_theme_main), context.getApplicationContext().getResources().getColor(R.color.defaultBrand)); } else { return context.getResources().getColor(R.color.primary); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 12013dc30..7a005b872 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -161,6 +161,8 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); + setTheme(R.style.AppTheme); + binding = ActivityMainBinding.inflate(getLayoutInflater()); headerBinding = NavHeaderMainBinding.bind(binding.navigationView.getHeaderView(0)); setContentView(binding.getRoot()); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java index ee1ace13b..3ec42756f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java @@ -1,12 +1,10 @@ package it.niedermann.nextcloud.deck.ui.branding; import android.content.res.ColorStateList; -import android.os.Bundle; import android.util.TypedValue; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; @@ -23,13 +21,6 @@ public abstract class BrandedActivity extends AppCompatActivity implements Brand protected int colorAccent; @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - @ColorInt final int mainColor = Application.readBrandMainColor(this); - setTheme(R.style.AppTheme); - } - - @Override protected void onStart() { super.onStart(); @@ -46,7 +37,7 @@ public abstract class BrandedActivity extends AppCompatActivity implements Brand protected void applyBrandToPrimaryTabLayout(@ColorInt int mainColor, @NonNull TabLayout tabLayout) { @ColorInt int finalMainColor = getSecondaryForegroundColorDependingOnTheme(this, mainColor); tabLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.primary)); - tabLayout.setTabTextColors(finalMainColor, finalMainColor); +// tabLayout.setTabTextColors(finalMainColor, finalMainColor); tabLayout.setTabIconTint(ColorStateList.valueOf(finalMainColor)); tabLayout.setSelectedTabIndicatorColor(finalMainColor); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandingUtil.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandingUtil.java index 85cd31e1b..6f65f5f3d 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandingUtil.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandingUtil.java @@ -7,6 +7,7 @@ import android.widget.EditText; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -28,18 +29,12 @@ public abstract class BrandingUtil { * Since we may collide with dark theme in this area, we have to make sure that the color is visible depending on the background */ @ColorInt - public static int - getSecondaryForegroundColorDependingOnTheme(@NonNull Context context, @ColorInt int mainColor) { - final boolean isDarkTheme = Application.isDarkTheme(context); - if (isDarkTheme && !contrastRatioIsSufficient(mainColor, Color.BLACK)) { - DeckLog.verbose("Contrast ratio between brand color " + String.format("#%06X", (0xFFFFFF & mainColor)) + " and dark theme is too low. Falling back to WHITE as brand color."); - return Color.WHITE; - } else if (!contrastRatioIsSufficient(mainColor, Color.WHITE)) { - DeckLog.verbose("Contrast ratio between brand color " + String.format("#%06X", (0xFFFFFF & mainColor)) + " and light theme is too low. Falling back to BLACK as brand color."); - return Color.BLACK; - } else { + public static int getSecondaryForegroundColorDependingOnTheme(@NonNull Context context, @ColorInt int mainColor) { + if (contrastRatioIsSufficient(mainColor, ContextCompat.getColor(context, R.color.primary))) { return mainColor; } + DeckLog.verbose("Contrast ratio between brand color " + String.format("#%06X", (0xFFFFFF & mainColor)) + " and primary theme background is too low. Falling back to WHITE/BLACK as brand color."); + return Application.isDarkTheme(context) ? Color.WHITE : Color.BLACK; } public static void applyBrandToFAB(@ColorInt int mainColor, @NonNull FloatingActionButton fab) { diff --git a/app/src/main/res/drawable/ic_check_white_24dp.xml b/app/src/main/res/drawable/ic_check_white_24dp.xml index 9779109f8..47dd2131a 100644 --- a/app/src/main/res/drawable/ic_check_white_24dp.xml +++ b/app/src/main/res/drawable/ic_check_white_24dp.xml @@ -1,5 +1,5 @@ <vector android:height="24dp" - android:tint="@color/accent" android:viewportHeight="24.0" + android:tint="@android:color/white" android:viewportHeight="24.0" android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> <path android:fillColor="#FF000000" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/> </vector> diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index d0a4ad1cb..12f7ec0ce 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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_width="match_parent" android:layout_height="match_parent" - xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical"> <com.google.android.material.appbar.AppBarLayout @@ -21,8 +21,9 @@ android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="@style/ThemeOverlay.AppCompat.Dark" - app:tabIndicatorColor="@color/accent" /> + app:tabIndicatorColor="@color/defaultBrand" + app:tabMode="fixed" + app:tabTextColor="@color/accent" /> </com.google.android.material.appbar.AppBarLayout> <androidx.viewpager2.widget.ViewPager2 diff --git a/app/src/main/res/layout/activity_import_account.xml b/app/src/main/res/layout/activity_import_account.xml index b4294db7b..ad7d31d46 100644 --- a/app/src/main/res/layout/activity_import_account.xml +++ b/app/src/main/res/layout/activity_import_account.xml @@ -44,6 +44,7 @@ android:layout_height="wrap_content" android:layout_below="@id/welcome_text" android:layout_centerHorizontal="true" + android:backgroundTint="@color/defaultBrand" android:paddingStart="32dp" android:paddingTop="24dp" android:paddingEnd="32dp" @@ -81,6 +82,7 @@ android:layout_centerHorizontal="true" android:layout_marginTop="16dp" android:text="@string/simple_update" + android:textColor="@color/defaultBrand" android:visibility="gone" tools:visibility="visible" /> </RelativeLayout> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 193f04674..3239b3e38 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -163,9 +163,9 @@ android:layout_height="wrap_content" android:layout_weight="1" app:tabGravity="center" - app:tabIndicatorColor="@color/accent" + app:tabIndicatorColor="@color/defaultBrand" app:tabMode="fixed" - app:tabTextColor="@android:color/white" /> + app:tabTextColor="@color/accent" /> <androidx.appcompat.widget.AppCompatImageButton android:id="@+id/list_menu_button" |