mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #2661 from deltachat/adb/issue-2652
improve landscape mode for webxdc
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isLandscape">true</bool>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isBigScreen">true</bool>
|
||||
</resources>
|
||||
@@ -258,4 +258,7 @@
|
||||
<attr name="compact" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<bool name="isLandscape">false</bool>
|
||||
<!-- if the device is big enough (ex. a tablet) -->
|
||||
<bool name="isBigScreen">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -14,6 +15,7 @@ import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.webkit.ValueCallback;
|
||||
@@ -99,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)
|
||||
@@ -197,6 +203,26 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
Log.i(TAG, "onConfigurationChanged(" + newConfig.orientation + ")");
|
||||
super.onConfigurationChanged(newConfig);
|
||||
// orientation might have changed, enter/exit fullscreen mode if needed
|
||||
setScreenMode();
|
||||
}
|
||||
|
||||
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.isLandscape) && !getResources().getBoolean(R.bool.isBigScreen);
|
||||
getWindow().getDecorView().setSystemUiVisibility(enable? View.SYSTEM_UI_FLAG_FULLSCREEN : 0);
|
||||
if (enable) {
|
||||
getSupportActionBar().hide();
|
||||
} else {
|
||||
getSupportActionBar().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean openOnlineUrl(String url) {
|
||||
if (url.startsWith("mailto:")) {
|
||||
|
||||
Reference in New Issue
Block a user