Esempio n. 1
0
  private void updateVisibleApps() {
    final HashSet<LaunchableActivity> infoList =
        mTrie.getAllStartingWith(
            stripAccents(mSearchEditText.getText().toString().toLowerCase().trim()));
    mActivityInfos.clear();
    mActivityInfos.addAll(infoList);
    mActivityInfos.addAll(mShareableActivityInfos);
    sortApps();
    Log.d("DEBUG_SEARCH", mActivityInfos.size() + "");

    mArrayAdapter.notifyDataSetChanged();
  }
Esempio n. 2
0
  private void removeActivitiesFromPackage(String packageName) {
    final List<LaunchableActivity> launchableActivitiesToRemove =
        mLaunchableActivityPackageNameHashMap.remove(packageName);
    if (launchableActivitiesToRemove == null) {
      return;
    }
    boolean activityListChanged = false;

    for (LaunchableActivity launchableActivityToRemove : launchableActivitiesToRemove) {
      final String className = launchableActivityToRemove.getClassName();
      Log.d("SearchActivity", "removing activity " + className);
      String activityLabel = launchableActivityToRemove.getActivityLabel();
      final List<String> subwords = getAllSubwords(stripAccents(activityLabel));
      for (String subword : subwords) {
        mTrie.remove(subword, launchableActivityToRemove);
      }
      if (mActivityInfos.remove(launchableActivityToRemove)) activityListChanged = true;
      // TODO DEBUGME if uncommented the next line causes a crash.
      // mLaunchableActivityPrefs.deletePreference(className);
    }

    if (activityListChanged) mArrayAdapter.notifyDataSetChanged();
  }
Esempio n. 3
0
  private void updateApps(final List<LaunchableActivity> updatedActivityInfos, boolean addToTrie) {

    for (LaunchableActivity launchableActivity : updatedActivityInfos) {
      final String packageName = launchableActivity.getComponent().getPackageName();
      mLaunchableActivityPackageNameHashMap.remove(packageName);
    }

    final String thisClassCanonicalName = this.getClass().getCanonicalName();
    for (LaunchableActivity launchableActivity : updatedActivityInfos) {
      final String className = launchableActivity.getComponent().getClassName();
      // don't show this activity in the launcher
      if (className.equals(thisClassCanonicalName)) {
        continue;
      }

      if (addToTrie) {
        final String activityLabel = launchableActivity.getActivityLabel();
        final List<String> subwords = getAllSubwords(stripAccents(activityLabel));
        for (String subword : subwords) {
          mTrie.put(subword, launchableActivity);
        }
      }
      final String packageName = launchableActivity.getComponent().getPackageName();

      List<LaunchableActivity> launchableActivitiesToUpdate =
          mLaunchableActivityPackageNameHashMap.remove(packageName);
      if (launchableActivitiesToUpdate == null) {
        launchableActivitiesToUpdate = new LinkedList<>();
      }
      launchableActivitiesToUpdate.add(launchableActivity);
      mLaunchableActivityPackageNameHashMap.put(packageName, launchableActivitiesToUpdate);
    }
    Log.d("SearchActivity", "updated activities: " + updatedActivityInfos.size());
    mLaunchableActivityPrefs.setAllPreferences(updatedActivityInfos);
    updateVisibleApps();
  }