From 442a8b5c7db375511c36f3b933ce55daa6d00b58 Mon Sep 17 00:00:00 2001 From: FeuRenard Date: Sun, 4 Sep 2016 02:08:02 +0200 Subject: [PATCH] Use contact color in VerifyIdentityActivity Fixes #3630 Closes #5664 // FREEBIE --- .../securesms/VerifyIdentityActivity.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java index 277aaa9e17..0aa21fe99f 100644 --- a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java +++ b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java @@ -23,6 +23,8 @@ import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.PorterDuff; import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.ColorDrawable; +import android.os.Build; import android.os.Bundle; import android.os.Vibrator; import android.support.annotation.DrawableRes; @@ -42,6 +44,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import org.thoughtcrime.securesms.color.MaterialColor; import org.thoughtcrime.securesms.components.camera.CameraView; import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; @@ -73,7 +76,7 @@ import java.nio.charset.Charset; * * @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(); @@ -99,6 +102,9 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_numbers); Recipient recipient = RecipientFactory.getRecipientForId(this, getIntent().getLongExtra(RECIPIENT_ID, -1), true); + recipient.addListener(this); + + setActionBarNotificationBarColor(recipient.getColor()); Bundle extras = new Bundle(); extras.putParcelable(VerifyDisplayFragment.REMOTE_IDENTITY, getIntent().getParcelableExtra(RECIPIENT_IDENTITY)); @@ -125,6 +131,16 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity return false; } + @Override + public void onModified(final Recipient recipient) { + Util.runOnMain(new Runnable() { + @Override + public void run() { + setActionBarNotificationBarColor(recipient.getColor()); + } + }); + } + @Override public void onQrDataFound(final String data) { Util.runOnMain(new Runnable() { @@ -153,6 +169,14 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity .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 final String REMOTE_NUMBER = "remote_number";