Use contact color in VerifyIdentityActivity

Fixes #3630
Closes #5664
// FREEBIE
This commit is contained in:
FeuRenard 2016-09-04 02:08:02 +02:00 committed by Moxie Marlinspike
parent 48d6d1c21d
commit 442a8b5c7d

View File

@ -23,6 +23,8 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
@ -42,6 +44,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.thoughtcrime.securesms.color.MaterialColor;
import org.thoughtcrime.securesms.components.camera.CameraView; import org.thoughtcrime.securesms.components.camera.CameraView;
import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable; import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable;
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
@ -73,7 +76,7 @@ import java.nio.charset.Charset;
* *
* @author Moxie Marlinspike * @author Moxie Marlinspike
*/ */
public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity implements ScanListener, View.OnClickListener { public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity implements Recipient.RecipientModifiedListener, ScanListener, View.OnClickListener {
private static final String TAG = VerifyIdentityActivity.class.getSimpleName(); private static final String TAG = VerifyIdentityActivity.class.getSimpleName();
@ -99,6 +102,9 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity
getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_numbers); getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_numbers);
Recipient recipient = RecipientFactory.getRecipientForId(this, getIntent().getLongExtra(RECIPIENT_ID, -1), true); Recipient recipient = RecipientFactory.getRecipientForId(this, getIntent().getLongExtra(RECIPIENT_ID, -1), true);
recipient.addListener(this);
setActionBarNotificationBarColor(recipient.getColor());
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putParcelable(VerifyDisplayFragment.REMOTE_IDENTITY, getIntent().getParcelableExtra(RECIPIENT_IDENTITY)); extras.putParcelable(VerifyDisplayFragment.REMOTE_IDENTITY, getIntent().getParcelableExtra(RECIPIENT_IDENTITY));
@ -125,6 +131,16 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity
return false; return false;
} }
@Override
public void onModified(final Recipient recipient) {
Util.runOnMain(new Runnable() {
@Override
public void run() {
setActionBarNotificationBarColor(recipient.getColor());
}
});
}
@Override @Override
public void onQrDataFound(final String data) { public void onQrDataFound(final String data) {
Util.runOnMain(new Runnable() { Util.runOnMain(new Runnable() {
@ -153,6 +169,14 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity
.commit(); .commit();
} }
private void setActionBarNotificationBarColor(MaterialColor color) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color.toActionBarColor(this)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(color.toStatusBarColor(this));
}
}
public static class VerifyDisplayFragment extends Fragment implements Recipients.RecipientsModifiedListener { public static class VerifyDisplayFragment extends Fragment implements Recipients.RecipientsModifiedListener {
public static final String REMOTE_NUMBER = "remote_number"; public static final String REMOTE_NUMBER = "remote_number";