コード例 #1
0
 public TabInfo(
     ManageApplications owner,
     ApplicationsState apps,
     CharSequence label,
     int listType,
     AppClickListener clickListener,
     Bundle savedInstanceState) {
   mOwner = owner;
   mApplicationsState = apps;
   mLabel = label;
   mListType = listType;
   switch (listType) {
     case LIST_TYPE_DOWNLOADED:
       mFilter = FILTER_APPS_THIRD_PARTY;
       break;
     case LIST_TYPE_SDCARD:
       mFilter = FILTER_APPS_SDCARD;
       break;
     default:
       mFilter = FILTER_APPS_ALL;
       break;
   }
   mClickListener = clickListener;
   mInvalidSizeStr = owner.getActivity().getText(R.string.invalid_size_value);
   mComputingSizeStr = owner.getActivity().getText(R.string.computing_size);
   mSavedInstanceState = savedInstanceState;
 }
コード例 #2
0
 void handleRunningProcessesAvail() {
   mLoadingContainer.startAnimation(
       AnimationUtils.loadAnimation(mOwner.getActivity(), android.R.anim.fade_out));
   mRunningProcessesView.startAnimation(
       AnimationUtils.loadAnimation(mOwner.getActivity(), android.R.anim.fade_in));
   mRunningProcessesView.setVisibility(View.VISIBLE);
   mLoadingContainer.setVisibility(View.GONE);
 }
コード例 #3
0
    public View build(LayoutInflater inflater, ViewGroup contentParent, View contentChild) {
      if (mRootView != null) {
        return mRootView;
      }

      mInflater = inflater;
      mRootView =
          inflater.inflate(
              mListType == LIST_TYPE_RUNNING
                  ? R.layout.manage_applications_running
                  : R.layout.manage_applications_apps,
              null);
      mRootView.setLayoutDirection(
          mRootView.getResources().getConfiguration().getLayoutDirection());
      mLoadingContainer = mRootView.findViewById(R.id.loading_container);
      mLoadingContainer.setVisibility(View.VISIBLE);
      mListContainer = mRootView.findViewById(R.id.list_container);
      if (mListContainer != null) {
        // Create adapter and list view here
        View emptyView = mListContainer.findViewById(com.android.internal.R.id.empty);
        ListView lv = (ListView) mListContainer.findViewById(android.R.id.list);
        if (emptyView != null) {
          lv.setEmptyView(emptyView);
        }
        lv.setOnItemClickListener(this);
        lv.setSaveEnabled(true);
        lv.setItemsCanFocus(true);
        lv.setTextFilterEnabled(true);
        lv.setFastScrollEnabled(true);
        mListView = lv;
        mApplications = new ApplicationsAdapter(mApplicationsState, this, mFilter);
        mListView.setAdapter(mApplications);
        mListView.setRecyclerListener(mApplications);
        mColorBar = (LinearColorBar) mListContainer.findViewById(R.id.storage_color_bar);
        mStorageChartLabel = (TextView) mListContainer.findViewById(R.id.storageChartLabel);
        mUsedStorageText = (TextView) mListContainer.findViewById(R.id.usedStorageText);
        mFreeStorageText = (TextView) mListContainer.findViewById(R.id.freeStorageText);
        Utils.prepareCustomPreferencesList(contentParent, contentChild, mListView, false);
        if (mFilter == FILTER_APPS_SDCARD) {
          mStorageChartLabel.setText(mOwner.getActivity().getText(R.string.sd_card_storage));
        } else {
          mStorageChartLabel.setText(mOwner.getActivity().getText(R.string.internal_storage));
        }
        applyCurrentStorage();
      }
      mRunningProcessesView = (RunningProcessesView) mRootView.findViewById(R.id.running_processes);
      if (mRunningProcessesView != null) {
        mRunningProcessesView.doCreate(mSavedInstanceState);
      }

      return mRootView;
    }
