From 9d3aa97d67cd5e266b6029f7c0d95834c7b95922 Mon Sep 17 00:00:00 2001 From: Eric Robertson <7073491+erobertson42@users.noreply.github.com> Date: Fri, 28 Jun 2019 16:35:13 -0400 Subject: [PATCH] fix always fullscreen mode The window layout was always being set to FULLSCREEN mode to workaround a flickering status bar bug, but it did not respect the app preference and return to FORCE_NOT_FULLSCREEN when applicable. This had a side effect of breaking the adjustResize windowSoftInputMode setting, where the soft keyboard being shown would not resize the viewport. --- src/android/XAPKDownloaderActivity.java | 49 +++++++++++++++++++------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/android/XAPKDownloaderActivity.java b/src/android/XAPKDownloaderActivity.java index c6af005..92af158 100644 --- a/src/android/XAPKDownloaderActivity.java +++ b/src/android/XAPKDownloaderActivity.java @@ -47,6 +47,8 @@ public class XAPKDownloaderActivity extends Activity implements IDownloaderClien private boolean progressInMB = false; private boolean autoReload = true; private Bundle bundle; + private int flagFS = WindowManager.LayoutParams.FLAG_FULLSCREEN; + private int flagNFS = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; // public static Activity cordovaActivity = null; @@ -81,15 +83,11 @@ boolean allExpansionFilesKnownAsDelivered (int[] versionList, long[] fileSizeLis } @Override public void onCreate (Bundle savedInstanceState) { - - if (cordovaActivity != null) { - // - cordovaActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - cordovaActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - // - } - super.onCreate (savedInstanceState); + + // We can't attempt downloading the files with a debug signature. + if (signatureIsDebug(this)) {Log.v (LOG_TAG, "Using debug signature: no download is possible."); finish (); return;} + xmlData = getIntent().getExtras(); // savedInstanceState; versionList[0] = this.getIntent().getIntExtra ("xapk_main_version" , 0); versionList[1] = this.getIntent().getIntExtra ("xapk_patch_version" , 0); @@ -106,7 +104,15 @@ boolean allExpansionFilesKnownAsDelivered (int[] versionList, long[] fileSizeLis } // Check if both expansion files are already available and downloaded before going any further. - if (allExpansionFilesKnownAsDelivered(versionList, fileSizeList)) {Log.v (LOG_TAG, "Files are already present."); finish (); return;} + if (allExpansionFilesKnownAsDelivered(versionList, fileSizeList)) {Log.v (LOG_TAG, "Files are already present."); finish (); return;} + + boolean forceNotFullScreen = (cordovaActivity.getWindow().getAttributes().flags & flagNFS) != 0; + + if (cordovaActivity != null) { + // + setFullscreen(true); + // + } // Download the expansion file(s). try { @@ -126,9 +132,6 @@ boolean allExpansionFilesKnownAsDelivered (int[] versionList, long[] fileSizeLis PendingIntent pendingIntent = PendingIntent.getActivity (this, 0, notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT); - // We can't attempt downloading the files with a debug signature. - if (signatureIsDebug(this)) {Log.v (LOG_TAG, "Using debug signature: no download is possible."); finish (); return;} - // Start the download service, if required. Log.v (LOG_TAG, "Starting the download service."); int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired (this, pendingIntent, XAPKDownloaderService.class); @@ -139,6 +142,12 @@ boolean allExpansionFilesKnownAsDelivered (int[] versionList, long[] fileSizeLis LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent); } Log.v (LOG_TAG, "No download required."); + + // If the app was not fullscreen but forced to be by the flickering status bar bug workaround, change it back + if (forceNotFullScreen != ((cordovaActivity.getWindow().getAttributes().flags & flagNFS) != 0)) { + setFullscreen(false); + } + finish (); return; } @@ -169,6 +178,12 @@ boolean allExpansionFilesKnownAsDelivered (int[] versionList, long[] fileSizeLis } mProgressDialog.show (); + + // If the app was not fullscreen but forced to be by the flickering status bar bug workaround, change it back + if (forceNotFullScreen != ((cordovaActivity.getWindow().getAttributes().flags & flagNFS) != 0)) { + setFullscreen(false); + } + return; } catch (NameNotFoundException e) { @@ -326,4 +341,14 @@ private boolean signatureIsDebug (Context ctx) { } return isDebug; } + + + // Set fullscreen mode on or off + private void setFullscreen(boolean fs) { + int off = (fs) ? flagNFS : flagFS; + int on = (fs) ? flagFS : flagNFS; + + cordovaActivity.getWindow().clearFlags(off); + cordovaActivity.getWindow().setFlags(on, on); + } }