Skip to content

Commit

Permalink
Launcher3: support google now tab
Browse files Browse the repository at this point in the history
Change-Id: I6efc1d5186e0f1bd4fa78ae7231999b984ce7222
  • Loading branch information
Thecrazyskull authored and xboxfanj committed Apr 25, 2017
1 parent c5fd123 commit 43294ca
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/com/android/launcher3/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ public void run() {
public ViewGroupFocusHelper mFocusHandler;
private boolean mRotationEnabled = false;

private LauncherTab mLauncherTab;

@Thunk void setOrientation() {
if (mRotationEnabled) {
unlockScreenOrientation(true);
Expand Down Expand Up @@ -456,6 +458,8 @@ protected void onCreate(Bundle savedInstanceState) {
IntentFilter filter = new IntentFilter(ACTION_APPWIDGET_HOST_RESET);
registerReceiver(mUiBroadcastReceiver, filter);

mLauncherTab = new LauncherTab(this);

mRotationEnabled = getResources().getBoolean(R.bool.allow_rotation);
// In case we are on a device with locked rotation, we should look at preferences to check
// if the user has specifically allowed rotation.
Expand Down Expand Up @@ -1059,6 +1063,9 @@ protected void onResume() {
mAllAppsController.showDiscoveryBounce();
}
mIsResumeFromActionScreenOff = false;

mLauncherTab.getClient().onResume();

if (mLauncherCallbacks != null) {
mLauncherCallbacks.onResume();
}
Expand All @@ -1080,6 +1087,8 @@ protected void onPause() {
mWorkspace.getCustomContentCallbacks().onHide();
}

mLauncherTab.getClient().onPause();

if (mLauncherCallbacks != null) {
mLauncherCallbacks.onPause();
}
Expand Down Expand Up @@ -1620,6 +1629,8 @@ public void onAttachedToWindow() {
mAttached = true;
mVisible = true;

mLauncherTab.getClient().onAttachedToWindow();

if (mLauncherCallbacks != null) {
mLauncherCallbacks.onAttachedToWindow();
}
Expand All @@ -1636,6 +1647,8 @@ public void onDetachedFromWindow() {
}
updateAutoAdvanceState();

mLauncherTab.getClient().onDetachedFromWindow();

if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDetachedFromWindow();
}
Expand Down Expand Up @@ -1865,6 +1878,8 @@ protected void onNewIntent(Intent intent) {
mWidgetsView.scrollToTop();
}

mLauncherTab.getClient().hideOverlay(true);

if (mLauncherCallbacks != null) {
mLauncherCallbacks.onHomeIntent();
}
Expand Down Expand Up @@ -1978,6 +1993,8 @@ public void onDestroy() {

LauncherAnimUtils.onDestroyActivity();

mLauncherTab.getClient().onDestroy();

if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
Expand Down
62 changes: 62 additions & 0 deletions src/com/android/launcher3/LauncherTab.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (C) 2017 Paranoid Android
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.android.launcher3;

import com.android.launcher3.Launcher.LauncherOverlay;
import com.android.launcher3.Launcher.LauncherOverlayCallbacks;

import com.google.android.libraries.launcherclient.LauncherClient;
import com.google.android.libraries.launcherclient.LauncherClientCallbacksAdapter;

public class LauncherTab {

private Launcher mLauncher;

private LauncherClient mLauncherClient;

public LauncherTab(Launcher launcher) {
mLauncher = launcher;
mLauncherClient = new LauncherClient(launcher, new LauncherClientCallbacksAdapter(), true);

launcher.setLauncherOverlay(new LauncherOverlays());
}

protected LauncherClient getClient() {
return mLauncherClient;
}

private class LauncherOverlays implements LauncherOverlay {
@Override
public void onScrollInteractionBegin() {
mLauncherClient.startMove();
}

@Override
public void onScrollInteractionEnd() {
mLauncherClient.endMove();
}

@Override
public void onScrollChange(float progress, boolean rtl) {
mLauncherClient.updateMove(progress);
}

@Override
public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks) {
}
}
}

1 comment on commit 43294ca

@PANCHOHACK
Copy link

Choose a reason for hiding this comment

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

Yo lo cree si gustan se los paso

Please sign in to comment.