Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Launcher

No description
by

Utah Chen

on 25 June 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Launcher

Launcher3
Build launcher3.apk in Eclipse
Manifest & .mk
new permissions
new activities
new service
com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS
android.permission.READ_EXTERNAL_STORAGE
ToggleWeightWatcher.java
WallpaperPickerActivity.java
WallpaperCropActivity.java
MemoryDumpActivity.java
MemoryTracker.java
1. In "Properties -> Android -> Project Build Target"
Change platform to be "Android 4.4.2"(API Level 19)

2. Modify AndroidManifest.xml
Add <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="19"/>

3. New folder “libs” under Launcher3 and add “android-support-v4.jar” into it.
Add it into build path in Eclipse

p.s
: android-support-v4.jar could be got from “extras/android/support/v4” folder in android sdk

4. Two ways to fix compile error:
[a.1] Remove LauncherBackupAgentHelper.java/LauncherBackupHelper.java
[a.2] Modify src/com/android/launcher3/LauncherProvider.java, remove LauncherBackupAgentHelper.dataChanged(getContext());

[b.1] add “host-libprotobuf-java-2.3.0-nano.jar” in folder “libs”
Add it into build patch in Eclipse

p.s
: host-libprotobuf-java-2.3.0-nano.jar is built from AOSP source.
You could do “mm” for external/protobuf then get it from out/host/linux-x86/framework
[b.2] build out BackupProtos.java from AOSP source.
(taking it from out\target\common\obj\APPS\Launcher3_intermediates\src\proto\src\com\android\launcher3\backup)
create src/com/android/launcher3/backup/BackupProtos.java

5. Clean project

6. Build and Run
Layout
Launcher
Initialization
AppWidget Working
mAppWidgetManager
mAppWidgetHost
AppWidgetManager
(android.appwidget.AppWidgetManager)
getAppWidgetInfo
according to given ID to grab AppWidgetProviderInfo

bindAppWidgetIdIfAllowed
set the component for a given appWidgetId
(android.content.ComponentName)

getInstalledProviders
get all existent AppWidgets Providers in list array
LauncherAppWidgetHost
(extends android.appwidget.AppWidgetHost)
- to create launcher defined LauncherAppWidgetHostView
Launcher applies addAppWidgetImpl(...)/completeAddAppWidget(...) to add widgets
1. Widget information/database -> mModel
2. View adding/listener register -> work with mAppWidgetHost and mWorkspace APIs

which interfaces of LauncherAppWidgetHost is applied in Launcher?
createView
deleteAppWidgetId
startListening
stopListening
LauncherAppWidgetHostView
(extends android.appwidget.AppWidgetHostView)
- to customize the AppWidgetHostView to define its own operations
(such as touch events handling and other callbacks)
(layout/
launcher.xml
)
FrameLayout
DragLayer
(FrameLayout)
WorkSpace
OverviewPanel
layout: page_indicator.xml
layout: layout/qsb_bar.xml
Hotseat
(launcher3.Hotseat.java, extends FrameLayout)
CellLayout
GridSize: grid.numHotseatIcons x 1
grid.numHotseatIcons is from LauncherAppState
layout: hotseat.xml
PageIndicator
(launcher3.PageIndicator.java, extends LinearLayout)
QuickSearchBar
(launcher3.SearchDropTargetBar.java, extends FrameLayout)
Switch of (
QuickSearchBar
and
DropTargetBar
)
DropTargetBar is consists fo (
mInfoDropTarget
+
mDeleteDropTarget
)
implements DragController.DragListener
onDragStart
onDragEnd
DragLayer
(launcher3.DragLayer.java, extends FrameLayout)
FrameLayout
(launcher3.Workspace.java, extends SmoothPagedView)
Scrim & Cling
ScrimView: a transparent Framelayout with backgroud 0xdd000000
Cling - guideline of launcher
layouts:
(1)first_run_cling
(2)workspace_cling
(3)folder_cling
workspace_cling
DrawableStateProxyView
(extends LinearLayout)
Provide a larger touch area than the microphone constrained by the search bar bounds
AppCustomizeTabHost
(extends TabHost.java)
Data Loading
in Launcher
layout/app_customize_pane.xml
Two tabs: APPS/WIDGETS
No widgets menu in Launcher3
Multiple childs(in CellLayout)
SmoothPagedView/PagedView
-- extends ViewGroup
-- handle touchEvent <--> page scroll/snap/bounding
-- smoothed scrolling animation
-- perform page indicator

