diff --git a/res/drawable/icon_link.xml b/res/drawable/icon_link.xml
new file mode 100644
index 0000000000..fdabbd20d4
--- /dev/null
+++ b/res/drawable/icon_link.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/res/layout/view_device_linking.xml b/res/layout/view_device_linking.xml
new file mode 100644
index 0000000000..455a32e00e
--- /dev/null
+++ b/res/layout/view_device_linking.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3a247866c8..590ca2e6cc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1571,6 +1571,7 @@
Copied to clipboard
Share Public Key
Show QR Code
+ Link Device
Show Seed
Your Seed
Copy
@@ -1610,6 +1611,10 @@
Your QR Code
This is your personal QR code. Other people can scan it to start a secure conversation with you.
Cancel
+
+ Waiting for Device
+ Create a new account on your other device and click \"Link Device\" when you\'re at the \"Create Your Loki Messenger Account\" step to start the linking process
+ Cancel
Scan QR Code
Scan the QR code of the person you\'d like to securely message. They can find their QR code by going into Loki Messenger\'s in-app settings and clicking \"Show QR Code\".
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 850e9c2734..99aa910c01 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -41,6 +41,10 @@
android:title="@string/activity_settings_show_qr_code_button_title"
android:icon="@drawable/icon_qr_code"/>
+
+
diff --git a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java
index d1f006b86a..ccd60233af 100644
--- a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java
+++ b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java
@@ -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 {
diff --git a/src/org/thoughtcrime/securesms/loki/DeviceLinkingDialog.kt b/src/org/thoughtcrime/securesms/loki/DeviceLinkingDialog.kt
new file mode 100644
index 0000000000..59c235719c
--- /dev/null
+++ b/src/org/thoughtcrime/securesms/loki/DeviceLinkingDialog.kt
@@ -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() }
+ }
+}
\ No newline at end of file
diff --git a/src/org/thoughtcrime/securesms/loki/QRCodeDialog.kt b/src/org/thoughtcrime/securesms/loki/QRCodeDialog.kt
index cf71a1312e..c82694db88 100644
--- a/src/org/thoughtcrime/securesms/loki/QRCodeDialog.kt
+++ b/src/org/thoughtcrime/securesms/loki/QRCodeDialog.kt
@@ -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)