当前位置: 首页>>代码示例>>Java>>正文


Java Utilities类代码示例

本文整理汇总了Java中com.android.launcher3.Utilities的典型用法代码示例。如果您正苦于以下问题:Java Utilities类的具体用法?Java Utilities怎么用?Java Utilities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Utilities类属于com.android.launcher3包,在下文中一共展示了Utilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateViewHolder

import com.android.launcher3.Utilities; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public WidgetsRowViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (DEBUG) {
        Log.v(TAG, "\nonCreateViewHolder");
    }

    ViewGroup container = (ViewGroup) mLayoutInflater.inflate(
            R.layout.widgets_list_row_view, parent, false);
    LinearLayout cellList = (LinearLayout) container.findViewById(R.id.widgets_cell_list);

    // if the end padding is 0, then container view (horizontal scroll view) doesn't respect
    // the end of the linear layout width + the start padding and doesn't allow scrolling.
    if (Utilities.ATLEAST_JB_MR1) {
        cellList.setPaddingRelative(mIndent, 0, 1, 0);
    } else {
        cellList.setPadding(mIndent, 0, 1, 0);
    }

    return new WidgetsRowViewHolder(container);
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:22,代码来源:WidgetsListAdapter.java

示例2: onCreate

import com.android.launcher3.Utilities; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences sp = Utilities.getPrefs(this);
    boolean show = sp.getBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, true);

    show = !show;
    sp.edit().putBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, show).apply();

    Launcher launcher = (Launcher) LauncherAppState.getInstance().getModel().getCallback();
    if (launcher != null && launcher.mWeightWatcher != null) {
        launcher.mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE);
    }
    finish();
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:17,代码来源:ToggleWeightWatcher.java

示例3: addWeightWatcher

