本文整理汇总了Java中com.android.launcher3.LauncherAppWidgetProviderInfo类的典型用法代码示例。如果您正苦于以下问题:Java LauncherAppWidgetProviderInfo类的具体用法?Java LauncherAppWidgetProviderInfo怎么用?Java LauncherAppWidgetProviderInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LauncherAppWidgetProviderInfo类属于com.android.launcher3包,在下文中一共展示了LauncherAppWidgetProviderInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PendingAddWidgetInfo
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
public PendingAddWidgetInfo(Context context, LauncherAppWidgetProviderInfo i) {
if (i.isCustomWidget) {
itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
} else {
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
}
this.info = i;
user = AppWidgetManagerCompat.getInstance(context).getUser(i);
componentName = i.provider;
previewImage = i.previewImage;
icon = i.icon;
spanX = i.spanX;
spanY = i.spanY;
minSpanX = i.minSpanX;
minSpanY = i.minSpanY;
}
示例2: PendingAddWidgetInfo
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
public PendingAddWidgetInfo(Launcher launcher, LauncherAppWidgetProviderInfo i, Parcelable data) {
if (i.isCustomWidget) {
itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
} else {
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
}
this.info = i;
user = AppWidgetManagerCompat.getInstance(launcher).getUser(i);
componentName = i.provider;
previewImage = i.previewImage;
icon = i.icon;
spanX = i.spanX;
spanY = i.spanY;
minSpanX = i.minSpanX;
minSpanY = i.minSpanY;
}
示例3: findProvider
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
@Override
public LauncherAppWidgetProviderInfo findProvider(
ComponentName provider, UserHandleCompat user) {
for (AppWidgetProviderInfo info : mAppWidgetManager.getInstalledProviders()) {
if (info.provider.equals(provider)) {
return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
}
}
return null;
}
示例4: getUser
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
@Override
public UserHandleCompat getUser(LauncherAppWidgetProviderInfo info) {
if (info.isCustomWidget) {
return UserHandleCompat.myUserHandle();
}
return UserHandleCompat.fromUser(info.getProfile());
}
示例5: getBadgeBitmap
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
@Override
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
int imageWidth, int imageHeight) {
if (info.isCustomWidget || info.getProfile().equals(android.os.Process.myUserHandle())) {
return bitmap;
}
// Add a user badge in the bottom right of the image.
final Resources res = mContext.getResources();
final int badgeMinTop = res.getDimensionPixelSize(R.dimen.profile_badge_minimum_top);
// choose min between badge size defined for widget tray versus width, height of the image.
// Width, height of the image can be smaller than widget tray badge size when being dropped
// to the workspace.
final int badgeSize = Math.min(res.getDimensionPixelSize(R.dimen.profile_badge_size),
Math.min(imageWidth, imageHeight - badgeMinTop));
final Rect badgeLocation = new Rect(0, 0, badgeSize, badgeSize);
final int top = Math.max(imageHeight - badgeSize, badgeMinTop);
if (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
badgeLocation.offset(0, top);
} else {
badgeLocation.offset(bitmap.getWidth() - badgeSize, top);
}
Drawable drawable = mPm.getUserBadgedDrawableForDensity(
new BitmapDrawable(res, bitmap), info.getProfile(), badgeLocation, 0);
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
bitmap.eraseColor(Color.TRANSPARENT);
Canvas c = new Canvas(bitmap);
drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
drawable.draw(c);
c.setBitmap(null);
return bitmap;
}
示例6: findProvider
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
@Override
public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandleCompat user) {
for (AppWidgetProviderInfo info : mAppWidgetManager
.getInstalledProvidersForProfile(user.getUser())) {
if (info.provider.equals(provider)) {
return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
}
}
return null;
}
示例7: WidgetItem
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
public WidgetItem(LauncherAppWidgetProviderInfo info, AppWidgetManagerCompat widgetManager) {
super(info.provider, widgetManager.getUser(info));
label = Utilities.trim(widgetManager.loadLabel(info));
widgetInfo = info;
activityInfo = null;
InvariantDeviceProfile idv = LauncherAppState.getInstance().getInvariantDeviceProfile();
spanX = Math.min(info.spanX, idv.numColumns);
spanY = Math.min(info.spanY, idv.numRows);
}
示例8: updateAndClone
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
public WidgetsModel updateAndClone(Context context) {
Preconditions.assertWorkerThread();
try {
final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
// Widgets
AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);
for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders()) {
widgetsAndShortcuts.add(new WidgetItem(
LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo),
widgetManager));
}
// Shortcuts
PackageManager pm = context.getPackageManager();
for (ResolveInfo info :
pm.queryIntentActivities(new Intent(Intent.ACTION_CREATE_SHORTCUT), 0)) {
widgetsAndShortcuts.add(new WidgetItem(info, pm));
}
setWidgetsAndShortcuts(widgetsAndShortcuts);
} catch (Exception e) {
if (!ProviderConfig.IS_DOGFOOD_BUILD &&
(e.getCause() instanceof TransactionTooLargeException ||
e.getCause() instanceof DeadObjectException)) {
// the returned value may be incomplete and will not be refreshed until the next
// time Launcher starts.
// TODO: after figuring out a repro step, introduce a dirty bit to check when
// onResume is called to refresh the widget provider list.
} else {
throw e;
}
}
return clone();
}
示例9: PendingRequestArgs
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
public PendingRequestArgs(Parcel parcel) {
readFromValues(ContentValues.CREATOR.createFromParcel(parcel));
mArg1 = parcel.readInt();
mObjectType = parcel.readInt();
if (parcel.readInt() != 0) {
mObject = mObjectType == TYPE_INTENT
? Intent.CREATOR.createFromParcel(parcel)
: new LauncherAppWidgetProviderInfo(parcel);
} else {
mObject = null;
}
}
示例10: getBadgeBitmap
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
@Override
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
int imageHeight) {
if (info.isCustomWidget || info.getProfile().equals(android.os.Process.myUserHandle())) {
return bitmap;
}
// Add a user badge in the bottom right of the image.
final Resources res = mContext.getResources();
final int badgeSize = res.getDimensionPixelSize(R.dimen.profile_badge_size);
final int badgeMinTop = res.getDimensionPixelSize(R.dimen.profile_badge_minimum_top);
final Rect badgeLocation = new Rect(0, 0, badgeSize, badgeSize);
final int top = Math.max(imageHeight - badgeSize, badgeMinTop);
if (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
badgeLocation.offset(0, top);
} else {
badgeLocation.offset(bitmap.getWidth() - badgeSize, top);
}
Drawable drawable = mPm.getUserBadgedDrawableForDensity(
new BitmapDrawable(res, bitmap), info.getProfile(), badgeLocation, 0);
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
bitmap.eraseColor(Color.TRANSPARENT);
Canvas c = new Canvas(bitmap);
drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
drawable.draw(c);
c.setBitmap(null);
return bitmap;
}
示例11: getComponentKey
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
/**
* @return a component key for the given widget or shortcut info.
*/
private ComponentKey getComponentKey(Object o) {
if (o instanceof LauncherAppWidgetProviderInfo) {
LauncherAppWidgetProviderInfo widgetInfo = (LauncherAppWidgetProviderInfo) o;
return new ComponentKey(widgetInfo.provider, mManager.getUser(widgetInfo));
} else {
ResolveInfo shortcutInfo = (ResolveInfo) o;
ComponentName cn = new ComponentName(shortcutInfo.activityInfo.packageName,
shortcutInfo.activityInfo.name);
// Currently, there are no work profile shortcuts
return new ComponentKey(cn, UserHandleCompat.myUserHandle());
}
}
示例12: getLabel
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
/**
* @return the label for the given widget or shortcut info. This may be an expensive call.
*/
private String getLabel(Object o) {
if (o instanceof LauncherAppWidgetProviderInfo) {
LauncherAppWidgetProviderInfo widgetInfo = (LauncherAppWidgetProviderInfo) o;
return Utilities.trim(mManager.loadLabel(widgetInfo));
} else {
ResolveInfo shortcutInfo = (ResolveInfo) o;
return Utilities.trim(shortcutInfo.loadLabel(mPackageManager));
}
}
示例13: applyFromAppWidgetProviderInfo
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
/**
* Apply the widget provider info to the view.
*/
public void applyFromAppWidgetProviderInfo(LauncherAppWidgetProviderInfo info,
WidgetPreviewLoader loader) {
InvariantDeviceProfile profile =
LauncherAppState.getInstance().getInvariantDeviceProfile();
mInfo = info;
// TODO(hyunyoungs): setup a cache for these labels.
mWidgetName.setText(AppWidgetManagerCompat.getInstance(getContext()).loadLabel(info));
int hSpan = Math.min(info.spanX, profile.numColumns);
int vSpan = Math.min(info.spanY, profile.numRows);
mWidgetDims.setText(String.format(mDimensionsFormatString, hSpan, vSpan));
mWidgetPreviewLoader = loader;
}
示例14: loadLabel
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
@Override
public String loadLabel(LauncherAppWidgetProviderInfo info) {
return Utilities.trim(info.label);
}
示例15: getUser
import com.android.launcher3.LauncherAppWidgetProviderInfo; //导入依赖的package包/类
@Override
public UserHandleCompat getUser(LauncherAppWidgetProviderInfo info) {
return UserHandleCompat.myUserHandle();
}