code cleanup

This commit is contained in:
Daniel Gultsch 2018-03-18 09:47:52 +01:00
parent 82ba4ce4fc
commit f2ea609b51

View file

@ -274,8 +274,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showCreateConferenceDialog(); showCreateConferenceDialog();
} }
}); });
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); binding.tabLayout.setupWithViewPager(binding.startConversationViewPager);
tabLayout.setupWithViewPager(binding.startConversationViewPager);
binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener); binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener);
mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager()); mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager());
binding.startConversationViewPager.setAdapter(mListPagerAdapter); binding.startConversationViewPager.setAdapter(mListPagerAdapter);
@ -385,15 +384,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setNegativeButton(R.string.cancel, null); builder.setNegativeButton(R.string.cancel, null);
builder.setTitle(R.string.action_delete_contact); builder.setTitle(R.string.action_delete_contact);
builder.setMessage(getString(R.string.remove_contact_text, builder.setMessage(getString(R.string.remove_contact_text, contact.getJid()));
contact.getJid())); builder.setPositiveButton(R.string.delete, (dialog, which) -> {
builder.setPositiveButton(R.string.delete, new OnClickListener() { xmppConnectionService.deleteContactOnServer(contact);
filter(mSearchEditText.getText().toString());
@Override
public void onClick(DialogInterface dialog, int which) {
xmppConnectionService.deleteContactOnServer(contact);
filter(mSearchEditText.getText().toString());
}
}); });
builder.create().show(); builder.create().show();
} }
@ -407,16 +401,12 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
builder.setTitle(R.string.delete_bookmark); builder.setTitle(R.string.delete_bookmark);
builder.setMessage(getString(R.string.remove_bookmark_text, builder.setMessage(getString(R.string.remove_bookmark_text,
bookmark.getJid())); bookmark.getJid()));
builder.setPositiveButton(R.string.delete, new OnClickListener() { builder.setPositiveButton(R.string.delete, (dialog, which) -> {
bookmark.setConversation(null);
@Override Account account = bookmark.getAccount();
public void onClick(DialogInterface dialog, int which) { account.getBookmarks().remove(bookmark);
bookmark.setConversation(null); xmppConnectionService.pushBookmarks(account);
Account account = bookmark.getAccount(); filter(mSearchEditText.getText().toString());
account.getBookmarks().remove(bookmark);
xmppConnectionService.pushBookmarks(account);
filter(mSearchEditText.getText().toString());
}
}); });
builder.create().show(); builder.create().show();
@ -642,24 +632,16 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.sync_with_contacts); builder.setTitle(R.string.sync_with_contacts);
builder.setMessage(R.string.sync_with_contacts_long); builder.setMessage(R.string.sync_with_contacts_long);
builder.setPositiveButton(R.string.next, new OnClickListener() { builder.setPositiveButton(R.string.next, (dialog, which) -> {
@Override if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
public void onClick(DialogInterface dialog, int which) { requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { }
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS); });
} builder.setOnDismissListener(dialog -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS);
} }
}); });
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS);
}
}
});
}
builder.create().show(); builder.create().show();
} else { } else {
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, 0); requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, 0);
@ -802,8 +784,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.verify_omemo_keys); builder.setTitle(R.string.verify_omemo_keys);
View view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null); View view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null);
final CheckBox isTrustedSource = (CheckBox) view.findViewById(R.id.trusted_source); final CheckBox isTrustedSource = view.findViewById(R.id.trusted_source);
TextView warning = (TextView) view.findViewById(R.id.warning); TextView warning = view.findViewById(R.id.warning);
String jid = contact.getJid().asBareJid().toString(); String jid = contact.getJid().asBareJid().toString();
SpannableString spannable = new SpannableString(getString(R.string.verifying_omemo_keys_trusted_source, jid, contact.getDisplayName())); SpannableString spannable = new SpannableString(getString(R.string.verifying_omemo_keys_trusted_source, jid, contact.getDisplayName()));
int start = spannable.toString().indexOf(jid); int start = spannable.toString().indexOf(jid);