Home | History | Annotate | Download | only in launcher3
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      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 android.content.Intent;
     20 import android.graphics.Rect;
     21 import android.os.Bundle;
     22 import android.view.Menu;
     23 import android.view.View;
     24 
     25 import com.android.launcher3.allapps.AllAppsSearchBarController;
     26 import com.android.launcher3.logging.UserEventDispatcher;
     27 import com.android.launcher3.util.ComponentKey;
     28 
     29 import java.io.FileDescriptor;
     30 import java.io.PrintWriter;
     31 import java.util.ArrayList;
     32 import java.util.List;
     33 
     34 /**
     35  * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks
     36  * in order to add additional functionality. Some of these are very general, and give extending
     37  * classes the ability to react to Activity life-cycle or specific user interactions. Others
     38  * are more specific and relate to replacing parts of the application, for example, the search
     39  * interface or the wallpaper picker.
     40  */
     41 public interface LauncherCallbacks {
     42 
     43     /*
     44      * Activity life-cycle methods. These methods are triggered after
     45      * the code in the corresponding Launcher method is executed.
     46      */
     47     public void preOnCreate();
     48     public void onCreate(Bundle savedInstanceState);
     49     public void preOnResume();
     50     public void onResume();
     51     public void onStart();
     52     public void onStop();
     53     public void onPause();
     54     public void onDestroy();
     55     public void onSaveInstanceState(Bundle outState);
     56     public void onPostCreate(Bundle savedInstanceState);
     57     public void onNewIntent(Intent intent);
     58     public void onActivityResult(int requestCode, int resultCode, Intent data);
     59     public void onRequestPermissionsResult(int requestCode, String[] permissions,
     60             int[] grantResults);
     61     public void onWindowFocusChanged(boolean hasFocus);
     62     public void onAttachedToWindow();
     63     public void onDetachedFromWindow();
     64     public boolean onPrepareOptionsMenu(Menu menu);
     65     public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args);
     66     public void onHomeIntent();
     67     public boolean handleBackPressed();
     68     public void onTrimMemory(int level);
     69 
     70     /*
     71      * Extension points for providing custom behavior on certain user interactions.
     72      */
     73     public void onLauncherProviderChange();
     74     public void finishBindingItems(final boolean upgradePath);
     75     public void bindAllApplications(ArrayList<AppInfo> apps);
     76     public void onInteractionBegin();
     77     public void onInteractionEnd();
     78 
     79     @Deprecated
     80     public void onWorkspaceLockedChanged();
     81 
     82     /**
     83      * Starts a search with {@param initialQuery}. Return false if search was not started.
     84      */
     85     public boolean startSearch(
     86             String initialQuery, boolean selectInitialQuery, Bundle appSearchData);
     87     public boolean hasCustomContentToLeft();
     88     public void populateCustomContentContainer();
     89     public View getQsbBar();
     90     public Bundle getAdditionalSearchWidgetOptions();
     91 
     92     /*
     93      * Extensions points for adding / replacing some other aspects of the Launcher experience.
     94      */
     95     public UserEventDispatcher getUserEventDispatcher();
     96     public boolean shouldMoveToDefaultScreenOnHomeIntent();
     97     public boolean hasSettings();
     98     public AllAppsSearchBarController getAllAppsSearchBarController();
     99     public List<ComponentKey> getPredictedApps();
    100     public static final int SEARCH_BAR_HEIGHT_NORMAL = 0, SEARCH_BAR_HEIGHT_TALL = 1;
    101     /** Must return one of {@link #SEARCH_BAR_HEIGHT_NORMAL} or {@link #SEARCH_BAR_HEIGHT_TALL} */
    102     public int getSearchBarHeight();
    103 
    104     /**
    105      * Sets the callbacks to allow reacting the actions of search overlays of the launcher.
    106      *
    107      * @param callbacks A set of callbacks to the Launcher, is actually a LauncherSearchCallback,
    108      *                  but for implementation purposes is passed around as an object.
    109      */
    110     public void setLauncherSearchCallback(Object callbacks);
    111 
    112     public boolean shouldShowDiscoveryBounce();
    113 }
    114