mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-04 07:41:40 -04:00
various color fixes
band-aid fixes for splash screen and material 3 dynamic color api change editbutton icon's color in card view based on editbutton background color make status bar transparent as per material 3, or tainted transparent for api level < 23 + light theme
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package protect.card_locker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class CatimaAppCompatActivity extends AppCompatActivity {
|
||||
@@ -10,4 +15,17 @@ public class CatimaAppCompatActivity extends AppCompatActivity {
|
||||
// Apply chosen language
|
||||
super.attachBaseContext(Utils.updateBaseContextLocale(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
// material you themes uses background color for top bar, let the layout underneath show through
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
getWindow().getDecorView().setSystemUiVisibility(Utils.isDarkModeEnabled(this) ? 0 : View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
} else {
|
||||
// icons are always white back then
|
||||
getWindow().setStatusBarColor(Utils.isDarkModeEnabled(this) ? Color.TRANSPARENT : Color.argb(127, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Guideline;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
@@ -575,7 +576,16 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
maximizeButton.setColorFilter(textColor);
|
||||
minimizeButton.setColorFilter(textColor);
|
||||
bottomSheetButton.setColorFilter(textColor);
|
||||
editButton.setBackgroundTintList(ColorStateList.valueOf(Utils.getComplementaryColor(darkenedColor)));
|
||||
int complementaryColor = Utils.getComplementaryColor(darkenedColor);
|
||||
editButton.setBackgroundTintList(ColorStateList.valueOf(complementaryColor));
|
||||
Drawable editButtonIcon = editButton.getDrawable();
|
||||
editButtonIcon.mutate();
|
||||
if (Utils.needsDarkForeground(complementaryColor)) {
|
||||
editButtonIcon.setTint(ContextCompat.getColor(this, R.color.md_theme_light_onBackground));
|
||||
} else {
|
||||
editButtonIcon.setTint(ContextCompat.getColor(this, R.color.md_theme_dark_onBackground));
|
||||
}
|
||||
editButton.setImageDrawable(editButtonIcon);
|
||||
|
||||
Bitmap icon = Utils.retrieveCardImage(this, loyaltyCard.id, ImageLocationType.icon);
|
||||
if (icon != null) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.database.CursorIndexOutOfBoundsException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -28,6 +29,7 @@ import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.splashscreen.SplashScreen;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
@@ -178,8 +180,18 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard
|
||||
protected void onCreate(Bundle inputSavedInstanceState) {
|
||||
super.onCreate(inputSavedInstanceState);
|
||||
SplashScreen.installSplashScreen(this);
|
||||
|
||||
// onPreCreate can't tell this activity uses a material theme due to splash screen, force color application here
|
||||
DynamicColors.applyIfAvailable(this);
|
||||
setTitle(R.string.app_name);
|
||||
|
||||
setContentView(R.layout.main_activity);
|
||||
|
||||
// XXX more dynamic color fixing due to splash screen
|
||||
TypedValue typedValue = new TypedValue();
|
||||
getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true);
|
||||
findViewById(android.R.id.content).setBackgroundColor(typedValue.data);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user