am b54a5989: Adding optional first run activity to Launcher
* commit 'b54a5989a21bef4e6bac304591ca4030bfbe709d': Adding optional first run activity to Launcher
This commit is contained in:
@@ -78,7 +78,3 @@ public class Alarm implements Runnable{
|
|||||||
return mAlarmPending;
|
return mAlarmPending;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnAlarmListener {
|
|
||||||
public void onAlarm(Alarm alarm);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -187,6 +187,9 @@ public class Launcher extends Activity
|
|||||||
// Type: int[]
|
// Type: int[]
|
||||||
private static final String RUNTIME_STATE_VIEW_IDS = "launcher.view_ids";
|
private static final String RUNTIME_STATE_VIEW_IDS = "launcher.view_ids";
|
||||||
|
|
||||||
|
|
||||||
|
static final String FIRST_RUN_ACTIVITY_DISPLAYED = "launcher.first_run_activity_displayed";
|
||||||
|
|
||||||
private static final String TOOLBAR_ICON_METADATA_NAME = "com.android.launcher.toolbar_icon";
|
private static final String TOOLBAR_ICON_METADATA_NAME = "com.android.launcher.toolbar_icon";
|
||||||
private static final String TOOLBAR_SEARCH_ICON_METADATA_NAME =
|
private static final String TOOLBAR_SEARCH_ICON_METADATA_NAME =
|
||||||
"com.android.launcher.toolbar_search_icon";
|
"com.android.launcher.toolbar_search_icon";
|
||||||
@@ -476,6 +479,7 @@ public class Launcher extends Activity
|
|||||||
// On large interfaces, we want the screen to auto-rotate based on the current orientation
|
// On large interfaces, we want the screen to auto-rotate based on the current orientation
|
||||||
unlockScreenOrientation(true);
|
unlockScreenOrientation(true);
|
||||||
|
|
||||||
|
showFirstRunActivity();
|
||||||
showFirstRunCling();
|
showFirstRunCling();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,6 +501,21 @@ public class Launcher extends Activity
|
|||||||
protected void addCustomContentToLeft() {
|
protected void addCustomContentToLeft() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be overridden by subclasses to indicate that there is an activity to launch
|
||||||
|
* before showing the standard launcher experience.
|
||||||
|
*/
|
||||||
|
protected boolean hasFirstRunActivity() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be overridden by subclasses to launch any first run activity
|
||||||
|
*/
|
||||||
|
protected Intent getFirstRunActivity() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked by subclasses to signal a change to the {@link #addCustomContentToLeft} value to
|
* Invoked by subclasses to signal a change to the {@link #addCustomContentToLeft} value to
|
||||||
* ensure the custom content page is added or removed if necessary.
|
* ensure the custom content page is added or removed if necessary.
|
||||||
@@ -4206,6 +4225,10 @@ public class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldRunFirstRunActivity() {
|
||||||
|
return !ActivityManager.isRunningInTestHarness();
|
||||||
|
}
|
||||||
|
|
||||||
/* Cling related */
|
/* Cling related */
|
||||||
private boolean isClingsEnabled() {
|
private boolean isClingsEnabled() {
|
||||||
if (DISABLE_CLINGS) {
|
if (DISABLE_CLINGS) {
|
||||||
@@ -4274,15 +4297,9 @@ public class Launcher extends Activity
|
|||||||
final Runnable cleanUpClingCb = new Runnable() {
|
final Runnable cleanUpClingCb = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
cling.cleanup();
|
cling.cleanup();
|
||||||
// We should update the shared preferences on a background thread
|
SharedPreferences.Editor editor = mSharedPrefs.edit();
|
||||||
new AsyncTask<Void, Void, Void>() {
|
editor.putBoolean(flag, true);
|
||||||
public Void doInBackground(Void ... args) {
|
editor.apply();
|
||||||
SharedPreferences.Editor editor = mSharedPrefs.edit();
|
|
||||||
editor.putBoolean(flag, true);
|
|
||||||
editor.commit();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
|
||||||
if (postAnimationCb != null) {
|
if (postAnimationCb != null) {
|
||||||
postAnimationCb.run();
|
postAnimationCb.run();
|
||||||
}
|
}
|
||||||
@@ -4379,10 +4396,29 @@ public class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showFirstRunActivity() {
|
||||||
|
if (shouldRunFirstRunActivity() && hasFirstRunActivity()
|
||||||
|
&& !mSharedPrefs.getBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, false)) {
|
||||||
|
Intent firstRunIntent = getFirstRunActivity();
|
||||||
|
if (firstRunIntent != null) {
|
||||||
|
startActivity(firstRunIntent);
|
||||||
|
markFirstRunActivityShown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markFirstRunActivityShown() {
|
||||||
|
SharedPreferences.Editor editor = mSharedPrefs.edit();
|
||||||
|
editor.putBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, true);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
public void showFirstRunCling() {
|
public void showFirstRunCling() {
|
||||||
if (isClingsEnabled() &&
|
if (isClingsEnabled() &&
|
||||||
!mSharedPrefs.getBoolean(Cling.FIRST_RUN_CLING_DISMISSED_KEY, false) &&
|
!mSharedPrefs.getBoolean(Cling.FIRST_RUN_CLING_DISMISSED_KEY, false) &&
|
||||||
!skipCustomClingIfNoAccounts() ) {
|
!skipCustomClingIfNoAccounts() ) {
|
||||||
|
|
||||||
|
|
||||||
// If we're not using the default workspace layout, replace workspace cling
|
// If we're not using the default workspace layout, replace workspace cling
|
||||||
// with a custom workspace cling (usually specified in an overlay)
|
// with a custom workspace cling (usually specified in an overlay)
|
||||||
// For now, only do this on tablets
|
// For now, only do this on tablets
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.android.launcher3;
|
||||||
|
|
||||||
|
public interface OnAlarmListener {
|
||||||
|
public void onAlarm(Alarm alarm);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user