Fix software shortcut in dialog did not update when content change.

Root Cause: Dialog only get updated when clicked the trigger button to show dialog.

Solution: Update the software shortcut content in dialog if needed in onResume() stage.

Bug: 183342594
Test: atest AccessibilityDialogUtilsTest
Change-Id: Ibcd66d6c57f1790f96f234e49f456cbc2c990f64
This commit is contained in:
jasonwshsu
2021-10-08 01:58:38 +08:00
parent 65022abe43
commit eba8e8da19
4 changed files with 111 additions and 17 deletions

View File

@@ -180,6 +180,23 @@ public class AccessibilityDialogUtils {
return alertDialog;
}
/**
* Updates the software shortcut in edit shortcut dialog.
*
* @param context A valid context
* @param editShortcutDialog Need to be a type of edit shortcut dialog
* @return True if the update is successful
*/
public static boolean updateSoftwareShortcutInDialog(Context context,
Dialog editShortcutDialog) {
final View container = editShortcutDialog.findViewById(R.id.container_layout);
if (container != null) {
initSoftwareShortcut(context, container);
return true;
}
return false;
}
private static AlertDialog createDialog(Context context, int dialogType,
CharSequence dialogTitle, DialogInterface.OnClickListener listener) {