-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
205 additions
and
27 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
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
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/github/gotify/settings/SettingsActivity.java
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,56 @@ | ||
package com.github.gotify.settings; | ||
|
||
import android.content.SharedPreferences; | ||
import android.os.Bundle; | ||
import android.view.MenuItem; | ||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.preference.PreferenceFragmentCompat; | ||
import androidx.preference.PreferenceManager; | ||
import com.github.gotify.R; | ||
|
||
public class SettingsActivity extends AppCompatActivity | ||
implements SharedPreferences.OnSharedPreferenceChangeListener { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.settings_activity); | ||
getSupportFragmentManager() | ||
.beginTransaction() | ||
.replace(R.id.settings, new SettingsFragment()) | ||
.commit(); | ||
setSupportActionBar(findViewById(R.id.toolbar)); | ||
ActionBar actionBar = getSupportActionBar(); | ||
if (actionBar != null) { | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
actionBar.setDisplayShowCustomEnabled(true); | ||
} | ||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); | ||
sharedPreferences.registerOnSharedPreferenceChangeListener(this); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(@NonNull MenuItem item) { | ||
if (item.getItemId() == android.R.id.home) { | ||
finish(); | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@Override | ||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { | ||
if (getString(R.string.setting_key_theme).equals(key)) { | ||
ThemeHelper.setTheme( | ||
this, sharedPreferences.getString(key, getString(R.string.theme_default))); | ||
} | ||
} | ||
|
||
public static class SettingsFragment extends PreferenceFragmentCompat { | ||
@Override | ||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { | ||
setPreferencesFromResource(R.xml.root_preferences, rootKey); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/github/gotify/settings/ThemeHelper.java
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,27 @@ | ||
package com.github.gotify.settings; | ||
|
||
import android.content.Context; | ||
import android.os.Build; | ||
import androidx.appcompat.app.AppCompatDelegate; | ||
import com.github.gotify.R; | ||
|
||
public final class ThemeHelper { | ||
private ThemeHelper() {} | ||
|
||
public static void setTheme(Context context, String newTheme) { | ||
AppCompatDelegate.setDefaultNightMode(ofKey(context, newTheme)); | ||
} | ||
|
||
private static int ofKey(Context context, String newTheme) { | ||
if (context.getString(R.string.theme_dark).equals(newTheme)) { | ||
return AppCompatDelegate.MODE_NIGHT_YES; | ||
} | ||
if (context.getString(R.string.theme_light).equals(newTheme)) { | ||
return AppCompatDelegate.MODE_NIGHT_NO; | ||
} | ||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { | ||
return AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY; | ||
} | ||
return AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<vector android:height="24dp" android:viewportHeight="20" | ||
android:viewportWidth="20" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#FF000000" android:pathData="M15.95,10.78c0.03,-0.25 0.05,-0.51 0.05,-0.78s-0.02,-0.53 -0.06,-0.78l1.69,-1.32c0.15,-0.12 0.19,-0.34 0.1,-0.51l-1.6,-2.77c-0.1,-0.18 -0.31,-0.24 -0.49,-0.18l-1.99,0.8c-0.42,-0.32 -0.86,-0.58 -1.35,-0.78L12,2.34c-0.03,-0.2 -0.2,-0.34 -0.4,-0.34H8.4c-0.2,0 -0.36,0.14 -0.39,0.34l-0.3,2.12c-0.49,0.2 -0.94,0.47 -1.35,0.78l-1.99,-0.8c-0.18,-0.07 -0.39,0 -0.49,0.18l-1.6,2.77c-0.1,0.18 -0.06,0.39 0.1,0.51l1.69,1.32c-0.04,0.25 -0.07,0.52 -0.07,0.78s0.02,0.53 0.06,0.78L2.37,12.1c-0.15,0.12 -0.19,0.34 -0.1,0.51l1.6,2.77c0.1,0.18 0.31,0.24 0.49,0.18l1.99,-0.8c0.42,0.32 0.86,0.58 1.35,0.78l0.3,2.12c0.04,0.2 0.2,0.34 0.4,0.34h3.2c0.2,0 0.37,-0.14 0.39,-0.34l0.3,-2.12c0.49,-0.2 0.94,-0.47 1.35,-0.78l1.99,0.8c0.18,0.07 0.39,0 0.49,-0.18l1.6,-2.77c0.1,-0.18 0.06,-0.39 -0.1,-0.51l-1.67,-1.32zM10,13c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"/> | ||
<path | ||
android:fillColor="@color/icons" | ||
android:pathData="M15.95,10.78c0.03,-0.25 0.05,-0.51 0.05,-0.78s-0.02,-0.53 -0.06,-0.78l1.69,-1.32c0.15,-0.12 0.19,-0.34 0.1,-0.51l-1.6,-2.77c-0.1,-0.18 -0.31,-0.24 -0.49,-0.18l-1.99,0.8c-0.42,-0.32 -0.86,-0.58 -1.35,-0.78L12,2.34c-0.03,-0.2 -0.2,-0.34 -0.4,-0.34H8.4c-0.2,0 -0.36,0.14 -0.39,0.34l-0.3,2.12c-0.49,0.2 -0.94,0.47 -1.35,0.78l-1.99,-0.8c-0.18,-0.07 -0.39,0 -0.49,0.18l-1.6,2.77c-0.1,0.18 -0.06,0.39 0.1,0.51l1.69,1.32c-0.04,0.25 -0.07,0.52 -0.07,0.78s0.02,0.53 0.06,0.78L2.37,12.1c-0.15,0.12 -0.19,0.34 -0.1,0.51l1.6,2.77c0.1,0.18 0.31,0.24 0.49,0.18l1.99,-0.8c0.42,0.32 0.86,0.58 1.35,0.78l0.3,2.12c0.04,0.2 0.2,0.34 0.4,0.34h3.2c0.2,0 0.37,-0.14 0.39,-0.34l0.3,-2.12c0.49,-0.2 0.94,-0.47 1.35,-0.78l1.99,0.8c0.18,0.07 0.39,0 0.49,-0.18l1.6,-2.77c0.1,-0.18 0.06,-0.39 -0.1,-0.51l-1.67,-1.32zM10,13c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"/> | ||
</vector> |
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,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/drawer_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" | ||
tools:openDrawer="start"> | ||
|
||
<androidx.coordinatorlayout.widget.CoordinatorLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
android:layout_height="match_parent"> | ||
|
||
<FrameLayout | ||
android:id="@+id/settings" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
</LinearLayout> | ||
|
||
<include | ||
layout="@layout/app_bar_drawer" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
</androidx.coordinatorlayout.widget.CoordinatorLayout> | ||
|
||
</androidx.drawerlayout.widget.DrawerLayout> |
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorNavPrimary">#000000</color> | ||
<color name="colorPrimaryDark">#3867d6</color> | ||
<color name="colorAccent">#1c49b4</color> | ||
<color name="icons">#434343</color> | ||
<color name="swipeBackground">#E74C3C</color> | ||
<color name="swipeIcon">#FFFFFF</color> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<resources> | ||
<string-array name="mode"> | ||
<item>@string/theme_light</item> | ||
<item>@string/theme_dark</item> | ||
<item>@string/theme_default</item> | ||
</string-array> | ||
<string name="theme_light">Light</string> | ||
<string name="theme_dark">Dark</string> | ||
<string name="theme_default">System Default</string> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorNavPrimary">#FFFFFF</color> | ||
<color name="colorPrimaryDark">#3867d6</color> | ||
<color name="colorAccent">#1c49b4</color> | ||
<color name="icons">#434343</color> | ||
<color name="icons">#797979</color> | ||
<color name="swipeBackground">#E74C3C</color> | ||
<color name="swipeIcon">#FFFFFF</color> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
<style name="AppTheme.Nav"> | ||
<item name="colorPrimary">@color/colorNavPrimary</item> | ||
</style> | ||
|
||
<style name="AppTheme.NoActionBar"> | ||
<item name="windowActionBar">false</item> | ||
<item name="windowNoTitle">true</item> | ||
</style> | ||
|
||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | ||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" /> | ||
|
||
<style name="AppTheme.PopupOverlay" parent="AppTheme" /> | ||
|
||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> | ||
<style name="AppTheme.Dialog" parent="AppTheme" > | ||
<item name="colorPrimary">@color/colorNavPrimary</item> | ||
</style> | ||
|
||
</resources> |
Oops, something went wrong.