Fix the app theme for both new and old devices. Giving up on showing the tab icons in place of having light vs dark theme.

This commit is contained in:
me committed 2025-07-20 19:19:46 -07:00
1 parent 255e2c46d4
commit 35c2e800b3
4 files changed
+74 -22

No files matched your search

@@ -1,6 +1,7 @@
package com.hyperling.carbupbeta;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
@@ -56,14 +57,27 @@ public class List extends ListInfo{
setName(listInfo.getName());
// ========== Style the buttons ==========
// Color!
linearLayout.setBackgroundColor(Color.BLACK);
btnDelete.setBackgroundColor(Color.LTGRAY);
btnDelete.setTextColor(Color.BLACK);
btnEdit.setBackgroundColor(Color.LTGRAY);
btnEdit.setTextColor(Color.BLACK);
btnItem.setBackgroundColor(Color.WHITE);
btnItem.setTextColor(getRandomColor());
/* Color! */
int currentNightMode =
context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK
;
switch (currentNightMode) {
// Light Mode
case Configuration.UI_MODE_NIGHT_NO:
linearLayout.setBackgroundColor(Color.BLACK);
btnDelete.setBackgroundColor(Color.LTGRAY);
btnDelete.setTextColor(Color.BLACK);
btnEdit.setBackgroundColor(Color.LTGRAY);
btnEdit.setTextColor(Color.BLACK);
btnItem.setBackgroundColor(Color.WHITE);
btnItem.setTextColor(getRandomColor());
break;// Dark Mode
case Configuration.UI_MODE_NIGHT_YES:
// Night mode is active, we're using dark theme
btnItem.setBackgroundColor(Color.DKGRAY);
break;
}
/* */
// Size!
//textSize = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth()/30;
btnDelete.setTextSize(16); //textSize-10);
@@ -1,6 +1,7 @@
package com.hyperling.carbupbeta;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.widget.LinearLayout;
import android.view.WindowManager;
@@ -64,13 +65,26 @@ public class ListItem extends ListItemInfo {
setName(listItemInfo.getName ());
// ========== Style the buttons ==========
// Color!
linearLayout.setBackgroundColor(Color.BLACK);
btnDelete.setBackgroundColor(Color.LTGRAY);
btnDelete.setTextColor(Color.BLACK);
btnEdit.setBackgroundColor(Color.LTGRAY);
btnEdit.setTextColor(Color.BLACK);
btnItem.setBackgroundColor(Color.WHITE);
/* Color! */
int currentNightMode =
context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK
;
switch (currentNightMode) {
// Light Mode
case Configuration.UI_MODE_NIGHT_NO:
linearLayout.setBackgroundColor(Color.BLACK);
btnDelete.setBackgroundColor(Color.LTGRAY);
btnDelete.setTextColor(Color.BLACK);
btnEdit.setBackgroundColor(Color.LTGRAY);
btnEdit.setTextColor(Color.BLACK);
btnItem.setBackgroundColor(Color.WHITE);
break;
// Dark Mode
case Configuration.UI_MODE_NIGHT_YES:
btnItem.setBackgroundColor(Color.DKGRAY);
break;
}
/* */
int[] colors = getColors(carbPerCal);
btnItem.setTextColor(Color.rgb(colors[0], colors[1], colors[2]));
// Size!
@@ -10,6 +10,7 @@ import android.widget.RelativeLayout;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
/**
* Created by ling on 1/1/16.
@@ -18,7 +19,7 @@ public class MySettingItem extends MySettingInfo{
private LinearLayout linearLayout;
private RelativeLayout relativeLayout;
Button btnItem;
TextView btnItem;
CheckBox checkBox;
private int textSize;
@@ -27,7 +28,7 @@ public class MySettingItem extends MySettingInfo{
// Instantiate the Views
linearLayout = new LinearLayout(context);
relativeLayout = new RelativeLayout(context);
btnItem = new Button(context);
btnItem = new TextView(context);
checkBox = new CheckBox(context);
// Give the views their required attributes (Wrap Content)
@@ -36,7 +37,7 @@ public class MySettingItem extends MySettingInfo{
LayoutParams item_lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
RelativeLayout.LayoutParams check_lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lay_lp.setMargins(1, 1, 1, 1);
lay_lp.setMargins(4,4,4,4);
linearLayout.setLayoutParams(lay_lp);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
@@ -55,15 +56,17 @@ public class MySettingItem extends MySettingInfo{
setName(info.getName());
setEnabled(info.getEnabled());
// ========== Style the buttons ==========
// Color!
/* ========== Style the buttons ========== */
/* Color! * /
linearLayout.setBackgroundColor(Color.LTGRAY);
relativeLayout.setBackgroundColor(Color.LTGRAY);
relativeLayout.setBackgroundColor(Color.DKGRAY);
btnItem.setBackgroundColor(Color.LTGRAY);
btnItem.setTextColor(Color.BLACK);
/* */
// Size!
//textSize = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth()/30;
btnItem.setTextSize(24); // textSize);
btnItem.setPadding(4,4,4,4);
// Add the items to the layout!
relativeLayout.addView(checkBox);