* commit '4b7e002b7dc471b273b1a597c7ac03dc2220cd88': Toggle between primary and managed profile in App notif settings
This commit is contained in:
committed by
Android Git Automerger
commit
b5e8bf20a9
@@ -36,6 +36,8 @@ import android.os.Parcelable;
|
|||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
@@ -44,12 +46,17 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.SectionIndexer;
|
import android.widget.SectionIndexer;
|
||||||
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.PinnedHeaderListFragment;
|
import com.android.settings.PinnedHeaderListFragment;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.UserSpinnerAdapter;
|
||||||
|
import com.android.settings.UserSpinnerAdapter.UserDetails;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -58,7 +65,8 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** Just a sectioned list of installed applications, nothing else to index **/
|
/** 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 String TAG = "AppNotificationSettings";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
@@ -79,6 +87,7 @@ public class AppNotificationSettings extends PinnedHeaderListFragment {
|
|||||||
private Signature[] mSystemSignature;
|
private Signature[] mSystemSignature;
|
||||||
private Parcelable mListViewState;
|
private Parcelable mListViewState;
|
||||||
private Backend mBackend = new Backend();
|
private Backend mBackend = new Backend();
|
||||||
|
private UserSpinnerAdapter mProfileSpinnerAdapter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -89,11 +98,37 @@ public class AppNotificationSettings extends PinnedHeaderListFragment {
|
|||||||
getActivity().setTitle(R.string.app_notifications_title);
|
getActivity().setTitle(R.string.app_notifications_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.notification_app_list, container, false);
|
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
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
@@ -120,6 +155,24 @@ public class AppNotificationSettings extends PinnedHeaderListFragment {
|
|||||||
loadAppsList();
|
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) {
|
public void setBackend(Backend backend) {
|
||||||
mBackend = backend;
|
mBackend = backend;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user