mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
fix bug if already in landscape mode, and improve tablet support
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- in small devices (e.i. not tablets) in landscape height is low, better enter fullscreen -->
|
||||
<bool name="webxdcFullscreen">true</bool>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- if the device is big enough (ex. a tablet), there is no need to enter fullscreen -->
|
||||
<bool name="webxdcFullscreen">false</bool>
|
||||
</resources>
|
||||
@@ -258,4 +258,6 @@
|
||||
<attr name="compact" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- in portrait mode there is enough height, no need to enter fullscreen -->
|
||||
<bool name="webxdcFullscreen">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -101,6 +101,10 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
protected void onCreate(Bundle state, boolean ready) {
|
||||
super.onCreate(state, ready);
|
||||
|
||||
// enter fullscreen mode if necessary,
|
||||
// this is needed here because if the app is opened while already in landscape mode, onConfigurationChanged() is not triggered
|
||||
setScreenMode();
|
||||
|
||||
webView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
@RequiresApi(21)
|
||||
@@ -203,14 +207,14 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
Log.i(TAG, "onConfigurationChanged(" + newConfig.orientation + ")");
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
setFullscreen(true);
|
||||
} else {
|
||||
setFullscreen(false);
|
||||
}
|
||||
// orientation might have changed, enter/exit fullscreen mode if needed
|
||||
setScreenMode();
|
||||
}
|
||||
|
||||
private void setFullscreen(boolean enable) {
|
||||
private void setScreenMode() {
|
||||
// enter/exit fullscreen mode depending on orientation (landscape/portrait),
|
||||
// on tablets there is enought height so fullscreen mode is never enabled there
|
||||
boolean enable = getResources().getBoolean(R.bool.webxdcFullscreen);
|
||||
getWindow().getDecorView().setSystemUiVisibility(enable? View.SYSTEM_UI_FLAG_FULLSCREEN : 0);
|
||||
if (enable) {
|
||||
getSupportActionBar().hide();
|
||||
|
||||
Reference in New Issue
Block a user