mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-31 21:00:15 +02:00
Bugfix for different ID same URL Apps (#299)
This commit is contained in:
@@ -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);
|
||||||
|
@@ -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,
|
||||||
),
|
),
|
||||||
|
@@ -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;
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user