Skip to content
This repository has been archived by the owner on Nov 9, 2018. It is now read-only.

Commit

Permalink
Corrected Android N Home and Recent Apps buttons action
Browse files Browse the repository at this point in the history
Auditors: @bbondy
  • Loading branch information
SergeyZhukovsky committed Sep 9, 2016
1 parent a360832 commit ae6f643
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ public static class EndExpandTransitionEvent {
}

public static class BeginCollapseTransitionEvent {
public BeginCollapseTransitionEvent() {
mFromCloseSystemDialogs = false;
}

public BeginCollapseTransitionEvent(boolean fromCloseSystemDialogs) {
mFromCloseSystemDialogs = fromCloseSystemDialogs;
}

public float mPeriod;
public boolean mFromCloseSystemDialogs;
}

public static class EndCollapseTransitionEvent {
Expand Down Expand Up @@ -812,7 +821,7 @@ public void onCloseSystemDialogs() {
if (delta < 200) {
return;
}
switchToBubbleView();
switchToBubbleView(true);
}

// Before this version select elements would crash WebView in a background service
Expand Down Expand Up @@ -985,7 +994,7 @@ public void onSelected(ActionItem actionItem, boolean always) {
}
// L_WATCH: L currently lacks getRecentTasks(), so minimize here
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}
}
}
Expand Down Expand Up @@ -1292,10 +1301,10 @@ public void collapseBubbleFlow(long time) {
mBubbleFlowDraggable.collapse(time, mOnBubbleFlowCollapseFinishedListener);
}

