Java Examples for com.android.launcher2.Launcher
The following java examples will help you to understand the usage of com.android.launcher2.Launcher. These source code samples are taken from different open source projects.
Example 1
| Project: FlickLauncher-master File: Folder.java View source code |
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mContent = (FolderPagedView) findViewById(R.id.folder_content);
mContent.setFolder(this);
mPageIndicator = (PageIndicatorDots) findViewById(R.id.folder_page_indicator);
mFolderName = (ExtendedEditText) findViewById(R.id.folder_name);
mFolderName.setOnBackKeyListener(new ExtendedEditText.OnBackKeyListener() {
@Override
public boolean onBackKey() {
// Close the activity on back key press
doneEditingFolderName(true);
return false;
}
});
mFolderName.setOnFocusChangeListener(this);
if (!Utilities.ATLEAST_MARSHMALLOW) {
// We disable action mode in older OSes where floating selection menu is not yet
// available.
mFolderName.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}
public void onDestroyActionMode(ActionMode mode) {
}
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
});
}
mFolderName.setOnEditorActionListener(this);
mFolderName.setSelectAllOnFocus(true);
mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
mFooter = findViewById(R.id.folder_footer);
// We find out how tall footer wants to be (it is set to wrap_content), so that
// we can allocate the appropriate amount of space for it.
int measureSpec = MeasureSpec.UNSPECIFIED;
mFooter.measure(measureSpec, measureSpec);
mFooterHeight = mFooter.getMeasuredHeight();
//Folder background color
if (Utilities.getFolderBackgroundPrefEnabled(getContext()) != -1) {
mFooter.setBackgroundColor(Utilities.getFolderBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()));
mContent.setBackgroundColor(Utilities.getFolderBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()));
}
}Example 2
| Project: Lanucher3-master File: LauncherRotationStressTest.java View source code |
@RepetitiveTest(numIterations = NUM_ITERATIONS)
public void testLauncherRotationStress() throws Exception {
Launcher launcher = getActivity();
getInstrumentation().waitForIdleSync();
SystemClock.sleep(WAIT_TIME_MS);
launcher.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getInstrumentation().waitForIdleSync();
SystemClock.sleep(WAIT_TIME_MS);
launcher.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}Example 3
| Project: selendroid-master File: BackgroundAppTest.java View source code |
/**
* Requires ANDROID_HOME to be set in enviroment.
* @throws Exception
*/
@Test
public void testBackgroundAppFunctionality() throws Exception {
openStartActivity();
driver().backgroundApp();
String currentActivity = adbCurrentActivity();
Assert.assertTrue(currentActivity.contains("com.android.launcher2.Launcher"));
driver().resumeApp();
currentActivity = adbCurrentActivity();
Assert.assertTrue(currentActivity.contains("io.selendroid.testapp.HomeScreenActivity"));
}Example 4
| Project: androidrocks-master File: WuffITTracker.java View source code |
public void onClick(View view) {
// finish();
// Intent { action=android.intent.action.MAIN categories={android.intent.category.HOME} flags=0x10200000 comp={com.android.launcher/com.android.launcher.Launcher} }
// Go Home
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
}Example 5
| Project: android_packages_apps_settings-master File: Settings.java View source code |
@Override
protected void onResume() {
super.onResume();
findPreference(KEY_CALL_SETTINGS).setEnabled(!AirplaneModeEnabler.isAirplaneModeOn(this));
Intent intent = new Intent();
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
PreferenceGroup parent = (PreferenceGroup) findPreference(KEY_PARENT);
ActivityInfo a = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY).activityInfo;
if (a != null && a.name.equals("com.android.launcher.Launcher") && (a.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
if (parent.findPreference(KEY_LAUNCHER) == null) {
parent.addPreference(mLauncherSettings);
}
} else {
if (parent.findPreference(KEY_LAUNCHER) != null) {
parent.removePreference(mLauncherSettings);
}
}
}Example 6
| Project: Launcher3-master File: Workspace.java View source code |
/**
* Initializes various states for this workspace.
*/
protected void initWorkspace() {
mCurrentPage = mDefaultPage;
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = mLauncher.getDeviceProfile();
mIconCache = app.getIconCache();
setWillNotDraw(false);
setClipChildren(false);
setClipToPadding(false);
setChildrenDrawnWithCacheEnabled(true);
setMinScale(mOverviewModeShrinkFactor);
setupLayoutTransition();
mWallpaperOffset = new WallpaperOffsetInterpolator();
Display display = mLauncher.getWindowManager().getDefaultDisplay();
display.getSize(mDisplaySize);
mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
// Set the wallpaper dimensions when Launcher starts up
setWallpaperDimension();
setEdgeGlowColor(getResources().getColor(R.color.workspace_edge_effect_color));
}Example 7
| Project: OpenSatNav-master File: About.java View source code |
/**
* Change the logo image using the resource name and package.
*
* @param resourceFileName
* String of the name of the image resource (as you would append
* it after "R.drawable.").
* @param resourcePackageName
* String of the name of the source package of the image resource
* (the package name of the calling app).
*/
protected void changeLogoImageResource(final String resourceFileName, final String resourcePackageName) {
try {
Resources resources = getPackageManager().getResourcesForApplication(resourcePackageName);
final int id = resources.getIdentifier(resourceFileName, null, null);
mLogoImage.setImageDrawable(resources.getDrawable(id));
} catch (// Not a resource id
NumberFormatException // Not a resource id
e) {
throw new IllegalArgumentException("Not a valid image.");
} catch (// Resource not found
NotFoundException // Resource not found
e) {
throw new IllegalArgumentException("Not a valid image.");
} catch (//Not a package name
NameNotFoundException //Not a package name
e) {
throw new IllegalArgumentException("Not a valid (image resource) package name.");
}
/*The idea for this came from:
android.content.Intent.ShortcutIconResource and related contstants and intents, in android.content.Intent: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/content/Intent.java;h=39888c1bc0f62effa788815e5b9376969d255766;hb=master
what's done with this in com.android.launcher.Launcher: http://android.git.kernel.org/?p=platform/packages/apps/Launcher.git;a=blob;f=src/com/android/launcher/Launcher.java;h=928f4caecde593d0fb430718de28d5e52df989ad;hb=HEAD
and in android.webkit.gears.DesktopAndroid: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/webkit/gears/DesktopAndroid.java
*/
}Example 8
| Project: Android_Paint-master File: AboutActivity.java View source code |
/**
* Change the logo image using the resource name and package.
*
* @param resourceFileName
* String of the name of the image resource (as you would append
* it after "R.drawable.").
* @param resourcePackageName
* String of the name of the source package of the image resource
* (the package name of the calling app).
*/
protected void changeLogoImageResource(final String resourceFileName, final String resourcePackageName) {
try {
Resources resources = getPackageManager().getResourcesForApplication(resourcePackageName);
final int id = resources.getIdentifier(resourceFileName, null, null);
mLogoImage.setImageDrawable(resources.getDrawable(id));
} catch (// Not a resource id
NumberFormatException // Not a resource id
e) {
throw new IllegalArgumentException("Not a valid image.");
} catch (// Resource not found
NotFoundException // Resource not found
e) {
throw new IllegalArgumentException("Not a valid image.");
} catch (//Not a package name
NameNotFoundException //Not a package name
e) {
throw new IllegalArgumentException("Not a valid (image resource) package name.");
}
/*The idea for this came from:
android.content.Intent.ShortcutIconResource and related contstants and intents, in android.content.Intent: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/content/Intent.java;h=39888c1bc0f62effa788815e5b9376969d255766;hb=master
what's done with this in com.android.launcher.Launcher: http://android.git.kernel.org/?p=platform/packages/apps/Launcher.git;a=blob;f=src/com/android/launcher/Launcher.java;h=928f4caecde593d0fb430718de28d5e52df989ad;hb=HEAD
and in android.webkit.gears.DesktopAndroid: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/webkit/gears/DesktopAndroid.java
*/
}Example 9
| Project: AppTracker-master File: LogAnalysisTest.java View source code |
public void testHomeLine() {
AnalyzedLogLine line = LogAnalyzer.analyzeLogLine("I/ActivityManager( 175): Starting: Intent { " + "act=android.intent.action.MAIN cat=[android.intent.category.HOME] " + "flg=0x10200000 cmp=com.android.launcher/.Launcher } from pid 175");
assertTrue(line.isStartHomeActivity());
}