Example usage for android.appwidget AppWidgetProviderInfo loadLabel

List of usage examples for android.appwidget AppWidgetProviderInfo loadLabel

Introduction

In this page you can find the example usage for android.appwidget AppWidgetProviderInfo loadLabel.

Prototype

public final String loadLabel(PackageManager packageManager) 

Source Link

Document

Loads the localized label to display to the user in the AppWidget picker.

Usage

From source file:com.farmerbb.taskbar.service.DashboardService.java

private void cellClick(View view, boolean isActualClick) {
    Bundle bundle = (Bundle) view.getTag();
    int cellId = bundle.getInt("cellId");
    int appWidgetId = bundle.getInt("appWidgetId", -1);

    int currentlySelectedCell = appWidgetId == -1 ? cellId : -1;

    SharedPreferences pref = U.getSharedPreferences(this);
    boolean shouldShowPlaceholder = pref
            .getBoolean("dashboard_widget_" + Integer.toString(cellId) + "_placeholder", false);
    if (isActualClick && ((appWidgetId == -1 && currentlySelectedCell == previouslySelectedCell)
            || shouldShowPlaceholder)) {
        fadeOut(false);//from   www  .j a v  a2  s.c om

        FrameLayout frameLayout = cells.get(currentlySelectedCell);
        frameLayout.findViewById(R.id.empty).setVisibility(View.GONE);

        Intent intent = new Intent("com.farmerbb.taskbar.ADD_WIDGET_REQUESTED");
        intent.putExtra("appWidgetId", APPWIDGET_HOST_ID);
        intent.putExtra("cellId", cellId);
        LocalBroadcastManager.getInstance(DashboardService.this).sendBroadcast(intent);

        if (shouldShowPlaceholder) {
            String providerName = pref.getString("dashboard_widget_" + Integer.toString(cellId) + "_provider",
                    "null");
            if (!providerName.equals("null")) {
                ComponentName componentName = ComponentName.unflattenFromString(providerName);

                List<AppWidgetProviderInfo> providerInfoList = mAppWidgetManager
                        .getInstalledProvidersForProfile(Process.myUserHandle());
                for (AppWidgetProviderInfo info : providerInfoList) {
                    if (info.provider.equals(componentName)) {
                        U.showToast(this,
                                getString(R.string.widget_restore_toast, info.loadLabel(getPackageManager())),
                                Toast.LENGTH_SHORT);
                        break;
                    }
                }
            }
        }

        previouslySelectedCell = -1;
    } else {
        for (int i = 0; i < maxSize; i++) {
            FrameLayout frameLayout = cells.get(i);
            frameLayout.findViewById(R.id.empty).setVisibility(
                    i == currentlySelectedCell && !shouldShowPlaceholder ? View.VISIBLE : View.GONE);
        }

        previouslySelectedCell = currentlySelectedCell;
    }
}

From source file:com.android.launcher2.AsyncTaskCallback.java

private void dumpAppWidgetProviderInfoList(String tag, String label, ArrayList<Object> list) {
    Log.d(tag, label + " size=" + list.size());
    for (Object i : list) {
        if (i instanceof AppWidgetProviderInfo) {
            AppWidgetProviderInfo info = (AppWidgetProviderInfo) i;
            Log.d(tag, "   label=\"" + info.label + "\" previewImage=" + info.previewImage + " resizeMode="
                    + info.resizeMode + " configure=" + info.configure + " initialLayout=" + info.initialLayout
                    + " minWidth=" + info.minWidth + " minHeight=" + info.minHeight);
        } else if (i instanceof ResolveInfo) {
            ResolveInfo info = (ResolveInfo) i;
            Log.d(tag, "   label=\"" + info.loadLabel(mPackageManager) + "\" icon=" + info.icon);
        }/*w  w  w .  jav a2 s  .co m*/
    }
}