Loading src/com/android/settings/webview/WebViewAppListAdapter.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.settings.webview; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.RemoteException; import android.graphics.Color; import android.support.annotation.VisibleForTesting; import android.view.LayoutInflater; import android.view.View; Loading @@ -36,6 +38,7 @@ import java.util.List; */ class WebViewAppListAdapter extends ArrayAdapter<WebViewApplicationInfo> { private final LayoutInflater mInflater; private final String mCurrentWebViewPackageName; public WebViewAppListAdapter(Context context, WebViewUpdateServiceWrapper webviewUpdateServiceWrapper) { Loading @@ -53,6 +56,10 @@ class WebViewAppListAdapter extends ArrayAdapter<WebViewApplicationInfo> { packageInfoList.add(info); } addAll(packageInfoList); PackageInfo currentWebViewPackage = webviewUpdateServiceWrapper.getCurrentWebViewPackage(); mCurrentWebViewPackageName = currentWebViewPackage == null ? null : currentWebViewPackage.packageName; } @Override Loading Loading @@ -80,6 +87,11 @@ class WebViewAppListAdapter extends ArrayAdapter<WebViewApplicationInfo> { holder.disabled.setVisibility(View.GONE); // Only allow a package to be chosen if it is enabled and installed for all users. convertView.setEnabled(isEnabled(position)); if (info.info.packageName.equals(mCurrentWebViewPackageName)) { convertView.setBackgroundColor(Color.GRAY); } else { convertView.setBackgroundColor(Color.WHITE); } return convertView; } Loading src/com/android/settings/webview/WebViewAppPreferenceController.java +4 −3 Original line number Diff line number Diff line Loading @@ -73,10 +73,11 @@ public class WebViewAppPreferenceController extends PreferenceController { * Handle the return-value from the WebViewAppPicker Activity. */ public void onActivityResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { // Update the preference summary no matter whether we succeeded to change the webview // implementation correctly - we might have changed implementation to one the user did not // choose. updateState(null); } } private String getCurrentWebViewPackageLabel(Context context) { PackageInfo webViewPackage = mWebViewUpdateServiceWrapper.getCurrentWebViewPackage(); Loading tests/robotests/src/com/android/settings/webview/WebViewAppPreferenceControllerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ public class WebViewAppPreferenceControllerTest { verify(controller, times(1)).updateState(any()); } @Test public void testOnActivityResultWithFailureDoesNothing() { @Test public void testOnActivityResultWithFailure() { WebViewUpdateServiceWrapper wvusWrapper = mock(WebViewUpdateServiceWrapper.class); WebViewAppPreferenceController controller = Loading @@ -78,6 +78,6 @@ public class WebViewAppPreferenceControllerTest { controller.displayPreference(mPreferenceScreen); // Makes sure Preference is non-null controller.onActivityResult(Activity.RESULT_CANCELED, new Intent(DEFAULT_PACKAGE_NAME)); verify(controller, never()).updateState(any()); verify(controller, times(1)).updateState(any()); } } Loading
src/com/android/settings/webview/WebViewAppListAdapter.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.settings.webview; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.RemoteException; import android.graphics.Color; import android.support.annotation.VisibleForTesting; import android.view.LayoutInflater; import android.view.View; Loading @@ -36,6 +38,7 @@ import java.util.List; */ class WebViewAppListAdapter extends ArrayAdapter<WebViewApplicationInfo> { private final LayoutInflater mInflater; private final String mCurrentWebViewPackageName; public WebViewAppListAdapter(Context context, WebViewUpdateServiceWrapper webviewUpdateServiceWrapper) { Loading @@ -53,6 +56,10 @@ class WebViewAppListAdapter extends ArrayAdapter<WebViewApplicationInfo> { packageInfoList.add(info); } addAll(packageInfoList); PackageInfo currentWebViewPackage = webviewUpdateServiceWrapper.getCurrentWebViewPackage(); mCurrentWebViewPackageName = currentWebViewPackage == null ? null : currentWebViewPackage.packageName; } @Override Loading Loading @@ -80,6 +87,11 @@ class WebViewAppListAdapter extends ArrayAdapter<WebViewApplicationInfo> { holder.disabled.setVisibility(View.GONE); // Only allow a package to be chosen if it is enabled and installed for all users. convertView.setEnabled(isEnabled(position)); if (info.info.packageName.equals(mCurrentWebViewPackageName)) { convertView.setBackgroundColor(Color.GRAY); } else { convertView.setBackgroundColor(Color.WHITE); } return convertView; } Loading
src/com/android/settings/webview/WebViewAppPreferenceController.java +4 −3 Original line number Diff line number Diff line Loading @@ -73,10 +73,11 @@ public class WebViewAppPreferenceController extends PreferenceController { * Handle the return-value from the WebViewAppPicker Activity. */ public void onActivityResult(int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { // Update the preference summary no matter whether we succeeded to change the webview // implementation correctly - we might have changed implementation to one the user did not // choose. updateState(null); } } private String getCurrentWebViewPackageLabel(Context context) { PackageInfo webViewPackage = mWebViewUpdateServiceWrapper.getCurrentWebViewPackage(); Loading
tests/robotests/src/com/android/settings/webview/WebViewAppPreferenceControllerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ public class WebViewAppPreferenceControllerTest { verify(controller, times(1)).updateState(any()); } @Test public void testOnActivityResultWithFailureDoesNothing() { @Test public void testOnActivityResultWithFailure() { WebViewUpdateServiceWrapper wvusWrapper = mock(WebViewUpdateServiceWrapper.class); WebViewAppPreferenceController controller = Loading @@ -78,6 +78,6 @@ public class WebViewAppPreferenceControllerTest { controller.displayPreference(mPreferenceScreen); // Makes sure Preference is non-null controller.onActivityResult(Activity.RESULT_CANCELED, new Intent(DEFAULT_PACKAGE_NAME)); verify(controller, never()).updateState(any()); verify(controller, times(1)).updateState(any()); } }