mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 17:10:33 +00:00
Merge branch 'feature-theme-change' of git://github.com/mauriciocolli/NewPipe into conf
This commit is contained in:
commit
af65a1cfef
@ -1,27 +1,27 @@
|
|||||||
package org.schabi.newpipe.settings;
|
package org.schabi.newpipe.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
||||||
import com.nononsenseapps.filepicker.FilePickerActivity;
|
import com.nononsenseapps.filepicker.FilePickerActivity;
|
||||||
|
|
||||||
import org.schabi.newpipe.App;
|
import org.schabi.newpipe.App;
|
||||||
|
import org.schabi.newpipe.MainActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||||
|
|
||||||
@ -98,6 +98,8 @@ public class SettingsFragment extends PreferenceFragment
|
|||||||
downloadPathAudioPreference = findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE);
|
downloadPathAudioPreference = findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE);
|
||||||
themePreference = findPreference(THEME);
|
themePreference = findPreference(THEME);
|
||||||
|
|
||||||
|
final String currentTheme = defaultPreferences.getString(THEME, "Light");
|
||||||
|
|
||||||
prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
|
||||||
@ -139,8 +141,27 @@ public class SettingsFragment extends PreferenceFragment
|
|||||||
}
|
}
|
||||||
else if (key == THEME)
|
else if (key == THEME)
|
||||||
{
|
{
|
||||||
String theme = sharedPreferences.getString(THEME, "Light");
|
String selectedTheme = sharedPreferences.getString(THEME, "Light");
|
||||||
themePreference.setSummary(theme);
|
themePreference.setSummary(selectedTheme);
|
||||||
|
|
||||||
|
if(!selectedTheme.equals(currentTheme)) { // If it's not the current theme
|
||||||
|
new AlertDialog.Builder(activity)
|
||||||
|
.setTitle(R.string.restart_title)
|
||||||
|
.setMessage(R.string.msg_restart)
|
||||||
|
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Intent intentToMain = new Intent(activity, MainActivity.class);
|
||||||
|
intentToMain.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
activity.startActivity(intentToMain);
|
||||||
|
|
||||||
|
activity.finish();
|
||||||
|
Runtime.getRuntime().exit(0);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.later, null)
|
||||||
|
.create().show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateSummary();
|
updateSummary();
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,8 @@
|
|||||||
<string name="error_report_title">Error report</string>
|
<string name="error_report_title">Error report</string>
|
||||||
<string name="all">All</string>
|
<string name="all">All</string>
|
||||||
<string name="channel">Channel</string>
|
<string name="channel">Channel</string>
|
||||||
|
<string name="yes">Yes</string>
|
||||||
|
<string name="later">Later</string>
|
||||||
|
|
||||||
<!-- error strings -->
|
<!-- error strings -->
|
||||||
<string name="general_error">Error</string>
|
<string name="general_error">Error</string>
|
||||||
@ -156,6 +158,7 @@
|
|||||||
<string name="short_thousand">K</string>
|
<string name="short_thousand">K</string>
|
||||||
<string name="short_million">M</string>
|
<string name="short_million">M</string>
|
||||||
<string name="short_billion">B</string>
|
<string name="short_billion">B</string>
|
||||||
|
<string name="restart_title">Restart</string>
|
||||||
|
|
||||||
<!-- Missions -->
|
<!-- Missions -->
|
||||||
<string name="start">Start</string>
|
<string name="start">Start</string>
|
||||||
@ -184,6 +187,7 @@
|
|||||||
<string name="msg_wait">Please wait…</string>
|
<string name="msg_wait">Please wait…</string>
|
||||||
<string name="msg_copied">Copied to clipboard.</string>
|
<string name="msg_copied">Copied to clipboard.</string>
|
||||||
<string name="no_available_dir">Please select an available download directory.</string>
|
<string name="no_available_dir">Please select an available download directory.</string>
|
||||||
|
<string name="msg_restart">You have to restart the application to apply the theme.\n\nDo you want to restart now?</string>
|
||||||
|
|
||||||
<!-- Checksum types -->
|
<!-- Checksum types -->
|
||||||
<string name="md5" translatable="false">MD5</string>
|
<string name="md5" translatable="false">MD5</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user