2017-09-03 08:04:18 +02:00
|
|
|
package org.schabi.newpipe.settings;
|
|
|
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.preference.PreferenceManager;
|
2019-10-04 14:59:08 +02:00
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.appcompat.app.ActionBar;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import androidx.preference.PreferenceFragmentCompat;
|
2017-09-03 08:04:18 +02:00
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import org.schabi.newpipe.MainActivity;
|
|
|
|
|
|
|
|
public abstract class BasePreferenceFragment extends PreferenceFragmentCompat {
|
|
|
|
protected final String TAG = getClass().getSimpleName() + "@" + Integer.toHexString(hashCode());
|
2018-08-28 20:02:25 +02:00
|
|
|
protected final boolean DEBUG = MainActivity.DEBUG;
|
2017-09-03 08:04:18 +02:00
|
|
|
|
|
|
|
protected SharedPreferences defaultPreferences;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
defaultPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
2017-09-28 15:36:15 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
2017-09-03 08:04:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
|
|
|
super.onViewCreated(view, savedInstanceState);
|
|
|
|
setDivider(null);
|
|
|
|
updateTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
updateTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateTitle() {
|
|
|
|
if (getActivity() instanceof AppCompatActivity) {
|
|
|
|
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
|
|
|
if (actionBar != null) actionBar.setTitle(getPreferenceScreen().getTitle());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|