import com.android.launcher3.Utilities; //导入依赖的package包/类
public static void addWeightWatcher(Launcher launcher) {
    if (MEMORY_DUMP_ENABLED) {
        boolean show = Utilities.getPrefs(launcher).getBoolean(SHOW_WEIGHT_WATCHER, true);

        int id = launcher.getResources().getIdentifier("zzz_weight_watcher", "layout",
                launcher.getPackageName());
        View watcher = launcher.getLayoutInflater().inflate(id, null);
        watcher.setAlpha(0.5f);
        ((FrameLayout) launcher.findViewById(R.id.launcher)).addView(watcher,
                new FrameLayout.LayoutParams(
                        FrameLayout.LayoutParams.MATCH_PARENT,
                        FrameLayout.LayoutParams.WRAP_CONTENT,
                        Gravity.BOTTOM)
        );

        watcher.setVisibility(show ? View.VISIBLE : View.GONE);
        launcher.mWeightWatcher = watcher;
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:20,代码来源:TestingUtils.java

示例4: unpinShortcut

import com.android.launcher3.Utilities; //导入依赖的package包/类
/**
 * Removes the given shortcut from the current list of pinned shortcuts.
 * (Runs on background thread)
 */
@TargetApi(25)
public void unpinShortcut(final ShortcutKey key) {
    if (Utilities.isNycMR1OrAbove()) {
        String packageName = key.componentName.getPackageName();
        String id = key.getId();
        UserHandleCompat user = key.user;
        List<String> pinnedIds = extractIds(queryForPinnedShortcuts(packageName, user));
        pinnedIds.remove(id);
        try {
            mLauncherApps.pinShortcuts(packageName, pinnedIds, user.getUser());
            mWasLastCallSuccess = true;
        } catch (SecurityException|IllegalStateException e) {
            Log.w(TAG, "Failed to unpin shortcut", e);
            mWasLastCallSuccess = false;
        }
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:22,代码来源:DeepShortcutManager.java

示例5: DragLayer

import com.android.launcher3.Utilities; //导入依赖的package包/类
/**
 * Used to create a new DragLayer from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 */
public DragLayer(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(false);
    setChildrenDrawingOrderEnabled(true);

    final Resources res = getResources();
    mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left);
    mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right);
    mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active);
    mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active);
    mIsRtl = Utilities.isRtl(res);
    mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:22,代码来源:DragLayer.java

示例6: getInstance

import com.android.launcher3.Utilities; //导入依赖的package包/类
public static UserManagerCompat getInstance(Context context) {
    synchronized (sInstanceLock) {
        if (sInstance == null) {
            if (Utilities.isNycMR1OrAbove()) {
                sInstance = new UserManagerCompatVNMr1(context.getApplicationContext());
            } else if (Utilities.isNycOrAbove()) {
                sInstance = new UserManagerCompatVN(context.getApplicationContext());
            } else if (Utilities.ATLEAST_MARSHMALLOW) {
                sInstance = new UserManagerCompatVM(context.getApplicationContext());
            } else if (Utilities.ATLEAST_LOLLIPOP) {
                sInstance = new UserManagerCompatVL(context.getApplicationContext());
            } else if (Utilities.ATLEAST_JB_MR1) {
                sInstance = new UserManagerCompatV17(context.getApplicationContext());
            } else {
                sInstance = new UserManagerCompatV16();
            }
        }
        return sInstance;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:21,代码来源:UserManagerCompat.java

示例7: onClick

import com.android.launcher3.Utilities; //导入依赖的package包/类
@Override
public void onClick(View v) {
    // When we have exited widget tray or are in transition, disregard clicks
    if (!mLauncher.isWidgetsViewVisible()
            || mLauncher.getWorkspace().isSwitchingState()
            || !(v instanceof WidgetCell)) return;

    // Let the user know that they have to long press to add a widget
    if (mWidgetInstructionToast != null) {
        mWidgetInstructionToast.cancel();
    }

    CharSequence msg = Utilities.wrapForTts(
            getContext().getText(R.string.long_press_widget_to_add),
            getContext().getString(R.string.long_accessible_way_to_add));
    mWidgetInstructionToast = Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT);
    mWidgetInstructionToast.show();
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:19,代码来源:WidgetsContainerView.java

示例8: AllAppsGridAdapter

import com.android.launcher3.Utilities; //导入依赖的package包/类
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnClickListener
        iconClickListener, View.OnLongClickListener iconLongClickListener) {
    Resources res = launcher.getResources();
    mLauncher = launcher;
    mApps = apps;
    mEmptySearchMessage = res.getString(R.string.all_apps_loading_message);
    mGridSizer = new GridSpanSizer();
    mGridLayoutMgr = new AppsGridLayoutManager(launcher);
    mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
    mItemDecoration = new GridItemDecoration();
    mLayoutInflater = LayoutInflater.from(launcher);
    mIconClickListener = iconClickListener;
    mIconLongClickListener = iconLongClickListener;
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset);
    mIsRtl = Utilities.isRtl(res);

    mSectionTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mSectionTextPaint.setTextSize(res.getDimensionPixelSize(
            R.dimen.all_apps_grid_section_text_size));
    mSectionTextPaint.setColor(Utilities.getColorAccent(launcher));
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:23,代码来源:AllAppsGridAdapter.java

示例9: doneEditingFolderName

import com.android.launcher3.Utilities; //导入依赖的package包/类
public void doneEditingFolderName(boolean commit) {
    mFolderName.setHint(sHintText);
    // Convert to a string here to ensure that no other state associated with the text field
    // gets saved.
    String newTitle = mFolderName.getText().toString();
    mInfo.setTitle(newTitle);
    LauncherModel.updateItemInDatabase(mLauncher, mInfo);

    if (commit) {
        Utilities.sendCustomAccessibilityEvent(
                this, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                getContext().getString(R.string.folder_renamed, newTitle));
    }

    // This ensures that focus is gained every time the field is clicked, which selects all
    // the text and brings up the soft keyboard if necessary.
    mFolderName.clearFocus();

    Selection.setSelection((Spannable) mFolderName.getText(), 0, 0);
    mIsEditingName = false;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:22,代码来源:Folder.java

示例10: FolderPagedView

import com.android.launcher3.Utilities; //导入依赖的package包/类
public FolderPagedView(Context context, AttributeSet attrs) {
    super(context, attrs);
    LauncherAppState app = LauncherAppState.getInstance();

    InvariantDeviceProfile profile = app.getInvariantDeviceProfile();
    mMaxCountX = profile.numFolderColumns;
    mMaxCountY = profile.numFolderRows;

    mMaxItemsPerPage = mMaxCountX * mMaxCountY;

    mInflater = LayoutInflater.from(context);
    mIconCache = app.getIconCache();

    mIsRtl = Utilities.isRtl(getResources());
    setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);

    setEdgeGlowColor(getResources().getColor(R.color.folder_edge_effect_color));
    mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:20,代码来源:FolderPagedView.java

示例11: computePreviewDrawingParams

import com.android.launcher3.Utilities; //导入依赖的package包/类
private void computePreviewDrawingParams(int drawableSize, int totalSize) {
    if (mIntrinsicIconSize != drawableSize || mTotalWidth != totalSize ||
            mPrevTopPadding != getPaddingTop()) {
        DeviceProfile grid = mLauncher.getDeviceProfile();

        mIntrinsicIconSize = drawableSize;
        mTotalWidth = totalSize;
        mPrevTopPadding = getPaddingTop();

        mBackground.setup(getResources().getDisplayMetrics(), grid, this, mTotalWidth,
                getPaddingTop());
        mPreviewLayoutRule.init(mBackground.previewSize, mIntrinsicIconSize,
                Utilities.isRtl(getResources()));

        updateItemDrawingParams(false);
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:18,代码来源:FolderIcon.java

示例12: drawBackgroundStroke

import com.android.launcher3.Utilities; //导入依赖的package包/类
public void drawBackgroundStroke(Canvas canvas, Paint paint) {
    canvas.save();
    canvas.translate(getOffsetX(), getOffsetY());

    paint.reset();
    paint.setAntiAlias(true);
    if(Utilities.getFolderPreviewCirclePrefEnabled(Launcher.getLauncherActivity().getApplicationContext()) != -1){
        paint.setColor(Utilities.getFolderPreviewCirclePrefEnabled(Launcher.getLauncherActivity().getApplicationContext()));
    }else {
        paint.setColor(Color.argb(255, BG_INTENSITY, BG_INTENSITY, BG_INTENSITY));
    }
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(mStrokeWidth);

    float radius = getScaledRadius();
    canvas.drawCircle(radius, radius, radius - 1, paint);

    canvas.restore();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:20,代码来源:FolderIcon.java

示例13: processAllUsers

import com.android.launcher3.Utilities; //导入依赖的package包/类
/**
 * Verifies that entries corresponding to {@param users} exist and removes all invalid entries.
 */
public static void processAllUsers(List<UserHandleCompat> users, Context context) {
    if (!Utilities.ATLEAST_LOLLIPOP) {
        return;
    }
    UserManagerCompat userManager = UserManagerCompat.getInstance(context);
    HashSet<String> validKeys = new HashSet<String>();
    for (UserHandleCompat user : users) {
        addAllUserKeys(userManager.getSerialNumberForUser(user), validKeys);
    }

    SharedPreferences prefs = context.getSharedPreferences(
            LauncherFiles.MANAGED_USER_PREFERENCES_KEY,
            Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    for (String key : prefs.getAll().keySet()) {
        if (!validKeys.contains(key)) {
            editor.remove(key);
        }
    }
    editor.apply();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:25,代码来源:ManagedProfileHeuristic.java

示例14: loadIcon

import com.android.launcher3.Utilities; //导入依赖的package包/类
/**
 * Loads the icon from the cursor and updates the {@param info} if the icon is an app resource.
 */
public Bitmap loadIcon(Cursor c, ShortcutInfo info) {
    Bitmap icon = null;
    String packageName = c.getString(iconPackageIndex);
    String resourceName = c.getString(iconResourceIndex);
    if (!TextUtils.isEmpty(packageName) || !TextUtils.isEmpty(resourceName)) {
        info.iconResource = new ShortcutIconResource();
        info.iconResource.packageName = packageName;
        info.iconResource.resourceName = resourceName;
        icon = Utilities.createIconBitmap(packageName, resourceName, mContext);
    }
    if (icon == null) {
        // Failed to load from resource, try loading from DB.
        icon = loadIcon(c);
    }
    return icon;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:20,代码来源:CursorIconInfo.java

示例15: onCreate

import com.android.launcher3.Utilities; //导入依赖的package包/类
@Override
@TargetApi(23)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_password);

    textView = (TextView) findViewById(R.id.errorText);
    passwordInput = (EditText) findViewById(R.id.password_input);

    passwordInput.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_ENTER
                    && event.getAction() == KeyEvent.ACTION_UP) {

                String password = ((EditText) v).getText().toString();

                SharedPreferences preferences = getSharedPreferences(Utilities.PASSWORD_SHARED_PREF, MODE_PRIVATE);
                String passEncrypted = preferences.getString(Utilities.encrypt("password"), Utilities.encrypt("NULLPASS"));
                String pass = Utilities.decrypt(passEncrypted);
                if(!password.equals(pass)){
                    textView.setText(getString(R.string.password_failed));
                }else{
                    textView.setText(getString(R.string.password_succeded));
                    textView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDarkFinger));
                    Intent returnIntent = new Intent();
                    returnIntent.putExtra("resultPassword", true);
                    setResult(Activity.RESULT_OK, returnIntent);
                    finish();
                }

            }

            return false;
        }
    });

}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:41,代码来源:PasswordActivitySettings.java


注:本文中的com.android.launcher3.Utilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。