move flash/flip-cam toggles

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-09-17 13:31:45 +02:00
parent c78967b6b1
commit 03cb3a66c6
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
6 changed files with 26 additions and 28 deletions

View file

@ -97,10 +97,6 @@ public class TakePhotoActivity extends AppCompatActivity {
imageCapture,
preview);
viewModel.getCameraSelectorToggleButtonImageResource()
.observe(
this,
res -> binding.switchCamera.setIcon(ContextCompat.getDrawable(this, res)));
viewModel.getTorchToggleButtonImageResource()
.observe(
this,

View file

@ -38,9 +38,7 @@ public class TakePictureViewModel extends ViewModel {
@NonNull
private CameraSelector cameraSelector = DEFAULT_BACK_CAMERA;
@NonNull
private final MutableLiveData<Integer> cameraSelectorToggleButtonImageResource =
new MutableLiveData<>(R.drawable.ic_baseline_camera_front_24);
@NonNull
private final MutableLiveData<Boolean> torchEnabled = new MutableLiveData<>(Boolean.FALSE);
@ -49,17 +47,11 @@ public class TakePictureViewModel extends ViewModel {
return this.cameraSelector;
}
public LiveData<Integer> getCameraSelectorToggleButtonImageResource() {
return this.cameraSelectorToggleButtonImageResource;
}
public void toggleCameraSelector() {
if (this.cameraSelector == DEFAULT_BACK_CAMERA) {
this.cameraSelector = DEFAULT_FRONT_CAMERA;
this.cameraSelectorToggleButtonImageResource.postValue(R.drawable.ic_baseline_camera_rear_24);
} else {
this.cameraSelector = DEFAULT_BACK_CAMERA;
this.cameraSelectorToggleButtonImageResource.postValue(R.drawable.ic_baseline_camera_front_24);
}
}

View file

@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#757575"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M10,20L5,20v2h5v2l3,-3 -3,-3v2zM14,20v2h5v-2h-5zM12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -1.99,0.9 -1.99,2S10.9,8 12,8zM17,0L7,0C5.9,0 5,0.9 5,2v14c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2L19,2c0,-1.1 -0.9,-2 -2,-2zM7,2h10v10.5c0,-1.67 -3.33,-2.5 -5,-2.5s-5,0.83 -5,2.5L7,2z"/>
</vector>

View file

@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#757575"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M10,20L5,20v2h5v2l3,-3 -3,-3v2zM14,20v2h5v-2h-5zM17,0L7,0C5.9,0 5,0.9 5,2v14c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2L19,2c0,-1.1 -0.9,-2 -2,-2zM12,6c-1.11,0 -2,-0.9 -2,-2s0.89,-2 1.99,-2 2,0.9 2,2C14,5.1 13.1,6 12,6z"/>
</vector>

View file

@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9,12c0,1.66 1.34,3 3,3s3,-1.34 3,-3s-1.34,-3 -3,-3S9,10.34 9,12z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M8,10V8H5.09C6.47,5.61 9.05,4 12,4c3.72,0 6.85,2.56 7.74,6h2.06c-0.93,-4.56 -4.96,-8 -9.8,-8C8.73,2 5.82,3.58 4,6.01V4H2v6H8z"/>
<path
android:fillColor="@android:color/white"
android:pathData="M16,14v2h2.91c-1.38,2.39 -3.96,4 -6.91,4c-3.72,0 -6.85,-2.56 -7.74,-6H2.2c0.93,4.56 4.96,8 9.8,8c3.27,0 6.18,-1.58 8,-4.01V20h2v-6H16z"/>
</vector>

View file

@ -52,6 +52,7 @@
android:layout_marginStart="0dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
android:contentDescription="@string/take_photo_toggle_torch"
android:insetLeft="4dp"
android:insetTop="4dp"
@ -66,8 +67,9 @@
app:iconPadding="0dp"
app:iconSize="24dp"
app:iconTint="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toBottomOf="@id/takePhoto"
app:layout_constraintEnd_toStartOf="@id/takePhoto"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/switchCamera"
@ -79,6 +81,7 @@
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="12dp"
android:contentDescription="@string/take_photo_switch_camera"
android:insetLeft="4dp"
android:insetTop="4dp"
@ -89,13 +92,14 @@
app:backgroundTint="#99121212"
app:cornerRadius="@dimen/button_corner_radius"
app:elevation="0dp"
app:icon="@drawable/ic_baseline_camera_front_24"
app:icon="@drawable/ic_baseline_flip_camera_android_24"
app:iconGravity="textStart"
app:iconPadding="0dp"
app:iconSize="24dp"
app:iconTint="@color/white"
app:layout_constraintEnd_toStartOf="@+id/toggle_torch"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toBottomOf="@id/takePhoto"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/takePhoto" />
<com.google.android.material.button.MaterialButton
android:id="@+id/retake"