summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorAlexandra Gherghina <alexgherghina@google.com>2014-07-24 17:28:36 +0100
committerAlexandra Gherghina <alexgherghina@google.com>2014-07-29 14:08:24 +0100
commita6145a656af1241fd771038715cf839a8fce76e1 (patch)
tree856e7aed6443aae83f3c9c0f83fb5bca8f1247aa /src/com/android
parent0598e6f6842ad08af1d8dbb31aa3ddd3df7e37ed (diff)
downloadpackages_apps_Settings-a6145a656af1241fd771038715cf839a8fce76e1.zip
packages_apps_Settings-a6145a656af1241fd771038715cf839a8fce76e1.tar.gz
packages_apps_Settings-a6145a656af1241fd771038715cf839a8fce76e1.tar.bz2
Toggle between primary and managed profile in App notif settings
This adds a spinner to the app notifications screen which can be used to toggle between the Settings app in the primary and managed profile so that the user can edit settings belonging to both profiles. Bug: 16369104 Change-Id: I31c2fb4c0bc318fb8fa5c152621a29fd0c4bb403
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/settings/notification/AppNotificationSettings.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 25047a4..f858677 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -36,6 +36,8 @@ import android.os.Parcelable;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.provider.Settings;
+import android.os.UserHandle;
+import android.os.UserManager;
import android.util.ArrayMap;
import android.util.Log;
import android.util.TypedValue;
@@ -44,12 +46,17 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.SectionIndexer;
+import android.widget.Spinner;
import android.widget.TextView;
import com.android.settings.PinnedHeaderListFragment;
import com.android.settings.R;
+import com.android.settings.UserSpinnerAdapter;
+import com.android.settings.UserSpinnerAdapter.UserDetails;
import java.text.Collator;
import java.util.ArrayList;
@@ -58,7 +65,8 @@ import java.util.Comparator;
import java.util.List;
/** Just a sectioned list of installed applications, nothing else to index **/
-public class AppNotificationSettings extends PinnedHeaderListFragment {
+public class AppNotificationSettings extends PinnedHeaderListFragment
+ implements OnItemSelectedListener {
private static final String TAG = "AppNotificationSettings";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -79,6 +87,7 @@ public class AppNotificationSettings extends PinnedHeaderListFragment {
private Signature[] mSystemSignature;
private Parcelable mListViewState;
private Backend mBackend = new Backend();
+ private UserSpinnerAdapter mProfileSpinnerAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -89,12 +98,38 @@ public class AppNotificationSettings extends PinnedHeaderListFragment {
getActivity().setTitle(R.string.app_notifications_title);
}
+ @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.notification_app_list, container, false);
}
@Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
+ List<UserHandle> userProfiles = um.getUserProfiles();
+ if (userProfiles.size() >= 2) {
+ Spinner spinner = (Spinner) getActivity().getLayoutInflater().inflate(
+ R.layout.spinner_view, null);
+ // TODO: Factor out spinner creation in a method in Utils class. See: http://b/16645615
+ UserHandle myUserHandle = new UserHandle(UserHandle.myUserId());
+ userProfiles.remove(myUserHandle);
+ userProfiles.add(0, myUserHandle);
+ ArrayList<UserDetails> userDetails = new ArrayList<UserDetails>(userProfiles.size());
+ final int count = userProfiles.size();
+ for (int i = 0; i < count; i++) {
+ userDetails.add(new UserDetails(userProfiles.get(i), um, mContext));
+ }
+
+ mProfileSpinnerAdapter = new UserSpinnerAdapter(mContext, userDetails);
+ spinner.setAdapter(mProfileSpinnerAdapter);
+ spinner.setOnItemSelectedListener(this);
+ setPinnedHeaderView(spinner);
+ }
+ }
+
+ @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
repositionScrollbar();
@@ -120,6 +155,24 @@ public class AppNotificationSettings extends PinnedHeaderListFragment {
loadAppsList();
}
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ UserHandle selectedUser = mProfileSpinnerAdapter.getUserHandle(position);
+ if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
+ // TODO: Factor out intent starting in a method in Utils class. See: http://b/16645615
+ Intent intent = new Intent();
+ intent.setClassName(mContext.getPackageName(),
+ com.android.settings.Settings.AppNotificationSettingsActivity.class.getName());
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivityAsUser(intent, selectedUser);
+ getActivity().finish();
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ }
+
public void setBackend(Backend backend) {
mBackend = backend;
}