List of usage examples for android.content ComponentName unflattenFromString
public static @Nullable ComponentName unflattenFromString(@NonNull String str)
From source file:com.googlecode.eyesfree.brailleback.IMEHelper.java
/** * Determines, from system settings, if {@code IMEClass} is the default * input method.//from ww w . j ava 2s . co m */ public static boolean isInputMethodDefault(Context context, Class<?> IMEClass) { final ComponentName imeComponentName = new ComponentName(context, IMEClass); final String defaultIMEId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); return defaultIMEId != null && imeComponentName.equals(ComponentName.unflattenFromString(defaultIMEId)); }
From source file:com.androidzeitgeist.dashwatch.dashclock.ExtensionManager.java
private void loadActiveExtensionList() { List<ComponentName> activeExtensions = new ArrayList<ComponentName>(); String extensions;//from w ww.j a va 2 s . c o m if (mDefaultPreferences.contains(PREF_ACTIVE_EXTENSIONS)) { extensions = mDefaultPreferences.getString(PREF_ACTIVE_EXTENSIONS, ""); } else { extensions = createDefaultExtensionList(); } String[] componentNameStrings = extensions.split(","); for (String componentNameString : componentNameStrings) { if (TextUtils.isEmpty(componentNameString)) { continue; } activeExtensions.add(ComponentName.unflattenFromString(componentNameString)); } setActiveExtensions(activeExtensions, false); }
From source file:edu.umich.flowfence.common.TaintSet.java
@Deprecated public boolean isTaintedWith(String taintKind) { return isTaintedWith(ComponentName.unflattenFromString(taintKind)); }
From source file:edu.umich.flowfence.common.TaintSet.java
@Deprecated public float getTaintAmount(String taintKind) { return getTaintAmount(ComponentName.unflattenFromString(taintKind)); }
From source file:com.battlelancer.seriesguide.extensions.ExtensionManager.java
/** * Queries the {@link android.content.pm.PackageManager} for any installed {@link * com.battlelancer.seriesguide.api.SeriesGuideExtension} extensions. Their info is extracted * into {@link com.battlelancer.seriesguide.extensions.ExtensionManager.Extension} objects. *///from w ww . j a v a 2 s .co m public List<Extension> queryAllAvailableExtensions() { Intent queryIntent = new Intent(SeriesGuideExtension.ACTION_SERIESGUIDE_EXTENSION); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(queryIntent, PackageManager.GET_META_DATA); List<Extension> extensions = new ArrayList<>(); for (ResolveInfo info : resolveInfos) { Extension extension = new Extension(); // get label, icon and component name extension.label = info.loadLabel(pm).toString(); extension.icon = info.loadIcon(pm); extension.componentName = new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name); // get description Context packageContext; try { packageContext = mContext.createPackageContext(extension.componentName.getPackageName(), 0); Resources packageRes = packageContext.getResources(); extension.description = packageRes.getString(info.serviceInfo.descriptionRes); } catch (SecurityException | PackageManager.NameNotFoundException | Resources.NotFoundException e) { Timber.e(e, "Reading description for extension " + extension.componentName + " failed"); extension.description = ""; } // get (optional) settings activity Bundle metaData = info.serviceInfo.metaData; if (metaData != null) { String settingsActivity = metaData.getString("settingsActivity"); if (!TextUtils.isEmpty(settingsActivity)) { extension.settingsActivity = ComponentName .unflattenFromString(info.serviceInfo.packageName + "/" + settingsActivity); } } Timber.d("queryAllAvailableExtensions: found extension " + extension.label + " " + extension.componentName); extensions.add(extension); } return extensions; }
From source file:edu.umich.flowfence.common.TaintSet.java
@Deprecated public float getTaintAmount(String taintKind, float amountIfNotTainted) { return getTaintAmount(ComponentName.unflattenFromString(taintKind), amountIfNotTainted); }
From source file:com.tasomaniac.openwith.resolver.ResolverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { final Intent intent = makeMyIntent(); setTheme(R.style.BottomSheet_Light); super.onCreate(savedInstanceState); mPm = getPackageManager();/*w ww .j a va2s . c om*/ mRequestedUri = intent.getData(); boolean isCallerPackagePreferred = false; final String callerPackage = getCallerPackage(); ResolveInfo lastChosen = null; final Cursor query = getContentResolver().query(withHost(intent.getData().getHost()), null, null, null, null); if (query != null && query.moveToFirst()) { final boolean isPreferred = query.getInt(query.getColumnIndex(PREFERRED)) == 1; final boolean isLastChosen = query.getInt(query.getColumnIndex(LAST_CHOSEN)) == 1; if (isPreferred || isLastChosen) { final String componentString = query.getString(query.getColumnIndex(COMPONENT)); final Intent lastChosenIntent = new Intent(); final ComponentName lastChosenComponent = ComponentName.unflattenFromString(componentString); lastChosenIntent.setComponent(lastChosenComponent); ResolveInfo ri = mPm.resolveActivity(lastChosenIntent, PackageManager.MATCH_DEFAULT_ONLY); if (isPreferred && ri != null) { isCallerPackagePreferred = ri.activityInfo.packageName.equals(callerPackage); if (!isCallerPackagePreferred) { intent.setComponent(lastChosenComponent); startActivity(intent); finish(); return; } } lastChosen = ri; } query.close(); } mPackageMonitor.register(this, getMainLooper(), false); mRegistered = true; final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); mIconDpi = am.getLauncherLargeIconDensity(); mAdapter = new ResolveListAdapter(this, getHistory(), intent, callerPackage, lastChosen, true); mAdapter.setPriorityItems(intent.getStringArrayExtra(EXTRA_PRIORITY_PACKAGES)); mAlwaysUseOption = true; final int layoutId; final boolean useHeader; if (mAdapter.hasFilteredItem()) { layoutId = R.layout.resolver_list_with_default; mAlwaysUseOption = false; useHeader = true; } else { useHeader = false; layoutId = R.layout.resolver_list; } //If the caller is already the preferred, don't change it. if (isCallerPackagePreferred) { mAlwaysUseOption = false; } int count = mAdapter.mList.size(); if (count > 1) { setContentView(layoutId); mListView = (RecyclerView) findViewById(R.id.resolver_list); mListView.setAdapter(mAdapter); mAdapter.setOnItemClickedListener(this); mAdapter.setOnItemLongClickedListener(this); if (mAlwaysUseOption) { mAdapter.setSelectable(true); } if (useHeader) { mAdapter.setHeader(new ResolveListAdapter.Header()); } } else if (count == 1) { startActivity(mAdapter.intentForPosition(0, false)); mPackageMonitor.unregister(); mRegistered = false; finish(); return; } else { setContentView(R.layout.resolver_list); final TextView empty = (TextView) findViewById(R.id.empty); empty.setVisibility(View.VISIBLE); mListView = (RecyclerView) findViewById(R.id.resolver_list); mListView.setVisibility(View.GONE); } mListView.setLayoutManager(new LinearLayoutManager(this)); // Prevent the Resolver window from becoming the top fullscreen window and thus from taking // control of the system bars. getWindow().clearFlags(FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR); final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel); if (rdl != null) { rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() { @Override public void onDismissed() { finish(); } }); } CharSequence title = getTitleForAction(); if (!TextUtils.isEmpty(title)) { final TextView titleView = (TextView) findViewById(R.id.title); if (titleView != null) { titleView.setText(title); } setTitle(title); } final ImageView iconView = (ImageView) findViewById(R.id.icon); final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem(); if (iconView != null && iconInfo != null) { new LoadIconIntoViewTask(iconView).execute(iconInfo); } if (mAlwaysUseOption || mAdapter.hasFilteredItem()) { final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar); if (buttonLayout != null) { buttonLayout.setVisibility(View.VISIBLE); mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always); mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once); } else { mAlwaysUseOption = false; } } if (mAdapter.hasFilteredItem()) { mAlwaysButton.setEnabled(true); mOnceButton.setEnabled(true); } }
From source file:com.appsimobile.appsii.module.apps.AppPageLoader.java
private List<HistoryItem> loadRecentApps() { Cursor cursor = mContext.getContentResolver().query(AppsContract.LaunchHistoryColumns.CONTENT_URI, AppHistoryQuery.PROJECTION, null, null, AppsContract.LaunchHistoryColumns.LAUNCH_COUNT + " DESC, " + AppsContract.LaunchHistoryColumns.LAST_LAUNCHED + " DESC "); List<HistoryItem> result = new ArrayList<>(); while (cursor.moveToNext()) { int count = cursor.getInt(AppHistoryQuery.LAUNCH_COUNT); String flattenedComponentName = cursor.getString(AppHistoryQuery.COMPONENT_NAME); long lastLaunched = cursor.getLong(AppHistoryQuery.LAST_LAUNCHED); ComponentName cn = ComponentName.unflattenFromString(flattenedComponentName); HistoryItem item = new HistoryItem(); item.componentName = cn;//from ww w. ja v a 2 s . c om item.launchCount = count; item.lastLaunched = lastLaunched; result.add(item); if (result.size() >= 9) break; } cursor.close(); return result; }
From source file:edu.umich.flowfence.common.QMDescriptor.java
public static QMDescriptor parse(String descriptorString) { Matcher matcher = NAME_PATTERN.matcher(Objects.requireNonNull(descriptorString, "descriptorString")); Validate.isTrue(matcher.matches(), "Can't parse QMDescriptor '%s'", descriptorString); ComponentName component = ComponentName.unflattenFromString(matcher.group(1)); String indicator = matcher.group(2); int kind = (indicator == null) ? KIND_CTOR : indicator.equals("#") ? KIND_INSTANCE : KIND_STATIC; String methodName = matcher.group(3); String[] typeNameArray = StringUtils.splitByWholeSeparator(matcher.group(4), ", "); List<String> typeNames = Arrays.asList(ArrayUtils.nullToEmpty(typeNameArray)); return new QMDescriptor(kind, component, methodName, typeNames, false); }
From source file:edu.umich.oasis.common.SodaDescriptor.java
public static SodaDescriptor parse(String descriptorString) { Matcher matcher = NAME_PATTERN.matcher(Objects.requireNonNull(descriptorString, "descriptorString")); Validate.isTrue(matcher.matches(), "Can't parse SodaDescriptor '%s'", descriptorString); ComponentName component = ComponentName.unflattenFromString(matcher.group(1)); String indicator = matcher.group(2); int kind = (indicator == null) ? KIND_CTOR : indicator.equals("#") ? KIND_INSTANCE : KIND_STATIC; String methodName = matcher.group(3); String[] typeNameArray = StringUtils.splitByWholeSeparator(matcher.group(4), ", "); List<String> typeNames = Arrays.asList(ArrayUtils.nullToEmpty(typeNameArray)); return new SodaDescriptor(kind, component, methodName, typeNames, false); }