Add storage_summary_donut above ProfileSelectStorageFragment

- Modify ProfileSelectFragment to support add preference xml in the
top, and tabLayout below the preferences. Base preference layout is
dummy_preference_screen.xml which contains no preference.
ProfileSelectStorageFragment contains StorageSummaryDonutPreference
above the tabLayout.
- Make StorageSummaryDonutPreferenceController self workable without
StorageDashboardFragment dependence.
- Rename inactive_apps.xml to dummy_preference_screen.xml
- Move ShadowPrivateStorageInfo from LowStorageSliceTest

Bug: 141601408
Test: manual
Change-Id: Ide12840dc81bb104f328e230ecda5d35bba01d7a
This commit is contained in:
Raff Tsai
2019-11-15 11:02:25 +08:00
parent dee1548f61
commit 84327f6aa3
18 changed files with 228 additions and 96 deletions

View File

@@ -22,13 +22,15 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.dashboard.DashboardFragment;
import com.google.android.material.tabs.TabLayout;
@@ -38,7 +40,9 @@ import java.lang.annotation.RetentionPolicy;
/**
* Base fragment class for profile settings.
*/
public abstract class ProfileSelectFragment extends InstrumentedFragment {
public abstract class ProfileSelectFragment extends DashboardFragment {
private static final String TAG = "ProfileSelectFragment";
/**
* Denotes the profile type.
@@ -63,16 +67,29 @@ public abstract class ProfileSelectFragment extends InstrumentedFragment {
*/
public static final int ALL = PERSONAL | WORK;
private View mContentView;
/**
* Used in fragment argument and pass {@link ProfileType} to it
*/
public static final String EXTRA_PROFILE = "profile";
private ViewGroup mContentView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mContentView = inflater.inflate(R.layout.profile_select_tablayout, null /* root */);
final ViewPager viewPager = mContentView.findViewById(R.id.view_pager);
viewPager.setAdapter(new ViewPagerAdapter(this));
final TabLayout tabs = mContentView.findViewById(R.id.tabs);
mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
final View tabContainer = mContentView.findViewById(R.id.tab_container);
final ViewPager viewPager = tabContainer.findViewById(R.id.view_pager);
viewPager.setAdapter(new ProfileSelectFragment.ViewPagerAdapter(this));
final TabLayout tabs = tabContainer.findViewById(R.id.tabs);
tabs.setupWithViewPager(viewPager);
tabContainer.setVisibility(View.VISIBLE);
final FrameLayout listContainer = mContentView.findViewById(android.R.id.list_container);
listContainer.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
return mContentView;
}
@@ -87,13 +104,23 @@ public abstract class ProfileSelectFragment extends InstrumentedFragment {
*/
public abstract Fragment[] getFragments();
@Override
protected int getPreferenceScreenResId() {
return R.xml.dummy_preference_screen;
}
@Override
protected String getLogTag() {
return TAG;
}
static class ViewPagerAdapter extends FragmentStatePagerAdapter {
private final Fragment[] mChildFragments;
private final Context mContext;
ViewPagerAdapter(ProfileSelectFragment fragment) {
super(fragment.getActivity().getSupportFragmentManager());
super(fragment.getChildFragmentManager());
mContext = fragment.getContext();
mChildFragments = fragment.getFragments();
}

View File

@@ -16,9 +16,6 @@
package com.android.settings.dashboard.profileselector;
import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_PERSONAL_ONLY;
import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ONLY;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
@@ -33,12 +30,12 @@ public class ProfileSelectManageApplications extends ProfileSelectFragment {
@Override
public Fragment[] getFragments() {
final Bundle workOnly = new Bundle();
workOnly.putBoolean(EXTRA_WORK_ONLY, true);
workOnly.putInt(EXTRA_PROFILE, ProfileSelectFragment.WORK);
final Fragment workFragment = new ManageApplications();
workFragment.setArguments(workOnly);
final Bundle personalOnly = new Bundle();
personalOnly.putBoolean(EXTRA_PERSONAL_ONLY, true);
personalOnly.putInt(EXTRA_PROFILE, ProfileSelectFragment.PERSONAL);
final Fragment personalFragment = new ManageApplications();
personalFragment.setArguments(personalOnly);
return new Fragment[]{

View File

@@ -23,6 +23,7 @@ import android.os.storage.VolumeInfo;
import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.android.settings.deviceinfo.StorageDashboardFragment;
import com.android.settings.deviceinfo.StorageProfileFragment;
@@ -35,6 +36,7 @@ public class ProfileSelectStorageFragment extends ProfileSelectFragment {
final Bundle storageBundle = new Bundle();
storageBundle.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
storageBundle.putInt(EXTRA_PROFILE, ProfileSelectFragment.PERSONAL);
final Fragment storageDashboardFragment = new StorageDashboardFragment();
storageDashboardFragment.setArguments(storageBundle);
@@ -46,7 +48,6 @@ public class ProfileSelectStorageFragment extends ProfileSelectFragment {
break;
}
}
// TODO(b/143330969): Need to think about more profile users case
if (targetUser != null) {
storageBundle.putInt(StorageProfileFragment.USER_ID_EXTRA, targetUser.id);
}
@@ -58,5 +59,10 @@ public class ProfileSelectStorageFragment extends ProfileSelectFragment {
storageProfileFragment
};
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.storage_summary_donut;
}
}