Initialize default preferences at startup

This commit is contained in:
Shinokuni 2019-12-20 18:07:24 +01:00
parent 6274540352
commit 88ffd9eb4b
2 changed files with 4 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import android.app.NotificationManager;
import android.os.Build; import android.os.Build;
import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import androidx.preference.PreferenceManager;
import com.facebook.stetho.Stetho; import com.facebook.stetho.Stetho;
import com.readrops.app.utils.SharedPreferencesManager; import com.readrops.app.utils.SharedPreferencesManager;
@ -29,6 +30,7 @@ public class ReadropsApp extends Application {
} }
createNotificationChannels(); createNotificationChannels();
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
if (Boolean.valueOf(SharedPreferencesManager.readString(this, SharedPreferencesManager.SharedPrefKey.DARK_THEME))) if (Boolean.valueOf(SharedPreferencesManager.readString(this, SharedPreferencesManager.SharedPrefKey.DARK_THEME)))
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);

View File

@ -16,14 +16,14 @@
android:title="@string/reload_feeds_colors" /> android:title="@string/reload_feeds_colors" />
<ListPreference <ListPreference
android:defaultValue="1" android:defaultValue="0"
android:entries="@array/open_items_in" android:entries="@array/open_items_in"
android:entryValues="@array/open_item_in_values" android:entryValues="@array/open_item_in_values"
android:key="open_items_in" android:key="open_items_in"
android:title="@string/open_items_in" /> android:title="@string/open_items_in" />
<ListPreference <ListPreference
android:defaultValue="1" android:defaultValue="false"
android:entries="@array/themes" android:entries="@array/themes"
android:entryValues="@array/themes_values" android:entryValues="@array/themes_values"
android:key="dark_theme" android:key="dark_theme"