Browse Source

Better way to check Signal setup while sending notifications

Signed-off-by: Arka Prava Basu <arkaprava94@gmail.com>
Arka Prava Basu 6 months ago
parent
commit
e4eec7a7af

+ 4 - 1
src/main/java/org/havenapp/main/ListActivity.java

@@ -33,6 +33,7 @@ import android.util.Log;
33 33
 import android.view.Menu;
34 34
 import android.view.MenuItem;
35 35
 import android.view.View;
36
+import android.widget.Toast;
36 37
 
37 38
 import com.google.android.material.floatingactionbutton.FloatingActionButton;
38 39
 import com.google.android.material.snackbar.Snackbar;
@@ -370,12 +371,14 @@ public class ListActivity extends AppCompatActivity {
370 371
     private void testNotifications ()
371 372
     {
372 373
 
373
-        if (!TextUtils.isEmpty(preferences.getSignalUsername())) {
374
+        if (preferences.isSignalVerified()) {
374 375
             SignalSender sender = SignalSender.getInstance(this, preferences.getSignalUsername().trim());
375 376
             ArrayList<String> recip = new ArrayList<>();
376 377
             recip.add(preferences.getRemotePhoneNumber());
377 378
             sender.sendMessage(recip, resourceManager.getString(R.string.signal_test_message),
378 379
                     null, null);
380
+        } else {
381
+            Toast.makeText(this, getString(R.string.setup_signal_toast), Toast.LENGTH_SHORT).show();
379 382
         }
380 383
     }
381 384
 }

+ 1 - 2
src/main/java/org/havenapp/main/service/MonitorService.java

@@ -368,8 +368,7 @@ public class MonitorService extends Service {
368 368
             alertMessage.append(getString(R.string.intrusion_detected,
369 369
                     eventTrigger.getStringType(new ResourceManager(this))));
370 370
 
371
-            if (mPrefs.isRemoteNotificationActive() &&
372
-                    mPrefs.getSignalUsername() != null) {
371
+            if (mPrefs.isRemoteNotificationActive() && mPrefs.isSignalVerified()) {
373 372
                 //since this is a secure channel, we can add the Onion address
374 373
                 if (mPrefs.getRemoteAccessActive() && (!TextUtils.isEmpty(mPrefs.getRemoteAccessOnion()))) {
375 374
                     alertMessage.append(" http://").append(mPrefs.getRemoteAccessOnion())

+ 1 - 0
src/main/res/values/strings.xml

@@ -187,5 +187,6 @@
187 187
     <string name="signal_reg_success_desc">You have successfully registered to Signal services. Next Step is to verify the registration for %s</string>
188 188
     <string name="verification_successful">Verification Successful</string>
189 189
     <string name="signal_verification_success_desc">All set to send Haven alerts from Signal!</string>
190
+    <string name="setup_signal_toast">Please set up Signal notifications from settings</string>
190 191
 
191 192
 </resources>