mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-15 06:56:30 +00:00
- Tablets now support landscape mode, phones remain portrait-only - Add OrientationAwareActivity base class for orientation management - Add DeviceUtils.isTablet() for runtime device detection - Update MainActivity and GeohashPickerActivity to extend OrientationAwareActivity - Uses multiple detection criteria (screen size, density, configuration) Fixes #480
29 lines
901 B
Kotlin
29 lines
901 B
Kotlin
package com.bitchat.android.ui
|
|
|
|
import android.content.pm.ActivityInfo
|
|
import android.os.Bundle
|
|
import androidx.activity.ComponentActivity
|
|
import com.bitchat.android.utils.DeviceUtils
|
|
|
|
/**
|
|
* Base activity that automatically sets orientation based on device type.
|
|
* Tablets can rotate to landscape, phones are locked to portrait.
|
|
*/
|
|
abstract class OrientationAwareActivity : ComponentActivity() {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setOrientationBasedOnDeviceType()
|
|
}
|
|
|
|
private fun setOrientationBasedOnDeviceType() {
|
|
requestedOrientation = if (DeviceUtils.isTablet(this)) {
|
|
// Allow all orientations on tablets
|
|
ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
|
} else {
|
|
// Lock to portrait on phones
|
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
|
}
|
|
}
|
|
}
|