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
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user