let the quick camera remember front/back mode

fixes #4438
closes #4440

//FREEBIE
This commit is contained in:
agrajaghh 2015-11-08 02:12:02 +01:00 committed by Moxie Marlinspike
parent f82a7fee49
commit 9201d50f05
3 changed files with 16 additions and 1 deletions

View File

@ -40,6 +40,7 @@ import java.util.List;
import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.jobqueue.Job; import org.whispersystems.jobqueue.Job;
import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.JobParameters;
@ -72,7 +73,7 @@ public class CameraView extends FrameLayout {
super(context, attrs, defStyle); super(context, attrs, defStyle);
setBackgroundColor(Color.BLACK); setBackgroundColor(Color.BLACK);
if (isMultiCamera()) cameraId = CameraInfo.CAMERA_FACING_FRONT; if (isMultiCamera()) cameraId = TextSecurePreferences.getDirectCaptureCameraId(context);
surface = new CameraSurfaceView(getContext()); surface = new CameraSurfaceView(getContext());
onOrientationChange = new OnOrientationChange(context.getApplicationContext()); onOrientationChange = new OnOrientationChange(context.getApplicationContext());
@ -238,6 +239,7 @@ public class CameraView extends FrameLayout {
: CameraInfo.CAMERA_FACING_BACK; : CameraInfo.CAMERA_FACING_BACK;
onPause(); onPause();
onResume(); onResume();
TextSecurePreferences.setDirectCaptureCameraId(getContext(), cameraId);
} }
} }

View File

@ -125,6 +125,8 @@ public class QuickAttachmentDrawer extends ViewGroup implements InputView {
fullScreenButton = (ImageButton) controls.findViewById(R.id.fullscreen_button); fullScreenButton = (ImageButton) controls.findViewById(R.id.fullscreen_button);
if (cameraView.isMultiCamera()) { if (cameraView.isMultiCamera()) {
swapCameraButton.setVisibility(View.VISIBLE); swapCameraButton.setVisibility(View.VISIBLE);
swapCameraButton.setImageResource(cameraView.isRearCamera() ? R.drawable.quick_camera_front
: R.drawable.quick_camera_rear);
swapCameraButton.setOnClickListener(new CameraFlipClickListener()); swapCameraButton.setOnClickListener(new CameraFlipClickListener());
} }
shutterButton.setOnClickListener(new ShutterClickListener()); shutterButton.setOnClickListener(new ShutterClickListener());

View File

@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.util;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.hardware.Camera.CameraInfo;
import android.os.Build; import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
@ -92,6 +93,16 @@ public class TextSecurePreferences {
public static final String SYSTEM_EMOJI_PREF = "pref_system_emoji"; public static final String SYSTEM_EMOJI_PREF = "pref_system_emoji";
private static final String MULTI_DEVICE_PROVISIONED_PREF = "pref_multi_device"; private static final String MULTI_DEVICE_PROVISIONED_PREF = "pref_multi_device";
public static final String DIRECT_CAPTURE_CAMERA_ID = "pref_direct_capture_camera_id";
public static void setDirectCaptureCameraId(Context context, int value) {
setIntegerPrefrence(context, DIRECT_CAPTURE_CAMERA_ID, value);
}
@SuppressWarnings("deprecation")
public static int getDirectCaptureCameraId(Context context) {
return getIntegerPreference(context, DIRECT_CAPTURE_CAMERA_ID, CameraInfo.CAMERA_FACING_FRONT);
}
public static void setMultiDevice(Context context, boolean value) { public static void setMultiDevice(Context context, boolean value) {
setBooleanPreference(context, MULTI_DEVICE_PROVISIONED_PREF, value); setBooleanPreference(context, MULTI_DEVICE_PROVISIONED_PREF, value);