Skip to content

Commit

Permalink
Fix dark mode on Xiaomi devices (#1566)
Browse files Browse the repository at this point in the history
Xiaomi devices have a force dark mode that breaks the app's reading view
and other views by trying to force them to be dark mode and changing the
colors on their own. This disables this functionality.
  • Loading branch information
ahmedre authored Mar 20, 2021
1 parent 44ed74b commit ed4c81b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:name=".QuranDataActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/Theme.AppCompat.NoActionBar">
android:theme="@style/QuranToolBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down Expand Up @@ -151,7 +151,7 @@
</intent-filter>
</activity>
<activity android:name=".pageselect.PageSelectActivity"
android:theme="@style/Theme.AppCompat.NoActionBar"/>
android:theme="@style/QuranToolBar"/>

<service
android:enabled="true"
Expand Down Expand Up @@ -191,7 +191,7 @@
android:name=".widget.ShowJumpFragmentActivity"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:theme="@style/Theme.AppCompat.Dialog" />
android:theme="@style/QuranDialog" />

<activity android:name=".ui.SheikhAudioManagerActivity" />

Expand Down
23 changes: 23 additions & 0 deletions app/src/main/res/values-v29/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Quran" parent="Theme.AppCompat">
<item name="colorAccent">@color/accent_color</item>
<item name="spinnerStyle">?attr/actionDropDownStyle</item>
<item name="spinnerDropDownItemStyle">@style/SherlockDropDownItem</item>
<item name="spinnerItemStyle">@style/SherlockSpinnerItem</item>
<item name="android:forceDarkAllowed">false</item>
</style>

<style name="QuranToolBar" parent="Theme.AppCompat.NoActionBar">
<item name="colorAccent">@color/accent_color</item>
<item name="windowActionModeOverlay">true</item>
<item name="spinnerStyle">?attr/actionDropDownStyle</item>
<item name="spinnerDropDownItemStyle">@style/SherlockDropDownItem</item>
<item name="spinnerItemStyle">@style/SherlockSpinnerItem</item>
<item name="android:forceDarkAllowed">false</item>
</style>

<style name="QuranDialog" parent="Theme.AppCompat.Dialog">
<item name="android:forceDarkAllowed">false</item>
</style>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
<style name="QuranToolBar.Overlay">
<item name="windowActionBarOverlay">true</item>
</style>
</resources>

<style name="QuranDialog" parent="Theme.AppCompat.Dialog" />
</resources>

0 comments on commit ed4c81b

Please sign in to comment.