CellLayout
-- GridView-like repository
-- handle the display of APP-icons/folder/shortcuts/widgets
-- applied in Workspace, AppCustomizeCellLayout(AppMenu), Hotseat, Folder
-- number of (row/column) --> constructor --> DeviceProfile --> DynamicGrid --> Launcher onCreate
layout/overview_panel.xml
LinearLayout with 3 TextView
-- WALLPAPERS
(goes to AppCustomizeTabHost.java in type WIDGETS)
-- WIDGETS
(start Activity with intent ACTION_SET_WALLPAPER)
-- SETTINGS
(do nothing)

LinearLayout
FrameLayout
Tab Container
(Apps/Widgets/Market)
-- gone in Launcher3
FrameLayout
Tab Content
AppsCustomizePagedView/AnimationBuffer
AppsCustomizePagedView
-- PagedViewWithDraggableItems, PagedView
-- Type.Apps: AppsCustomizeCellLayout(CellLayout)
Type.Widgets: PagedViewGridLayout(GridLayout)
-- handle display items in each page

AnimationBuffer
-- FrameLayout
-- handle the animation when tab changed
(Apps menu <--> Widgets menu)
PageIndicator(extends LinearLayout)
-- layout/page_indicator.xml
-- same with the indicator in workspace
Initialization Process
(onCreate in Launcher.java)
01.
LauncherAppState app = LauncherAppState.getInstance();
initialize LauncherModel
register receiver for intents
PACKAGE_ADDED/REMOVED/CHANGED
EXTERNAL_APPLICATION_AVAILABLE/UNAVAILABLE
LOCALE/CONFIGURATION/GLOBAL_SEARCH CHANGED
register observer for Launcher Settings

02.
DeviceProfile grid = app.initDynamicGrid(......);
initialize the grid attribution for CellLayout

03.
mSharedPrefs = getSharedPreferences(......);
get shared preference

04.
mDragController = new DragController(this);
beginning of all drag-drop behaviors/controller

05.
mAppWidgetManager = AppWidgetManager.getInstance(this);

mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
Widget manager and display on Launcher

06.
setContentView(R.layout.launcher);

setupViews();
set layout for Launcher

07.
registerContentObservers();
register database observer for APP_WIDGET

08.
restoreState();
restore some states in Launcher.java/Workspace.java/AppCustomizeTabHost.java

09.
mAppsCustomizeContent.onPackagesUpdated(......);
Get the list of all apps and widgets, invalidate these information in App/Widgets menu

10.
mModel.startLoader(......);
load database of Launcher setting into LauncherModel
update all views in workspace according to these data

11.
register receiver for intent ACTION_CLOSE_SYSTEM_DIALOGS
-- closeSystemDialogs();

12.
updateGlobalIcons();
handle the display of (global search + voice search + app market) icons

13.
showFirstRunCling();
determine to initialize/show/remove "First Run" Cling (tutorial display)
Loading launcher data
(in LauncherModel.java)

Entry: startLoader()/startLoaderFromBackground()

Flow of loader task running
1.loadAndBindWorkspace (loadWorkspace, bindWorkspace)
2.loadAndBindAllApps (loadAllApps, onlyBindAllApps)
3.During loading process,
query/tell Launcher.java with callbacks
(Launcher.java implements LauncherModel.Callbacks)

loadWorkspace:
load data from LauncherSettings.Favorites.CONTENT_URI
types: APPLICATION, SHORTCUT, FOLDER, APPWIDGET

bindWorkspace:
tell workspace to add screen - bindWorkspaceScreens();
load all items in each page - bindWorkspaceItems();
(callbacks.startBinding/bindItems/bindFolders/bindAppWidgets)

loadAllApps:
get application information from packageManager.queryIntentActivities(......);

onlyBindAllApps:
bind application with callbacks.bindAllApplications(...);
Drag & Drop
DragLayer: extends Framelayout

New a DragController object in Launcher initialization
Set dragController in DragLayer

handle touch event with mDragController.
dispatchTouchEvent/onInterceptTouchEvent/onTouchEvent

DragView: handle display/animation/removal the dragged view

also see interface
-- DragSource (who can originate a drag behavior)
-- DropTarget (the area receives dropped object)
-- DragScroller (handle the scrolling while drag)
Full transcript