Commit 18af9a5a by Tim Van Patten Committed by Commit Bot

ANGLE In Use Dialog Box

When ANGLE is enabled for an app, show a dialog box to the user to indicate that ANGLE is in use. This is useful because there are not (or at least shouldn't be) any visual indication that a different OpenGL driver is in use. Clean up some missed renaming/logging related to the "Enable ANGLE for all" setting. Bug: angleproject:3006 Test: Load an app with ANGLE enabled and verify dialog box is shown. Test: Load an app without ANGLE and verify dialog box is not shown. Change-Id: I46ec89567c93efaf156a4801948cd48aabd5f4fb Reviewed-on: https://chromium-review.googlesource.com/c/1383374Reviewed-by: 's avatarTobin Ehlis <tobine@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
parent e4a52cb5
......@@ -7,6 +7,7 @@
<resources>
<string name="global_settings_driver_all_angle">angle_gl_driver_all_angle</string>
<string name="global_settings_angle_in_use_dialog_box">angle_in_use_dialog_box</string>
<string name="global_settings_driver_selection_pkgs">angle_gl_driver_selection_pkgs</string>
<string name="global_settings_driver_selection_values">angle_gl_driver_selection_values</string>
</resources>
\ No newline at end of file
......@@ -8,6 +8,7 @@
<resources>
<string name="pref_key_angle_flags_category">angle_flags_category</string>
<string name="pref_key_all_angle">all_pkgs_use_angle</string>
<string name="pref_key_angle_in_use_dialog">angle_in_use_dialog_box</string>
<string name="pref_key_select_opengl_driver_category">select_opengl_driver_category</string>
<string name="pref_key_installed_pkgs">installed_pkgs</string>
</resources>
\ No newline at end of file
......@@ -19,7 +19,12 @@
<!-- This is the label for a toggle button.
When the toggle is enabled, we will use ANGLE for all PKGs, regardless of any other settings.
This is also used as a Quick Settings tile label. -->
<string name="rules_file">Use ANGLE for all apps</string>
<string name="use_angle_for_all_apps">Use ANGLE for all apps</string>
<!-- This is the label for a toggle button.
When the toggle is enabled, we will show a dialog box indicating that ANGLE is in use.
This is also used as a Quick Settings tile label. -->
<string name="show_angle_in_use_dialog_box">Show dialog box when ANGLE is loaded</string>
<!-- ListPreference title listing installed packages [CHAR_LIMIT=50]-->
<string name="select_opengl_driver_title">Select OpenGL Driver</string>
......
......@@ -16,11 +16,17 @@
Enable the switch once Android can boot with ANGLE enabled for everything-->
<android.support.v14.preference.SwitchPreference
android:key="@string/pref_key_all_angle"
android:title="@string/rules_file"
android:title="@string/use_angle_for_all_apps"
android:summary="@string/global_settings_driver_all_angle"
android:defaultValue="false"
android:enabled="false"/>
<android.support.v14.preference.SwitchPreference
android:key="@string/pref_key_angle_in_use_dialog"
android:title="@string/show_angle_in_use_dialog_box"
android:summary="@string/global_settings_angle_in_use_dialog_box"
android:defaultValue="false"
android:enabled="true"/>
</PreferenceCategory>
<PreferenceCategory
......
......@@ -48,6 +48,21 @@ class GlobalSettings
}
}
Boolean getShowAngleInUseDialogBox()
{
ContentResolver contentResolver = mContext.getContentResolver();
try
{
int showAngleInUseDialogBox = Settings.Global.getInt(contentResolver,
mContext.getString(R.string.global_settings_angle_in_use_dialog_box));
return (showAngleInUseDialogBox == 1);
}
catch (Settings.SettingNotFoundException e)
{
return false;
}
}
static void updateAllUseAngle(Context context, Boolean allUseAngle)
{
ContentResolver contentResolver = context.getContentResolver();
......@@ -55,6 +70,14 @@ class GlobalSettings
context.getString(R.string.global_settings_driver_all_angle), allUseAngle ? 1 : 0);
}
static void updateShowAngleInUseDialog(Context context, Boolean showAngleInUseDialog)
{
ContentResolver contentResolver = context.getContentResolver();
Settings.Global.putInt(contentResolver,
context.getString(R.string.global_settings_angle_in_use_dialog_box),
showAngleInUseDialog ? 1 : 0);
}
void updatePkg(String pkgName, String driver)
{
int pkgIndex = getGlobalSettingsPkgIndex(pkgName);
......
......@@ -40,6 +40,7 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
private GlobalSettings mGlobalSettings;
private Receiver mRefreshReceiver;
private SwitchPreference mAllAngleSwitchPref;
private SwitchPreference mShowAngleInUseDialogSwitchPref;
private List<PackageInfo> mInstalledPkgs = new ArrayList<>();
private List<ListPreference> mDriverListPrefs = new ArrayList<>();
......@@ -87,6 +88,22 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
}
});
String showAngleInUseDialogKey =
getContext().getString(R.string.pref_key_angle_in_use_dialog);
Boolean showAngleInUseDialogBox = mPrefs.getBoolean(showAngleInUseDialogKey, false);
mShowAngleInUseDialogSwitchPref =
(SwitchPreference) findPreference(showAngleInUseDialogKey);
mShowAngleInUseDialogSwitchPref.setChecked(mGlobalSettings.getShowAngleInUseDialogBox());
mShowAngleInUseDialogSwitchPref.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference)
{
Receiver.updateShowAngleInUseDialogBox(getContext());
return true;
}
});
String selectDriverCatKey =
getContext().getString(R.string.pref_key_select_opengl_driver_category);
PreferenceCategory installedPkgsCat =
......
......@@ -32,6 +32,18 @@ public class Receiver extends BroadcastReceiver
GlobalSettings.updateAllUseAngle(context, allUseAngle);
Log.v(TAG, "Use Rules File set to: " + allUseAngle);
Log.v(TAG, "All PKGs use ANGLE set to: " + allUseAngle);
}
static void updateShowAngleInUseDialogBox(Context context)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String showAngleInUseDialogBoxKey =
context.getString(R.string.pref_key_angle_in_use_dialog);
boolean showAngleInUseDialogBox = prefs.getBoolean(showAngleInUseDialogBoxKey, false);
GlobalSettings.updateShowAngleInUseDialog(context, showAngleInUseDialogBox);
Log.v(TAG, "Show 'ANGLE In Use' dialog box set to: " + showAngleInUseDialogBox);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment