code cleanup

This commit is contained in:
Daniel Gultsch 2018-03-18 09:47:52 +01:00
parent 82ba4ce4fc
commit f2ea609b51
1 changed files with 21 additions and 39 deletions

View File

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