use just 1 orientation button at toggling orientation

This commit is contained in:
tibbi 2019-01-02 15:47:24 +01:00
parent 50dd2766c8
commit 528dc06a10
3 changed files with 12 additions and 15 deletions

View file

@ -124,7 +124,8 @@
<activity
android:name=".activities.VideoPlayerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"/>
android:configChanges="orientation|keyboardHidden|screenSize"
android:parentActivityName=".activities.MediaActivity"/>
<activity
android:name=".activities.PanoramaPhotoActivity"

View file

@ -25,10 +25,8 @@ import kotlinx.android.synthetic.main.activity_video_player.*
import java.io.File
open class VideoPlayerActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
private var mMedium: Medium? = null
private var mIsFullScreen = false
private var mCurrentOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
private var mFragment: ViewPagerFragment? = null
private var mUri: Uri? = null
@ -100,15 +98,18 @@ open class VideoPlayerActivity : SimpleActivity(), ViewPagerFragment.FragmentLis
}
when (item.itemId) {
R.id.menu_force_portrait -> forceOrientation(true)
R.id.menu_force_landscape -> forceOrientation(false)
R.id.menu_change_orientation -> changeOrientation()
else -> return super.onOptionsItemSelected(item)
}
return true
}
private fun forceOrientation(portrait: Boolean) {
private fun changeOrientation() {
requestedOrientation = if (resources.configuration.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
} else {
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
}
override fun fragmentClicked() {

View file

@ -2,14 +2,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_force_portrait"
android:icon="@drawable/ic_orientation_portrait"
android:title="@string/force_portrait"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_force_landscape"
android:icon="@drawable/ic_orientation_landscape"
android:title="@string/force_landscape"
android:id="@+id/menu_change_orientation"
android:icon="@drawable/ic_orientation_auto"
android:title="@string/change_orientation"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_share"