mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-03 14:00:32 +00:00
Merge pull request #5879 from TacoTheDank/clean-oncreatepreferences
Clean up unnecessary onCreate in settings fragments
This commit is contained in:
commit
daa5b7827a
@ -2,7 +2,6 @@ package org.schabi.newpipe.settings;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
@ -11,8 +10,8 @@ import leakcanary.LeakCanary;
|
|||||||
|
|
||||||
public class DebugSettingsFragment extends BasePreferenceFragment {
|
public class DebugSettingsFragment extends BasePreferenceFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
super.onCreate(savedInstanceState);
|
addPreferencesFromResource(R.xml.debug_settings);
|
||||||
|
|
||||||
final Preference showMemoryLeaksPreference
|
final Preference showMemoryLeaksPreference
|
||||||
= findPreference(getString(R.string.show_memory_leaks_key));
|
= findPreference(getString(R.string.show_memory_leaks_key));
|
||||||
@ -31,9 +30,4 @@ public class DebugSettingsFragment extends BasePreferenceFragment {
|
|||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
|
||||||
addPreferencesFromResource(R.xml.debug_settings);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import android.os.Bundle;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
@ -21,8 +20,8 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
|||||||
private String captionSettingsKey;
|
private String captionSettingsKey;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
super.onCreate(savedInstanceState);
|
addPreferencesFromResource(R.xml.appearance_settings);
|
||||||
|
|
||||||
final String themeKey = getString(R.string.theme_key);
|
final String themeKey = getString(R.string.theme_key);
|
||||||
// the key of the active theme when settings were opened (or recreated after theme change)
|
// the key of the active theme when settings were opened (or recreated after theme change)
|
||||||
@ -58,11 +57,6 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
|
||||||
addPreferencesFromResource(R.xml.appearance_settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(final Preference preference) {
|
public boolean onPreferenceTreeClick(final Preference preference) {
|
||||||
if (preference.getKey().equals(captionSettingsKey) && CAPTIONING_SETTINGS_ACCESSIBLE) {
|
if (preference.getKey().equals(captionSettingsKey) && CAPTIONING_SETTINGS_ACCESSIBLE) {
|
||||||
|
@ -10,7 +10,6 @@ import android.util.Log;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
@ -50,8 +49,35 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||||||
private String initialLanguage;
|
private String initialLanguage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
super.onCreate(savedInstanceState);
|
final File homeDir = ContextCompat.getDataDir(requireContext());
|
||||||
|
manager = new ContentSettingsManager(new NewPipeFileLocator(homeDir));
|
||||||
|
manager.deleteSettingsFile();
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.content_settings);
|
||||||
|
|
||||||
|
final Preference importDataPreference = findPreference(getString(R.string.import_data));
|
||||||
|
importDataPreference.setOnPreferenceClickListener(p -> {
|
||||||
|
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, false)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_MODE,
|
||||||
|
FilePickerActivityHelper.MODE_FILE);
|
||||||
|
startActivityForResult(i, REQUEST_IMPORT_PATH);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
final Preference exportDataPreference = findPreference(getString(R.string.export_data));
|
||||||
|
exportDataPreference.setOnPreferenceClickListener(p -> {
|
||||||
|
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true)
|
||||||
|
.putExtra(FilePickerActivityHelper.EXTRA_MODE,
|
||||||
|
FilePickerActivityHelper.MODE_DIR);
|
||||||
|
startActivityForResult(i, REQUEST_EXPORT_PATH);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
thumbnailLoadToggleKey = getString(R.string.download_thumbnail_key);
|
thumbnailLoadToggleKey = getString(R.string.download_thumbnail_key);
|
||||||
youtubeRestrictedModeEnabledKey = getString(R.string.youtube_restricted_mode_enabled);
|
youtubeRestrictedModeEnabledKey = getString(R.string.youtube_restricted_mode_enabled);
|
||||||
|
|
||||||
@ -103,37 +129,6 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
|
||||||
final File homeDir = ContextCompat.getDataDir(requireContext());
|
|
||||||
manager = new ContentSettingsManager(new NewPipeFileLocator(homeDir));
|
|
||||||
manager.deleteSettingsFile();
|
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.content_settings);
|
|
||||||
|
|
||||||
final Preference importDataPreference = findPreference(getString(R.string.import_data));
|
|
||||||
importDataPreference.setOnPreferenceClickListener(p -> {
|
|
||||||
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
|
||||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
|
||||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, false)
|
|
||||||
.putExtra(FilePickerActivityHelper.EXTRA_MODE,
|
|
||||||
FilePickerActivityHelper.MODE_FILE);
|
|
||||||
startActivityForResult(i, REQUEST_IMPORT_PATH);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
final Preference exportDataPreference = findPreference(getString(R.string.export_data));
|
|
||||||
exportDataPreference.setOnPreferenceClickListener(p -> {
|
|
||||||
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
|
||||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
|
||||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true)
|
|
||||||
.putExtra(FilePickerActivityHelper.EXTRA_MODE,
|
|
||||||
FilePickerActivityHelper.MODE_DIR);
|
|
||||||
startActivityForResult(i, REQUEST_EXPORT_PATH);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
@ -11,7 +11,6 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
@ -46,8 +45,8 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||||||
private Context ctx;
|
private Context ctx;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
super.onCreate(savedInstanceState);
|
addPreferencesFromResource(R.xml.download_settings);
|
||||||
|
|
||||||
downloadPathVideoPreference = getString(R.string.download_path_video_key);
|
downloadPathVideoPreference = getString(R.string.download_path_video_key);
|
||||||
downloadPathAudioPreference = getString(R.string.download_path_audio_key);
|
downloadPathAudioPreference = getString(R.string.download_path_audio_key);
|
||||||
@ -76,11 +75,6 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
|
||||||
addPreferencesFromResource(R.xml.download_settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(final Context context) {
|
public void onAttach(final Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
@ -5,7 +5,6 @@ import android.os.Bundle;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
@ -29,8 +28,9 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
|||||||
private CompositeDisposable disposables;
|
private CompositeDisposable disposables;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
super.onCreate(savedInstanceState);
|
addPreferencesFromResource(R.xml.history_settings);
|
||||||
|
|
||||||
cacheWipeKey = getString(R.string.metadata_cache_wipe_key);
|
cacheWipeKey = getString(R.string.metadata_cache_wipe_key);
|
||||||
viewsHistoryClearKey = getString(R.string.clear_views_history_key);
|
viewsHistoryClearKey = getString(R.string.clear_views_history_key);
|
||||||
playbackStatesClearKey = getString(R.string.clear_playback_states_key);
|
playbackStatesClearKey = getString(R.string.clear_playback_states_key);
|
||||||
@ -39,11 +39,6 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
|||||||
disposables = new CompositeDisposable();
|
disposables = new CompositeDisposable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
|
||||||
addPreferencesFromResource(R.xml.history_settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(final Preference preference) {
|
public boolean onPreferenceTreeClick(final Preference preference) {
|
||||||
if (preference.getKey().equals(cacheWipeKey)) {
|
if (preference.getKey().equals(cacheWipeKey)) {
|
||||||
|
@ -2,7 +2,6 @@ package org.schabi.newpipe.settings;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
@ -16,15 +15,10 @@ public class UpdateSettingsFragment extends BasePreferenceFragment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
super.onCreate(savedInstanceState);
|
addPreferencesFromResource(R.xml.update_settings);
|
||||||
|
|
||||||
final String updateToggleKey = getString(R.string.update_app_key);
|
final String updateToggleKey = getString(R.string.update_app_key);
|
||||||
findPreference(updateToggleKey).setOnPreferenceChangeListener(updatePreferenceChange);
|
findPreference(updateToggleKey).setOnPreferenceChangeListener(updatePreferenceChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
|
||||||
addPreferencesFromResource(R.xml.update_settings);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import android.provider.Settings;
|
|||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
@ -23,8 +22,8 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||||||
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||||
super.onCreate(savedInstanceState);
|
addPreferencesFromResource(R.xml.video_audio_settings);
|
||||||
|
|
||||||
updateSeekOptions();
|
updateSeekOptions();
|
||||||
|
|
||||||
@ -104,11 +103,6 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
|
||||||
addPreferencesFromResource(R.xml.video_audio_settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
Loading…
Reference in New Issue
Block a user