|
33 | 33 | import android.content.res.Resources; |
34 | 34 | import android.graphics.Canvas; |
35 | 35 | import android.graphics.Rect; |
36 | | -import android.os.Bundle; |
37 | 36 | import android.os.Looper; |
38 | 37 | import android.os.Parcel; |
39 | 38 | import android.os.Parcelable; |
40 | 39 | import android.os.SystemClock; |
41 | | -import android.os.UserHandle; |
42 | 40 | import android.os.UserManager; |
43 | 41 | import android.util.AttributeSet; |
44 | 42 | import android.util.Log; |
@@ -898,48 +896,19 @@ private void addDefaultWidgets() { |
898 | 896 | addWidgetButton.setOnClickListener(new OnClickListener() { |
899 | 897 | @Override |
900 | 898 | public void onClick(View v) { |
901 | | - mCallback.setOnDismissRunnable(new Runnable() { |
902 | | - |
903 | | - @Override |
904 | | - public void run() { |
905 | | - launchPickActivityIntent(); |
906 | | - } |
907 | | - }); |
908 | | - mCallback.dismiss(false); |
| 899 | + int appWidgetId = mAppWidgetHost.allocateAppWidgetId(); |
| 900 | + if (appWidgetId != -1) { |
| 901 | + mActivityLauncher.launchWidgetPicker(appWidgetId); |
| 902 | + } else { |
| 903 | + Log.e(TAG, "Unable to allocate an AppWidget id in lock screen"); |
| 904 | + } |
909 | 905 | } |
910 | 906 | }); |
911 | 907 |
|
912 | 908 | enableUserSelectorIfNecessary(); |
913 | 909 | initializeTransportControl(); |
914 | 910 | } |
915 | 911 |
|
916 | | - private void launchPickActivityIntent() { |
917 | | - // Create intent to pick widget |
918 | | - Intent pickIntent = new Intent(AppWidgetManager.ACTION_KEYGUARD_APPWIDGET_PICK); |
919 | | - |
920 | | - int appWidgetId = mAppWidgetHost.allocateAppWidgetId(); |
921 | | - if (appWidgetId != -1) { |
922 | | - pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); |
923 | | - pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false); |
924 | | - pickIntent.putExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER, |
925 | | - AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD); |
926 | | - |
927 | | - Bundle options = new Bundle(); |
928 | | - options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, |
929 | | - AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD); |
930 | | - pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options); |
931 | | - pickIntent.addFlags( |
932 | | - Intent.FLAG_ACTIVITY_NEW_TASK |
933 | | - | Intent.FLAG_ACTIVITY_SINGLE_TOP |
934 | | - | Intent.FLAG_ACTIVITY_CLEAR_TOP |
935 | | - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
936 | | - mContext.startActivityAsUser(pickIntent, |
937 | | - new UserHandle(UserHandle.USER_CURRENT)); |
938 | | - } else { |
939 | | - Log.e(TAG, "Unable to allocate an AppWidget id in lock screen"); |
940 | | - } |
941 | | - } |
942 | | - |
943 | 912 | private void removeTransportFromWidgetPager() { |
944 | 913 | int page = getWidgetPosition(R.id.keyguard_transport_control); |
945 | 914 | if (page != -1) { |
|
0 commit comments