瀏覽代碼

Fix #91

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 年之前
父節點
當前提交
45916be8c9

+ 20 - 7
app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

@@ -202,7 +202,9 @@ public class CallActivity extends AppCompatActivity {
     private View.OnClickListener videoOnClickListener;
 
     private String baseUrl;
-    
+
+    private boolean initialPermissionsCheck = true;
+
     private static int getSystemUiVisibility() {
         int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
         flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
@@ -412,7 +414,7 @@ public class CallActivity extends AppCompatActivity {
                     R.string.nc_permissions_settings, this);
         } else {
             EffortlessPermissions.requestPermissions(this, R.string.nc_permissions_audio,
-                    100, PERMISSIONS_MICROPHONE);
+                    R.string.nc_proceed, R.string.nc_empty, 100, PERMISSIONS_MICROPHONE);
         }
     }
 
@@ -448,7 +450,7 @@ public class CallActivity extends AppCompatActivity {
                     R.string.nc_permissions_settings, this);
         } else {
             EffortlessPermissions.requestPermissions(this, R.string.nc_permissions_video,
-                    100, PERMISSIONS_CAMERA);
+                    R.string.nc_proceed, R.string.nc_empty, 100, PERMISSIONS_CAMERA);
         }
 
     }
@@ -525,13 +527,14 @@ public class CallActivity extends AppCompatActivity {
 
     private void checkPermissions() {
         EffortlessPermissions.requestPermissions(this, R.string.nc_permissions,
-                100, PERMISSIONS_CALL);
+                R.string.nc_proceed, R.string.nc_empty, 100, PERMISSIONS_CALL);
+
     }
 
     @AfterPermissionGranted(100)
     private void onPermissionsGranted() {
         if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CALL)) {
-            if (!videoOn) {
+            if (!videoOn && !initialPermissionsCheck) {
                 onCameraClick();
             }
 
@@ -544,7 +547,11 @@ public class CallActivity extends AppCompatActivity {
             }
 
             if (cameraSwitchButton != null && cameraEnumerator.getDeviceNames().length > 1) {
-                cameraSwitchButton.setVisibility(View.VISIBLE);
+                if (!initialPermissionsCheck) {
+                    cameraSwitchButton.setVisibility(View.VISIBLE);
+                } else {
+                    cameraSwitchButton.setVisibility(View.GONE);
+                }
             }
 
             if (!inCall) {
@@ -554,6 +561,8 @@ public class CallActivity extends AppCompatActivity {
                 PERMISSIONS_CALL)) {
             checkIfSomeAreApproved();
         }
+
+        initialPermissionsCheck = false;
     }
 
     private void checkIfSomeAreApproved() {
@@ -565,12 +574,13 @@ public class CallActivity extends AppCompatActivity {
             cameraSwitchButton.setVisibility(View.VISIBLE);
         }
 
-        if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CAMERA)) {
+        if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CAMERA) && !initialPermissionsCheck) {
             if (!videoOn) {
                 onCameraClick();
             }
         } else {
             cameraControlButton.getFrontImageView().setImageResource(R.drawable.ic_videocam_off_white_24px);
+            cameraControlButton.setAlpha(0.7f);
             if (cameraSwitchButton != null) {
                 cameraSwitchButton.setVisibility(View.GONE);
             }
@@ -591,6 +601,7 @@ public class CallActivity extends AppCompatActivity {
 
     @AfterPermissionDenied(100)
     private void onPermissionsDenied() {
+        initialPermissionsCheck = false;
         if (cameraEnumerator.getDeviceNames().length == 0) {
             cameraControlButton.setVisibility(View.GONE);
         } else if (cameraEnumerator.getDeviceNames().length == 1) {
@@ -600,6 +611,8 @@ public class CallActivity extends AppCompatActivity {
         if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CAMERA) ||
                 EffortlessPermissions.hasPermissions(this, PERMISSIONS_MICROPHONE)) {
             checkIfSomeAreApproved();
+        } else if (!inCall) {
+            startCall();
         }
     }
 

+ 1 - 1
app/src/main/java/com/nextcloud/talk/api/NcApi.java

@@ -180,7 +180,7 @@ public interface NcApi {
     */
     @FormUrlEncoded
     @POST
-    Observable<SignalingOverall> sendSignalingMessages(@Nullable@Header("Authorization") String authorization, @Url String url,
+    Observable<SignalingOverall> sendSignalingMessages(@Nullable @Header("Authorization") String authorization, @Url String url,
                                                        @Field("messages") String messages);
 
     /*

+ 1 - 1
app/src/main/java/com/nextcloud/talk/application/NextcloudTalkApplication.java

@@ -134,7 +134,7 @@ public class NextcloudTalkApplication extends MultiDexApplication implements Pro
         new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true).startNow().build().schedule();
 
     }
-    
+
     @Override
     public void onTerminate() {
         super.onTerminate();

+ 3 - 3
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java

@@ -462,9 +462,9 @@ public class ContactsController extends BaseController implements SearchView.OnQ
         fastScroller.setBubbleTextCreator(position -> {
             IFlexible abstractFlexibleItem = adapter.getItem(position);
             if (abstractFlexibleItem instanceof UserItem) {
-                return ((UserItem)adapter.getItem(position)).getHeader().getModel();
+                return ((UserItem) adapter.getItem(position)).getHeader().getModel();
             } else {
-                return ((UserHeaderItem)adapter.getItem(position)).getModel();
+                return ((UserHeaderItem) adapter.getItem(position)).getModel();
             }
         });
     }
@@ -585,7 +585,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
         } else if (adapter.getItem(position) instanceof NewCallHeaderItem) {
             adapter.toggleSelection(position);
             isPublicCall = adapter.isSelected(position);
-            ((NewCallHeaderItem)adapter.getItem(position)).togglePublicCall(isPublicCall);
+            ((NewCallHeaderItem) adapter.getItem(position)).togglePublicCall(isPublicCall);
             checkAndHandleBottomButtons();
         }
         return true;

+ 5 - 7
app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java

@@ -75,15 +75,8 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
     private Room room;
     private List<AbstractFlexibleItem> menuItems;
     private FlexibleAdapter<AbstractFlexibleItem> adapter;
-
-    @Parcel
-    public enum MenuType {
-        REGULAR, SHARE, NEW_CONVERSATION
-    }
-
     private MenuType menuType;
     private Intent shareIntent;
-
     public CallMenuController(Bundle args) {
         super(args);
         this.room = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ROOM));
@@ -262,4 +255,9 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
 
         return true;
     }
+
+    @Parcel
+    public enum MenuType {
+        REGULAR, SHARE, NEW_CONVERSATION
+    }
 }

+ 1 - 1
app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java

@@ -215,7 +215,7 @@ public class EntryMenuController extends BaseController {
                         }
                     } else if (editText.getText().toString().startsWith("http://") ||
                             editText.getText().toString().startsWith("https://") &&
-                            editText.getText().toString().contains("/call/")) {
+                                    editText.getText().toString().contains("/call/")) {
                         // operation code 10
                         if (!proceedButton.isEnabled()) {
                             proceedButton.setEnabled(true);

+ 4 - 3
app/src/main/res/layout/activity_call.xml

@@ -62,7 +62,7 @@
             android:layout_width="60dp"
             android:layout_height="60dp"
             android:layout_marginEnd="20dp"
-            app:alpha="0.7"
+            android:alpha="0.7"
             app:checked="false"
             app:enableInitialAnimation="false"
             app:frontBackgroundColor="@color/colorPrimary"
@@ -74,7 +74,8 @@
             android:layout_width="60dp"
             android:layout_height="60dp"
             android:layout_marginEnd="20dp"
-            app:alpha="0.7"
+            android:alpha="0.7"
+            android:visibility="gone"
             app:checked="false"
             app:enableInitialAnimation="false"
             app:frontBackgroundColor="@color/colorPrimary"
@@ -86,7 +87,7 @@
             android:layout_width="60dp"
             android:layout_height="60dp"
             android:layout_marginEnd="20dp"
-            app:alpha="0.7"
+            android:alpha="0.7"
             app:checked="false"
             app:enableInitialAnimation="false"
             app:frontBackgroundColor="@color/colorPrimary"

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

@@ -131,4 +131,7 @@
     <string name="nc_talk_soon">\n\nTalk soon,\n %1$s</string>
     <string name="nc_share_subject">Call invitation</string>
     <string name="nc_share_text_pass">\n\nPassword for the call is: %1$s</string>
+
+    <!-- Magical stuff -->
+    <string name="nc_empty"></string>
 </resources>