Appease the linter

This commit is contained in:
Moxie Marlinspike 2017-12-05 11:52:03 -08:00
parent 27e11e9627
commit 06e0d7d72d
2 changed files with 169 additions and 176 deletions

View File

@ -22,7 +22,6 @@ import android.annotation.TargetApi;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -43,6 +42,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.WindowCompat; import android.support.v4.view.WindowCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
@ -71,7 +71,6 @@ import com.google.protobuf.ByteString;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener;
import org.thoughtcrime.securesms.audio.AudioRecorder; import org.thoughtcrime.securesms.audio.AudioRecorder;
import org.thoughtcrime.securesms.audio.AudioSlidePlayer; import org.thoughtcrime.securesms.audio.AudioSlidePlayer;
import org.thoughtcrime.securesms.color.MaterialColor; import org.thoughtcrime.securesms.color.MaterialColor;
@ -154,6 +153,7 @@ import org.thoughtcrime.securesms.util.ExpirationUtil;
import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.GroupUtil;
import org.thoughtcrime.securesms.util.IdentityUtil; import org.thoughtcrime.securesms.util.IdentityUtil;
import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil; import org.thoughtcrime.securesms.util.ViewUtil;
@ -478,15 +478,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
final MenuItem item = menu.findItem(R.id.menu_expiring_messages); final MenuItem item = menu.findItem(R.id.menu_expiring_messages);
final View actionView = MenuItemCompat.getActionView(item); final View actionView = MenuItemCompat.getActionView(item);
final TextView badgeView = (TextView)actionView.findViewById(R.id.expiration_badge); final TextView badgeView = actionView.findViewById(R.id.expiration_badge);
badgeView.setText(ExpirationUtil.getExpirationAbbreviatedDisplayValue(this, recipient.getExpireMessages())); badgeView.setText(ExpirationUtil.getExpirationAbbreviatedDisplayValue(this, recipient.getExpireMessages()));
actionView.setOnClickListener(new OnClickListener() { actionView.setOnClickListener(v -> onOptionsItemSelected(item));
@Override
public void onClick(View v) {
onOptionsItemSelected(item);
}
});
} else { } else {
inflater.inflate(R.menu.conversation_expiring_off, menu); inflater.inflate(R.menu.conversation_expiring_off, menu);
} }
@ -592,9 +587,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
return; return;
} }
ExpirationDialog.show(this, recipient.getExpireMessages(), new ExpirationDialog.OnClickListener() { //noinspection CodeBlock2Expr
@Override ExpirationDialog.show(this, recipient.getExpireMessages(), expirationTime -> {
public void onClick(final int expirationTime) {
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
@ -611,14 +605,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
if (fragment != null) fragment.setLastSeen(0); if (fragment != null) fragment.setLastSeen(0);
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}); });
} }
private void handleMuteNotifications() { private void handleMuteNotifications() {
MuteDialog.show(this, new MuteDialog.MuteSelectionListener() { MuteDialog.show(this, until -> {
@Override
public void onMuted(final long until) {
recipient.setMuted(until); recipient.setMuted(until);
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@ -630,7 +621,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
return null; return null;
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}); });
} }
@ -658,13 +648,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
private void handleUnblock() { private void handleUnblock() {
//noinspection CodeBlock2Expr
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setTitle(R.string.ConversationActivity_unblock_this_contact_question) .setTitle(R.string.ConversationActivity_unblock_this_contact_question)
.setMessage(R.string.ConversationActivity_you_will_once_again_be_able_to_receive_messages_and_calls_from_this_contact) .setMessage(R.string.ConversationActivity_you_will_once_again_be_able_to_receive_messages_and_calls_from_this_contact)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(R.string.ConversationActivity_unblock, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.ConversationActivity_unblock, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
@ -678,7 +667,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
return null; return null;
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}).show(); }).show();
} }
@ -717,9 +705,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
builder.setIconAttribute(R.attr.dialog_alert_icon); builder.setIconAttribute(R.attr.dialog_alert_icon);
builder.setCancelable(true); builder.setCancelable(true);
builder.setMessage(R.string.ConversationActivity_this_may_help_if_youre_having_encryption_problems); builder.setMessage(R.string.ConversationActivity_this_may_help_if_youre_having_encryption_problems);
builder.setPositiveButton(R.string.ConversationActivity_reset, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.ConversationActivity_reset, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
if (isSingleConversation()) { if (isSingleConversation()) {
final Context context = getApplicationContext(); final Context context = getApplicationContext();
@ -738,7 +724,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, endSessionMessage); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, endSessionMessage);
} }
}
}); });
builder.setNegativeButton(android.R.string.cancel, null); builder.setNegativeButton(android.R.string.cancel, null);
builder.show(); builder.show();
@ -762,10 +747,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
builder.setIconAttribute(R.attr.dialog_info_icon); builder.setIconAttribute(R.attr.dialog_info_icon);
builder.setCancelable(true); builder.setCancelable(true);
builder.setMessage(getString(R.string.ConversationActivity_are_you_sure_you_want_to_leave_this_group)); builder.setMessage(getString(R.string.ConversationActivity_are_you_sure_you_want_to_leave_this_group));
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.yes, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
Context self = ConversationActivity.this; Context self = ConversationActivity.this;
try { try {
String groupId = getRecipient().getAddress().toGroupString(); String groupId = getRecipient().getAddress().toGroupString();
DatabaseFactory.getGroupDatabase(self).setActive(groupId, false); DatabaseFactory.getGroupDatabase(self).setActive(groupId, false);
@ -783,7 +767,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
Log.w(TAG, e); Log.w(TAG, e);
Toast.makeText(self, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show(); Toast.makeText(self, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show();
} }
}
}); });
builder.setNegativeButton(R.string.no, null); builder.setNegativeButton(R.string.no, null);
@ -910,8 +893,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private void handleManualMmsRequired() { private void handleManualMmsRequired() {
Toast.makeText(this, R.string.MmsDownloader_error_reading_mms_settings, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.MmsDownloader_error_reading_mms_settings, Toast.LENGTH_LONG).show();
Bundle extras = getIntent().getExtras();
Intent intent = new Intent(this, PromptMmsActivity.class); Intent intent = new Intent(this, PromptMmsActivity.class);
intent.putExtras(getIntent().getExtras()); if (extras != null) intent.putExtras(extras);
startActivity(intent); startActivity(intent);
} }
@ -922,9 +906,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
if (message == null) return; if (message == null) return;
new UnverifiedSendDialog(this, message, unverifiedRecords, new UnverifiedSendDialog.ResendListener() { //noinspection CodeBlock2Expr
@Override new UnverifiedSendDialog(this, message, unverifiedRecords, () -> {
public void onResendMessage() {
initializeIdentityRecords().addListener(new ListenableFuture.Listener<Boolean>() { initializeIdentityRecords().addListener(new ListenableFuture.Listener<Boolean>() {
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(Boolean result) {
@ -936,7 +919,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
throw new AssertionError(e); throw new AssertionError(e);
} }
}); });
}
}).show(); }).show();
} }
@ -947,9 +929,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
if (untrustedMessage == null) return; if (untrustedMessage == null) return;
new UntrustedSendDialog(this, untrustedMessage, untrustedRecords, new UntrustedSendDialog.ResendListener() { //noinspection CodeBlock2Expr
@Override new UntrustedSendDialog(this, untrustedMessage, untrustedRecords, () -> {
public void onResendMessage() {
initializeIdentityRecords().addListener(new ListenableFuture.Listener<Boolean>() { initializeIdentityRecords().addListener(new ListenableFuture.Listener<Boolean>() {
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(Boolean result) {
@ -961,7 +942,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
throw new AssertionError(e); throw new AssertionError(e);
} }
}); });
}
}).show(); }).show();
} }
@ -1031,16 +1011,22 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
protected void onPostExecute(List<Draft> drafts) { protected void onPostExecute(List<Draft> drafts) {
for (Draft draft : drafts) { for (Draft draft : drafts) {
try { try {
if (draft.getType().equals(Draft.TEXT)) { switch (draft.getType()) {
case Draft.TEXT:
composeText.setText(draft.getValue()); composeText.setText(draft.getValue());
} else if (draft.getType().equals(Draft.LOCATION)) { break;
case Draft.LOCATION:
attachmentManager.setLocation(masterSecret, SignalPlace.deserialize(draft.getValue()), getCurrentMediaConstraints()); attachmentManager.setLocation(masterSecret, SignalPlace.deserialize(draft.getValue()), getCurrentMediaConstraints());
} else if (draft.getType().equals(Draft.IMAGE)) { break;
case Draft.IMAGE:
setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE); setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE);
} else if (draft.getType().equals(Draft.AUDIO)) { break;
case Draft.AUDIO:
setMedia(Uri.parse(draft.getValue()), MediaType.AUDIO); setMedia(Uri.parse(draft.getValue()), MediaType.AUDIO);
} else if (draft.getType().equals(Draft.VIDEO)) { break;
case Draft.VIDEO:
setMedia(Uri.parse(draft.getValue()), MediaType.VIDEO); setMedia(Uri.parse(draft.getValue()), MediaType.VIDEO);
break;
} }
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, e); Log.w(TAG, e);
@ -1215,7 +1201,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
private void initializeViews() { private void initializeViews() {
titleView = (ConversationTitleView) getSupportActionBar().getCustomView(); ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar == null) throw new AssertionError();
titleView = (ConversationTitleView) supportActionBar.getCustomView();
buttonToggle = ViewUtil.findById(this, R.id.button_toggle); buttonToggle = ViewUtil.findById(this, R.id.button_toggle);
sendButton = ViewUtil.findById(this, R.id.send_button); sendButton = ViewUtil.findById(this, R.id.send_button);
attachButton = ViewUtil.findById(this, R.id.attach_button); attachButton = ViewUtil.findById(this, R.id.attach_button);
@ -1258,15 +1247,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
attachButton.setOnLongClickListener(new AttachButtonLongClickListener()); attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
sendButton.setOnClickListener(sendButtonListener); sendButton.setOnClickListener(sendButtonListener);
sendButton.setEnabled(true); sendButton.setEnabled(true);
sendButton.addOnTransportChangedListener(new OnTransportChangedListener() { sendButton.addOnTransportChangedListener((newTransport, manuallySelected) -> {
@Override
public void onChange(TransportOption newTransport, boolean manuallySelected) {
calculateCharactersRemaining(); calculateCharactersRemaining();
composeText.setTransport(newTransport); composeText.setTransport(newTransport);
buttonToggle.getBackground().setColorFilter(newTransport.getBackgroundColor(), Mode.MULTIPLY); buttonToggle.getBackground().setColorFilter(newTransport.getBackgroundColor(), Mode.MULTIPLY);
buttonToggle.getBackground().invalidateSelf(); buttonToggle.getBackground().invalidateSelf();
if (manuallySelected) recordSubscriptionIdPreference(newTransport.getSimSubscriptionId()); if (manuallySelected) recordSubscriptionIdPreference(newTransport.getSimSubscriptionId());
}
}); });
titleView.setOnClickListener(v -> handleConversationSettings()); titleView.setOnClickListener(v -> handleConversationSettings());
@ -1291,16 +1277,19 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
protected void initializeActionBar() { protected void initializeActionBar() {
getSupportActionBar().setDisplayHomeAsUpEnabled(false); ActionBar supportActionBar = getSupportActionBar();
getSupportActionBar().setCustomView(R.layout.conversation_title_view); if (supportActionBar == null) throw new AssertionError();
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false); supportActionBar.setDisplayHomeAsUpEnabled(false);
supportActionBar.setCustomView(R.layout.conversation_title_view);
supportActionBar.setDisplayShowCustomEnabled(true);
supportActionBar.setDisplayShowTitleEnabled(false);
} }
private void initializeResources() { private void initializeResources() {
if (recipient != null) recipient.removeListener(this); if (recipient != null) recipient.removeListener(this);
recipient = Recipient.from(this, (Address)getIntent().getParcelableExtra(ADDRESS_EXTRA), true); recipient = Recipient.from(this, getIntent().getParcelableExtra(ADDRESS_EXTRA), true);
threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1); threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1);
archived = getIntent().getBooleanExtra(IS_ARCHIVED_EXTRA, false); archived = getIntent().getBooleanExtra(IS_ARCHIVED_EXTRA, false);
distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT); distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
@ -1410,12 +1399,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
builder.setIconAttribute(R.attr.conversation_attach_contact_info); builder.setIconAttribute(R.attr.conversation_attach_contact_info);
builder.setTitle(R.string.ConversationActivity_select_contact_info); builder.setTitle(R.string.ConversationActivity_select_contact_info);
builder.setItems(numberItems, new DialogInterface.OnClickListener() { builder.setItems(numberItems, (dialog, which) -> composeText.append(numbers[which]));
@Override
public void onClick(DialogInterface dialog, int which) {
composeText.append(numbers[which]);
}
});
builder.show(); builder.show();
} }
@ -1481,7 +1465,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
private void setActionBarColor(MaterialColor color) { private void setActionBarColor(MaterialColor color) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color.toActionBarColor(this))); ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar == null) throw new AssertionError();
supportActionBar.setBackgroundDrawable(new ColorDrawable(color.toActionBarColor(this)));
setStatusBarColor(color.toStatusBarColor(this)); setStatusBarColor(color.toStatusBarColor(this));
} }
@ -1516,8 +1502,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
CharacterState characterState = transportOption.calculateCharacters(messageBody); CharacterState characterState = transportOption.calculateCharacters(messageBody);
if (characterState.charactersRemaining <= 15 || characterState.messagesSpent > 1) { if (characterState.charactersRemaining <= 15 || characterState.messagesSpent > 1) {
charactersLeft.setText(characterState.charactersRemaining + "/" + characterState.maxMessageSize charactersLeft.setText(String.format(dynamicLanguage.getCurrentLocale(),
+ " (" + characterState.messagesSpent + ")"); "%d/%d (%d)",
characterState.charactersRemaining,
characterState.maxMessageSize,
characterState.messagesSpent));
charactersLeft.setVisibility(View.VISIBLE); charactersLeft.setVisibility(View.VISIBLE);
} else { } else {
charactersLeft.setVisibility(View.GONE); charactersLeft.setVisibility(View.GONE);
@ -1535,6 +1524,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
return record.isPresent() && record.get().isActive(); return record.isPresent() && record.get().isActive();
} }
@SuppressWarnings("SimplifiableIfStatement")
private boolean isSelfConversation() { private boolean isSelfConversation() {
if (!TextSecurePreferences.isPushRegistered(this)) return false; if (!TextSecurePreferences.isPushRegistered(this)) return false;
if (recipient.isGroupRecipient()) return false; if (recipient.isGroupRecipient()) return false;
@ -1774,10 +1764,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override @Override
public void onAttachmentDrawerStateChanged(DrawerState drawerState) { public void onAttachmentDrawerStateChanged(DrawerState drawerState) {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar == null) throw new AssertionError();
if (drawerState == DrawerState.FULL_EXPANDED) { if (drawerState == DrawerState.FULL_EXPANDED) {
getSupportActionBar().hide(); supportActionBar.hide();
} else { } else {
getSupportActionBar().show(); supportActionBar.show();
} }
if (drawerState == DrawerState.COLLAPSED) { if (drawerState == DrawerState.COLLAPSED) {
@ -1818,8 +1811,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override @Override
public void onRecorderStarted() { public void onRecorderStarted() {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = ServiceUtil.getVibrator(this);
vibrator.vibrate(20); vibrator.vibrate(20);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
audioRecorder.startRecording(); audioRecorder.startRecording();
@ -1827,8 +1821,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override @Override
public void onRecorderFinished() { public void onRecorderFinished() {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = ServiceUtil.getVibrator(this);
vibrator.vibrate(20); vibrator.vibrate(20);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording(); ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
@ -1866,8 +1861,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override @Override
public void onRecorderCanceled() { public void onRecorderCanceled() {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = ServiceUtil.getVibrator(this);
vibrator.vibrate(50); vibrator.vibrate(50);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording(); ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
@ -2017,12 +2013,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
calculateCharactersRemaining(); calculateCharactersRemaining();
if (composeText.getTextTrimmed().length() == 0 || beforeLength == 0) { if (composeText.getTextTrimmed().length() == 0 || beforeLength == 0) {
composeText.postDelayed(new Runnable() { composeText.postDelayed(ConversationActivity.this::updateToggleButtonState, 50);
@Override
public void run() {
updateToggleButtonState();
}
}, 50);
} }
} }
@ -2092,16 +2083,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(ConversationActivity.this);
builder.setIconAttribute(R.attr.dialog_alert_icon); builder.setIconAttribute(R.attr.dialog_alert_icon);
builder.setTitle("No longer verified"); builder.setTitle("No longer verified");
builder.setItems(unverifiedNames, new DialogInterface.OnClickListener() { builder.setItems(unverifiedNames, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(ConversationActivity.this, VerifyIdentityActivity.class); Intent intent = new Intent(ConversationActivity.this, VerifyIdentityActivity.class);
intent.putExtra(VerifyIdentityActivity.ADDRESS_EXTRA, unverifiedIdentities.get(which).getAddress()); intent.putExtra(VerifyIdentityActivity.ADDRESS_EXTRA, unverifiedIdentities.get(which).getAddress());
intent.putExtra(VerifyIdentityActivity.IDENTITY_EXTRA, new IdentityKeyParcelable(unverifiedIdentities.get(which).getIdentityKey())); intent.putExtra(VerifyIdentityActivity.IDENTITY_EXTRA, new IdentityKeyParcelable(unverifiedIdentities.get(which).getIdentityKey()));
intent.putExtra(VerifyIdentityActivity.VERIFIED_EXTRA, false); intent.putExtra(VerifyIdentityActivity.VERIFIED_EXTRA, false);
startActivity(intent); startActivity(intent);
}
}); });
builder.show(); builder.show();
} }

View File

@ -7,6 +7,7 @@ import android.content.Context;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.Vibrator;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -43,4 +44,8 @@ public class ServiceUtil {
public static AlarmManager getAlarmManager(Context context) { public static AlarmManager getAlarmManager(Context context) {
return (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); return (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
} }
public static Vibrator getVibrator(Context context) {
return (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
}
} }