This commit is contained in:
Niels Andriesse 2019-11-18 13:21:52 +11:00
parent 35ee1c1391
commit e785eab28b
2 changed files with 6 additions and 10 deletions

View File

@ -36,14 +36,12 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.util.ArraySet;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.widget.Toast;
import org.jetbrains.annotations.NotNull;
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
import org.thoughtcrime.securesms.database.Database;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.loki.DeviceLinkingDialog;
import org.thoughtcrime.securesms.loki.DeviceLinkingDialogDelegate;
@ -59,14 +57,12 @@ import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
import org.whispersystems.signalservice.loki.api.PairingAuthorisation;
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec;
import org.whispersystems.signalservice.loki.utilities.Analytics;
import org.whispersystems.signalservice.loki.utilities.SerializationKt;
import java.io.File;
import java.util.Set;
import network.loki.messenger.R;
@ -202,10 +198,10 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
// Disable if we hit the cap of 1 linked device
if (isMasterDevice) {
Context context = getContext();
String ourNumber = TextSecurePreferences.getLocalNumber(context);
boolean shouldEnableDeviceLinking = DatabaseFactory.getLokiAPIDatabase(context).getPairingAuthorisations(ourNumber).size() <= 1;
linkDevicePreference.setEnabled(shouldEnableDeviceLinking);
linkDevicePreference.getIcon().setAlpha(shouldEnableDeviceLinking ? 255 : 124);
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context);
boolean isDeviceLinkingEnabled = DatabaseFactory.getLokiAPIDatabase(context).getPairingAuthorisations(userHexEncodedPublicKey).size() <= 1;
linkDevicePreference.setEnabled(isDeviceLinkingEnabled);
linkDevicePreference.getIcon().setAlpha(isDeviceLinkingEnabled ? 255 : 124);
} else {
// Hide if this is a slave device
linkDevicePreference.setVisible(false);

View File

@ -155,14 +155,14 @@ public class AvatarImageView extends AppCompatImageView {
}
private void updateImage() { updateImage(getWidth(), getHeight()); }
private void updateImage(int w, int h) {
if (w == 0 || h == 0 || recipient == null) { return; }
Drawable image;
Context context = this.getContext();
if (recipient.isGroupRecipient()) {
String name = Optional.fromNullable(recipient.getName()).or(Optional.fromNullable(TextSecurePreferences.getProfileName(context))).or("");
MaterialColor fallbackColor = recipient.getColor();