Commit 438b7c6e authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Android WebAPKs] Do not remove task when user presses back in new-style WebAPK

- This CL changes the back button when a user is in a WebAPK from using
Activity#finish() to using Activity#finishAndRemoveTask()
- Activity#finishAndRemoveTask() is still used if the user pressed back
while the splash screen is up because WebApkActivity is still translucent
at this point and Activity#finish() causes an ugly transition when
WebApkActivity is translucent.

BUG=982956

Change-Id: Ie39b2c6902bef2d22e6052a47013f15975fbb611
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717556
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarPavel Shmakov <pshmakov@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681846}
parent 90301bb8
......@@ -157,6 +157,10 @@ public class SplashController extends EmptyTabObserver implements InflationObser
mParentView.addView(mSplashView);
}
public boolean isSplashShowing() {
return mSplashView != null;
}
@VisibleForTesting
View getSplashScreenForTests() {
return mSplashView;
......
......@@ -134,7 +134,7 @@ public class WebApkActivity extends WebappActivity {
protected boolean handleBackPressed() {
if (super.handleBackPressed()) return true;
if (getWebappInfo().isSplashProvidedByWebApk()) {
if (getWebappInfo().isSplashProvidedByWebApk() && isSplashShowing()) {
// When the WebAPK provides the splash screen, the splash screen activity is stacked
// underneath the WebAPK. The splash screen finishes itself in
// {@link Activity#onResume()}. When finishing the WebApkActivity, there is sometimes a
......
......@@ -899,6 +899,10 @@ public class WebappActivity extends SingleTabActivity {
getWindowAndroid(), (byte) mWebappInfo.orientation());
}
protected boolean isSplashShowing() {
return mSplashController.isSplashShowing();
}
/**
* Register an observer to the splashscreen hidden/visible events for this activity.
*/
......
......@@ -51,9 +51,7 @@
[[#use_new_splash]]
<activity android:name="org.chromium.webapk.shell_apk.h2o.H2OOpaqueMainActivity"
android:theme="@style/SplashTheme"
android:relinquishTaskIdentity="true"
android:excludeFromRecents="true"
android:noHistory="true">
android:relinquishTaskIdentity="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
......
......@@ -12,4 +12,4 @@
# //chrome/android/webapk/shell_apk:webapk is changed. This includes
# Java files, Android resource files and AndroidManifest.xml. Does not affect
# Chrome.apk
current_shell_apk_version = 101
current_shell_apk_version = 102
......@@ -5,7 +5,6 @@
package org.chromium.webapk.shell_apk;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
......@@ -282,14 +281,6 @@ public class WebApkUtils {
.setData(Uri.parse("http://"));
}
public static void finishAndRemoveTask(Activity activity) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
activity.finishAndRemoveTask();
} else {
activity.finish();
}
}
public static String getNotificationChannelName(Context context) {
return context.getString(R.string.notification_channel_name);
}
......
......@@ -35,5 +35,6 @@ public class H2OOpaqueMainActivity extends Activity {
overridePendingTransition(0, 0);
H2OLauncher.copyIntentExtrasAndLaunch(
appContext, getIntent(), null, new ComponentName(appContext, SplashActivity.class));
finish();
}
}
......@@ -104,7 +104,7 @@ public class SplashActivity extends Activity {
super.onResume();
mResumed = true;
if (mResult == ActivityResult.CANCELED) {
WebApkUtils.finishAndRemoveTask(this);
finish();
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment