Add work/personal profile tab for storage page

- Add ProfileSelectStorageFragment
- Check featureFlag in SecondaryUserController to decide show/hide
workprofile item StorageDashboardFragment

Bug: 141601408
Test: manual
Change-Id: I97762d3b1a4985e2b186b34fc37c7976c2f69224
This commit is contained in:
Raff Tsai
2019-10-25 13:01:34 +08:00
parent 8ed2568882
commit 539ab8ace4
7 changed files with 102 additions and 21 deletions

View File

@@ -19,9 +19,8 @@ package com.android.settings.dashboard.profileselector;
import android.util.ArrayMap;
import com.android.settings.accounts.AccountDashboardFragment;
import com.android.settings.accounts.AccountProfileSelectFragment;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.applications.manageapplications.ProfileSelectManageApplications;
import com.android.settings.deviceinfo.StorageDashboardFragment;
import java.util.Map;
@@ -39,8 +38,10 @@ public class ProfileFragmentBridge {
static {
FRAGMENT_MAP = new ArrayMap<>();
FRAGMENT_MAP.put(AccountDashboardFragment.class.getName(),
AccountProfileSelectFragment.class.getName());
ProfileSelectAccountFragment.class.getName());
FRAGMENT_MAP.put(ManageApplications.class.getName(),
ProfileSelectManageApplications.class.getName());
FRAGMENT_MAP.put(StorageDashboardFragment.class.getName(),
ProfileSelectStorageFragment.class.getName());
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2019 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.dashboard.profileselector;
import androidx.fragment.app.Fragment;
import com.android.settings.accounts.AccountPersonalDashboardFragment;
import com.android.settings.accounts.AccountWorkProfileDashboardFragment;
/**
* Account Setting page for personal/managed profile.
*/
public class ProfileSelectAccountFragment extends ProfileSelectFragment {
@Override
public Fragment[] getFragments() {
return new Fragment[] {
new AccountPersonalDashboardFragment(),
new AccountWorkProfileDashboardFragment()
};
}
}

View File

@@ -30,6 +30,8 @@ import androidx.viewpager.widget.ViewPager;
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
import com.google.android.material.tabs.TabLayout;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -69,6 +71,8 @@ public abstract class ProfileSelectFragment extends InstrumentedFragment {
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);
tabs.setupWithViewPager(viewPager);
return mContentView;
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2019 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.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;
import com.android.settings.applications.manageapplications.ManageApplications;
/**
* Application Setting page for personal/managed profile.
*/
public class ProfileSelectManageApplications extends ProfileSelectFragment {
@Override
public Fragment[] getFragments() {
final Bundle workOnly = new Bundle();
workOnly.putBoolean(EXTRA_WORK_ONLY, true);
final Fragment workFragment = new ManageApplications();
workFragment.setArguments(workOnly);
final Bundle personalOnly = new Bundle();
personalOnly.putBoolean(EXTRA_PERSONAL_ONLY, true);
final Fragment personalFragment = new ManageApplications();
personalFragment.setArguments(personalOnly);
return new Fragment[]{
personalFragment, //0
workFragment
};
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2019 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.dashboard.profileselector;
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.UserManager;
import android.os.storage.VolumeInfo;
import androidx.fragment.app.Fragment;
import com.android.settings.deviceinfo.StorageDashboardFragment;
import com.android.settings.deviceinfo.StorageProfileFragment;
/**
* Storage Setting page for personal/managed profile.
*/
public class ProfileSelectStorageFragment extends ProfileSelectFragment {
@Override
public Fragment[] getFragments() {
final Bundle storageBundle = new Bundle();
storageBundle.putString(VolumeInfo.EXTRA_VOLUME_ID, VolumeInfo.ID_PRIVATE_INTERNAL);
final Fragment storageDashboardFragment = new StorageDashboardFragment();
storageDashboardFragment.setArguments(storageBundle);
UserInfo targetUser = null;
for (UserInfo info : UserManager.get(getActivity()).getUsers()) {
if (!info.isPrimary()) {
targetUser = info;
break;
}
}
// TODO(b/143330969): Need to think about more profile users case
if (targetUser != null) {
storageBundle.putInt(StorageProfileFragment.USER_ID_EXTRA, targetUser.id);
}
final Fragment storageProfileFragment = new StorageProfileFragment();
storageProfileFragment.setArguments(storageBundle);
return new Fragment[]{
storageDashboardFragment,
storageProfileFragment
};
}
}