Bugfix for different ID same URL Apps (#299)

This commit is contained in:
Imran Remtulla
2023-02-18 18:31:42 -05:00
parent 86131ae3ce
commit ea81b0e66e
4 changed files with 17 additions and 18 deletions

View File

@@ -118,7 +118,7 @@ class _AddAppPageState extends State<AddAppPage> {
await settingsProvider.getInstallPermission(); await settingsProvider.getInstallPermission();
} }
// Only download the APK here if you need to for the package ID // Only download the APK here if you need to for the package ID
if (sourceProvider.isTempId(app.id) && if (sourceProvider.isTempId(app) &&
app.additionalSettings['trackOnly'] != true) { app.additionalSettings['trackOnly'] != true) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
var apkUrl = await appsProvider.confirmApkUrl(app, context); var apkUrl = await appsProvider.confirmApkUrl(app, context);

View File

@@ -113,7 +113,7 @@ class _AppPageState extends State<AppPage> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const SizedBox(height: 150), const SizedBox(height: 125),
app?.installedInfo != null app?.installedInfo != null
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [ ? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Image.memory( Image.memory(
@@ -136,6 +136,14 @@ class _AppPageState extends State<AppPage> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineMedium, style: Theme.of(context).textTheme.headlineMedium,
), ),
const SizedBox(
height: 8,
),
Text(
app?.app.id ?? '',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.labelSmall,
),
const SizedBox( const SizedBox(
height: 32, height: 32,
), ),

View File

@@ -182,7 +182,7 @@ class AppsProvider with ChangeNotifier {
// The former case should be handled (give the App its real ID), the latter is a security issue // The former case should be handled (give the App its real ID), the latter is a security issue
var newInfo = await PackageArchiveInfo.fromPath(downloadedFile.path); var newInfo = await PackageArchiveInfo.fromPath(downloadedFile.path);
if (app.id != newInfo.packageName) { if (app.id != newInfo.packageName) {
if (apps[app.id] != null && !SourceProvider().isTempId(app.id)) { if (apps[app.id] != null && !SourceProvider().isTempId(app)) {
throw IDChangedError(); throw IDChangedError();
} }
var originalAppId = app.id; var originalAppId = app.id;

View File

@@ -350,21 +350,12 @@ class SourceProvider {
return false; return false;
} }
String generateTempID(AppNames names, AppSource source) => String generateTempID(
'${names.author.toLowerCase()}_${names.name.toLowerCase()}_${source.host}'; String standardUrl, Map<String, dynamic> additionalSettings) =>
(standardUrl + additionalSettings.toString()).hashCode.toString();
bool isTempId(String id) { bool isTempId(App app) {
List<String> parts = id.split('_'); return app.id == generateTempID(app.url, app.additionalSettings);
if (parts.length < 3) {
return false;
}
for (int i = 0; i < parts.length - 1; i++) {
if (RegExp('.*[A-Z].*').hasMatch(parts[i])) {
// TODO: Look into RegEx for non-Latin characters
return false;
}
}
return true;
} }
Future<App> getApp( Future<App> getApp(
@@ -400,7 +391,7 @@ class SourceProvider {
currentApp?.id ?? currentApp?.id ??
source.tryInferringAppId(standardUrl, source.tryInferringAppId(standardUrl,
additionalSettings: additionalSettings) ?? additionalSettings: additionalSettings) ??
generateTempID(apk.names, source), generateTempID(standardUrl, additionalSettings),
standardUrl, standardUrl,
apk.names.author[0].toUpperCase() + apk.names.author.substring(1), apk.names.author[0].toUpperCase() + apk.names.author.substring(1),
name.trim().isNotEmpty name.trim().isNotEmpty