Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7fff579 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "revamp storage settings header" into sc-dev

* changes:
  Add option menu in StorageDashboardFragment
  Revamp Storage Settings header part
parents 228cc886 c2274953
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -27,10 +27,22 @@
    <item
        android:id="@+id/storage_format"
        android:title="@string/storage_menu_format" />
    <item
        android:id="@+id/storage_format_as_portable"
        android:title="@string/storage_menu_format_public"
        android:visible="false" />
    <item
        android:id="@+id/storage_format_as_internal"
        android:title="@string/storage_menu_format_private"
        android:visible="false" />
    <item
        android:id="@+id/storage_migrate"
        android:title="@string/storage_menu_migrate" />
    <item
        android:id="@+id/storage_free"
        android:title="@string/storage_menu_free" />
    <item
        android:id="@+id/storage_forget"
        android:title="@string/storage_menu_forget"
        android:visible="false" />
</menu>
+8 −0
Original line number Diff line number Diff line
@@ -3368,6 +3368,10 @@
    <string name="storage_menu_manage">Manage storage</string>
    <!-- Storage setting. Keywords for Free up space. [CHAR LIMIT=NONE] -->
    <string name="keywords_storage_menu_free">clean, storage</string>
    <!-- Storage setting. Title for storage free up option. [CHAR LIMIT=30] -->
    <string name="storage_free_up_space_title">Free up space</string>
    <!-- Storage setting. Summary for storage free up option. [CHAR LIMIT=NONE] -->
    <string name="storage_free_up_space_summary">Go to Files app to manage and free up space</string>
    <!-- Storage setting.  Title for USB transfer settings [CHAR LIMIT=30]-->
    <string name="storage_title_usb">USB computer connection</string>
@@ -11571,6 +11575,10 @@
    <!-- Follows the percent of storage used by a storage volume. Exposed inside of a donut graph. [CHAR LIMIT=7]-->
    <string name="storage_percent_full">used</string>
    <!-- Summary of a single storage volume used space. [CHAR LIMIT=24] -->
    <string name="storage_usage_summary"><xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g> used</string>
    <!-- Summary of a single storage volume total space. [CHAR LIMIT=24] -->
    <string name="storage_total_summary">Total <xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g></string>
    <!-- Label for button allow user to remove the instant app from the device. -->
    <string name="clear_instant_app_data">Clear app</string>
+15 −4
Original line number Diff line number Diff line
@@ -19,11 +19,22 @@
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/storage_settings"
    android:orderingFromXml="false">
    <com.android.settings.deviceinfo.storage.StorageSummaryDonutPreference
    <com.android.settingslib.widget.SettingsSpinnerPreference
        android:key="storage_spinner"
        android:order="-2"
        settings:searchable="false"
        settings:controller="com.android.settings.deviceinfo.storage.StorageSelectionPreferenceController"/>
    <com.android.settingslib.widget.UsageProgressBarPreference
        android:key="storage_summary"
        android:order="0"
        android:order="-1"
        settings:searchable="false"
        settings:controller="com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController"/>
        settings:controller="com.android.settings.deviceinfo.storage.StorageUsageProgressBarPreferenceController"/>
    <Preference
        android:key="free_up_space"
        android:order="0"
        android:title="@string/storage_free_up_space_title"
        android:summary="@string/storage_free_up_space_summary"
        settings:allowDividerAbove="true"/>
    <com.android.settings.widget.PrimarySwitchPreference
        android:fragment="com.android.settings.deletionhelper.AutomaticStorageManagerSettings"
        android:key="toggle_asm"
+0 −85
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.deviceinfo;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.storage.VolumeInfo;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.android.settings.R;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
import com.android.settingslib.core.lifecycle.events.OnOptionsItemSelected;
import com.android.settingslib.core.lifecycle.events.OnPrepareOptionsMenu;

import java.util.Objects;

/**
 * Handles the option menu on the Storage settings.
 */
public class PrivateVolumeOptionMenuController implements LifecycleObserver, OnCreateOptionsMenu,
        OnPrepareOptionsMenu, OnOptionsItemSelected {
    private static final int OPTIONS_MENU_MIGRATE_DATA = 100;

    private Context mContext;
    private VolumeInfo mVolumeInfo;
    private PackageManager mPm;

    public PrivateVolumeOptionMenuController(
            Context context, VolumeInfo volumeInfo, PackageManager packageManager) {
        mContext = context;
        mVolumeInfo = volumeInfo;
        mPm = packageManager;
    }

    @Override
    public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
        menu.add(Menu.NONE, OPTIONS_MENU_MIGRATE_DATA, 0, R.string.storage_menu_migrate);
    }

    @Override
    public void onPrepareOptionsMenu(Menu menu) {
        if (mVolumeInfo == null) {
            return;
        }

        // Only offer to migrate when not current storage
        final VolumeInfo privateVol = mPm.getPrimaryStorageCurrentVolume();
        final MenuItem migrate = menu.findItem(OPTIONS_MENU_MIGRATE_DATA);
        if (migrate != null) {
            migrate.setVisible((privateVol != null)
                    && (privateVol.getType() == VolumeInfo.TYPE_PRIVATE)
                    && !Objects.equals(mVolumeInfo, privateVol)
                    && privateVol.isMountedWritable());
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == OPTIONS_MENU_MIGRATE_DATA) {
            final Intent intent = new Intent(mContext, StorageWizardMigrateConfirm.class);
            intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolumeInfo.getId());
            mContext.startActivity(intent);
            return true;
        }
        return false;
    }
}
+270 −25

File changed.

Preview size limit exceeded, changes collapsed.

Loading