Loading packages/SettingsLib/res/layout/user_preference.xml 0 → 100644 +47 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2014 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/widget_frame" android:layout_width="match_parent" android:layout_height="@dimen/user_spinner_item_height" android:paddingStart="@dimen/user_spinner_padding_sides" android:paddingEnd="@dimen/user_spinner_padding_sides" android:orientation="horizontal" > <ImageView android:id="@+android:id/icon" android:layout_width="@dimen/user_icon_view_height" android:layout_height="@dimen/user_icon_view_height" android:layout_gravity="center" android:scaleType="fitCenter" android:paddingBottom="@dimen/user_spinner_padding" android:paddingTop="@dimen/user_spinner_padding" /> <TextView android:id="@+android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_gravity="center" android:labelFor="@+android:id/icon" android:ellipsize="marquee" android:fadingEdge="horizontal" android:paddingStart="@dimen/user_spinner_padding" android:paddingEnd="@dimen/user_spinner_padding" style="?android:attr/textAppearanceMedium" /> </LinearLayout> packages/SettingsLib/res/values/dimens.xml +8 −0 Original line number Diff line number Diff line Loading @@ -23,4 +23,12 @@ <dimen name="disappear_y_translation">-32dp</dimen> <dimen name="circle_avatar_size">40dp</dimen> <!-- Height of a user icon view --> <dimen name="user_icon_view_height">56dp</dimen> <!-- User spinner --> <dimen name="user_spinner_height">72dp</dimen> <dimen name="user_spinner_padding">4dp</dimen> <dimen name="user_spinner_padding_sides">20dp</dimen> <dimen name="user_spinner_item_height">56dp</dimen> </resources> packages/SettingsLib/res/values/strings.xml +8 −0 Original line number Diff line number Diff line Loading @@ -340,4 +340,12 @@ <item>kor</item> </string-array> <!-- Title for profile selection dialog [CHAR LIMIT=30] --> <string name="choose_profile">Choose Profile</string> <!-- Header for items under the personal user [CHAR LIMIT=30] --> <string name="category_personal">Personal</string> <!-- Header for items under the work user [CHAR LIMIT=30] --> <string name="category_work">Work</string> </resources> packages/SettingsLib/src/com/android/settingslib/drawer/DashboardTile.java +0 −17 Original line number Diff line number Diff line Loading @@ -49,19 +49,6 @@ public class DashboardTile implements Parcelable { */ public Icon icon; /** * Full class name of the fragment to display when this tile is * selected. * @attr ref android.R.styleable#PreferenceHeader_fragment */ public String fragment; /** * Optional arguments to supply to the fragment when it is * instantiated. */ public Bundle fragmentArguments; /** * Intent to launch when the preference is selected. */ Loading Loading @@ -106,8 +93,6 @@ public class DashboardTile implements Parcelable { } else { dest.writeByte((byte) 0); } dest.writeString(fragment); dest.writeBundle(fragmentArguments); if (intent != null) { dest.writeByte((byte) 1); intent.writeToParcel(dest, flags); Loading @@ -130,8 +115,6 @@ public class DashboardTile implements Parcelable { if (in.readByte() != 0) { icon = Icon.CREATOR.createFromParcel(in); } fragment = in.readString(); fragmentArguments = in.readBundle(); if (in.readByte() != 0) { intent = Intent.CREATOR.createFromParcel(in); } Loading packages/SettingsLib/src/com/android/settingslib/drawer/ProfileSelectDialog.java 0 → 100644 +67 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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.settingslib.drawer; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.FragmentManager; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; public class ProfileSelectDialog extends DialogFragment implements OnClickListener { private static final String ARG_SELECTED_TILE = "selectedTile"; private DashboardTile mSelectedTile; public static void show(FragmentManager manager, DashboardTile tile) { ProfileSelectDialog dialog = new ProfileSelectDialog(); Bundle args = new Bundle(); args.putParcelable(ARG_SELECTED_TILE, tile); dialog.setArguments(args); dialog.show(manager, "select_profile"); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSelectedTile = getArguments().getParcelable(ARG_SELECTED_TILE); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Context context = getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(context); UserAdapter adapter = UserAdapter.createUserAdapter(UserManager.get(context), context, mSelectedTile.userHandle); builder.setTitle(com.android.settingslib.R.string.choose_profile) .setAdapter(adapter, this); return builder.create(); } @Override public void onClick(DialogInterface dialog, int which) { UserHandle user = mSelectedTile.userHandle.get(which); getActivity().startActivityAsUser(mSelectedTile.intent, user); ((SettingsDrawerActivity) getActivity()).onProfileTileOpen(); } } Loading
packages/SettingsLib/res/layout/user_preference.xml 0 → 100644 +47 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2014 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/widget_frame" android:layout_width="match_parent" android:layout_height="@dimen/user_spinner_item_height" android:paddingStart="@dimen/user_spinner_padding_sides" android:paddingEnd="@dimen/user_spinner_padding_sides" android:orientation="horizontal" > <ImageView android:id="@+android:id/icon" android:layout_width="@dimen/user_icon_view_height" android:layout_height="@dimen/user_icon_view_height" android:layout_gravity="center" android:scaleType="fitCenter" android:paddingBottom="@dimen/user_spinner_padding" android:paddingTop="@dimen/user_spinner_padding" /> <TextView android:id="@+android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_gravity="center" android:labelFor="@+android:id/icon" android:ellipsize="marquee" android:fadingEdge="horizontal" android:paddingStart="@dimen/user_spinner_padding" android:paddingEnd="@dimen/user_spinner_padding" style="?android:attr/textAppearanceMedium" /> </LinearLayout>
packages/SettingsLib/res/values/dimens.xml +8 −0 Original line number Diff line number Diff line Loading @@ -23,4 +23,12 @@ <dimen name="disappear_y_translation">-32dp</dimen> <dimen name="circle_avatar_size">40dp</dimen> <!-- Height of a user icon view --> <dimen name="user_icon_view_height">56dp</dimen> <!-- User spinner --> <dimen name="user_spinner_height">72dp</dimen> <dimen name="user_spinner_padding">4dp</dimen> <dimen name="user_spinner_padding_sides">20dp</dimen> <dimen name="user_spinner_item_height">56dp</dimen> </resources>
packages/SettingsLib/res/values/strings.xml +8 −0 Original line number Diff line number Diff line Loading @@ -340,4 +340,12 @@ <item>kor</item> </string-array> <!-- Title for profile selection dialog [CHAR LIMIT=30] --> <string name="choose_profile">Choose Profile</string> <!-- Header for items under the personal user [CHAR LIMIT=30] --> <string name="category_personal">Personal</string> <!-- Header for items under the work user [CHAR LIMIT=30] --> <string name="category_work">Work</string> </resources>
packages/SettingsLib/src/com/android/settingslib/drawer/DashboardTile.java +0 −17 Original line number Diff line number Diff line Loading @@ -49,19 +49,6 @@ public class DashboardTile implements Parcelable { */ public Icon icon; /** * Full class name of the fragment to display when this tile is * selected. * @attr ref android.R.styleable#PreferenceHeader_fragment */ public String fragment; /** * Optional arguments to supply to the fragment when it is * instantiated. */ public Bundle fragmentArguments; /** * Intent to launch when the preference is selected. */ Loading Loading @@ -106,8 +93,6 @@ public class DashboardTile implements Parcelable { } else { dest.writeByte((byte) 0); } dest.writeString(fragment); dest.writeBundle(fragmentArguments); if (intent != null) { dest.writeByte((byte) 1); intent.writeToParcel(dest, flags); Loading @@ -130,8 +115,6 @@ public class DashboardTile implements Parcelable { if (in.readByte() != 0) { icon = Icon.CREATOR.createFromParcel(in); } fragment = in.readString(); fragmentArguments = in.readBundle(); if (in.readByte() != 0) { intent = Intent.CREATOR.createFromParcel(in); } Loading
packages/SettingsLib/src/com/android/settingslib/drawer/ProfileSelectDialog.java 0 → 100644 +67 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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.settingslib.drawer; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.FragmentManager; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; public class ProfileSelectDialog extends DialogFragment implements OnClickListener { private static final String ARG_SELECTED_TILE = "selectedTile"; private DashboardTile mSelectedTile; public static void show(FragmentManager manager, DashboardTile tile) { ProfileSelectDialog dialog = new ProfileSelectDialog(); Bundle args = new Bundle(); args.putParcelable(ARG_SELECTED_TILE, tile); dialog.setArguments(args); dialog.show(manager, "select_profile"); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSelectedTile = getArguments().getParcelable(ARG_SELECTED_TILE); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Context context = getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(context); UserAdapter adapter = UserAdapter.createUserAdapter(UserManager.get(context), context, mSelectedTile.userHandle); builder.setTitle(com.android.settingslib.R.string.choose_profile) .setAdapter(adapter, this); return builder.create(); } @Override public void onClick(DialogInterface dialog, int which) { UserHandle user = mSelectedTile.userHandle.get(which); getActivity().startActivityAsUser(mSelectedTile.intent, user); ((SettingsDrawerActivity) getActivity()).onProfileTileOpen(); } }