public void switchToBubbleView() {
public void switchToBubbleView(boolean fromCloseSystemDialogs) {
mCanAutoDisplayLink = false;
if (MainController.get().getActiveTabCount() > 0) {
mBubbleDraggable.switchToBubbleView();
mBubbleDraggable.switchToBubbleView(fromCloseSystemDialogs);
} else {
// If there's no tabs, ensuring pressing Home will cause the CanvasView to go away. Fix #448
MainApplication.postEvent(mContext, new MainController.EndCollapseTransitionEvent());
Expand All @@ -1321,7 +1330,7 @@ public void endAppPolling() {
AppPoller.AppPollerListener mAppPollerListener = new AppPoller.AppPollerListener() {
@Override
public void onAppChanged() {
switchToBubbleView();
switchToBubbleView(false);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,6 @@ public void onReloadMainServiceEvent(ReloadMainServiceEvent event) {
@Override
public void onReceive(Context context, Intent myIntent) {
if (myIntent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
// TODO made a Nougat after SDK update. It's a fix for it to avoid delays on HOME and Recent Apps button click
if (Build.VERSION.SDK_INT >= 24) {
try {
Thread.sleep(300);
} catch (InterruptedException e) {

}
}
MainController.get().onCloseSystemDialogs();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,11 +856,6 @@ public Set<String> getFallbackRedirectHosts() {
public boolean redirectUrlToBrowser(URL url) {
String host = url.getHost();

for(String redirectHost : mFallbackRedirectHosts) {
if (host.endsWith("." + redirectHost)) {
return true;
}
}
String hostAlt = host.contains("www.") ? host.replace("www.", "") : "www." + host;
return mFallbackRedirectHosts.contains(host) || mFallbackRedirectHosts.contains(hostAlt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public void onCancel() {
});
}

public void switchToBubbleView() {
doAnimateToBubbleView(0);
public void switchToBubbleView(boolean fromCloseSystemDialogs) {
doAnimateToBubbleView(0, fromCloseSystemDialogs);
}

public void switchToExpandedView() {
Expand All @@ -132,7 +132,7 @@ private void doSnapAction(Constant.BubbleAction action) {
if (mMode == Mode.ContentView && action == Constant.BubbleAction.Close) {
doAnimateToContentView();
} else {
doAnimateToBubbleView(0);
doAnimateToBubbleView(0, false);
}
} else {
mMode = Mode.BubbleView;
Expand Down Expand Up @@ -272,7 +272,7 @@ public void snapToBubbleView() {
MainApplication.postEvent(getContext(), mEndCollapseTransitionEvent);
}

private void doAnimateToBubbleView(int animTimeMs) {
private void doAnimateToBubbleView(int animTimeMs, boolean fromCloseSystemDialogs) {
if (mAnimActive) {
if (mMode == Mode.BubbleView) {
return;
Expand Down Expand Up @@ -331,7 +331,7 @@ public void onCancel() {
mainController.collapseBubbleFlow((long) (contentPeriod * 1000));

mBeginCollapseTransitionEvent.mPeriod = contentPeriod;
MainApplication.postEvent(getContext(), mBeginCollapseTransitionEvent);
MainApplication.postEvent(getContext(), new MainController.BeginCollapseTransitionEvent(fromCloseSystemDialogs));
}

private void doAnimateToContentView() {
Expand Down Expand Up @@ -565,7 +565,7 @@ public void onActionUp(DraggableHelper.ReleaseEvent e) {
doAnimateToContentView();
} else {
CrashTracking.log("BubbleDraggable.configure(): onActionUp() - doAnimateToBubbleView()");
doAnimateToBubbleView(0);
doAnimateToBubbleView(0, false);
}
}
}
Expand Down Expand Up @@ -644,7 +644,7 @@ public void update(float dt) {
@Override
public void onOrientationChanged() {
if (mMode == Mode.BubbleView) {
doAnimateToBubbleView(1);
doAnimateToBubbleView(1, false);
} else {
switchToExpandedView();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void configure(EventHandler eventHandler) {
@Override
public void onCenterItemClicked(BubbleFlowView sender, View view) {
try {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}
catch (NullPointerException exc) {
CrashTracking.logHandledException(exc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -455,7 +456,10 @@ public void onBeginCollapseTransition(MainController.BeginCollapseTransitionEven
fadeOut();
}

MainApplication.postEvent(getContext(), mMinimizeExpandedActivityEvent);
// TODO: replace 24 with Android N version once we update an SDK
if (Build.VERSION.SDK_INT < 24 || !e.mFromCloseSystemDialogs) {
MainApplication.postEvent(getContext(), mMinimizeExpandedActivityEvent);
}
}

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public void onSelected(ActionItem actionItem) {

// L_WATCH: L currently lacks getRecentTasks(), so minimize here
if (isCopyToClipboardAction == false && Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}

//if (closeBubbleOnShare && isCopyToClipboardAction == false && MainController.get() != null) {
Expand Down Expand Up @@ -821,7 +821,7 @@ public boolean shouldOverrideUrlLoading(String urlAsString, boolean viaUserInput
if (urlAsString.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(urlAsString));
if (MainApplication.loadIntent(getContext(), intent, urlAsString, mInitialUrlLoadStartTime)) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}
mConsecutiveRedirectCount = 0;
return true;
Expand Down Expand Up @@ -1558,7 +1558,7 @@ public void onAppOpened() {
MainController.get().closeTab(mOwnerTabView, true, false);
// L_WATCH: L currently lacks getRecentTasks(), so minimize here
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}
}
}
Expand Down Expand Up @@ -1756,7 +1756,7 @@ public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(context, SettingsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(intent);
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
break;
}
}
Expand Down Expand Up @@ -1792,7 +1792,7 @@ private void onDownloadStart(String urlAsString) {
MainController.get().closeTab(mOwnerTabView, true, false);
// L_WATCH: L currently lacks getRecentTasks(), so minimize here
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}
}
}
Expand Down Expand Up @@ -2294,7 +2294,7 @@ private boolean openInBrowser(String urlAsString, boolean canShowUndoPrompt) {
MainController.get().closeTab(mOwnerTabView, MainController.get().contentViewShowing(), canShowUndoPrompt);
// L_WATCH: L currently lacks getRecentTasks(), so minimize here
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}
return true;
}
Expand All @@ -2318,7 +2318,7 @@ private boolean openInApp(ResolveInfo resolveInfo, String urlAsString) {

// L_WATCH: L currently lacks getRecentTasks(), so minimize here
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT && null != mainController) {
mainController.switchToBubbleView();
mainController.switchToBubbleView(false);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void minimize() {
}

void showFileBrowser(final String[] acceptTypes, ValueCallback<Uri[]> filePathCallback) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
mFilePathCallback = filePathCallback;

Runnable runnable = new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void onActionClick() {
intent.setDataAndType(imageUri, "image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private boolean loadYouTubeVideo(String id) {
mYouTubeResolveInfo.activityInfo.name, Config.YOUTUBE_WATCH_PREFIX + id, -1, true)) {
// L_WATCH: L currently lacks getRecentTasks(), so minimize here
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
MainController.get().switchToBubbleView();
MainController.get().switchToBubbleView(false);
}
return true;
}
Expand Down

1 comment on commit ae6f643

@bbondy
Copy link
Member

@bbondy bbondy commented on ae6f643 Sep 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.