Commit a67a07e9 authored by narinder Rana's avatar narinder Rana
Browse files

Merge branch 'Q_2826' into 'v1-q'

Fix dark mode colour issues in Q

See merge request !14
parents 8d646c59 de3b706d
......@@ -34,5 +34,6 @@ LOCAL_STATIC_JAVA_LIBRARIES := cr
LOCAL_STATIC_ANDROID_LIBRARIES += androidx.legacy_legacy-support-v4
LOCAL_STATIC_ANDROID_LIBRARIES += androidx.gridlayout_gridlayout
LOCAL_STATIC_ANDROID_LIBRARIES += androidx.recyclerview_recyclerview
LOCAL_STATIC_ANDROID_LIBRARIES += androidx.webkit_webkit
include $(BUILD_PACKAGE)
......@@ -31,7 +31,7 @@
android:minHeight="?android:attr/actionBarSize"
android:navigationContentDescription="@string/desc_navigate_up"
android:navigationIcon="?android:attr/homeAsUpIndicator"
android:popupTheme="@android:style/ThemeOverlay.Material.Light"
android:popupTheme="@style/Theme.Toolbar.Popup"
android:theme="@style/Theme.Toolbar"
android:title="@string/title_history" />
......
......@@ -39,4 +39,13 @@
<!-- Ripple color when a button is pressed in a pad. -->
<color name="pad_button_ripple_color">#33FFFFFF</color>
<!-- Background color for the advanced pad. -->
<color name="pad_advanced_background_color">#131313</color>
<!-- Text color for a button in the advanced pad. -->
<color name="pad_button_advanced_text_color">#CCFFFFFF</color>
<!-- Ripple color when a button is pressed in a pad. -->
<color name="pad_button_advanced_ripple_color">#1AFFFFFF</color>
</resources>
......@@ -24,4 +24,5 @@
</style>
<style name="Theme.Toolbar" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar" />
<style name="Theme.Toolbar.Popup" parent="@android:style/ThemeOverlay.Material.Dark" />
</resources>
......@@ -48,7 +48,7 @@
<color name="pad_operator_background_color">@color/calculator_statusbar_color</color>
<!-- Background color for the advanced pad. -->
<color name="pad_advanced_background_color">#ececec</color>
<color name="pad_advanced_background_color">@lineageos.platform:color/color_default_deep_grey</color>
<!-- Text color for a button in a pad. -->
<color name="pad_button_text_color">#333</color>
......
......@@ -17,4 +17,5 @@
<resources>
<style name="Theme.Toolbar" parent="@android:style/ThemeOverlay.Material.ActionBar" />
<style name="Theme.Toolbar.Popup" parent="@android:style/ThemeOverlay.Material.Light" />
</resources>
package com.android.calculator2;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebView;
import androidx.webkit.WebViewFeature;
import androidx.webkit.WebSettingsCompat;
public class Licenses extends Activity {
private static final String LICENSE_URL = "file:///android_asset/licenses.html";
......@@ -17,6 +22,18 @@ public class Licenses extends Activity {
webView.loadUrl(LICENSE_URL);
setContentView(webView);
handleDayNightMode(webView);
}
private void handleDayNightMode(WebView webView) {
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
if (isInDarkMode()) {
WebSettingsCompat.setForceDark(webView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
} else {
WebSettingsCompat.setForceDark(webView.getSettings(), WebSettingsCompat.FORCE_DARK_AUTO);
}
}
}
@Override
......@@ -27,4 +44,12 @@ public class Licenses extends Activity {
}
return super.onOptionsItemSelected(item);
}
private boolean isInDarkMode() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
int nightModeFlags = getApplication().getApplicationContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
return nightModeFlags == Configuration.UI_MODE_NIGHT_YES;
}
return false;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment