diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2015-04-03 15:16:13 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2015-04-07 17:13:12 -0700 |
commit | e8981e3c581a43a3caef7211b864e47093bd4781 (patch) | |
tree | a3522e363bdc7f173917a64073149e5f32e988aa /src | |
parent | 6e338dbe62aa96d2ff0a441f11fd47ee82d84045 (diff) | |
download | packages_apps_Settings-e8981e3c581a43a3caef7211b864e47093bd4781.zip packages_apps_Settings-e8981e3c581a43a3caef7211b864e47093bd4781.tar.gz packages_apps_Settings-e8981e3c581a43a3caef7211b864e47093bd4781.tar.bz2 |
Settings - add support for Launch by Default - part 2
UX fixes
- make the ManageApplications list to be able to handle some disable items
- add domain list for App that are not verified
Change-Id: Ib37c6f3f3dd1d1cdc17db434967f583cc89e068c
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/applications/AppLaunchSettings.java | 52 | ||||
-rw-r--r-- | src/com/android/settings/applications/ManageApplications.java | 25 |
2 files changed, 51 insertions, 26 deletions
diff --git a/src/com/android/settings/applications/AppLaunchSettings.java b/src/com/android/settings/applications/AppLaunchSettings.java index c0a662a..05a1fca 100644 --- a/src/com/android/settings/applications/AppLaunchSettings.java +++ b/src/com/android/settings/applications/AppLaunchSettings.java @@ -17,8 +17,13 @@ package com.android.settings.applications; import android.app.AlertDialog; +import android.content.ComponentName; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.ApplicationInfo; import android.content.pm.IntentFilterVerificationInfo; import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.UserHandle; import android.preference.Preference; @@ -32,6 +37,10 @@ import com.android.settings.R; import java.util.List; +import static android.content.pm.PackageManager.GET_ACTIVITIES; +import static android.content.pm.PackageManager.GET_META_DATA; +import static android.content.pm.PackageManager.GET_RESOLVED_FILTER; + public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListener, Preference.OnPreferenceChangeListener { @@ -57,29 +66,48 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe mOpenDomainUrls = (SwitchPreference) findPreference(KEY_OPEN_DOMAIN_URLS); mOpenDomainUrls.setOnPreferenceChangeListener(this); - final int status = mPm.getIntentVerificationStatus(mPackageName, myUserId); - boolean checked = status == PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS; - mOpenDomainUrls.setChecked(checked); + boolean hasDomainUrls = + (mAppEntry.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS) != 0; + List<IntentFilterVerificationInfo> iviList = mPm.getIntentFilterVerifications(mPackageName); + + boolean enabled = hasDomainUrls && (iviList.size() != 0); + + mOpenDomainUrls.setEnabled(enabled); + if (enabled) { + final int status = mPm.getIntentVerificationStatus(mPackageName, myUserId); + boolean checked = + (status == PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS); + mOpenDomainUrls.setChecked(checked); + } + + List<IntentFilter> filters = mPm.getAllIntentFilters(mPackageName); mAppDomainUrls = (AppDomainsPreference) findPreference(KEY_SUPPORTED_DOMAIN_URLS); - CharSequence[] entries = getEntries(mPackageName); + CharSequence[] entries = getEntries(iviList, filters); mAppDomainUrls.setTitles(entries); mAppDomainUrls.setValues(new int[entries.length]); mClearDefaultsPreference = (ClearDefaultsPreference) findPreference(KEY_CLEAR_DEFAULTS); } - private CharSequence[] getEntries(String packageName) { + private CharSequence[] getEntries(List<IntentFilterVerificationInfo> iviList, + List<IntentFilter> filters) { ArraySet<String> result = new ArraySet<>(); - - List<IntentFilterVerificationInfo> list = - mPm.getIntentFilterVerifications(packageName); - for (IntentFilterVerificationInfo ivi : list) { - for (String host : ivi.getDomains()) { - result.add(host); + if (iviList.size() > 0) { + for (IntentFilterVerificationInfo ivi : iviList) { + for (String host : ivi.getDomains()) { + result.add(host); + } + } + } + if (filters != null && filters.size() > 0) { + for (IntentFilter filter : filters) { + if (filter.hasDataScheme(IntentFilter.SCHEME_HTTP) || + filter.hasDataScheme(IntentFilter.SCHEME_HTTPS)) { + result.addAll(filter.getHostsList()); + } } } - return result.toArray(new CharSequence[0]); } diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java index b416aef..b0b35ab 100644 --- a/src/com/android/settings/applications/ManageApplications.java +++ b/src/com/android/settings/applications/ManageApplications.java @@ -497,7 +497,9 @@ public class ManageApplications extends InstrumentedFragment ApplicationsState.AppEntry entry = mApplications.getAppEntry(position); mCurrentPkgName = entry.info.packageName; mCurrentUid = entry.info.uid; - startApplicationDetailsActivity(); + if (isAppEntryViewEnabled(entry)) { + startApplicationDetailsActivity(); + } } } @@ -585,6 +587,13 @@ public class ManageApplications extends InstrumentedFragment } + private static boolean isAppEntryViewEnabled(AppEntry entry) { + if ((entry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0 || !entry.info.enabled) { + return false; + } + return true; + } + /* * Custom adapter implementation for the ListView * This adapter maintains a map for each displayed application and its properties @@ -879,19 +888,6 @@ public class ManageApplications extends InstrumentedFragment return false; } - @Override - public boolean isEnabled(int position) { - ApplicationsState.AppEntry entry = mEntries.get(position); - synchronized (entry) { - if ((entry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0) { - return false; - } else if (!entry.info.enabled) { - return false; - } - return true; - } - } - public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unnecessary calls // to findViewById() on each row. @@ -928,6 +924,7 @@ public class ManageApplications extends InstrumentedFragment holder.updateSizeText(mManageApplications.mInvalidSizeStr, mWhichSize); break; } + convertView.setEnabled(isAppEntryViewEnabled(entry)); if ((entry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0) { holder.disabled.setVisibility(View.VISIBLE); holder.disabled.setText(R.string.not_installed); |