Browse Source

Code Inspection 16/May/2022.

Signed-off-by: Sofian Benissa <sofian.benissa@mubs.edu.lb>
Sofian Benissa 1 month ago
parent
commit
4e611f367e
29 changed files with 181 additions and 161 deletions
  1. 1 1
      .idea/deploymentTargetDropDown.xml
  2. 2 0
      .idea/misc.xml
  3. 5 5
      app/build.gradle
  4. 1 0
      app/src/main/AndroidManifest.xml
  5. 15 15
      app/src/main/java/com/dx/anonymousmessenger/DxApplication.java
  6. 13 15
      app/src/main/java/com/dx/anonymousmessenger/call/CallActionReceiver.java
  7. 11 11
      app/src/main/java/com/dx/anonymousmessenger/call/CallService.java
  8. 1 1
      app/src/main/java/com/dx/anonymousmessenger/crypto/DxSignalKeyStore.java
  9. 2 2
      app/src/main/java/com/dx/anonymousmessenger/crypto/KeyExchangeMessage.java
  10. 4 4
      app/src/main/java/com/dx/anonymousmessenger/file/FileHelper.java
  11. 2 2
      app/src/main/java/com/dx/anonymousmessenger/media/AudioPlayer.java
  12. 39 24
      app/src/main/java/com/dx/anonymousmessenger/media/AudioRecordingService.java
  13. 2 2
      app/src/main/java/com/dx/anonymousmessenger/messages/MessageReceiver.java
  14. 2 2
      app/src/main/java/com/dx/anonymousmessenger/tor/ServerSocketViaTor.java
  15. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/custom/ScreenFilterDialogFragment.java
  16. 10 10
      app/src/main/java/com/dx/anonymousmessenger/ui/custom/StrengthMeter.java
  17. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/custom/TapSafeFrameLayout.java
  18. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/custom/TapSafeToolbar.java
  19. 3 0
      app/src/main/java/com/dx/anonymousmessenger/ui/view/app/AppFragment.java
  20. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/view/app/ContactListAdapter.java
  21. 1 3
      app/src/main/java/com/dx/anonymousmessenger/ui/view/app/PasswordEntryFragment.java
  22. 42 44
      app/src/main/java/com/dx/anonymousmessenger/ui/view/call/CallActivity.java
  23. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/view/log/LogRecycleViewAdapter.java
  24. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/view/message_list/MessageListActivity.java
  25. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/view/notepad/NotepadRecycleViewAdapter.java
  26. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/view/setup/BridgeRecyclerViewAdapter.java
  27. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/view/setup/SetupUsernameFragment.java
  28. 2 2
      app/src/main/java/com/dx/anonymousmessenger/ui/view/single_activity/MyProfileActivity.java
  29. 5 0
      app/src/main/res/values-ar/strings.xml

+ 1 - 1
.idea/deploymentTargetDropDown.xml

@@ -12,6 +12,6 @@
         </deviceKey>
       </Target>
     </targetSelectedWithDropDown>
-    <timeTargetWasSelectedWithDropDown value="2022-05-07T19:50:45.785915Z" />
+    <timeTargetWasSelectedWithDropDown value="2022-05-12T12:30:30.599508Z" />
   </component>
 </project>

+ 2 - 0
.idea/misc.xml

@@ -17,6 +17,7 @@
         <entry key="app/src/main/res/layout/activity_notepad.xml" value="0.23175675675675675" />
         <entry key="app/src/main/res/layout/activity_setup_in_process.xml" value="0.23175675675675675" />
         <entry key="app/src/main/res/layout/activity_verify_identity.xml" value="0.23175675675675675" />
+        <entry key="app/src/main/res/layout/fragment_app.xml" value="0.1" />
         <entry key="app/src/main/res/layout/fragment_password_entry.xml" value="0.23175675675675675" />
         <entry key="app/src/main/res/layout/fragment_setup_password2.xml" value="0.22" />
         <entry key="app/src/main/res/layout/fragment_setup_settings.xml" value="0.23175675675675675" />
@@ -34,6 +35,7 @@
         <entry key="app/src/main/res/layout/item_message_sent_ok_quote.xml" value="0.33" />
         <entry key="app/src/main/res/layout/my_text_view.xml" value="0.33" />
         <entry key="app/src/main/res/layout/tips_rv_item.xml" value="0.23175675675675675" />
+        <entry key="app/src/main/res/layout/toolbar.xml" value="0.20277777777777778" />
         <entry key="app/src/main/res/menu/app_menu2.xml" value="0.23175675675675675" />
       </map>
     </option>

+ 5 - 5
app/build.gradle

