make all top icons Buttons with same height

This commit is contained in:
darthpaul 2022-09-29 17:00:57 +01:00
parent a324da022a
commit c38bab6824
2 changed files with 25 additions and 10 deletions

View File

@ -402,7 +402,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
FLASH_ON -> R.drawable.ic_flash_on_vector
else -> R.drawable.ic_flash_auto_vector
}
toggle_flash.setImageResource(flashDrawable)
toggle_flash.icon = AppCompatResources.getDrawable(this, flashDrawable)
toggle_flash.transitionName = "${getString(R.string.toggle_flash)}$state"
}
@ -555,8 +555,20 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
private fun hasStorageAndCameraPermissions(): Boolean {
return if (mIsInPhotoMode) {
return if (mIsInPhotoMode) hasPhotoModePermissions() else hasVideoModePermissions()
}
private fun hasPhotoModePermissions(): Boolean {
return if (isTiramisuPlus()) {
hasPermission(PERMISSION_READ_MEDIA_IMAGES) && hasPermission(PERMISSION_CAMERA)
} else {
hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA)
}
}
private fun hasVideoModePermissions(): Boolean {
return if (isTiramisuPlus()) {
hasPermission(PERMISSION_READ_MEDIA_VIDEO) && hasPermission(PERMISSION_CAMERA) && hasPermission(PERMISSION_RECORD_AUDIO)
} else {
hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA) && hasPermission(PERMISSION_RECORD_AUDIO)
}
@ -619,7 +631,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
toggle_flash.beVisible()
} else {
toggle_flash.beInvisible()
toggle_flash.setImageResource(R.drawable.ic_flash_off_vector)
toggle_flash.icon = AppCompatResources.getDrawable(this, R.drawable.ic_flash_off_vector)
mPreview?.setFlashlightState(FLASH_OFF)
}
}
@ -728,7 +740,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
override fun displaySelectedResolution(resolutionOption: ResolutionOption) {
val imageRes = resolutionOption.imageDrawableResId
change_resolution.setImageResource(imageRes)
change_resolution.icon = AppCompatResources.getDrawable(this, imageRes)
change_resolution.transitionName = "${resolutionOption.buttonViewId}"
}

View File

@ -7,22 +7,24 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
<com.google.android.material.button.MaterialButton
android:id="@+id/toggle_flash"
style="@style/Widget.App.Button.OutlineButton.IconOnly"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="@string/toggle_flash"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_flash_off_vector"
app:icon="@drawable/ic_flash_off_vector"
app:layout_constraintEnd_toStartOf="@id/change_resolution"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
<com.google.android.material.button.MaterialButton
android:id="@+id/change_resolution"
style="@style/Widget.App.Button.OutlineButton.IconOnly"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -32,16 +34,17 @@
app:layout_constraintEnd_toStartOf="@id/settings"
app:layout_constraintStart_toEndOf="@id/toggle_flash"
app:layout_constraintTop_toTopOf="@id/toggle_flash"
tools:src="@drawable/ic_photo_4x3" />
tools:icon="@drawable/ic_photo_4x3" />
<ImageView
<com.google.android.material.button.MaterialButton
android:id="@+id/settings"
style="@style/Widget.App.Button.OutlineButton.IconOnly"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="@string/settings"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_settings_cog_vector"
app:icon="@drawable/ic_settings_cog_vector"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/change_resolution"
app:layout_constraintTop_toTopOf="@id/toggle_flash" />