Skip to content

Commit 43294ca

Browse files
Thecrazyskullxboxfanj
authored andcommitted
Launcher3: support google now tab
Change-Id: I6efc1d5186e0f1bd4fa78ae7231999b984ce7222
1 parent c5fd123 commit 43294ca

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

src/com/android/launcher3/Launcher.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ public void run() {
355355
public ViewGroupFocusHelper mFocusHandler;
356356
private boolean mRotationEnabled = false;
357357

358+
private LauncherTab mLauncherTab;
359+
358360
@Thunk void setOrientation() {
359361
if (mRotationEnabled) {
360362
unlockScreenOrientation(true);
@@ -456,6 +458,8 @@ protected void onCreate(Bundle savedInstanceState) {
456458
IntentFilter filter = new IntentFilter(ACTION_APPWIDGET_HOST_RESET);
457459
registerReceiver(mUiBroadcastReceiver, filter);
458460

461+
mLauncherTab = new LauncherTab(this);
462+
459463
mRotationEnabled = getResources().getBoolean(R.bool.allow_rotation);
460464
// In case we are on a device with locked rotation, we should look at preferences to check
461465
// if the user has specifically allowed rotation.
@@ -1059,6 +1063,9 @@ protected void onResume() {
10591063
mAllAppsController.showDiscoveryBounce();
10601064
}
10611065
mIsResumeFromActionScreenOff = false;
1066+
1067+
mLauncherTab.getClient().onResume();
1068+
10621069
if (mLauncherCallbacks != null) {
10631070
mLauncherCallbacks.onResume();
10641071
}
@@ -1080,6 +1087,8 @@ protected void onPause() {
10801087
mWorkspace.getCustomContentCallbacks().onHide();
10811088
}
10821089

1090+
mLauncherTab.getClient().onPause();
1091+
10831092
if (mLauncherCallbacks != null) {
10841093
mLauncherCallbacks.onPause();
10851094
}
@@ -1620,6 +1629,8 @@ public void onAttachedToWindow() {
16201629
mAttached = true;
16211630
mVisible = true;
16221631

1632+
mLauncherTab.getClient().onAttachedToWindow();
1633+
16231634
if (mLauncherCallbacks != null) {
16241635
mLauncherCallbacks.onAttachedToWindow();
16251636
}
@@ -1636,6 +1647,8 @@ public void onDetachedFromWindow() {
16361647
}
16371648
updateAutoAdvanceState();
16381649

1650+
mLauncherTab.getClient().onDetachedFromWindow();
1651+
16391652
if (mLauncherCallbacks != null) {
16401653
mLauncherCallbacks.onDetachedFromWindow();
16411654
}
@@ -1865,6 +1878,8 @@ protected void onNewIntent(Intent intent) {
18651878
mWidgetsView.scrollToTop();
18661879
}
18671880

1881+
mLauncherTab.getClient().hideOverlay(true);
1882+
18681883
if (mLauncherCallbacks != null) {
18691884
mLauncherCallbacks.onHomeIntent();
18701885
}
@@ -1978,6 +1993,8 @@ public void onDestroy() {
19781993

19791994
LauncherAnimUtils.onDestroyActivity();
19801995

1996+
mLauncherTab.getClient().onDestroy();
1997+
19811998
if (mLauncherCallbacks != null) {
19821999
mLauncherCallbacks.onDestroy();
19832000
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (C) 2017 Paranoid Android
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.launcher3;
18+
19+
import com.android.launcher3.Launcher.LauncherOverlay;
20+
import com.android.launcher3.Launcher.LauncherOverlayCallbacks;
21+
22+
import com.google.android.libraries.launcherclient.LauncherClient;
23+
import com.google.android.libraries.launcherclient.LauncherClientCallbacksAdapter;
24+
25+
public class LauncherTab {
26+
27+
private Launcher mLauncher;
28+
29+
private LauncherClient mLauncherClient;
30+
31+
public LauncherTab(Launcher launcher) {
32+
mLauncher = launcher;
33+
mLauncherClient = new LauncherClient(launcher, new LauncherClientCallbacksAdapter(), true);
34+
35+
launcher.setLauncherOverlay(new LauncherOverlays());
36+
}
37+
38+
protected LauncherClient getClient() {
39+
return mLauncherClient;
40+
}
41+
42+
private class LauncherOverlays implements LauncherOverlay {
43+
@Override
44+
public void onScrollInteractionBegin() {
45+
mLauncherClient.startMove();
46+
}
47+
48+
@Override
49+
public void onScrollInteractionEnd() {
50+
mLauncherClient.endMove();
51+
}
52+
53+
@Override
54+
public void onScrollChange(float progress, boolean rtl) {
55+
mLauncherClient.updateMove(progress);
56+
}
57+
58+
@Override
59+
public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks) {
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)