Ejemplo n.º 1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setHasOptionsMenu(true);

    mApplicationsState = ApplicationsState.getInstance(getActivity().getApplication());
    mApplicationsAdapter = new ApplicationsAdapter(mApplicationsState);
    Intent intent = getActivity().getIntent();
    String action = intent.getAction();
    String defaultTabTag = TAB_DOWNLOADED;
    String className = getArguments() != null ? getArguments().getString("classname") : null;
    if (className == null) {
      className = intent.getComponent().getClassName();
    }
    if (className.equals(RunningServicesActivity.class.getName())
        || className.endsWith(".RunningServices")) {
      defaultTabTag = TAB_RUNNING;
    } else if (className.equals(StorageUseActivity.class.getName())
        || Intent.ACTION_MANAGE_PACKAGE_STORAGE.equals(action)
        || className.endsWith(".StorageUse")) {
      mSortOrder = SORT_ORDER_SIZE;
      mFilterApps = FILTER_APPS_ALL;
      defaultTabTag = TAB_ALL;
    } else if (Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS.equals(action)) {
      // Select the all-apps tab, with the default sorting
      defaultTabTag = TAB_ALL;
    }

    if (savedInstanceState != null) {
      mSortOrder = savedInstanceState.getInt("sortOrder", mSortOrder);
      mFilterApps = savedInstanceState.getInt("filterApps", mFilterApps);
      String tmp = savedInstanceState.getString("defaultTabTag");
      if (tmp != null) defaultTabTag = tmp;
      mShowBackground = savedInstanceState.getBoolean("showBackground", false);
    }

    mDefaultTab = defaultTabTag;

    mDataFileStats = new StatFs("/data");
    mSDCardFileStats = new StatFs(Environment.getExternalStorageDirectory().toString());

    mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
    mComputingSizeStr = getActivity().getText(R.string.computing_size);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setHasOptionsMenu(true);

    mApplicationsState = ApplicationsState.getInstance(getActivity().getApplication());
    Intent intent = getActivity().getIntent();
    String action = intent.getAction();
    int defaultListType = LIST_TYPE_DOWNLOADED;
    String className = getArguments() != null ? getArguments().getString("classname") : null;
    if (className == null) {
      className = intent.getComponent().getClassName();
    }
    if (className.equals(RunningServicesActivity.class.getName())
        || className.endsWith(".RunningServices")) {
      defaultListType = LIST_TYPE_RUNNING;
    } else if (className.equals(StorageUseActivity.class.getName())
        || Intent.ACTION_MANAGE_PACKAGE_STORAGE.equals(action)
        || className.endsWith(".StorageUse")) {
      mSortOrder = SORT_ORDER_SIZE;
      defaultListType = LIST_TYPE_ALL;
    } else if (Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS.equals(action)) {
      // Select the all-apps list, with the default sorting
      defaultListType = LIST_TYPE_ALL;
    }

    if (savedInstanceState != null) {
      mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder);
      int tmp = savedInstanceState.getInt(EXTRA_DEFAULT_LIST_TYPE, -1);
      if (tmp != -1) defaultListType = tmp;
      mShowBackground = savedInstanceState.getBoolean(EXTRA_SHOW_BACKGROUND, false);
    }

    mDefaultListType = defaultListType;

    final Intent containerIntent =
        new Intent().setComponent(StorageMeasurement.DEFAULT_CONTAINER_COMPONENT);
    getActivity().bindService(containerIntent, mContainerConnection, Context.BIND_AUTO_CREATE);

    mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
    mComputingSizeStr = getActivity().getText(R.string.computing_size);

    TabInfo tab =
        new TabInfo(
            this,
            mApplicationsState,
            getActivity().getString(R.string.filter_apps_third_party),
            LIST_TYPE_DOWNLOADED,
            this,
            savedInstanceState);
    mTabs.add(tab);

    if (!Environment.isExternalStorageEmulated()) {
      tab =
          new TabInfo(
              this,
              mApplicationsState,
              getActivity().getString(R.string.filter_apps_onsdcard),
              LIST_TYPE_SDCARD,
              this,
              savedInstanceState);
      mTabs.add(tab);
    }

    tab =
        new TabInfo(
            this,
            mApplicationsState,
            getActivity().getString(R.string.filter_apps_running),
            LIST_TYPE_RUNNING,
            this,
            savedInstanceState);
    mTabs.add(tab);

    tab =
        new TabInfo(
            this,
            mApplicationsState,
            getActivity().getString(R.string.filter_apps_all),
            LIST_TYPE_ALL,
            this,
            savedInstanceState);
    mTabs.add(tab);
  }