split the Rotate button to 3 orientations

This commit is contained in:
tibbi 2017-11-08 21:22:35 +01:00
parent b41f1e97e6
commit 43d49beca0
2 changed files with 18 additions and 4 deletions

View File

@ -286,7 +286,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
R.id.menu_edit -> openEditor(Uri.fromFile(getCurrentFile()))
R.id.menu_properties -> showProperties()
R.id.menu_show_on_map -> showOnMap()
R.id.menu_rotate -> rotateImage()
R.id.menu_rotate_right -> rotateImage(90)
R.id.menu_rotate_left -> rotateImage(270)
R.id.menu_rotate_one_eighty -> rotateImage(180)
R.id.menu_lock_orientation -> toggleLockOrientation()
R.id.menu_save_as -> saveImageAs()
R.id.menu_settings -> launchSettings()
@ -469,8 +471,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
}
private fun rotateImage() {
mRotationDegrees = (mRotationDegrees + 90) % 360
private fun rotateImage(degrees: Int) {
mRotationDegrees = (mRotationDegrees + degrees) % 360
getCurrentFragment()?.let {
(it as? PhotoFragment)?.rotateImageViewBy(mRotationDegrees)
}

View File

@ -21,7 +21,19 @@
android:id="@+id/menu_rotate"
android:icon="@drawable/ic_rotate_right"
android:title="@string/rotate"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom">
<menu>
<item
android:id="@+id/menu_rotate_right"
android:title="@string/rotate_right"/>
<item
android:id="@+id/menu_rotate_left"
android:title="@string/rotate_left"/>
<item
android:id="@+id/menu_rotate_one_eighty"
android:title="@string/rotate_one_eighty"/>
</menu>
</item>
<item
android:id="@+id/menu_share_2"
android:icon="@drawable/ic_share"