List of usage examples for android.content ComponentName unflattenFromString
public static @Nullable ComponentName unflattenFromString(@NonNull String str)
From source file:edu.umich.flowfence.testapp.TestQM.java
public String getState() { trace("getState", this); IEventChannelAPI eventApi = (IEventChannelAPI) FlowfenceContext.getInstance().getTrustedAPI("event"); eventApi.fireEvent(ComponentName.unflattenFromString("edu.umich.flowfence.testapp/testChannel"), "Channel Test", state); return state; }
From source file:edu.umich.oasis.testapp.TestSoda.java
public String getState() { trace("getState", this); IEventChannelAPI eventApi = (IEventChannelAPI) OASISContext.getInstance().getTrustedAPI("event"); eventApi.fireEvent(ComponentName.unflattenFromString("edu.umich.oasis.testapp/testChannel"), "Channel Test", state);/*from w w w. j av a 2 s . co m*/ return state; }
From source file:com.farmerbb.taskbar.receiver.ReceiveSettingsReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Ignore this broadcast if this is the free version if (BuildConfig.APPLICATION_ID.equals(BuildConfig.PAID_APPLICATION_ID)) { // Get pinned and blocked apps PinnedBlockedApps pba = PinnedBlockedApps.getInstance(context); pba.clear(context);/* ww w . ja va2 s . co m*/ String[] pinnedAppsPackageNames = intent.getStringArrayExtra("pinned_apps_package_names"); String[] pinnedAppsComponentNames = intent.getStringArrayExtra("pinned_apps_component_names"); String[] pinnedAppsLabels = intent.getStringArrayExtra("pinned_apps_labels"); long[] pinnedAppsUserIds = intent.getLongArrayExtra("pinned_apps_user_ids"); UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE); if (pinnedAppsPackageNames != null && pinnedAppsComponentNames != null && pinnedAppsLabels != null) for (int i = 0; i < pinnedAppsPackageNames.length; i++) { Intent throwaway = new Intent(); throwaway.setComponent(ComponentName.unflattenFromString(pinnedAppsComponentNames[i])); long userId; if (pinnedAppsUserIds != null) userId = pinnedAppsUserIds[i]; else userId = userManager.getSerialNumberForUser(Process.myUserHandle()); AppEntry newEntry = new AppEntry(pinnedAppsPackageNames[i], pinnedAppsComponentNames[i], pinnedAppsLabels[i], IconCache.getInstance(context).getIcon(context, context.getPackageManager(), launcherApps.resolveActivity(throwaway, userManager.getUserForSerialNumber(userId))), true); newEntry.setUserId(userId); pba.addPinnedApp(context, newEntry); } String[] blockedAppsPackageNames = intent.getStringArrayExtra("blocked_apps_package_names"); String[] blockedAppsComponentNames = intent.getStringArrayExtra("blocked_apps_component_names"); String[] blockedAppsLabels = intent.getStringArrayExtra("blocked_apps_labels"); if (blockedAppsPackageNames != null && blockedAppsComponentNames != null && blockedAppsLabels != null) for (int i = 0; i < blockedAppsPackageNames.length; i++) { pba.addBlockedApp(context, new AppEntry(blockedAppsPackageNames[i], blockedAppsComponentNames[i], blockedAppsLabels[i], null, false)); } // Get blacklist Blacklist blacklist = Blacklist.getInstance(context); blacklist.clear(context); String[] blacklistPackageNames = intent.getStringArrayExtra("blacklist_package_names"); String[] blacklistLabels = intent.getStringArrayExtra("blacklist_labels"); if (blacklistPackageNames != null && blacklistLabels != null) for (int i = 0; i < blacklistPackageNames.length; i++) { blacklist.addBlockedApp(context, new BlacklistEntry(blacklistPackageNames[i], blacklistLabels[i])); } // Get top apps TopApps topApps = TopApps.getInstance(context); topApps.clear(context); String[] topAppsPackageNames = intent.getStringArrayExtra("top_apps_package_names"); String[] topAppsLabels = intent.getStringArrayExtra("top_apps_labels"); if (topAppsPackageNames != null && topAppsLabels != null) for (int i = 0; i < topAppsPackageNames.length; i++) { topApps.addTopApp(context, new BlacklistEntry(topAppsPackageNames[i], topAppsLabels[i])); } // Get saved window sizes if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { SavedWindowSizes savedWindowSizes = SavedWindowSizes.getInstance(context); savedWindowSizes.clear(context); String[] savedWindowSizesComponentNames = intent .getStringArrayExtra("saved_window_sizes_component_names"); String[] savedWindowSizesWindowSizes = intent .getStringArrayExtra("saved_window_sizes_window_sizes"); if (savedWindowSizesComponentNames != null && savedWindowSizesWindowSizes != null) for (int i = 0; i < savedWindowSizesComponentNames.length; i++) { savedWindowSizes.setWindowSize(context, savedWindowSizesComponentNames[i], savedWindowSizesWindowSizes[i]); } } // Get shared preferences String contents = intent.getStringExtra("preferences"); if (contents.length() > 0) try { File file = new File(context.getFilesDir().getParent() + "/shared_prefs/" + BuildConfig.APPLICATION_ID + "_preferences.xml"); FileOutputStream output = new FileOutputStream(file); output.write(contents.getBytes()); output.close(); } catch (IOException e) { /* Gracefully fail */ } try { File file = new File(context.getFilesDir() + File.separator + "imported_successfully"); if (file.createNewFile()) LocalBroadcastManager.getInstance(context) .sendBroadcast(new Intent("com.farmerbb.taskbar.IMPORT_FINISHED")); } catch (IOException e) { /* Gracefully fail */ } } }
From source file:com.farmerbb.taskbar.adapter.StartMenuAdapter.java
@Override public @NonNull View getView(int position, View convertView, final @NonNull ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(isGrid ? R.layout.row_alt : R.layout.row, parent, false);/*www .j a v a 2 s. c om*/ final AppEntry entry = getItem(position); assert entry != null; final SharedPreferences pref = U.getSharedPreferences(getContext()); TextView textView = (TextView) convertView.findViewById(R.id.name); textView.setText(entry.getLabel()); Intent intent = new Intent(); intent.setComponent(ComponentName.unflattenFromString(entry.getComponentName())); ActivityInfo activityInfo = intent.resolveActivityInfo(getContext().getPackageManager(), 0); if (activityInfo != null) textView.setTypeface(null, isTopApp(activityInfo) ? Typeface.BOLD : Typeface.NORMAL); switch (pref.getString("theme", "light")) { case "light": textView.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color)); break; case "dark": textView.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_dark)); break; } ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); imageView.setImageDrawable(entry.getIcon(getContext())); LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.entry); layout.setOnClickListener(view -> { LocalBroadcastManager.getInstance(getContext()) .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU")); U.launchApp(getContext(), entry.getPackageName(), entry.getComponentName(), entry.getUserId(getContext()), null, false, false); }); layout.setOnLongClickListener(view -> { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); return true; }); layout.setOnGenericMotionListener((view, motionEvent) -> { int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); } if (action == MotionEvent.ACTION_SCROLL && pref.getBoolean("visual_feedback", true)) view.setBackgroundColor(0); return false; }); if (pref.getBoolean("visual_feedback", true)) { layout.setOnHoverListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) { int backgroundTint = pref.getBoolean("transparent_start_menu", false) ? U.getAccentColor(getContext()) : U.getBackgroundTint(getContext()); //noinspection ResourceAsColor backgroundTint = ColorUtils.setAlphaComponent(backgroundTint, Color.alpha(backgroundTint) / 2); v.setBackgroundColor(backgroundTint); } if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) v.setBackgroundColor(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) v.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT)); return false; }); layout.setOnTouchListener((v, event) -> { v.setAlpha( event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE ? 0.5f : 1); return false; }); } return convertView; }
From source file:com.google.android.apps.muzei.SourceManager.java
private void loadStoredData() { // Load selected source info String selectedSource = mSharedPrefs.getString(PREF_SELECTED_SOURCE, null); if (selectedSource != null) { mSelectedSource = ComponentName.unflattenFromString(selectedSource); } else {/*from w w w . j a v a2 s. c o m*/ selectDefaultSource(); return; } mSelectedSourceToken = mSharedPrefs.getString(PREF_SELECTED_SOURCE_TOKEN, null); // Load current source states Set<String> sourceStates = mSharedPrefs.getStringSet(PREF_SOURCE_STATES, null); mSourceStates.clear(); if (sourceStates != null) { for (String sourceStatesPair : sourceStates) { String[] pair = sourceStatesPair.split("\\|", 2); try { mSourceStates.put(ComponentName.unflattenFromString(pair[0]), SourceState.fromJson((JSONObject) new JSONTokener(pair[1]).nextValue())); } catch (JSONException e) { LOGE(TAG, "Error loading source state.", e); } } } }
From source file:com.googlecode.eyesfree.brailleback.IMEHelper.java
/** * Determines from system settings if {@code IMEClass} is an enabled input * method./* w w w . j a v a2s . co m*/ */ public static boolean isInputMethodEnabled(Context context, Class<?> IMEClass) { final ComponentName imeComponentName = new ComponentName(context, IMEClass); final String enabledIMEIds = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS); if (enabledIMEIds == null) { return false; } for (String enabledIMEId : enabledIMEIds.split(":")) { if (imeComponentName.equals(ComponentName.unflattenFromString(enabledIMEId))) { return true; } } return false; }
From source file:edu.umich.flowfence.common.TaintSet.java
public static TaintSet singleton(String taintKind) { return singleton(ComponentName.unflattenFromString(taintKind)); }
From source file:com.nks.nksmod.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from ww w . j a va 2s . c o m*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_info) { Intent intent = new Intent(this, InformationActivity.class); startActivity(intent); } if (id == R.id.nav_update) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName .unflattenFromString("com.nks.nksmod.otaupdater/com.nks.nksmod.otaupdater.OTAUpdaterActivity")); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } /* if (id == R.id.nav_gallery) { } else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_manage) { } else if (id == R.id.nav_share) { } else if (id == R.id.nav_send) { } */ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:edu.umich.flowfence.common.TaintSet.java
public static TaintSet singleton(String taintKind, float amount) { return singleton(ComponentName.unflattenFromString(taintKind), amount); }
From source file:com.androidzeitgeist.dashwatch.muzei.SourceManager.java
private void loadStoredData() { // Load selected source info String selectedSource = mSharedPrefs.getString(PREF_SELECTED_SOURCE, null); if (selectedSource != null) { mSelectedSource = ComponentName.unflattenFromString(selectedSource); } else {// ww w . ja va 2 s. c o m selectDefaultSource(); return; } mSelectedSourceToken = mSharedPrefs.getString(PREF_SELECTED_SOURCE_TOKEN, null); // Load current source states Set<String> sourceStates = mSharedPrefs.getStringSet(PREF_SOURCE_STATES, null); mSourceStates.clear(); if (sourceStates != null) { for (String sourceStatesPair : sourceStates) { String[] pair = sourceStatesPair.split("\\|", 2); try { mSourceStates.put(ComponentName.unflattenFromString(pair[0]), SourceState.fromJson((JSONObject) new JSONTokener(pair[1]).nextValue())); } catch (JSONException e) { Log.e(TAG, "Error loading source state.", e); } } } }