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:
@@ -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);
|
||||
|
@@ -14,15 +14,36 @@
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="CarbUp" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<style name="OriginalTheme"
|
||||
parent="@android:style/Theme.Light.NoTitleBar">
|
||||
</style>
|
||||
|
||||
<style name="CarbUp" parent="Theme.AppCompat.DayNight.DarkActionBar">
|
||||
<!--
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
-->
|
||||
<!--
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:colorForeground">@color/colorPrimary</item>
|
||||
-->
|
||||
</style>
|
||||
|
||||
<style name="CarbUpTesting" parent="@android:style/Theme.DeviceDefault">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<!--
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:colorForeground">@color/colorPrimary</item>
|
||||
-->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user