Implement device linking dialog skeleton

This commit is contained in:
Niels Andriesse
2019-09-30 16:22:12 +10:00
parent 0f6a7e88b6
commit e77ee30c9b
7 changed files with 112 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ import android.support.v7.preference.Preference;
import android.widget.Toast;
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
import org.thoughtcrime.securesms.loki.DeviceLinkingDialog;
import org.thoughtcrime.securesms.loki.QRCodeDialog;
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
@@ -80,6 +81,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
// private static final String PREFERENCE_CATEGORY_ADVANCED = "preference_category_advanced";
private static final String PREFERENCE_CATEGORY_PUBLIC_KEY = "preference_category_public_key";
private static final String PREFERENCE_CATEGORY_QR_CODE = "preference_category_qr_code";
private static final String PREFERENCE_CATEGORY_LINK_DEVICE = "preference_category_link_device";
private static final String PREFERENCE_CATEGORY_SEED = "preference_category_seed";
private final DynamicTheme dynamicTheme = new DynamicTheme();
@@ -176,7 +178,9 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
this.findPreference(PREFERENCE_CATEGORY_PUBLIC_KEY)
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_PUBLIC_KEY));
this.findPreference(PREFERENCE_CATEGORY_QR_CODE)
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_QR_CODE));
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_QR_CODE));
this.findPreference(PREFERENCE_CATEGORY_LINK_DEVICE)
.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_LINK_DEVICE));
this.findPreference(PREFERENCE_CATEGORY_SEED)
.setOnPreferenceClickListener(new CategoryClickListener((PREFERENCE_CATEGORY_SEED)));
@@ -238,6 +242,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
Drawable advanced = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_advanced_white_24dp));
Drawable publicKey = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_textsms_24dp));
Drawable qrCode = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_qr_code));
Drawable linkDevice = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_link));
Drawable seed = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_seedling));
int[] tintAttr = new int[]{R.attr.pref_icon_tint};
@@ -254,6 +259,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
DrawableCompat.setTint(advanced, color);
DrawableCompat.setTint(publicKey, color);
DrawableCompat.setTint(qrCode, color);
DrawableCompat.setTint(linkDevice, color);
DrawableCompat.setTint(seed, color);
// this.findPreference(PREFERENCE_CATEGORY_SMS_MMS).setIcon(sms);
@@ -265,6 +271,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
// this.findPreference(PREFERENCE_CATEGORY_ADVANCED).setIcon(advanced);
this.findPreference(PREFERENCE_CATEGORY_PUBLIC_KEY).setIcon(publicKey);
this.findPreference(PREFERENCE_CATEGORY_QR_CODE).setIcon(qrCode);
this.findPreference(PREFERENCE_CATEGORY_LINK_DEVICE).setIcon(linkDevice);
this.findPreference(PREFERENCE_CATEGORY_SEED).setIcon(seed);
}
@@ -319,6 +326,9 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
case PREFERENCE_CATEGORY_QR_CODE:
QRCodeDialog.INSTANCE.show(getContext());
break;
case PREFERENCE_CATEGORY_LINK_DEVICE:
DeviceLinkingDialog.INSTANCE.show(getContext());
break;
case PREFERENCE_CATEGORY_SEED:
File languageFileDirectory = new File(getContext().getApplicationInfo().dataDir);
try {

View File

@@ -0,0 +1,33 @@
package org.thoughtcrime.securesms.loki
import android.content.Context
import android.graphics.Color
import android.graphics.PorterDuff
import android.support.v7.app.AlertDialog
import android.util.AttributeSet
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.view_device_linking.view.*
import kotlinx.android.synthetic.main.view_qr_code.view.cancelButton
import network.loki.messenger.R
object DeviceLinkingDialog {
fun show(context: Context) {
val view = DeviceLinkingView(context)
val dialog = AlertDialog.Builder(context).setView(view).show()
view.onCancel = { dialog.dismiss() }
}
}
class DeviceLinkingView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : LinearLayout(context, attrs, defStyleAttr) {
var onCancel: (() -> Unit)? = null
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context) : this(context, null)
init {
inflate(context, R.layout.view_device_linking, this)
spinner.indeterminateDrawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN)
cancelButton.setOnClickListener { onCancel?.invoke() }
}
}

View File

@@ -27,7 +27,7 @@ class QRCodeView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : Li
constructor(context: Context) : this(context, null)
init {
inflate(getContext(), R.layout.view_qr_code, this)
inflate(context, R.layout.view_qr_code, this)
val hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
val displayMetrics = DisplayMetrics()
ServiceUtil.getWindowManager(context).defaultDisplay.getMetrics(displayMetrics)