Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve app selector UI #1616

Merged
merged 9 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,21 @@
"widgetTitle": "Patcher",
"patchButton": "Patch",

"armv7WarningDialogText": "Patching on ARMv7 devices is not yet supported and might fail. Proceed anyways?",
"armv7WarningDialogText": "Patching on ARMv7 devices is not yet supported and might fail. Continue anyways?",

"removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n{patches}\n\nProceed anyways?",
"removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n{patches}\n\nContinue anyways?",
"requiredOptionDialogText" : "Some patch options have to be set."
},
"appSelectorCard": {
"widgetTitle": "Select an application",
"widgetTitleSelected": "Selected application",
"widgetSubtitle": "No application selected",
"widgetTitle": "Select an app",
"widgetTitleSelected": "Selected app",
"widgetSubtitle": "No app selected",

"noAppsLabel": "No applications found",
"notInstalled":"App not installed",

"currentVersion": "Current",
"suggestedVersion": "Suggested",
"allVersions": "All versions"
"anyVersion": "Any version"
},
"patchSelectorCard": {
"widgetTitle": "Select patches",
Expand All @@ -101,8 +100,8 @@
"widgetSubtitle": "We are online!"
},
"appSelectorView": {
"viewTitle": "Select an application",
"searchBarHint": "Search applications",
"viewTitle": "Select an app",
"searchBarHint": "Search app",

"storageButton": "Storage",
"selectFromStorageButton": "Select from storage",
Expand All @@ -111,7 +110,7 @@

"downloadToast": "Download function is not available yet",

"requireSuggestedAppVersionDialogText": "The version of the app you have selected does not match the suggested version. Please select the app that matches the suggested version.\n\nSelected version: v{selected}\nSuggested version: v{suggested}\n\nTo proceed anyway, disable \"Require suggested app version\" in the settings.",
"requireSuggestedAppVersionDialogText": "The version of the app you have selected does not match the suggested version which can lead to unexpected issues. Please use the suggested version.\n\nSelected version: {selected}\nSuggested version: {suggested}\n\nTo continue anyway, disable \"Require suggested app version\" in the settings.",

"featureNotAvailable": "Feature not implemented",
"featureNotAvailableText": "This application is a split APK and cannot be selected. Unfortunately, this feature is only available for rooted users at the moment. However, you can still install the application by selecting its APK files from your device's storage instead"
Expand Down Expand Up @@ -164,7 +163,7 @@
"installerView": {
"widgetTitle": "Installer",
"installType": "Select install type",
"installTypeDescription": "Select the installation type to proceed with.",
"installTypeDescription": "Select the installation type to continue with.",

"installButton": "Install",
"installRootType": "Mount",
Expand Down Expand Up @@ -241,6 +240,7 @@

"versionCompatibilityCheckLabel": "Version compatibility check",
"versionCompatibilityCheckHint": "Prevent selecting patches that are not compatible with the selected app version",

"requireSuggestedAppVersionLabel": "Require suggested app version",
"requireSuggestedAppVersionHint": "Prevent selecting an app with a version that is not the suggested",
"requireSuggestedAppVersionDialogText": "Selecting an app that is not the suggested version may cause unexpected issues.\n\nDo you want to proceed anyways?",
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/app_selector/app_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AppSelectorViewModel extends BaseViewModel {
final String suggestedVersion = getSuggestedVersion(packageName);

if (suggestedVersion.isNotEmpty) {
await openDefaultBrowser('$packageName apk version v$suggestedVersion');
await openDefaultBrowser('$packageName apk version $suggestedVersion');
} else {
await openDefaultBrowser('$packageName apk');
}
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ class InstallerViewModel extends BaseViewModel {
String suggestedVersion = _patcherAPI.getSuggestedVersion(_app.packageName);
if (suggestedVersion.isEmpty) {
suggestedVersion = 'Any';
} else {
suggestedVersion = 'v$suggestedVersion';
}
return suggestedVersion;
}
Expand Down
47 changes: 6 additions & 41 deletions lib/ui/views/patcher/patcher_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,52 +148,17 @@ class PatcherViewModel extends BaseViewModel {
}

String getAppSelectionString() {
String text = '${selectedApp!.name} (${selectedApp!.packageName})';
if (text.length > 32) {
text = '${text.substring(0, 32)}...)';
}
return text;
}

String getCurrentVersionString(BuildContext context) {
return '${FlutterI18n.translate(
context,
'appSelectorCard.currentVersion',
)}: v${selectedApp!.version}';
return '${selectedApp!.name} ${selectedApp!.version}';
}

Future<void> searchSuggestedVersionOnWeb() async {
final String suggestedVersion =
_patcherAPI.getSuggestedVersion(selectedApp!.packageName);

if (suggestedVersion.isNotEmpty) {
await openDefaultBrowser(
'${selectedApp!.packageName} apk version v$suggestedVersion',
);
} else {
await openDefaultBrowser('${selectedApp!.packageName} apk');
}
}

String getSuggestedVersion() {
return _patcherAPI.getSuggestedVersion(selectedApp!.packageName);
Future<void> queryVersion(String suggestedVersion) async {
await openDefaultBrowser(
'${selectedApp!.packageName} apk version $suggestedVersion',
);
}

String getSuggestedVersionString(BuildContext context) {
String suggestedVersion =
_patcherAPI.getSuggestedVersion(selectedApp!.packageName);
if (suggestedVersion.isEmpty) {
suggestedVersion = FlutterI18n.translate(
context,
'appSelectorCard.allVersions',
);
} else {
suggestedVersion = 'v$suggestedVersion';
}
return '${FlutterI18n.translate(
context,
'appSelectorCard.suggestedVersion',
)}: $suggestedVersion';
return _patcherAPI.getSuggestedVersion(selectedApp!.packageName);
}

Future<void> openDefaultBrowser(String query) async {
Expand Down
77 changes: 38 additions & 39 deletions lib/ui/widgets/appSelectorView/installed_app_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,43 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.name,
maxLines: 2,
overflow: TextOverflow.visible,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 4,
children: [
Text(
widget.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 16,
),
),
Text(
widget.installedVersion,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 16,
),
),
Text(
widget.patchesCount == 1
? '• ${widget.patchesCount} patch'
: '• ${widget.patchesCount} patches',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
Text(widget.pkgName),
I18nText(
FlutterI18n.translate(
context,
'installed',
translationParams: {
'version': 'v${widget.installedVersion}',
},
),
Text(
widget.pkgName,
),
const SizedBox(height: 4),
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Expand All @@ -85,7 +103,7 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
borderRadius:
const BorderRadius.all(Radius.circular(8)),
child: Container(
padding: const EdgeInsets.all(4),
padding: const EdgeInsets.fromLTRB(8, 4, 8, 4),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand All @@ -95,18 +113,10 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
'version': widget.suggestedVersion.isEmpty
? FlutterI18n.translate(
context,
'appSelectorCard.allVersions',
'appSelectorCard.anyVersion',
)
: 'v${widget.suggestedVersion}',
: widget.suggestedVersion,
},
child: Text(
'',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSecondaryContainer,
),
),
),
const SizedBox(width: 4),
Icon(
Expand All @@ -121,17 +131,6 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
),
),
),
const SizedBox(width: 4),
Text(
widget.patchesCount == 1
? '• ${widget.patchesCount} patch'
: '• ${widget.patchesCount} patches',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
],
Expand Down