Add data class PreferredShortcut to replace inner class UserShortcutType

* Add basic function equals(), hashcode() into data class
* Change flatternToString() to toString()
* Change constructor to fromString(flatternToString)

Bug: 158540780
Test: atest PreferredShortcutTest
Change-Id: I0ee46dd940d22ff9f168b95fe75d9cff2f0fddfb
This commit is contained in:
jasonwshsu
2020-07-19 23:43:29 +08:00
committed by Jason Hsu
parent ca40e8d31c
commit 26f1b5f65c
7 changed files with 175 additions and 125 deletions

View File

@@ -226,9 +226,9 @@ public class ToggleScreenMagnificationPreferenceFragment extends
Collectors.toSet());
info.removeAll(filtered);
}
final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(
MAGNIFICATION_CONTROLLER_NAME, type);
info.add(shortcut.flattenToString());
final PreferredShortcut shortcut = new PreferredShortcut(MAGNIFICATION_CONTROLLER_NAME,
type);
info.add(shortcut.toString());
SharedPreferenceUtils.setUserShortcutType(context, info);
}
@@ -284,7 +284,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
final String str = (String) filtered.toArray()[0];
final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(str);
final PreferredShortcut shortcut = PreferredShortcut.fromString(str);
return shortcut.getType();
}