am ef1961c7
: am 7cce6d0c
: am f330857a
: am b852fcbd
: Merge "Offer \'ask\' as an available app-linking state" into mnc-dev
* commit 'ef1961c7326aa60e1e3bbb738394c535b7f952af': Offer 'ask' as an available app-linking state
This commit is contained in:
@@ -6580,6 +6580,15 @@
|
||||
<item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps can open their supported links</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Explanation that the app that will ALWAYS be launched to open web links to domains that it understands -->
|
||||
<string name="app_link_open_always">Open in this app</string>
|
||||
|
||||
<!-- Explanation that the user will be asked whether to launch the app to open web links to domains that it understands -->
|
||||
<string name="app_link_open_ask">Ask every time</string>
|
||||
|
||||
<!-- Explanation that the app that will NEVER be launched to open web links to domains that it understands -->
|
||||
<string name="app_link_open_never">Don’t open in this app</string>
|
||||
|
||||
<!-- Fingerprint hint message when finger was not recognized.-->
|
||||
<string name="fingerprint_not_recognized">Not recognized</string>
|
||||
|
||||
|
@@ -20,18 +20,16 @@
|
||||
<PreferenceCategory android:key="app_launch_domain_links"
|
||||
android:title="@string/app_launch_domain_links_title">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="app_launch_open_domain_urls"
|
||||
android:title="@string/app_launch_open_domain_urls_title"
|
||||
android:summary="@string/app_launch_open_domain_urls_summary"
|
||||
/>
|
||||
|
||||
<com.android.settings.DropDownPreference
|
||||
android:key="app_link_state"
|
||||
android:persistent="false"
|
||||
android:title="@string/app_launch_open_domain_urls_title" />
|
||||
|
||||
<com.android.settings.applications.AppDomainsPreference
|
||||
android:key="app_launch_supported_domain_urls"
|
||||
android:title="@string/app_launch_supported_domain_urls_title"
|
||||
android:persistent="false"
|
||||
android:dependency="app_launch_open_domain_urls"
|
||||
android:dependency="app_link_state"
|
||||
/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
@@ -31,9 +31,13 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.settings.DropDownPreference;
|
||||
import com.android.settings.DropDownPreference.Callback;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
|
||||
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
|
||||
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
|
||||
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
|
||||
|
||||
@@ -43,14 +47,14 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe
|
||||
Preference.OnPreferenceChangeListener {
|
||||
private static final String TAG = "AppLaunchSettings";
|
||||
|
||||
private static final String KEY_OPEN_DOMAIN_URLS = "app_launch_open_domain_urls";
|
||||
private static final String KEY_APP_LINK_STATE = "app_link_state";
|
||||
private static final String KEY_SUPPORTED_DOMAIN_URLS = "app_launch_supported_domain_urls";
|
||||
private static final String KEY_CLEAR_DEFAULTS = "app_launch_clear_defaults";
|
||||
|
||||
private PackageManager mPm;
|
||||
|
||||
private boolean mHasDomainUrls;
|
||||
private SwitchPreference mOpenDomainUrls;
|
||||
private DropDownPreference mAppLinkState;
|
||||
private AppDomainsPreference mAppDomainUrls;
|
||||
private ClearDefaultsPreference mClearDefaultsPreference;
|
||||
|
||||
@@ -62,9 +66,6 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe
|
||||
|
||||
mPm = getActivity().getPackageManager();
|
||||
|
||||
mOpenDomainUrls = (SwitchPreference) findPreference(KEY_OPEN_DOMAIN_URLS);
|
||||
mOpenDomainUrls.setOnPreferenceChangeListener(this);
|
||||
|
||||
mHasDomainUrls =
|
||||
(mAppEntry.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS) != 0;
|
||||
List<IntentFilterVerificationInfo> iviList = mPm.getIntentFilterVerifications(mPackageName);
|
||||
@@ -78,20 +79,62 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe
|
||||
|
||||
mClearDefaultsPreference = (ClearDefaultsPreference) findPreference(KEY_CLEAR_DEFAULTS);
|
||||
|
||||
updateDomainUrlPrefState();
|
||||
buildStateDropDown();
|
||||
}
|
||||
|
||||
private void updateDomainUrlPrefState() {
|
||||
mOpenDomainUrls.setEnabled(mHasDomainUrls);
|
||||
private void buildStateDropDown() {
|
||||
mAppLinkState = (DropDownPreference) findPreference(KEY_APP_LINK_STATE);
|
||||
|
||||
boolean checked = false;
|
||||
// Designed order of states in the dropdown:
|
||||
//
|
||||
// * always
|
||||
// * ask
|
||||
// * never
|
||||
mAppLinkState.addItem(R.string.app_link_open_always,
|
||||
INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS);
|
||||
mAppLinkState.addItem(R.string.app_link_open_ask,
|
||||
INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK);
|
||||
mAppLinkState.addItem(R.string.app_link_open_never,
|
||||
INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER);
|
||||
|
||||
mAppLinkState.setEnabled(mHasDomainUrls);
|
||||
if (mHasDomainUrls) {
|
||||
final int status = mPm.getIntentVerificationStatus(mPackageName, UserHandle.myUserId());
|
||||
if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
|
||||
checked = true;
|
||||
// Present 'undefined' as 'ask' because the OS treats them identically for
|
||||
// purposes of the UI (and does the right thing around pending domain
|
||||
// verifications that might arrive after the user chooses 'ask' in this UI).
|
||||
final int state = mPm.getIntentVerificationStatus(mPackageName, UserHandle.myUserId());
|
||||
mAppLinkState.setSelectedValue(
|
||||
(state == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED)
|
||||
? INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK
|
||||
: state);
|
||||
|
||||
// Set the callback only after setting the initial selected item
|
||||
mAppLinkState.setCallback(new Callback() {
|
||||
@Override
|
||||
public boolean onItemSelected(int pos, Object value) {
|
||||
return updateAppLinkState((Integer) value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
mOpenDomainUrls.setChecked(checked);
|
||||
|
||||
private boolean updateAppLinkState(final int newState) {
|
||||
final int userId = UserHandle.myUserId();
|
||||
final int priorState = mPm.getIntentVerificationStatus(mPackageName, userId);
|
||||
|
||||
if (priorState == newState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean success = mPm.updateIntentVerificationStatus(mPackageName, newState, userId);
|
||||
if (success) {
|
||||
// Read back the state to see if the change worked
|
||||
final int updatedState = mPm.getIntentVerificationStatus(mPackageName, userId);
|
||||
success = (newState == updatedState);
|
||||
} else {
|
||||
Log.e(TAG, "Couldn't update intent verification status!");
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private CharSequence[] getEntries(String packageName, List<IntentFilterVerificationInfo> iviList,
|
||||
@@ -104,7 +147,6 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe
|
||||
protected boolean refreshUi() {
|
||||
mClearDefaultsPreference.setPackageName(mPackageName);
|
||||
mClearDefaultsPreference.setAppEntry(mAppEntry);
|
||||
updateDomainUrlPrefState();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -121,26 +163,8 @@ public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListe
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean ret = false;
|
||||
final String key = preference.getKey();
|
||||
if (KEY_OPEN_DOMAIN_URLS.equals(key)) {
|
||||
final SwitchPreference pref = (SwitchPreference) preference;
|
||||
final Boolean switchedOn = (Boolean) newValue;
|
||||
int newState = switchedOn ?
|
||||
INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS :
|
||||
INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
|
||||
final int userId = UserHandle.myUserId();
|
||||
boolean success = mPm.updateIntentVerificationStatus(mPackageName, newState, userId);
|
||||
if (success) {
|
||||
// read back the state to ensure canonicality
|
||||
newState = mPm.getIntentVerificationStatus(mPackageName, userId);
|
||||
ret = (newState == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS);
|
||||
pref.setChecked(ret);
|
||||
} else {
|
||||
Log.e(TAG, "Couldn't update intent verification status!");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
// actual updates are handled by the app link dropdown callback
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user