Skip to content

Commit

Permalink
Merge pull request #139 from erobertson42/cordova-6.5.0_issue115
Browse files Browse the repository at this point in the history
fix always fullscreen mode + check for debug mode when trying to download
  • Loading branch information
agamemnus authored Jun 28, 2019
2 parents 81293fa + 9d3aa97 commit 7fefcc3
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions src/android/XAPKDownloaderActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// <Workaround for Cordova/Crosswalk flickering status bar bug./>
public static Activity cordovaActivity = null;
Expand Down Expand Up @@ -81,15 +83,11 @@ boolean allExpansionFilesKnownAsDelivered (int[] versionList, long[] fileSizeLis
}

@Override public void onCreate (Bundle savedInstanceState) {

if (cordovaActivity != null) {
// <Workaround for Cordova/Crosswalk flickering status bar bug./>
cordovaActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
cordovaActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// <Workaround for Cordova/Crosswalk flickering status bar bug./>
}

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);
Expand All @@ -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) {
// <Workaround for Cordova/Crosswalk flickering status bar bug./>
setFullscreen(true);
// <Workaround for Cordova/Crosswalk flickering status bar bug./>
}

// Download the expansion file(s).
try {
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 7fefcc3

Please sign in to comment.