コード例 #4
0
 void applyCurrentStorage() {
   // If view hierarchy is not yet created, no views to update.
   if (mRootView == null) {
     return;
   }
   if (mTotalStorage > 0) {
     BidiFormatter bidiFormatter = BidiFormatter.getInstance();
     mColorBar.setRatios(
         (mTotalStorage - mFreeStorage - mAppStorage) / (float) mTotalStorage,
         mAppStorage / (float) mTotalStorage,
         mFreeStorage / (float) mTotalStorage);
     long usedStorage = mTotalStorage - mFreeStorage;
     if (mLastUsedStorage != usedStorage) {
       mLastUsedStorage = usedStorage;
       String sizeStr =
           bidiFormatter.unicodeWrap(
               Formatter.formatShortFileSize(mOwner.getActivity(), usedStorage));
       mUsedStorageText.setText(
           mOwner
               .getActivity()
               .getResources()
               .getString(R.string.service_foreground_processes, sizeStr));
     }
     if (mLastFreeStorage != mFreeStorage) {
       mLastFreeStorage = mFreeStorage;
       String sizeStr =
           bidiFormatter.unicodeWrap(
               Formatter.formatShortFileSize(mOwner.getActivity(), mFreeStorage));
       mFreeStorageText.setText(
           mOwner
               .getActivity()
               .getResources()
               .getString(R.string.service_background_processes, sizeStr));
     }
   } else {
     mColorBar.setRatios(0, 0, 0);
     if (mLastUsedStorage != -1) {
       mLastUsedStorage = -1;
       mUsedStorageText.setText("");
     }
     if (mLastFreeStorage != -1) {
       mLastFreeStorage = -1;
       mFreeStorageText.setText("");
     }
   }
 }
コード例 #5
0
    void updateStorageUsage() {
      // Make sure a callback didn't come at an inopportune time.
      if (mOwner.getActivity() == null) return;
      // Doesn't make sense for stuff that is not an app list.
      if (mApplications == null) return;

      mFreeStorage = 0;
      mAppStorage = 0;
      mTotalStorage = 0;

      if (mFilter == FILTER_APPS_SDCARD) {
        if (mContainerService != null) {
          try {
            final long[] stats =
                mContainerService.getFileSystemStats(
                    Environment.getExternalStorageDirectory().getPath());
            mTotalStorage = stats[0];
            mFreeStorage = stats[1];
          } catch (RemoteException e) {
            Log.w(TAG, "Problem in container service", e);
          }
        }

        if (mApplications != null) {
          final int N = mApplications.getCount();
          for (int i = 0; i < N; i++) {
            ApplicationsState.AppEntry ae = mApplications.getAppEntry(i);
            mAppStorage += ae.externalCodeSize + ae.externalDataSize + ae.externalCacheSize;
          }
        }
      } else {
        if (mContainerService != null) {
          try {
            final long[] stats =
                mContainerService.getFileSystemStats(Environment.getDataDirectory().getPath());
            mTotalStorage = stats[0];
            mFreeStorage = stats[1];
          } catch (RemoteException e) {
            Log.w(TAG, "Problem in container service", e);
          }
        }

        final boolean emulatedStorage = Environment.isExternalStorageEmulated();
        if (mApplications != null) {
          final int N = mApplications.getCount();
          for (int i = 0; i < N; i++) {
            ApplicationsState.AppEntry ae = mApplications.getAppEntry(i);
            mAppStorage += ae.codeSize + ae.dataSize;
            if (emulatedStorage) {
              mAppStorage += ae.externalCodeSize + ae.externalDataSize;
            }
          }
        }
        mFreeStorage += mApplicationsState.sumCacheSizes();
      }

      applyCurrentStorage();
    }
 public ApplicationsAdapter(
     ApplicationsState state, ManageApplications manageApplications, int filterMode) {
   mState = state;
   mSession = state.newSession(this);
   mManageApplications = manageApplications;
   mContext = manageApplications.getActivity();
   mPm = mContext.getPackageManager();
   mFilterMode = filterMode;
   if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
     mExtraInfoBridge =
         new AppStateNotificationBridge(
             mContext.getPackageManager(), mState, this, manageApplications.mNotifBackend);
   } else if (mManageApplications.mListType == LIST_TYPE_USAGE_ACCESS) {
     mExtraInfoBridge = new AppStateUsageBridge(mContext, mState, this);
   } else if (mManageApplications.mListType == LIST_TYPE_HIGH_POWER) {
     mExtraInfoBridge = new AppStatePowerBridge(mState, this);
   } else if (mManageApplications.mListType == LIST_TYPE_OVERLAY) {
     mExtraInfoBridge = new AppStateOverlayBridge(mContext, mState, this);
   } else if (mManageApplications.mListType == LIST_TYPE_WRITE_SETTINGS) {
     mExtraInfoBridge = new AppStateWriteSettingsBridge(mContext, mState, this);
   } else {
     mExtraInfoBridge = null;
   }
 }
 @Override
 public void onRunningStateChanged(boolean running) {
   mManageApplications.getActivity().setProgressBarIndeterminateVisibility(running);
 }
 public FilterSpinnerAdapter(ManageApplications manageApplications) {
   super(manageApplications.getActivity(), R.layout.filter_spinner_item);
   setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   mManageApplications = manageApplications;
 }