blob: 5862d3e08b5ec25aff63c19b4d0b1860cf64eb92 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.app;
18
19import com.android.internal.R;
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -080020import com.android.internal.content.PackageMonitor;
21
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.content.ComponentName;
23import android.content.Context;
24import android.content.DialogInterface;
25import android.content.Intent;
26import android.content.IntentFilter;
27import android.content.pm.ActivityInfo;
Dianne Hackborneb034652009-09-07 00:49:58 -070028import android.content.pm.LabeledIntent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.content.pm.PackageManager;
30import android.content.pm.ResolveInfo;
Dianne Hackborneb034652009-09-07 00:49:58 -070031import android.graphics.drawable.Drawable;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.net.Uri;
33import android.os.Bundle;
34import android.os.PatternMatcher;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035import android.util.Log;
Adam Powell2d809622012-03-22 15:24:43 -070036import android.view.LayoutInflater;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037import android.view.View;
38import android.view.ViewGroup;
Adam Powell2d809622012-03-22 15:24:43 -070039import android.widget.AdapterView;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040import android.widget.BaseAdapter;
41import android.widget.CheckBox;
42import android.widget.CompoundButton;
43import android.widget.ImageView;
Adam Powell2d809622012-03-22 15:24:43 -070044import android.widget.ListView;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045import android.widget.TextView;
Adam Powell2d809622012-03-22 15:24:43 -070046
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047import java.util.ArrayList;
48import java.util.Collections;
49import java.util.HashSet;
50import java.util.Iterator;
51import java.util.List;
52import java.util.Set;
53
54/**
55 * This activity is displayed when the system attempts to start an Intent for
56 * which there is more than one matching activity, allowing the user to decide
57 * which to go to. It is not normally used directly by application developers.
58 */
59public class ResolverActivity extends AlertActivity implements
60 DialogInterface.OnClickListener, CheckBox.OnCheckedChangeListener {
61 private ResolveListAdapter mAdapter;
62 private CheckBox mAlwaysCheck;
63 private TextView mClearDefaultHint;
64 private PackageManager mPm;
65
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -080066 private final PackageMonitor mPackageMonitor = new PackageMonitor() {
67 @Override public void onSomePackagesChanged() {
68 mAdapter.handlePackagesChanged();
69 }
70 };
71
Dianne Hackborn905577f2011-09-07 18:31:28 -070072 private Intent makeMyIntent() {
73 Intent intent = new Intent(getIntent());
74 // The resolver activity is set to be hidden from recent tasks.
75 // we don't want this attribute to be propagated to the next activity
76 // being launched. Note that if the original Intent also had this
77 // flag set, we are now losing it. That should be a very rare case
78 // and we can live with this.
79 intent.setFlags(intent.getFlags()&~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
80 return intent;
81 }
82
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 @Override
84 protected void onCreate(Bundle savedInstanceState) {
Dianne Hackborn905577f2011-09-07 18:31:28 -070085 onCreate(savedInstanceState, makeMyIntent(),
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 getResources().getText(com.android.internal.R.string.whichApplication),
Jeff Hamiltond88e9aa2011-01-24 14:53:00 -060087 null, null, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 }
89
90 protected void onCreate(Bundle savedInstanceState, Intent intent,
Jeff Hamiltond88e9aa2011-01-24 14:53:00 -060091 CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList,
Mike Lockwoodbce6f8f2011-03-13 17:26:52 -040092 boolean alwaysUseOption) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 super.onCreate(savedInstanceState);
94 mPm = getPackageManager();
95 intent.setComponent(null);
96
97 AlertController.AlertParams ap = mAlertParams;
98
99 ap.mTitle = title;
100 ap.mOnClickListener = this;
101
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700102 mPackageMonitor.register(this, getMainLooper(), false);
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800103
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 if (alwaysUseOption) {
105 LayoutInflater inflater = (LayoutInflater) getSystemService(
106 Context.LAYOUT_INFLATER_SERVICE);
107 ap.mView = inflater.inflate(R.layout.always_use_checkbox, null);
108 mAlwaysCheck = (CheckBox)ap.mView.findViewById(com.android.internal.R.id.alwaysUse);
109 mAlwaysCheck.setText(R.string.alwaysUse);
110 mAlwaysCheck.setOnCheckedChangeListener(this);
111 mClearDefaultHint = (TextView)ap.mView.findViewById(
112 com.android.internal.R.id.clearDefaultHint);
113 mClearDefaultHint.setVisibility(View.GONE);
114 }
Jeff Hamiltond88e9aa2011-01-24 14:53:00 -0600115 mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList);
Mike Lockwood02eb8742011-02-27 09:10:37 -0800116 int count = mAdapter.getCount();
Mike Lockwoodbce6f8f2011-03-13 17:26:52 -0400117 if (count > 1) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 ap.mAdapter = mAdapter;
Mike Lockwood02eb8742011-02-27 09:10:37 -0800119 } else if (count == 1) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120 startActivity(mAdapter.intentForPosition(0));
121 finish();
122 return;
123 } else {
124 ap.mMessage = getResources().getText(com.android.internal.R.string.noApplications);
125 }
126
127 setupAlert();
Adam Powell2d809622012-03-22 15:24:43 -0700128
129 ListView lv = mAlert.getListView();
130 if (lv != null) {
131 lv.setOnItemLongClickListener(new ItemLongClickListener());
132 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800133 }
134
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800135 @Override
136 protected void onRestart() {
137 super.onRestart();
Dianne Hackbornd0d75032012-04-19 23:12:09 -0700138 mPackageMonitor.register(this, getMainLooper(), false);
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800139 mAdapter.handlePackagesChanged();
140 }
141
142 @Override
143 protected void onStop() {
144 super.onStop();
145 mPackageMonitor.unregister();
146 }
147
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800148 public void onClick(DialogInterface dialog, int which) {
149 ResolveInfo ri = mAdapter.resolveInfoForPosition(which);
150 Intent intent = mAdapter.intentForPosition(which);
Mike Lockwood02eb8742011-02-27 09:10:37 -0800151 boolean alwaysCheck = (mAlwaysCheck != null && mAlwaysCheck.isChecked());
152 onIntentSelected(ri, intent, alwaysCheck);
153 finish();
154 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800155
Mike Lockwood02eb8742011-02-27 09:10:37 -0800156 protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) {
157 if (alwaysCheck) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800158 // Build a reasonable intent filter, based on what matched.
159 IntentFilter filter = new IntentFilter();
160
161 if (intent.getAction() != null) {
162 filter.addAction(intent.getAction());
163 }
164 Set<String> categories = intent.getCategories();
165 if (categories != null) {
166 for (String cat : categories) {
167 filter.addCategory(cat);
168 }
169 }
170 filter.addCategory(Intent.CATEGORY_DEFAULT);
171
172 int cat = ri.match&IntentFilter.MATCH_CATEGORY_MASK;
173 Uri data = intent.getData();
174 if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
175 String mimeType = intent.resolveType(this);
176 if (mimeType != null) {
177 try {
178 filter.addDataType(mimeType);
179 } catch (IntentFilter.MalformedMimeTypeException e) {
180 Log.w("ResolverActivity", e);
181 filter = null;
182 }
183 }
Dianne Hackborn5ef402b2010-03-26 17:17:25 -0700184 }
185 if (data != null && data.getScheme() != null) {
186 // We need the data specification if there was no type,
187 // OR if the scheme is not one of our magical "file:"
188 // or "content:" schemes (see IntentFilter for the reason).
189 if (cat != IntentFilter.MATCH_CATEGORY_TYPE
190 || (!"file".equals(data.getScheme())
191 && !"content".equals(data.getScheme()))) {
192 filter.addDataScheme(data.getScheme());
193
194 // Look through the resolved filter to determine which part
195 // of it matched the original Intent.
196 Iterator<IntentFilter.AuthorityEntry> aIt = ri.filter.authoritiesIterator();
197 if (aIt != null) {
198 while (aIt.hasNext()) {
199 IntentFilter.AuthorityEntry a = aIt.next();
200 if (a.match(data) >= 0) {
201 int port = a.getPort();
202 filter.addDataAuthority(a.getHost(),
203 port >= 0 ? Integer.toString(port) : null);
204 break;
205 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800206 }
207 }
Dianne Hackborn5ef402b2010-03-26 17:17:25 -0700208 Iterator<PatternMatcher> pIt = ri.filter.pathsIterator();
209 if (pIt != null) {
210 String path = data.getPath();
211 while (path != null && pIt.hasNext()) {
212 PatternMatcher p = pIt.next();
213 if (p.match(path)) {
214 filter.addDataPath(p.getPath(), p.getType());
215 break;
216 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800217 }
218 }
219 }
220 }
221
222 if (filter != null) {
223 final int N = mAdapter.mList.size();
224 ComponentName[] set = new ComponentName[N];
225 int bestMatch = 0;
226 for (int i=0; i<N; i++) {
227 ResolveInfo r = mAdapter.mList.get(i).ri;
228 set[i] = new ComponentName(r.activityInfo.packageName,
229 r.activityInfo.name);
230 if (r.match > bestMatch) bestMatch = r.match;
231 }
232 getPackageManager().addPreferredActivity(filter, bestMatch, set,
233 intent.getComponent());
234 }
235 }
236
237 if (intent != null) {
238 startActivity(intent);
239 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800240 }
241
242 private final class DisplayResolveInfo {
243 ResolveInfo ri;
244 CharSequence displayLabel;
Dianne Hackborneb034652009-09-07 00:49:58 -0700245 Drawable displayIcon;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800246 CharSequence extendedInfo;
Dianne Hackborneb034652009-09-07 00:49:58 -0700247 Intent origIntent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800248
Dianne Hackborneb034652009-09-07 00:49:58 -0700249 DisplayResolveInfo(ResolveInfo pri, CharSequence pLabel,
250 CharSequence pInfo, Intent pOrigIntent) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800251 ri = pri;
252 displayLabel = pLabel;
253 extendedInfo = pInfo;
Dianne Hackborneb034652009-09-07 00:49:58 -0700254 origIntent = pOrigIntent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800255 }
256 }
257
258 private final class ResolveListAdapter extends BaseAdapter {
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800259 private final Intent[] mInitialIntents;
260 private final List<ResolveInfo> mBaseResolveList;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800261 private final Intent mIntent;
262 private final LayoutInflater mInflater;
263
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800264 private List<ResolveInfo> mCurrentResolveList;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 private List<DisplayResolveInfo> mList;
266
Dianne Hackborneb034652009-09-07 00:49:58 -0700267 public ResolveListAdapter(Context context, Intent intent,
Jeff Hamiltond88e9aa2011-01-24 14:53:00 -0600268 Intent[] initialIntents, List<ResolveInfo> rList) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800269 mIntent = new Intent(intent);
270 mIntent.setComponent(null);
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800271 mInitialIntents = initialIntents;
272 mBaseResolveList = rList;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273 mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800274 rebuildList();
275 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800276
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800277 public void handlePackagesChanged() {
278 rebuildList();
279 notifyDataSetChanged();
280 if (mList.size() <= 0) {
281 // We no longer have any items... just finish the activity.
282 finish();
283 }
284 }
285
286 private void rebuildList() {
287 if (mBaseResolveList != null) {
288 mCurrentResolveList = mBaseResolveList;
289 } else {
290 mCurrentResolveList = mPm.queryIntentActivities(
291 mIntent, PackageManager.MATCH_DEFAULT_ONLY
Jeff Hamiltond88e9aa2011-01-24 14:53:00 -0600292 | (mAlwaysCheck != null ? PackageManager.GET_RESOLVED_FILTER : 0));
293 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 int N;
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800295 if ((mCurrentResolveList != null) && ((N = mCurrentResolveList.size()) > 0)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800296 // Only display the first matches that are either of equal
297 // priority or have asked to be default options.
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800298 ResolveInfo r0 = mCurrentResolveList.get(0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 for (int i=1; i<N; i++) {
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800300 ResolveInfo ri = mCurrentResolveList.get(i);
Joe Onorato43a17652011-04-06 19:22:23 -0700301 if (false) Log.v(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800302 "ResolveListActivity",
303 r0.activityInfo.name + "=" +
304 r0.priority + "/" + r0.isDefault + " vs " +
305 ri.activityInfo.name + "=" +
306 ri.priority + "/" + ri.isDefault);
307 if (r0.priority != ri.priority ||
308 r0.isDefault != ri.isDefault) {
309 while (i < N) {
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800310 mCurrentResolveList.remove(i);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311 N--;
312 }
313 }
314 }
315 if (N > 1) {
316 ResolveInfo.DisplayNameComparator rComparator =
317 new ResolveInfo.DisplayNameComparator(mPm);
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800318 Collections.sort(mCurrentResolveList, rComparator);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319 }
Dianne Hackborneb034652009-09-07 00:49:58 -0700320
321 mList = new ArrayList<DisplayResolveInfo>();
322
323 // First put the initial items at the top.
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800324 if (mInitialIntents != null) {
325 for (int i=0; i<mInitialIntents.length; i++) {
326 Intent ii = mInitialIntents[i];
Dianne Hackborneb034652009-09-07 00:49:58 -0700327 if (ii == null) {
328 continue;
329 }
330 ActivityInfo ai = ii.resolveActivityInfo(
331 getPackageManager(), 0);
332 if (ai == null) {
333 Log.w("ResolverActivity", "No activity found for "
334 + ii);
335 continue;
336 }
337 ResolveInfo ri = new ResolveInfo();
338 ri.activityInfo = ai;
339 if (ii instanceof LabeledIntent) {
340 LabeledIntent li = (LabeledIntent)ii;
341 ri.resolvePackageName = li.getSourcePackage();
342 ri.labelRes = li.getLabelResource();
343 ri.nonLocalizedLabel = li.getNonLocalizedLabel();
344 ri.icon = li.getIconResource();
345 }
346 mList.add(new DisplayResolveInfo(ri,
347 ri.loadLabel(getPackageManager()), null, ii));
348 }
349 }
350
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800351 // Check for applications with same name and use application name or
352 // package name if necessary
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800353 r0 = mCurrentResolveList.get(0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800354 int start = 0;
355 CharSequence r0Label = r0.loadLabel(mPm);
356 for (int i = 1; i < N; i++) {
357 if (r0Label == null) {
358 r0Label = r0.activityInfo.packageName;
359 }
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800360 ResolveInfo ri = mCurrentResolveList.get(i);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800361 CharSequence riLabel = ri.loadLabel(mPm);
362 if (riLabel == null) {
363 riLabel = ri.activityInfo.packageName;
364 }
365 if (riLabel.equals(r0Label)) {
366 continue;
367 }
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800368 processGroup(mCurrentResolveList, start, (i-1), r0, r0Label);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369 r0 = ri;
370 r0Label = riLabel;
371 start = i;
372 }
373 // Process last group
Dianne Hackborne8f2c7f2012-03-01 17:30:53 -0800374 processGroup(mCurrentResolveList, start, (N-1), r0, r0Label);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800375 }
376 }
377
378 private void processGroup(List<ResolveInfo> rList, int start, int end, ResolveInfo ro,
379 CharSequence roLabel) {
380 // Process labels from start to i
381 int num = end - start+1;
382 if (num == 1) {
383 // No duplicate labels. Use label for entry at start
Dianne Hackborneb034652009-09-07 00:49:58 -0700384 mList.add(new DisplayResolveInfo(ro, roLabel, null, null));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800385 } else {
386 boolean usePkg = false;
387 CharSequence startApp = ro.activityInfo.applicationInfo.loadLabel(mPm);
388 if (startApp == null) {
389 usePkg = true;
390 }
391 if (!usePkg) {
392 // Use HashSet to track duplicates
393 HashSet<CharSequence> duplicates =
394 new HashSet<CharSequence>();
395 duplicates.add(startApp);
396 for (int j = start+1; j <= end ; j++) {
397 ResolveInfo jRi = rList.get(j);
398 CharSequence jApp = jRi.activityInfo.applicationInfo.loadLabel(mPm);
399 if ( (jApp == null) || (duplicates.contains(jApp))) {
400 usePkg = true;
401 break;
402 } else {
403 duplicates.add(jApp);
404 }
405 }
406 // Clear HashSet for later use
407 duplicates.clear();
408 }
409 for (int k = start; k <= end; k++) {
410 ResolveInfo add = rList.get(k);
411 if (usePkg) {
412 // Use application name for all entries from start to end-1
413 mList.add(new DisplayResolveInfo(add, roLabel,
Dianne Hackborneb034652009-09-07 00:49:58 -0700414 add.activityInfo.packageName, null));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800415 } else {
416 // Use package name for all entries from start to end-1
417 mList.add(new DisplayResolveInfo(add, roLabel,
Dianne Hackborneb034652009-09-07 00:49:58 -0700418 add.activityInfo.applicationInfo.loadLabel(mPm), null));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419 }
420 }
421 }
422 }
423
424 public ResolveInfo resolveInfoForPosition(int position) {
425 if (mList == null) {
426 return null;
427 }
428
429 return mList.get(position).ri;
430 }
431
432 public Intent intentForPosition(int position) {
433 if (mList == null) {
434 return null;
435 }
436
Dianne Hackborneb034652009-09-07 00:49:58 -0700437 DisplayResolveInfo dri = mList.get(position);
438
439 Intent intent = new Intent(dri.origIntent != null
440 ? dri.origIntent : mIntent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800441 intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
442 |Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
Dianne Hackborneb034652009-09-07 00:49:58 -0700443 ActivityInfo ai = dri.ri.activityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800444 intent.setComponent(new ComponentName(
445 ai.applicationInfo.packageName, ai.name));
446 return intent;
447 }
448
449 public int getCount() {
450 return mList != null ? mList.size() : 0;
451 }
452
453 public Object getItem(int position) {
454 return position;
455 }
456
457 public long getItemId(int position) {
458 return position;
459 }
460
461 public View getView(int position, View convertView, ViewGroup parent) {
462 View view;
463 if (convertView == null) {
464 view = mInflater.inflate(
465 com.android.internal.R.layout.resolve_list_item, parent, false);
466 } else {
467 view = convertView;
468 }
469 bindView(view, mList.get(position));
470 return view;
471 }
472
473 private final void bindView(View view, DisplayResolveInfo info) {
474 TextView text = (TextView)view.findViewById(com.android.internal.R.id.text1);
475 TextView text2 = (TextView)view.findViewById(com.android.internal.R.id.text2);
476 ImageView icon = (ImageView)view.findViewById(R.id.icon);
477 text.setText(info.displayLabel);
478 if (info.extendedInfo != null) {
479 text2.setVisibility(View.VISIBLE);
480 text2.setText(info.extendedInfo);
481 } else {
482 text2.setVisibility(View.GONE);
483 }
Dianne Hackborneb034652009-09-07 00:49:58 -0700484 if (info.displayIcon == null) {
485 info.displayIcon = info.ri.loadIcon(mPm);
486 }
487 icon.setImageDrawable(info.displayIcon);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800488 }
489 }
490
491 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
492 if (mClearDefaultHint == null) return;
493
494 if(isChecked) {
495 mClearDefaultHint.setVisibility(View.VISIBLE);
496 } else {
497 mClearDefaultHint.setVisibility(View.GONE);
498 }
499 }
Adam Powell2d809622012-03-22 15:24:43 -0700500
501 class ItemLongClickListener implements AdapterView.OnItemLongClickListener {
502
503 @Override
504 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
505 ResolveInfo ri = mAdapter.resolveInfoForPosition(position);
506 Intent in = new Intent().setAction("android.settings.APPLICATION_DETAILS_SETTINGS")
507 .setData(Uri.fromParts("package", ri.activityInfo.packageName, null));
508 startActivity(in);
509 return true;
510 }
511
512 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800513}
514