@@ -7,11 +7,11 @@ android {
         targetCompatibility JavaVersion.VERSION_1_8
     }
     defaultConfig {
-        applicationId "com.dx.anonymousmessenger"
+        applicationId "com.example.anonymousmessenger"
         minSdkVersion 21
         targetSdkVersion 32
-        versionCode 49
-        versionName "0.8.13"
+        versionCode 50
+        versionName "0.8.14"
         setProperty("archivesBaseName", applicationId + "-v" + versionCode + "(" + versionName + ")")
         ndk{
             abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
@@ -25,7 +25,7 @@ android {
     buildTypes {
         release {
             minifyEnabled false
-            debuggable false
+            debuggable true
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
         debug {
@@ -62,7 +62,7 @@ dependencies {
     implementation 'androidx.recyclerview:recyclerview:1.2.1'
 //    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
 
-    implementation 'com.google.android.material:material:1.5.0'
+    implementation 'com.google.android.material:material:1.6.0'
     implementation 'com.google.zxing:core:3.3.3'
     implementation 'me.dm7.barcodescanner:zxing:1.9.13'
     implementation 'com.google.protobuf:protobuf-java:3.9.2' //later versions min api 26+

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -3,6 +3,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     package="com.dx.anonymousmessenger">
 
+    <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />
     <uses-permission android:name="android.permission.INTERNET" />
 
     <uses-feature

+ 15 - 15
app/src/main/java/com/dx/anonymousmessenger/DxApplication.java

@@ -286,17 +286,17 @@ public class DxApplication extends Application {
 
     public void queueUnsentMessages(String address){
         if(syncingAddress!=null && syncingAddress.equals(address)){
-            System.out.println("Already Syncing with: "+syncingAddress);
+//            System.out.println("Already Syncing with: "+syncingAddress);
             return;
         }
-        System.out.println("Starting Sync.............");
+//        System.out.println("Starting Sync.............");
         new Thread(()-> doQueueUnsentMessages(address)).start();
     }
 
     public void doQueueUnsentMessages(String address){
-        System.out.println("Waiting sync start : "+address);
+//        System.out.println("Waiting sync start : "+address);
         synchronized (peerQueueLock) {
-            System.out.println("sync start: "+address);
+//            System.out.println("sync start: "+address);
             try {
 //                syncing = true;
                 syncingAddress = address;
@@ -309,22 +309,22 @@ public class DxApplication extends Application {
                         sendMediaMessageWithoutSaving(qum, this, address, false, true);
                     }
                 }
-                System.out.println("getting undelivered list.........");
+//                System.out.println("getting undelivered list.........");
                 List<QuotedUserMessage> undeliveredMessageList = DbHelper.getUndeliveredMessageList(this, address);
                 if (undeliveredMessageList.size() == 0) {
-                    System.out.println("LIST SIZE WAS ZERO 00000000");
+//                    System.out.println("LIST SIZE WAS ZERO 00000000");
 //                    syncing = false;
                     syncingAddress = null;
                     return;
                 }
-                System.out.println("LIST SIZE : "+undeliveredMessageList.size());
-                //todo: double sending occurs because there is a queue pool, we need to stop using it
+//                System.out.println("LIST SIZE : "+undeliveredMessageList.size());
+                //double sending occurs because there is a queue pool, we need to stop using it
                 // the queue pool should be cleared if the message is already there
                 //double is because there are two syncing functions (all & by address)
                 //also bad because we clear the queue in separate functions and threads
                 //maybe make sendQueuedMessages synchronized?
 //            addToMessagesQueue(undeliveredMessageList);
-                System.out.println("Sending.........");
+//                System.out.println("Sending.........");
                 sendQueuedMessages(undeliveredMessageList);
 //                syncing = false;
                 syncingAddress = null;
@@ -367,7 +367,7 @@ public class DxApplication extends Application {
         contentIntent.putExtra("address",address.substring(0,10));
         contentIntent.setAction(type);
         contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
-        PendingIntent pendingIntent = null;
+        PendingIntent pendingIntent;
         if (android.os.Build.VERSION.SDK_INT >= 31) {
             pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, PendingIntent.FLAG_MUTABLE);
         }else
@@ -380,7 +380,7 @@ public class DxApplication extends Application {
         Intent answerIntent = new Intent(context, DxCallService.class);
         answerIntent.putExtra("address",address.substring(0,10));
         answerIntent.setAction("answer");
-        PendingIntent answerPendingIntent = null;
+        PendingIntent answerPendingIntent;
         if (Build.VERSION.SDK_INT >= 31) {
             answerPendingIntent = PendingIntent.getService(context, 0, answerIntent, PendingIntent.FLAG_MUTABLE);
         }else{
@@ -390,7 +390,7 @@ public class DxApplication extends Application {
         Intent hangupIntent = new Intent(context, DxCallService.class);
         hangupIntent.putExtra("address",address.substring(0,10));
         hangupIntent.setAction("hangup");
-        PendingIntent hangupPendingIntent = null;
+        PendingIntent hangupPendingIntent;
         if (Build.VERSION.SDK_INT >= 31) {
             hangupPendingIntent = PendingIntent.getService(context, 0, hangupIntent, PendingIntent.FLAG_MUTABLE);
         }else{
@@ -659,7 +659,7 @@ public class DxApplication extends Application {
         resultIntent.setComponent(componentName);
         TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
         stackBuilder.addNextIntentWithParentStack(resultIntent);
-        PendingIntent resultPendingIntent = null;
+        PendingIntent resultPendingIntent;
         if (Build.VERSION.SDK_INT >= 31) {
             resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_MUTABLE);
         }else{
@@ -716,7 +716,7 @@ public class DxApplication extends Application {
         resultIntent.setComponent(componentName);
         TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
         stackBuilder.addNextIntentWithParentStack(resultIntent);
-        PendingIntent resultPendingIntent = null;
+        PendingIntent resultPendingIntent;
         if (Build.VERSION.SDK_INT >= 31) {
             resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_MUTABLE);
         }else{
@@ -800,7 +800,7 @@ public class DxApplication extends Application {
         resultIntent.setComponent(componentName);
         TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
         stackBuilder.addNextIntentWithParentStack(resultIntent);
-        PendingIntent gotoApp = null;
+        PendingIntent gotoApp;
         if (Build.VERSION.SDK_INT >= 31) {
             gotoApp = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_MUTABLE);
         }else{

+ 13 - 15
app/src/main/java/com/dx/anonymousmessenger/call/CallActionReceiver.java

@@ -4,29 +4,27 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 
-import java.util.Objects;
-
 public class CallActionReceiver extends BroadcastReceiver {
 
     @Override
     public void onReceive(Context context, Intent intent) {
         String action=intent.getStringExtra("action");
-        if(Objects.requireNonNull(action).equals("answer")){
-            answer();
-        }
-        else if(action.equals("hangup")){
-            hangup();
-        }
+//        if(Objects.requireNonNull(action).equals("answer")){
+//            answer();
+//        }
+//        else if(action.equals("hangup")){
+//            hangup();
+//        }
         //This is used to close the notification tray
         Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
         context.sendBroadcast(it);
     }
 
-    public void answer(){
-
-    }
-
-    public void hangup(){
-
-    }
+//    public void answer(){
+//
+//    }
+//
+//    public void hangup(){
+//
+//    }
 }

+ 11 - 11
app/src/main/java/com/dx/anonymousmessenger/call/CallService.java

@@ -31,10 +31,10 @@ public class CallService extends Service {
         return null;
     }
 
-    @Override
-    public void onCreate() {
-        super.onCreate();
-    }
+//    @Override
+//    public void onCreate() {
+//        super.onCreate();
+//    }
 
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
@@ -48,9 +48,9 @@ public class CallService extends Service {
 //        else if (intent.getAction().equals(ACTION_LOCAL_HANGUP))                handleLocalHangup(intent);
 //        else if (intent.getAction().equals(ACTION_SET_MUTE_AUDIO))              handleSetMuteAudio(intent);
 //        else if (intent.getAction().equals(ACTION_START_OUTGOING_CALL))         handleStartOutgoingCall(intent);
-        else if (intent.getAction().equals(ACTION_START_OUTGOING_CALL_RESPONSE)) handleOutgoingCallResponse(intent);
+//        else if (intent.getAction().equals(ACTION_START_OUTGOING_CALL_RESPONSE)) handleOutgoingCallResponse(intent);
 //        else if (intent.getAction().equals(ACTION_START_INCOMING_CALL))         handleStartIncomingCall(intent);
-        else if (intent.getAction().equals(ACTION_ACCEPT_CALL))                 handleAcceptCall(intent);
+//        else if (intent.getAction().equals(ACTION_ACCEPT_CALL))                 handleAcceptCall(intent);
 //        else if (intent.getAction().equals(ACTION_LOCAL_RINGING))               handleLocalRinging(intent);
 //        else if (intent.getAction().equals(ACTION_REMOTE_RINGING))              handleRemoteRinging(intent);
 //        else if (intent.getAction().equals(ACTION_RECEIVE_ANSWER))              handleReceivedAnswer(intent);
@@ -60,12 +60,12 @@ public class CallService extends Service {
         return START_NOT_STICKY;
     }
 
-    private void handleOutgoingCallResponse(Intent intent) {
-        handleAcceptCall(intent);
-    }
+//    private void handleOutgoingCallResponse(Intent intent) {
+//        handleAcceptCall(intent);
+//    }
 
-    private void handleAcceptCall(Intent intent) {
-    }
+//    private void handleAcceptCall(Intent intent) {
+//    }
 
 //    private void handleStartIncomingCall(Intent intent) {
 //        startForeground(1,getCallNotification(intent.getStringExtra("address"),"Incoming call"));

+ 1 - 1
app/src/main/java/com/dx/anonymousmessenger/crypto/DxSignalKeyStore.java

@@ -205,7 +205,7 @@ public class DxSignalKeyStore implements SignalProtocolStore {
         android.database.Cursor c=database.rawQuery("SELECT identity_key FROM identity WHERE address=?",new Object[]{addressName});
         if(c.moveToFirst())
         {
-            serializedIdentity = c.getString(c.getColumnIndex("identity_key"));
+            serializedIdentity = c.getString(Math.max(c.getColumnIndex("identity_key"),0));
             c.close();
 
         }else{

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/crypto/KeyExchangeMessage.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.crypto;
 
+import static org.whispersystems.libsignal.protocol.SignalProtos.KeyExchangeMessage.Builder;
+
 import com.google.protobuf.ByteString;
 
 import org.whispersystems.libsignal.IdentityKey;
@@ -15,8 +17,6 @@ import org.whispersystems.libsignal.util.ByteUtil;
 
 import java.io.IOException;
 
-import static org.whispersystems.libsignal.protocol.SignalProtos.KeyExchangeMessage.Builder;
-
 public class KeyExchangeMessage {
 
     public static final int INITIATE_FLAG              = 0x01;

+ 4 - 4
app/src/main/java/com/dx/anonymousmessenger/file/FileHelper.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.file;
 
+import static android.content.Context.DOWNLOAD_SERVICE;
+
 import android.app.DownloadManager;
 import android.content.Context;
 import android.database.Cursor;
@@ -37,8 +39,6 @@ import javax.crypto.NoSuchPaddingException;
 import javax.crypto.spec.GCMParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 
-import static android.content.Context.DOWNLOAD_SERVICE;
-
 public class FileHelper {
     public static final int IV_LENGTH = 12;
 
@@ -369,7 +369,7 @@ public class FileHelper {
         if (Objects.equals(uri.getScheme(), "content")) {
             try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) {
                 if (cursor != null && cursor.moveToFirst()) {
-                    result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
+                    result = cursor.getString(Math.max(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME), 0));
                 }
             }
         }
@@ -394,7 +394,7 @@ public class FileHelper {
             };
             try (Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null)) {
                 if (cursor != null && cursor.moveToFirst()) {
-                    result = cursor.getString(cursor.getColumnIndex(OpenableColumns.SIZE));
+                    result = cursor.getString(Math.max(cursor.getColumnIndex(OpenableColumns.SIZE), 0));
                 }
             }
         }

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/media/AudioPlayer.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.media;
 
+import static com.dx.anonymousmessenger.file.FileHelper.getFile;
+
 import android.media.AudioFormat;
 import android.media.AudioManager;
 import android.media.AudioRecord;
@@ -11,8 +13,6 @@ import com.dx.anonymousmessenger.util.CallBack;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
-import static com.dx.anonymousmessenger.file.FileHelper.getFile;
-
 public class AudioPlayer {
     private AudioTrack at;
 //    public AudioManager audioManager;

+ 39 - 24
app/src/main/java/com/dx/anonymousmessenger/media/AudioRecordingService.java

@@ -1,7 +1,9 @@
 package com.dx.anonymousmessenger.media;
 
+import android.Manifest;
 import android.app.Service;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.media.AudioFormat;
 import android.media.AudioRecord;
 import android.media.MediaRecorder;
@@ -9,6 +11,7 @@ import android.os.Handler;
 import android.os.IBinder;
 import android.widget.Toast;
 
+import androidx.core.app.ActivityCompat;
 import androidx.localbroadcastmanager.content.LocalBroadcastManager;
 
 import com.dx.anonymousmessenger.DxApplication;
@@ -26,7 +29,7 @@ import java.util.Objects;
 
 public class AudioRecordingService extends Service {
     AudioRecord recorder;
-    private final int sampleRate = 16000 ; // 44100 for music
+    private final int sampleRate = 16000; // 44100 for music
     private final int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_MONO;
     private final int audioFormat = AudioFormat.ENCODING_PCM_8BIT;
     private final int minBufSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
@@ -52,7 +55,7 @@ public class AudioRecordingService extends Service {
 
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
-        if(Objects.equals(intent.getAction(), "stop_recording")){
+        if (Objects.equals(intent.getAction(), "stop_recording")) {
             outputStream = null;
             status = false;
             stopRecording();
@@ -68,7 +71,7 @@ public class AudioRecordingService extends Service {
 
     @Override
     public void onDestroy() {
-        new Thread(()->{
+        new Thread(() -> {
             try {
                 stopRecording();
             } catch (Exception e) {
@@ -80,26 +83,27 @@ public class AudioRecordingService extends Service {
 
     public void stopRecording() {
         status = false;
-        if(recorder==null || recorder.getState()==AudioRecord.STATE_UNINITIALIZED){
+        if (recorder == null || recorder.getState() == AudioRecord.STATE_UNINITIALIZED) {
             return;
         }
-        try{
+        try {
             recorder.stop();
             recorder.release();
-        }catch (Exception ignored){}
+        } catch (Exception ignored) {
+        }
 
-        if(outputStream==null){
+        if (outputStream == null) {
             return;
         }
         //put recorded stream into bytes
-        if(outputStream.size() >= Runtime.getRuntime().freeMemory()){
+        if (outputStream.size() >= Runtime.getRuntime().freeMemory()) {
             return;
         }
-        if(outputStream.size() <= 0){
+        if (outputStream.size() <= 0) {
             return;
         }
         byte[] recorded = outputStream.toByteArray();
-        if(recorded.length <= 0){
+        if (recorded.length <= 0) {
             return;
         }
         //get app ready
@@ -110,40 +114,51 @@ public class AudioRecordingService extends Service {
         String filename = String.valueOf(time);
         String path = null;
         try {
-            path = FileHelper.saveFile(recorded,app,filename);
+            path = FileHelper.saveFile(recorded, app, filename);
         } catch (NoSuchAlgorithmException e) {
             e.printStackTrace();
         }
-        if(path==null){
+        if (path == null) {
             return;
         }
         //save metadata in encrypted database with reference to encrypted file
-        QuotedUserMessage qum = new QuotedUserMessage(app.getHostname(),app.getAccount().getNickname(),time,false,address,filename,path,"audio");
+        QuotedUserMessage qum = new QuotedUserMessage(app.getHostname(), app.getAccount().getNickname(), time, false, address, filename, path, "audio");
         //send message and get received status
-        MessageSender.sendMediaMessage(qum,app,address);
+        MessageSender.sendMediaMessage(qum, app, address);
     }
 
     @SuppressWarnings("BusyWait")
-    public void startTiming(){
-        try{
-            while(status){
+    public void startTiming() {
+        try {
+            while (status) {
                 try {
                     Thread.sleep(1000);
-                }catch (Exception ignored) {}
+                } catch (Exception ignored) {
+                }
                 callTimer++;
                 Intent gcm_rec = new Intent("recording_action");
-                gcm_rec.putExtra("action","timer");
-                gcm_rec.putExtra("time",Utils.getMinutesAndSecondsFromSeconds(callTimer));
+                gcm_rec.putExtra("action", "timer");
+                gcm_rec.putExtra("time", Utils.getMinutesAndSecondsFromSeconds(callTimer));
                 LocalBroadcastManager.getInstance(getApplication()).sendBroadcast(gcm_rec);
             }
-        }catch (Exception ignored){
+        } catch (Exception ignored) {
         }
     }
 
-    public void startRecording(){
+    public void startRecording() {
         byte[] buffer = new byte[minBufSize];
-        try{
-            recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,sampleRate,channelConfig,audioFormat,buffer.length);
+        try {
+            if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
+                // TODO: Consider calling
+                //    ActivityCompat#requestPermissions
+                // here to request the missing permissions, and then overriding
+                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
+                //                                          int[] grantResults)
+                // to handle the case where the user grants the permission. See the documentation
+                // for ActivityCompat#requestPermissions for more details.
+                return;
+            }
+            recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, channelConfig, audioFormat, buffer.length);
 //            if(recorder.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED ){
 //                Handler handler = new Handler(getMainLooper());
 //                handler.post(()->{

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/messages/MessageReceiver.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.messages;
 
+import static com.dx.anonymousmessenger.messages.MessageSender.sendKeyExchangeMessage;
+
 import android.content.Intent;
 import android.util.Log;
 
@@ -23,8 +25,6 @@ import org.whispersystems.libsignal.UntrustedIdentityException;
 
 import java.util.Date;
 
-import static com.dx.anonymousmessenger.messages.MessageSender.sendKeyExchangeMessage;
-
 public class MessageReceiver {
 
     public static void messageReceiver(String msg, DxApplication app){

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/tor/ServerSocketViaTor.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.tor;
 
+import static com.dx.anonymousmessenger.file.FileHelper.IV_LENGTH;
+
 import android.content.Context;
 import android.content.Intent;
 import android.os.StatFs;
@@ -46,8 +48,6 @@ import javax.crypto.Cipher;
 import javax.crypto.spec.GCMParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 
-import static com.dx.anonymousmessenger.file.FileHelper.IV_LENGTH;
-
 public class ServerSocketViaTor {
     private static final int TOTAL_SEC_PER_STARTUP = 300;//these are secs not millis
     private static final int hiddenservicedirport = 5780;

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/custom/ScreenFilterDialogFragment.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.custom;
 
+import static android.os.Build.VERSION.SDK_INT;
+
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Dialog;
@@ -16,8 +18,6 @@ import androidx.fragment.app.DialogFragment;
 
 import com.dx.anonymousmessenger.R;
 
-import static android.os.Build.VERSION.SDK_INT;
-
 public class ScreenFilterDialogFragment extends DialogFragment {
 
     public static final String TAG = ScreenFilterDialogFragment.class.getName();

+ 10 - 10
app/src/main/java/com/dx/anonymousmessenger/ui/custom/StrengthMeter.java

@@ -1,5 +1,15 @@
 package com.dx.anonymousmessenger.ui.custom;
 
+import static android.graphics.Color.BLACK;
+import static android.graphics.Paint.Style.FILL;
+import static android.graphics.Paint.Style.STROKE;
+import static android.graphics.drawable.ClipDrawable.HORIZONTAL;
+import static android.view.Gravity.START;
+import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.QUITE_STRONG;
+import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.QUITE_WEAK;
+import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.STRONG;
+import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.WEAK;
+
 import android.content.Context;
 import android.graphics.Color;
 import android.graphics.Paint;
@@ -13,16 +23,6 @@ import android.widget.ProgressBar;
 import androidx.annotation.Nullable;
 import androidx.core.content.ContextCompat;
 
-import static android.graphics.Color.BLACK;
-import static android.graphics.Paint.Style.FILL;
-import static android.graphics.Paint.Style.STROKE;
-import static android.graphics.drawable.ClipDrawable.HORIZONTAL;
-import static android.view.Gravity.START;
-import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.QUITE_STRONG;
-import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.QUITE_WEAK;
-import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.STRONG;
-import static com.dx.anonymousmessenger.crypto.PasswordStrengthEstimator.WEAK;
-
 public class StrengthMeter extends ProgressBar {
 
     private static final int MAX = 100;

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/custom/TapSafeFrameLayout.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.custom;
 
+import static android.view.MotionEvent.FLAG_WINDOW_IS_OBSCURED;
+
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
@@ -9,8 +11,6 @@ import android.widget.FrameLayout;
 import androidx.annotation.AttrRes;
 import androidx.annotation.Nullable;
 
-import static android.view.MotionEvent.FLAG_WINDOW_IS_OBSCURED;
-
 public class TapSafeFrameLayout extends FrameLayout {
 
     @Nullable

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/custom/TapSafeToolbar.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.custom;
 
+import static android.view.MotionEvent.FLAG_WINDOW_IS_OBSCURED;
+
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
@@ -8,8 +10,6 @@ import android.view.View;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
-import static android.view.MotionEvent.FLAG_WINDOW_IS_OBSCURED;
-
 public class TapSafeToolbar  extends androidx.appcompat.widget.Toolbar{
 
     @Nullable

+ 3 - 0
app/src/main/java/com/dx/anonymousmessenger/ui/view/app/AppFragment.java

@@ -494,6 +494,9 @@ public class AppFragment extends Fragment {
                     if(account.getProfileImagePath().equals("")){
                         throw new Resources.NotFoundException("");
                     }
+
+                    //commented this out because I was not able to make the profile image small enough here to fit in an icon correctly...
+
 //                    byte[] image = FileHelper.getFile(((DxApplication) requireActivity().getApplication()).getAccount().getProfileImagePath(), ((DxApplication) requireActivity().getApplication()));
 //                    if (image == null) {
 //                        throw new Resources.NotFoundException("");

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/view/app/ContactListAdapter.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.view.app;
 
+import static androidx.recyclerview.widget.RecyclerView.ViewHolder;
+
 import android.annotation.SuppressLint;
 import android.app.ActivityOptions;
 import android.app.AlertDialog;
@@ -35,8 +37,6 @@ import com.dx.anonymousmessenger.util.Utils;
 
 import java.util.List;
 
-import static androidx.recyclerview.widget.RecyclerView.ViewHolder;
-
 public class ContactListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
     private static final int VIEW_TYPE_READ = 1;
     private static final int VIEW_TYPE_UNREAD = 2;

+ 1 - 3
app/src/main/java/com/dx/anonymousmessenger/ui/view/app/PasswordEntryFragment.java

@@ -85,9 +85,7 @@ public class PasswordEntryFragment extends Fragment {
         ((MaterialToolbar)requireActivity().findViewById(R.id.toolbar)).setNavigationIcon(R.drawable.ic_stat_name);
         //try the easy password here and login if it works
         login(true);
-        btn_next.setOnClickListener(v -> {
-            login(false);
-        });
+        btn_next.setOnClickListener(v -> login(false));
 
         txtPassword.addTextChangedListener(new TextWatcher() {
             @Override

+ 42 - 44
app/src/main/java/com/dx/anonymousmessenger/ui/view/call/CallActivity.java

@@ -231,25 +231,24 @@ public class CallActivity extends DxActivity {
     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
         super.onRequestPermissionsResult(requestCode, permissions, grantResults);
         if (requestCode == REQUEST_CODE) {// If request is cancelled, the result arrays are empty.
-            if (grantResults.length > 0 &&
-                    grantResults[0] == PackageManager.PERMISSION_GRANTED) {
-                // Permission is granted. Continue the action or workflow
-                // in your app.
-            } else {
-                new AlertDialog.Builder(getApplicationContext(), R.style.AppAlertDialog)
-                        .setTitle("Denied Microphone Permission")
-                        .setMessage("this way you can't make or receive calls")
-                        .setIcon(android.R.drawable.ic_dialog_alert)
-                        .setPositiveButton(R.string.ask_me_again, (dialog, which) -> getMicrophonePerms())
-                        .setNegativeButton(R.string.no_thanks, (dialog, which) -> {
+            if (grantResults.length <= 0 ||
+                    grantResults[0] != PackageManager.PERMISSION_GRANTED) {
+                        new AlertDialog.Builder(getApplicationContext(), R.style.AppAlertDialog)
+                                .setTitle("Denied Microphone Permission")
+                                .setMessage("this way you can't make or receive calls")
+                                .setIcon(android.R.drawable.ic_dialog_alert)
+                                .setPositiveButton(R.string.ask_me_again, (dialog, which) -> getMicrophonePerms())
+                                .setNegativeButton(R.string.no_thanks, (dialog, which) -> {
+
+                                });
+                        // Explain to the user that the feature is unavailable because
+                        // the features requires a permission that the user has denied.
+                        // At the same time, respect the user's decision. Don't link to
+                        // system settings in an effort to convince the user to change
+                        // their decision.
+                    }  // Permission is granted. Continue the action or workflow
+            // in your app.
 
-                        });
-                // Explain to the user that the feature is unavailable because
-                // the features requires a permission that the user has denied.
-                // At the same time, respect the user's decision. Don't link to
-                // system settings in an effort to convince the user to change
-                // their decision.
-            }
         }
         // Other 'case' lines to check for other
         // permissions this app might request.
@@ -257,33 +256,32 @@ public class CallActivity extends DxActivity {
 
     public void getMicrophonePerms(){
         if (ContextCompat.checkSelfPermission(
-                this, Manifest.permission.RECORD_AUDIO) ==
-                PackageManager.PERMISSION_GRANTED) {
-            // You can use the API that requires the permission.
-
-        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-            if (shouldShowRequestPermissionRationale(Manifest.permission.RECORD_AUDIO)) {
-                // In an educational UI, explain to the user why your app requires this
-                // permission for a specific feature to behave as expected. In this UI,
-                // include a "cancel" or "no thanks" button that allows the user to
-                // continue using your app without granting the permission.
-                new AlertDialog.Builder(getApplicationContext(),R.style.AppAlertDialog)
-                        .setTitle(R.string.mic_perm_ask_title)
-                        .setMessage(R.string.why_need_mic)
-                        .setIcon(android.R.drawable.ic_dialog_alert)
-                        .setPositiveButton(R.string.ask_for_mic_btn, (dialog, which) -> requestPermissions(
-                                new String[] { Manifest.permission.RECORD_AUDIO },
-                                REQUEST_CODE))
-                        .setNegativeButton(R.string.no_thanks, (dialog, which) -> {
+                this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+                if (shouldShowRequestPermissionRationale(Manifest.permission.RECORD_AUDIO)) {
+                    // In an educational UI, explain to the user why your app requires this
+                    // permission for a specific feature to behave as expected. In this UI,
+                    // include a "cancel" or "no thanks" button that allows the user to
+                    // continue using your app without granting the permission.
+                    new AlertDialog.Builder(getApplicationContext(),R.style.AppAlertDialog)
+                            .setTitle(R.string.mic_perm_ask_title)
+                            .setMessage(R.string.why_need_mic)
+                            .setIcon(android.R.drawable.ic_dialog_alert)
+                            .setPositiveButton(R.string.ask_for_mic_btn, (dialog, which) -> requestPermissions(
+                                    new String[] { Manifest.permission.RECORD_AUDIO },
+                                    REQUEST_CODE))
+                            .setNegativeButton(R.string.no_thanks, (dialog, which) -> {
 
-                        });
-            } else {
-                // You can directly ask for the permission.
-                // The registered ActivityResultCallback gets the result of this request.
-                requestPermissions(
-                        new String[] { Manifest.permission.RECORD_AUDIO },
-                        REQUEST_CODE);
+                            });
+                } else {
+                    // You can directly ask for the permission.
+                    // The registered ActivityResultCallback gets the result of this request.
+                    requestPermissions(
+                            new String[] { Manifest.permission.RECORD_AUDIO },
+                            REQUEST_CODE);
+                }
             }
-        }
+        }  // You can use the API that requires the permission.
+
     }
 }

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/view/log/LogRecycleViewAdapter.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.view.log;
 
+import static androidx.core.content.ContextCompat.getSystemService;
+
 import android.app.AlertDialog;
 import android.content.ClipData;
 import android.content.ClipboardManager;
@@ -24,8 +26,6 @@ import com.google.android.material.snackbar.Snackbar;
 import java.util.List;
 import java.util.Objects;
 
-import static androidx.core.content.ContextCompat.getSystemService;
-
 
 public class LogRecycleViewAdapter extends RecyclerView.Adapter<LogRecycleViewAdapter.ViewHolder>{
     final Context context;

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/view/message_list/MessageListActivity.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.view.message_list;
 
+import static java.util.Objects.requireNonNull;
+
 import android.Manifest;
 import android.annotation.SuppressLint;
 import android.app.ActivityOptions;
@@ -82,8 +84,6 @@ import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicReference;
 
-import static java.util.Objects.requireNonNull;
-
 public class MessageListActivity extends DxActivity implements ActivityCompat.OnRequestPermissionsResultCallback, ComponentCallbacks2, ContactListAdapter.ItemClickListener, CallBack {
 
     private static final int READ_STORAGE_REQUEST_CODE = 1;

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/view/notepad/NotepadRecycleViewAdapter.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.view.notepad;
 
+import static androidx.core.content.ContextCompat.getSystemService;
+
 import android.annotation.SuppressLint;
 import android.app.AlertDialog;
 import android.content.ClipData;
@@ -25,8 +27,6 @@ import com.google.android.material.snackbar.Snackbar;
 import java.util.List;
 import java.util.Objects;
 
-import static androidx.core.content.ContextCompat.getSystemService;
-
 public class NotepadRecycleViewAdapter extends RecyclerView.Adapter<NotepadRecycleViewAdapter.ViewHolder>{
     final Context context;
     final LayoutInflater mInflater;

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/view/setup/BridgeRecyclerViewAdapter.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.view.setup;
 
+import static androidx.core.content.ContextCompat.getSystemService;
+
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.ClipData;
@@ -24,8 +26,6 @@ import com.google.android.material.snackbar.Snackbar;
 import java.util.List;
 import java.util.Objects;
 
-import static androidx.core.content.ContextCompat.getSystemService;
-
 public class BridgeRecyclerViewAdapter extends RecyclerView.Adapter<BridgeRecyclerViewAdapter.ViewHolder>{
     final Context context;
     final LayoutInflater mInflater;

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/view/setup/SetupUsernameFragment.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.view.setup;
 
+import static android.view.inputmethod.EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING;
+
 import android.os.Build;
 import android.os.Bundle;
 import android.text.Editable;
@@ -19,8 +21,6 @@ import com.google.android.material.textfield.TextInputEditText;
 
 import java.util.Objects;
 
-import static android.view.inputmethod.EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING;
-
 public class SetupUsernameFragment extends Fragment {
     private String error;
 

+ 2 - 2
app/src/main/java/com/dx/anonymousmessenger/ui/view/single_activity/MyProfileActivity.java

@@ -1,5 +1,7 @@
 package com.dx.anonymousmessenger.ui.view.single_activity;
 
+import static java.util.Objects.requireNonNull;
+
 import android.Manifest;
 import android.app.AlertDialog;
 import android.content.ClipData;
@@ -35,8 +37,6 @@ import com.google.android.material.snackbar.Snackbar;
 import com.google.android.material.textfield.TextInputEditText;
 import com.google.android.material.textfield.TextInputLayout;
 
-import static java.util.Objects.requireNonNull;
-
 public class MyProfileActivity extends DxActivity {
 
     private static final int STORAGE_CODE = 0;

+ 5 - 0
app/src/main/res/values-ar/strings.xml

@@ -330,4 +330,9 @@
     <string name="light_theme">السمة المضيئة</string>
     <string name="invalid_bridge">جسر غير صالح</string>
     <string name="bridge_added">تمت إضافة جسر</string>
+    <string name="nickname_help_explain">إضغط للحصول على مزيد من المعلومات حول إستعمال الإسم المستعار</string>
+    <string name="no_recent_messages">لا توجد رسائل حديثة</string>
+    <string name="unpinned_messages_get_deleted">هل تعلم أن الرسائل غير المثبتة تختفي بعد 24 ساعة؟</string>
+    <string name="continue_without_password">لا تستعمل كلمة مرور</string>
+    <string name="verify_identity_how_to">قارن هذه الأرقام على الجهازين, إذا كانا متماثلين إذا التشفير يعمل بشكل صحيح...</string>
 </resources>