Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-06-30 15:57:09 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2020-06-30 20:47:30 +0300
commitddfc0aae8e290e4f4dc226a811e21c7ed91f3220 (patch)
tree935886d06f884f2e18b96671fac1e88829e9bece /app/src/main/java/it
parent1497de1134d0711e499d13c36531c69ba9fd6ae5 (diff)
#525 Adjust design to new style of Nextcloud app
Use board color for branding
Diffstat (limited to 'app/src/main/java/it')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java15
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandingUtil.java15
2 files changed, 21 insertions, 9 deletions
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 c487a5edd..6aec91c6c 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
@@ -96,7 +96,6 @@ import it.niedermann.nextcloud.deck.ui.stack.StackAdapter;
import it.niedermann.nextcloud.deck.ui.stack.StackFragment;
import it.niedermann.nextcloud.deck.util.DrawerMenuUtil;
-import static android.graphics.Color.parseColor;
import static androidx.lifecycle.Transformations.switchMap;
import static it.niedermann.nextcloud.deck.Application.NO_ACCOUNT_ID;
import static it.niedermann.nextcloud.deck.Application.NO_BOARD_ID;
@@ -105,8 +104,10 @@ import static it.niedermann.nextcloud.deck.Application.saveCurrentAccountId;
import static it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.LiveDataHelper.observeOnce;
import static it.niedermann.nextcloud.deck.ui.branding.BrandingUtil.applyBrandToFAB;
import static it.niedermann.nextcloud.deck.ui.branding.BrandingUtil.applyBrandToPrimaryTabLayout;
+import static it.niedermann.nextcloud.deck.ui.branding.BrandingUtil.clearBrandColors;
import static it.niedermann.nextcloud.deck.ui.branding.BrandingUtil.saveBrandColors;
import static it.niedermann.nextcloud.deck.util.ColorUtil.contrastRatioIsSufficient;
+import static it.niedermann.nextcloud.deck.util.ColorUtil.contrastRatioIsSufficientBigAreas;
import static it.niedermann.nextcloud.deck.util.DrawerMenuUtil.MENU_ID_ABOUT;
import static it.niedermann.nextcloud.deck.util.DrawerMenuUtil.MENU_ID_ADD_BOARD;
import static it.niedermann.nextcloud.deck.util.DrawerMenuUtil.MENU_ID_ARCHIVED_BOARDS;
@@ -196,8 +197,8 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
}
}).observe(this, (List<Account> accounts) -> {
if (accounts == null || accounts.size() == 0) {
- // Last account has been deleted. hasAccounts LiveData will handle this, but we make sure, that branding is reset.
- saveBrandColors(this, getResources().getColor(R.color.primary));
+ // Last account has been deleted. hasAccounts LiveData will handle this, but we make sure, that branding is reset.
+ saveBrandColors(this, colorAccent);
return;
}
@@ -235,7 +236,6 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
SingleAccountHelper.setCurrentAccount(getApplicationContext(), mainViewModel.getCurrentAccount().getName());
syncManager = new SyncManager(this);
- saveBrandColors(this, parseColor(mainViewModel.getCurrentAccount().getColor()));
saveCurrentAccountId(this, mainViewModel.getCurrentAccount().getId());
if (mainViewModel.getCurrentAccount().isMaintenanceEnabled()) {
refreshCapabilities(mainViewModel.getCurrentAccount());
@@ -268,6 +268,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
setCurrentBoard(boardsList.get(0));
}
} else {
+ clearBrandColors(this);
clearCurrentBoard();
}
@@ -421,7 +422,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
// TODO We assume, that the background of the spinner is always white
binding.swipeRefreshLayout.setColorSchemeColors(contrastRatioIsSufficient(Color.WHITE, mainColor) ? mainColor : colorAccent);
headerBinding.headerView.setBackgroundColor(mainColor);
- @ColorInt final int headerTextColor = contrastRatioIsSufficient(mainColor, Color.WHITE) ? Color.WHITE : Color.BLACK;
+ @ColorInt final int headerTextColor = contrastRatioIsSufficientBigAreas(mainColor, Color.WHITE) ? Color.WHITE : Color.BLACK;
DrawableCompat.setTint(headerBinding.logo.getDrawable(), headerTextColor);
headerBinding.appName.setTextColor(headerTextColor);
}
@@ -518,8 +519,6 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
if (mainViewModel.getCurrentAccount().getServerDeckVersionAsObject().isSupported(MainActivity.this) && !response.getDeckVersion().isSupported(MainActivity.this)) {
recreate();
}
- @ColorInt final int mainColor = parseColor(response.getColor());
- runOnUiThread(() -> saveBrandColors(MainActivity.this, mainColor));
}
}
@@ -546,6 +545,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
if (stacksLiveData != null) {
stacksLiveData.removeObservers(this);
}
+ saveBrandColors(this, Color.parseColor('#' + board.getColor()));
mainViewModel.setCurrentBoard(board);
filterViewModel.clearFilterInformation();
@@ -938,6 +938,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener
} else if (this.boardsList.size() > 1) { // Select second board after deletion
setCurrentBoard(this.boardsList.get(1));
} else { // No other board is available, open create dialog
+ clearBrandColors(this);
clearCurrentBoard();
EditBoardDialogFragment.newInstance().show(getSupportFragmentManager(), addBoard);
}
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 fca1a766b..220b4cf4f 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
@@ -46,9 +46,9 @@ public abstract class BrandingUtil {
if (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.defaultBrand));
+ return sharedPreferences.getInt(context.getString(R.string.shared_preference_theme_main), context.getApplicationContext().getResources().getColor(R.color.accent));
} else {
- return context.getResources().getColor(R.color.primary);
+ return context.getResources().getColor(R.color.defaultBrand);
}
}
@@ -63,6 +63,17 @@ public abstract class BrandingUtil {
editor.apply();
}
+ public static void clearBrandColors(@NonNull Context context) {
+ if (isBrandingEnabled(context) && context instanceof BrandedActivity) {
+ final BrandedActivity activity = (BrandedActivity) context;
+ activity.applyBrand(ContextCompat.getColor(context, R.color.accent));
+ }
+ SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
+ DeckLog.log("--- Write: Remove: shared_preference_theme_main" + " | ");
+ editor.remove(context.getString(R.string.shared_preference_theme_main));
+ editor.apply();
+ }
+
/**
* Since we may collide with dark theme in this area, we have to make sure that the color is visible depending on the background
*/