Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix always fullscreen mode #139

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}