summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2019-09-04 20:28:32 +0300
committerArne Schwabe <arne@rfc2549.org>2019-09-04 20:30:46 +0300
commitb49591c377bb2e8c2adb0789a2bf1863b5d3d576 (patch)
tree568e36f88c49804f67296e16385674d834d81f7f
parent10d7110c352072a98edaa827800939aa16e85f6d (diff)
Implement dark mode
-rw-r--r--main/src/main/res/values-night-v21/styles.xml27
-rw-r--r--main/src/main/res/values-v21/styles.xml (renamed from main/src/ui/res/values-v21/styles.xml)2
-rw-r--r--main/src/ui/java/de/blinkt/openvpn/fragments/GraphFragment.java32
-rw-r--r--main/src/ui/res/layout/log_fragment.xml2
-rw-r--r--main/src/ui/res/values-night-v21/refs.xml9
5 files changed, 62 insertions, 10 deletions
diff --git a/main/src/main/res/values-night-v21/styles.xml b/main/src/main/res/values-night-v21/styles.xml
new file mode 100644
index 00000000..24d530fe
--- /dev/null
+++ b/main/src/main/res/values-night-v21/styles.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (c) 2012-2019 Arne Schwabe
+ ~ Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
+ -->
+
+<resources>
+ <style name="blinkt.baseTheme" parent="android:Theme.Material">
+ <item name="android:colorPrimary">@color/primary</item>
+ <item name="android:colorPrimaryDark">@color/primary_dark</item>
+ <item name="android:colorAccent">@color/accent</item>
+ <item name="android:alertDialogTheme">@style/blinkt.alertDialog</item>
+ </style>
+
+ <style name="blinkt.dialog" parent="android:Theme.Material.Dialog">
+ <item name="android:colorPrimary">@color/primary</item>
+ <item name="android:colorPrimaryDark">@color/primary_dark</item>
+ <item name="android:colorAccent">@color/accent</item>
+ <item name="android:alertDialogTheme">@style/blinkt.alertDialog</item>
+ </style>
+
+ <style name="blinkt.alertDialog" parent="android:Theme.Material.Dialog.Alert">
+ <item name="android:colorPrimary">@color/primary</item>
+ <item name="android:colorPrimaryDark">@color/primary_dark</item>
+ <item name="android:colorAccent">@color/accent</item>
+ </style>
+</resources> \ No newline at end of file
diff --git a/main/src/ui/res/values-v21/styles.xml b/main/src/main/res/values-v21/styles.xml
index fa27ebe8..e422fdb5 100644
--- a/main/src/ui/res/values-v21/styles.xml
+++ b/main/src/main/res/values-v21/styles.xml
@@ -26,4 +26,6 @@
<item name="android:colorAccent">@color/accent</item>
</style>
+ <style name="Theme.CreateShortCut" parent="android:Theme.Material.DialogWhenLarge" />
+
</resources>
diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/GraphFragment.java b/main/src/ui/java/de/blinkt/openvpn/fragments/GraphFragment.java
index 8ad5209c..4ddf90c4 100644
--- a/main/src/ui/java/de/blinkt/openvpn/fragments/GraphFragment.java
+++ b/main/src/ui/java/de/blinkt/openvpn/fragments/GraphFragment.java
@@ -7,11 +7,10 @@ package de.blinkt.openvpn.fragments;
import android.app.Fragment;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -21,15 +20,15 @@ import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
-import com.github.mikephil.charting.formatter.DefaultAxisValueFormatter;
-import com.github.mikephil.charting.formatter.IAxisValueFormatter;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
@@ -59,6 +58,7 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
private int mColourIn;
private int mColourOut;
private int mColourPoint;
+ private int mTextColour;
private long firstTs;
private TextView mSpeedStatus;
@@ -69,13 +69,14 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
private static final int TIME_PERIOD_HOURS = 2;
private Handler mHandler;
+
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.graph, container, false);
- mListView = (ListView) v.findViewById(R.id.graph_listview);
- mSpeedStatus = (TextView) v.findViewById(R.id.speedStatus);
- CheckBox logScaleView = (CheckBox) v.findViewById(R.id.useLogScale);
+ mListView = v.findViewById(R.id.graph_listview);
+ mSpeedStatus = v.findViewById(R.id.speedStatus);
+ CheckBox logScaleView = v.findViewById(R.id.useLogScale);
mLogScale = getActivity().getPreferences(MODE_PRIVATE).getBoolean(PREF_USE_LOG, false);
logScaleView.setChecked(mLogScale);
@@ -91,6 +92,16 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
mColourOut = getActivity().getResources().getColor(R.color.dataOut);
mColourPoint = getActivity().getResources().getColor(android.R.color.black);
+ int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ switch (currentNightMode) {
+ case Configuration.UI_MODE_NIGHT_NO:
+ mTextColour = getActivity().getResources().getColor(android.R.color.primary_text_light);
+ break;
+ case Configuration.UI_MODE_NIGHT_YES:
+ mTextColour = getActivity().getResources().getColor(android.R.color.primary_text_dark);
+ break;
+ }
+
logScaleView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -190,11 +201,13 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
// holder.chart.setValueTypeface(mTf);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
+ holder.chart.getLegend().setTextColor(mTextColour);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
+ xAxis.setTextColor(mTextColour);
switch (position) {
case TIME_PERIOD_HOURS:
@@ -241,6 +254,7 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
return humanReadableByteCount((long) value, true, res);
}
});
+ yAxis.setTextColor(mTextColour);
holder.chart.getAxisRight().setEnabled(false);
@@ -392,6 +406,8 @@ public class GraphFragment extends Fragment implements VpnStatus.ByteCountListen
dataSet.setMode(LineDataSet.Mode.LINEAR);
dataSet.setDrawValues(false);
+ dataSet.setValueTextColor(mTextColour);
+
}
}
diff --git a/main/src/ui/res/layout/log_fragment.xml b/main/src/ui/res/layout/log_fragment.xml
index ab070117..abfe7894 100644
--- a/main/src/ui/res/layout/log_fragment.xml
+++ b/main/src/ui/res/layout/log_fragment.xml
@@ -11,7 +11,6 @@
android:orientation="vertical">
<LinearLayout
- android:background="@drawable/white_rect"
android:elevation="1dp"
android:orientation="vertical"
android:layout_height="wrap_content"
@@ -23,7 +22,6 @@
android:text="@string/speed_waiting"
android:singleLine="true"
android:id="@+id/speed"
- tools:ignore="InconsistentLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
diff --git a/main/src/ui/res/values-night-v21/refs.xml b/main/src/ui/res/values-night-v21/refs.xml
new file mode 100644
index 00000000..bc498d41
--- /dev/null
+++ b/main/src/ui/res/values-night-v21/refs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (c) 2012-2016 Arne Schwabe
+ ~ Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
+ -->
+
+<resources>
+ <drawable name="vpn_item_edit">@drawable/ic_edit_white_24dp</drawable>
+</resources> \ No newline at end of file