Added button to manage blocked senders

This commit is contained in:
M66B
2022-03-23 09:38:40 +01:00
parent fef6e21ca5
commit cb727e6c0f
5 changed files with 35 additions and 4 deletions

View File

@@ -1645,8 +1645,14 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
}
private void onManageLocalContacts(Intent intent) {
Bundle args = new Bundle();
args.putBoolean("junk", intent.getBooleanExtra("junk", false));
FragmentContacts fragment = new FragmentContacts();
fragment.setArguments(args);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentContacts()).addToBackStack("contacts");
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("contacts");
fragmentTransaction.commit();
}

View File

@@ -96,7 +96,7 @@ public class FragmentContacts extends FragmentBase {
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
setSubtitle(junk ? R.string.title_block_sender : R.string.menu_contacts);
setSubtitle(junk ? R.string.title_blocked_senders : R.string.menu_contacts);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_contacts, container, false);
@@ -236,7 +236,7 @@ public class FragmentContacts extends FragmentBase {
private void onMenuJunk(boolean junk) {
this.junk = junk;
setSubtitle(junk ? R.string.title_block_sender : R.string.menu_contacts);
setSubtitle(junk ? R.string.title_blocked_senders : R.string.menu_contacts);
adapter.filter(junk
? Arrays.asList(EntityContact.TYPE_JUNK, EntityContact.TYPE_NO_JUNK)
: new ArrayList<>());

View File

@@ -61,6 +61,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swSuggestReceived;
private SwitchCompat swSuggestFrequently;
private Button btnLocalContacts;
private Button btnBlockedSenders;
private SwitchCompat swPrefixOnce;
private SwitchCompat swPrefixCount;
private RadioGroup rgRe;
@@ -128,6 +129,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swSuggestReceived = view.findViewById(R.id.swSuggestReceived);
swSuggestFrequently = view.findViewById(R.id.swSuggestFrequently);
btnLocalContacts = view.findViewById(R.id.btnLocalContacts);
btnBlockedSenders = view.findViewById(R.id.btnBlockedSenders);
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swPrefixCount = view.findViewById(R.id.swPrefixCount);
rgRe = view.findViewById(R.id.rgRe);
@@ -239,6 +241,15 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
btnBlockedSenders.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_MANAGE_LOCAL_CONTACTS)
.putExtra("junk", true));
}
});
swPrefixOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {