fixed settings title change on frag transaction
This commit is contained in:
@@ -2,7 +2,6 @@ package net.headlezz.notificationlogger;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
|
|
||||||
public class BlacklistFragment extends Fragment {
|
public class BlacklistFragment extends Fragment {
|
||||||
|
|
||||||
@@ -10,6 +9,5 @@ public class BlacklistFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
((AppCompatActivity) activity).getSupportActionBar().setTitle("Blacklist");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if(getSupportFragmentManager().findFragmentById(R.id.fragment_holder) == null) {
|
if(getSupportFragmentManager().findFragmentById(R.id.fragment_holder) == null) {
|
||||||
PreferenceFragment pf = new PreferenceFragment();
|
showSettingsScreen();
|
||||||
getSupportFragmentManager().beginTransaction()
|
|
||||||
.add(R.id.fragment_holder, pf)
|
|
||||||
.commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,5 +51,20 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
|||||||
.replace(R.id.fragment_holder, new BlacklistFragment())
|
.replace(R.id.fragment_holder, new BlacklistFragment())
|
||||||
.addToBackStack("blacklist")
|
.addToBackStack("blacklist")
|
||||||
.commit();
|
.commit();
|
||||||
|
getSupportActionBar().setTitle(getString(R.string.title_blacklist));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showSettingsScreen() {
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.fragment_holder, new PreferenceFragment())
|
||||||
|
.commit();
|
||||||
|
getSupportActionBar().setTitle(getString(R.string.title_settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if(getSupportFragmentManager().getBackStackEntryCount() > 0)
|
||||||
|
getSupportActionBar().setTitle(getString(R.string.title_settings));
|
||||||
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Pref
|
|||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
mCallbacks = (PreferenceCallbacks) activity;
|
mCallbacks = (PreferenceCallbacks) activity;
|
||||||
((AppCompatActivity) activity).getSupportActionBar().setTitle("Settings");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -15,4 +15,5 @@
|
|||||||
<string name="pref_about_title">About</string>
|
<string name="pref_about_title">About</string>
|
||||||
<string name="fab_cd_create_notification">FAB: Create notification</string>
|
<string name="fab_cd_create_notification">FAB: Create notification</string>
|
||||||
<string name="title_create_notification">Create notification</string>
|
<string name="title_create_notification">Create notification</string>
|
||||||
|
<string name="title_blacklist">Blacklist</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user