#1381 AndroidX Preference. Nav bar color

This commit is contained in:
sictiru 2020-11-21 14:42:37 -08:00
parent 9439d0ef43
commit 56a9bd6fad
5 changed files with 38 additions and 24 deletions

View file

@ -39,6 +39,7 @@ dependencies {
implementation 'com.github.jinatonic.confetti:confetti:1.1.2'
implementation 'com.google.android.play:core:1.8.3'
implementation "com.google.android.material:material:1.2.1"
implementation "androidx.preference:preference-ktx:1.1.1"
}
android {

View file

@ -394,4 +394,22 @@
<item name="popupMenuBackground">@color/gray13</item>
</style>
<style name="preferenceTheme" parent="@style/PreferenceThemeOverlay">
<item name="preferenceCategoryStyle">@style/preferenceCategory</item>
<item name="checkBoxPreferenceStyle">@style/checkBoxPreference</item>
<item name="dialogPreferenceStyle">@style/dialogPreference</item>
</style>
<style name="preferenceCategory" parent="Preference.Category.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="checkBoxPreference" parent="Preference.CheckBoxPreference.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="dialogPreference" parent="Preference.DialogPreference.Material">
<item name="iconSpaceReserved">false</item>
</style>
</resources>

View file

@ -48,6 +48,7 @@
<item name="selectorOverlayBackgroundText">@style/selectorOverlayBackgroundText</item>
<item name="muteicon">@style/muteicon</item>
<item name="android:textColor">@color/black</item>
<item name="preferenceTheme">@style/preferenceTheme</item>
</style>
<style name="NewsBlurDarkTheme" parent="Theme.MaterialComponents">
@ -98,6 +99,8 @@
<item name="selectorOverlayBackgroundText">@style/selectorOverlayBackgroundText.dark</item>
<item name="muteicon">@style/muteicon.dark</item>
<item name="android:textColor">@color/white</item>
<item name="preferenceTheme">@style/preferenceTheme</item>
<item name="android:navigationBarColor">@android:color/black</item>
</style>
<style name="NewsBlurBlackTheme" parent="Theme.MaterialComponents" >
@ -148,5 +151,7 @@
<item name="selectorOverlayBackgroundText">@style/selectorOverlayBackgroundText.dark</item>
<item name="muteicon">@style/muteicon.dark</item>
<item name="android:textColor">@color/white</item>
<item name="preferenceTheme">@style/preferenceTheme</item>
<item name="android:navigationBarColor">@android:color/black</item>
</style>
</resources>

View file

@ -1,9 +1,9 @@
package com.newsblur.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import com.newsblur.R;
import com.newsblur.fragment.SettingsFragment;
@ -21,8 +21,10 @@ public class Settings extends AppCompatActivity implements SharedPreferences.OnS
UIUtils.setCustomActionBar(this, R.drawable.logo, getString(R.string.settings), true);
SettingsFragment fragment = new SettingsFragment();
getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
getSupportFragmentManager()
.beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
SharedPreferences prefs = getSharedPreferences(PrefConstants.PREFERENCES, 0);
prefs.registerOnSharedPreferenceChangeListener(this);
@ -30,21 +32,10 @@ public class Settings extends AppCompatActivity implements SharedPreferences.OnS
@Override
protected void onDestroy() {
super.onDestroy();
SharedPreferences prefs = getSharedPreferences(PrefConstants.PREFERENCES, 0);
prefs.unregisterOnSharedPreferenceChangeListener(this);
}
super.onDestroy();
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override

View file

@ -1,20 +1,19 @@
package com.newsblur.fragment;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import com.newsblur.R;
import com.newsblur.util.PrefConstants;
public class SettingsFragment extends PreferenceFragment {
public class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setSharedPreferencesName(PrefConstants.PREFERENCES);
addPreferencesFromResource(R.xml.activity_settings);
setPreferencesFromResource(R.xml.activity_settings, rootKey);
}
}
}