Added dark theme
This commit is contained in:
parent
e4aa69b8d3
commit
68e80e6054
14 changed files with 75 additions and 14 deletions
|
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.ActionBar;
|
||||
|
|
@ -16,6 +17,8 @@ import android.view.ViewGroup;
|
|||
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Christian Schabesberger on 31.08.15.
|
||||
|
|
@ -43,6 +46,10 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceBundle) {
|
||||
if (Objects.equals(PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.getString("theme", "1"), "0")) {
|
||||
setTheme(R.style.DarkTheme);
|
||||
}
|
||||
getDelegate().installViewFactory();
|
||||
getDelegate().onCreate(savedInstanceBundle);
|
||||
super.onCreate(savedInstanceBundle);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.schabi.newpipe.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ListActivity;
|
||||
import android.content.ClipData;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
|
@ -55,6 +56,7 @@ public class SettingsFragment extends PreferenceFragment
|
|||
String DOWNLOAD_PATH_PREFERENCE;
|
||||
String DOWNLOAD_PATH_AUDIO_PREFERENCE;
|
||||
String USE_TOR_KEY;
|
||||
String THEME;
|
||||
|
||||
public static final int REQUEST_INSTALL_ORBOT = 0x1234;
|
||||
|
||||
|
|
@ -63,11 +65,12 @@ public class SettingsFragment extends PreferenceFragment
|
|||
private ListPreference searchLanguagePreference;
|
||||
private Preference downloadPathPreference;
|
||||
private Preference downloadPathAudioPreference;
|
||||
private Preference themePreference;
|
||||
private SharedPreferences defaultPreferences;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.settings);
|
||||
|
||||
|
|
@ -81,6 +84,7 @@ public class SettingsFragment extends PreferenceFragment
|
|||
SEARCH_LANGUAGE_PREFERENCE = getString(R.string.search_language_key);
|
||||
DOWNLOAD_PATH_PREFERENCE = getString(R.string.download_path_key);
|
||||
DOWNLOAD_PATH_AUDIO_PREFERENCE = getString(R.string.download_path_audio_key);
|
||||
THEME = getString(R.string.theme_key);
|
||||
USE_TOR_KEY = getString(R.string.use_tor_key);
|
||||
|
||||
// get pref objects
|
||||
|
|
@ -92,6 +96,7 @@ public class SettingsFragment extends PreferenceFragment
|
|||
(ListPreference) findPreference(SEARCH_LANGUAGE_PREFERENCE);
|
||||
downloadPathPreference = findPreference(DOWNLOAD_PATH_PREFERENCE);
|
||||
downloadPathAudioPreference = findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE);
|
||||
themePreference = findPreference(THEME);
|
||||
|
||||
prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
|
|
@ -132,6 +137,11 @@ public class SettingsFragment extends PreferenceFragment
|
|||
downloadPathAudioPreference
|
||||
.setSummary(downloadPath);
|
||||
}
|
||||
else if (key == THEME)
|
||||
{
|
||||
String theme = sharedPreferences.getString(THEME, "Light");
|
||||
themePreference.setSummary(theme);
|
||||
}
|
||||
updateSummary();
|
||||
}
|
||||
};
|
||||
|
|
@ -161,7 +171,6 @@ public class SettingsFragment extends PreferenceFragment
|
|||
activity.startActivityForResult(i, R.string.download_path_audio_key);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
|
||||
|
|
@ -216,8 +225,8 @@ public class SettingsFragment extends PreferenceFragment
|
|||
// installing the app does not necessarily return RESULT_OK
|
||||
App.configureTor(requestCode == REQUEST_INSTALL_ORBOT
|
||||
&& OrbotHelper.requestStartTor(a));
|
||||
|
||||
}
|
||||
|
||||
updateSummary();
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
|
@ -239,6 +248,9 @@ public class SettingsFragment extends PreferenceFragment
|
|||
downloadPathAudioPreference.setSummary(
|
||||
defaultPreferences.getString(DOWNLOAD_PATH_AUDIO_PREFERENCE,
|
||||
getString(R.string.download_path_audio_summary)));
|
||||
themePreference.setSummary(
|
||||
defaultPreferences.getString(THEME,
|
||||
getString(R.string.light_theme_title)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue