-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from norkator/feature/basic-dark-theme
Implement very simple dark theme
- Loading branch information
Showing
13 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.nitramite.utils; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.content.res.Configuration; | ||
import android.preference.PreferenceManager; | ||
import android.util.Log; | ||
|
||
import com.nitramite.apcupsdmonitor.Constants; | ||
|
||
import static android.content.res.Configuration.UI_MODE_NIGHT_YES; | ||
|
||
|
||
public class ThemeUtils { | ||
|
||
@SuppressWarnings("HardCodedStringLiteral") | ||
public enum Theme { | ||
BASIC(1), | ||
DARK(2), | ||
AUTO(3); | ||
|
||
private int num; | ||
|
||
Theme(int num) { | ||
this.num = num; | ||
} | ||
|
||
public static Theme getCurrentTheme(Context context) { | ||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); | ||
int theme = preferences.getBoolean(Constants.SP_USE_DARK_THEME, false) ? 2 : 1; | ||
for (Theme b : Theme.values()) { | ||
if (b.num == theme) { | ||
|
||
return b; | ||
} | ||
} | ||
return BASIC; | ||
} | ||
|
||
public static boolean isDarkThemeForced(Context context) { | ||
Theme currentTheme = getCurrentTheme(context); | ||
return currentTheme == DARK; | ||
} | ||
|
||
public static boolean isDarkTheme(Context context) { | ||
Theme currentTheme = getCurrentTheme(context); | ||
int nightModeFlags = | ||
context.getResources().getConfiguration().uiMode & | ||
Configuration.UI_MODE_NIGHT_MASK; | ||
Log.i("TU", "Nightmode: " + nightModeFlags); | ||
return (nightModeFlags == UI_MODE_NIGHT_YES) || currentTheme == DARK; | ||
} | ||
|
||
public static boolean isAutoTheme(Context context) { | ||
Theme currentTheme = getCurrentTheme(context); | ||
return currentTheme == AUTO; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<resources> | ||
|
||
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
<item name="android:navigationBarColor">@color/black</item> | ||
<item name="android:statusBarColor">@color/black</item> | ||
<item name="android:textColor">@color/color_white</item> | ||
<item name="android:textColorSecondary">@color/color_white</item> | ||
<item name="android:windowBackground">@color/background_darker</item> | ||
<item name="android:itemBackground">@color/background_darker</item> | ||
<item name="android:actionMenuTextColor">@color/color_white</item> | ||
<item name="eventsTextBackgroundColor">@color/black</item> | ||
</style> | ||
|
||
<style name="AppTheme.NoActionBar"> | ||
<item name="windowActionBar">false</item> | ||
<item name="windowNoTitle">true</item> | ||
<item name="android:windowDrawsSystemBarBackgrounds">true</item> | ||
<item name="android:statusBarColor">@android:color/transparent</item> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters