mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
show a toast in the qr activity if someone is joining
This commit is contained in:
@@ -31,6 +31,7 @@ package com.b44t.messenger;
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.b44t.messenger.Components.ForegroundDetector;
|
||||
|
||||
@@ -220,6 +221,8 @@ public class MrMailbox {
|
||||
public final static int MR_EVENT_IMEX_PROGRESS = 2051;
|
||||
public final static int MR_EVENT_IMEX_FILE_WRITTEN = 2052;
|
||||
|
||||
public final static int MR_EVENT_SECURE_JOIN_REQUESTED = 2060;
|
||||
|
||||
public final static int MR_EVENT_IS_OFFLINE = 2081;
|
||||
public final static int MR_EVENT_GET_STRING = 2091;
|
||||
public final static int MR_EVENT_GET_QUANTITIY_STRING = 2092;
|
||||
@@ -264,6 +267,15 @@ public class MrMailbox {
|
||||
}
|
||||
return 0;
|
||||
|
||||
case MR_EVENT_SECURE_JOIN_REQUESTED:
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.secureJoinRequested, (int)data1);
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
|
||||
case MR_EVENT_MSGS_CHANGED:
|
||||
case MR_EVENT_INCOMING_MSG:
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
|
||||
@@ -36,6 +36,7 @@ public class NotificationCenter {
|
||||
public static final int imexEnded = totalEvents++;
|
||||
public static final int imexProgress = totalEvents++;
|
||||
public static final int imexFileWritten = totalEvents++;
|
||||
public static final int secureJoinRequested = totalEvents++;
|
||||
public static final int didReceivedNewMessages = totalEvents++;
|
||||
public static final int updateInterfaces = totalEvents++;
|
||||
public static final int dialogsNeedReload = totalEvents++;
|
||||
|
||||
@@ -4,13 +4,14 @@ import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
public class QRshowActivity extends Activity {
|
||||
public class QRshowActivity extends Activity implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
public final static int WHITE = 0xFFFFFFFF;
|
||||
public final static int BLACK = 0xFF000000;
|
||||
@@ -29,6 +30,14 @@ public class QRshowActivity extends Activity {
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.secureJoinRequested);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.secureJoinRequested);
|
||||
}
|
||||
|
||||
Bitmap encodeAsBitmap(String str) throws WriterException {
|
||||
@@ -56,4 +65,13 @@ public class QRshowActivity extends Activity {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if( id==NotificationCenter.secureJoinRequested ) {
|
||||
int contact_id = (Integer)args[0];
|
||||
String msg = String.format(ApplicationLoader.applicationContext.getString(R.string.OobSecureJoinRequested), MrMailbox.getContact(contact_id).getNameNAddr());
|
||||
AndroidUtilities.showHint(ApplicationLoader.applicationContext, msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -435,4 +435,5 @@
|
||||
<string name="OobFingerprintOk">Contact <![CDATA[<i>]]>%1$s<![CDATA[</i>]]> verified. Start chatting?</string>
|
||||
<string name="OobFingerprintMismatch">The scanned fingerprint does <![CDATA[<b>]]>not match<![CDATA[</b>]]> the fingerprint last seen for <![CDATA[<i>]]>%1$s<![CDATA[</i>]]>.</string>
|
||||
<string name="OobFingerprintWithoutAddr">This QR code contains a fingerprint but no e-mail address.\n\nFor an out-of-band-verification, please establish an encrpyted connection to the recipient first.</string>
|
||||
<string name="OobSecureJoinRequested">%1$s joins.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user