blacklist fragment
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package net.headlezz.notificationlogger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
public class BlacklistFragment extends Fragment {
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
((AppCompatActivity) activity).getSupportActionBar().setTitle("Blacklist");
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
||||
ButterKnife.bind(this);
|
||||
setSupportActionBar(mToolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setTitle(R.string.title_settings);
|
||||
|
||||
if(getSupportFragmentManager().findFragmentById(R.id.fragment_holder) == null) {
|
||||
PreferenceFragment pf = new PreferenceFragment();
|
||||
@@ -34,6 +33,7 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAboutScreen() {
|
||||
// TODO add other libraries
|
||||
LibsSupportFragment aboutFrag = new LibsBuilder()
|
||||
@@ -47,4 +47,12 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
||||
.addToBackStack("about")
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBlacklistScreen() {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_holder, new BlacklistFragment())
|
||||
.addToBackStack("blacklist")
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.headlezz.notificationlogger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||
|
||||
@@ -10,32 +11,40 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Pref
|
||||
private PreferenceCallbacks mCallbacks;
|
||||
|
||||
final String PREF_ABOUT = "pref_about";
|
||||
|
||||
final String PREF_BLACKLIST = "pref_blacklist";
|
||||
|
||||
|
||||
interface PreferenceCallbacks {
|
||||
void showAboutScreen();
|
||||
void showBlacklistScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle bundle, String s) {
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
findPreference(PREF_ABOUT).setOnPreferenceClickListener(this);
|
||||
findPreference(PREF_BLACKLIST).setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if(preference.getKey().equals(PREF_ABOUT)) {
|
||||
String key = preference.getKey();
|
||||
if(key.equals(PREF_ABOUT)) {
|
||||
mCallbacks.showAboutScreen();
|
||||
return true;
|
||||
} else if(key.equals(PREF_BLACKLIST)) {
|
||||
mCallbacks.showBlacklistScreen();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
mCallbacks = (PreferenceCallbacks) activity;
|
||||
((AppCompatActivity) activity).getSupportActionBar().setTitle("Settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user