Don't duplicate colors, use the theme #757
This commit is contained in:
parent
5cfb108d52
commit
6b1ba4d161
|
@ -197,7 +197,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||||
checkAndRequestPermissions();
|
checkAndRequestPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeLog cl = new ChangeLog(this, (GBApplication.isDarkThemeEnabled() ? "body { color: #ffffff; background-color: #282828; }\n" : "") + DEFAULT_CSS);
|
ChangeLog cl = createChangeLog();
|
||||||
if (cl.isFirstRun()) {
|
if (cl.isFirstRun()) {
|
||||||
cl.getLogDialog().show();
|
cl.getLogDialog().show();
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||||
GBApplication.quit();
|
GBApplication.quit();
|
||||||
return true;
|
return true;
|
||||||
case R.id.external_changelog:
|
case R.id.external_changelog:
|
||||||
ChangeLog cl = new ChangeLog(this, (GBApplication.isDarkThemeEnabled() ? "body { color: #ffffff; background-color: #282828; }\n" : "") + DEFAULT_CSS);
|
ChangeLog cl = createChangeLog();
|
||||||
cl.getFullLogDialog().show();
|
cl.getFullLogDialog().show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,14 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ChangeLog createChangeLog() {
|
||||||
|
String css = ChangeLog.DEFAULT_CSS;
|
||||||
|
css += "body { "
|
||||||
|
+ "color: " + AndroidUtils.getTextColorHex(getBaseContext()) + "; "
|
||||||
|
+ "background-color: " + AndroidUtils.getBackgroundColorHex(getBaseContext()) + ";" +
|
||||||
|
"}";
|
||||||
|
return new ChangeLog(this, css);
|
||||||
|
}
|
||||||
private void launchDiscoveryActivity() {
|
private void launchDiscoveryActivity() {
|
||||||
startActivity(new Intent(this, DiscoveryActivity.class));
|
startActivity(new Intent(this, DiscoveryActivity.class));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,16 @@ import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.ParcelUuid;
|
import android.os.ParcelUuid;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
|
||||||
public class AndroidUtils {
|
public class AndroidUtils {
|
||||||
public static ParcelUuid[] toParcelUUids(Parcelable[] uuids) {
|
public static ParcelUuid[] toParcelUUids(Parcelable[] uuids) {
|
||||||
if (uuids == null) {
|
if (uuids == null) {
|
||||||
|
@ -74,4 +78,39 @@ public class AndroidUtils {
|
||||||
activity.getBaseContext().getResources().updateConfiguration(config, activity.getBaseContext().getResources().getDisplayMetrics());
|
activity.getBaseContext().getResources().updateConfiguration(config, activity.getBaseContext().getResources().getDisplayMetrics());
|
||||||
activity.recreate();
|
activity.recreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the theme dependent text color as a css-style hex string.
|
||||||
|
* @param context the context to access the colour
|
||||||
|
*/
|
||||||
|
public static String getTextColorHex(Context context) {
|
||||||
|
int color;
|
||||||
|
if (GBApplication.isDarkThemeEnabled()) {
|
||||||
|
color = context.getResources().getColor(R.color.primarytext_dark);
|
||||||
|
} else {
|
||||||
|
color = context.getResources().getColor(R.color.primarytext_light);
|
||||||
|
}
|
||||||
|
return colorToHex(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the theme dependent background color as a css-style hex string.
|
||||||
|
* @param context the context to access the colour
|
||||||
|
*/
|
||||||
|
public static String getBackgroundColorHex(Context context) {
|
||||||
|
int color;
|
||||||
|
if (GBApplication.isDarkThemeEnabled()) {
|
||||||
|
color = context.getResources().getColor(R.color.cardview_dark_background);
|
||||||
|
} else {
|
||||||
|
color = context.getResources().getColor(R.color.cardview_light_background);
|
||||||
|
}
|
||||||
|
return colorToHex(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String colorToHex(int color) {
|
||||||
|
return "#"
|
||||||
|
+ Integer.toHexString(Color.red(color))
|
||||||
|
+ Integer.toHexString(Color.green(color))
|
||||||
|
+ Integer.toHexString(Color.blue(color));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue