mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
c78662fbfe
* replace all print statements with printV * restore backup error message * missing print statements, error fixes * Update cw_core/lib/utils/print_verbose.dart [skip ci] * Update cw_core/lib/utils/print_verbose.dart [skip ci] * CW-846: Correctly display balance (#1848) * Correctly display balance even with frozen coins * remove package= from AndroidMainfest.xml * update namespace * print -> printV --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
import 'dart:io';
|
|
import 'package:cake_wallet/utils/package_info.dart';
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
|
|
enum DistributionType { googleplay, github, appstore, fdroid }
|
|
|
|
class DistributionInfo {
|
|
DistributionInfo._();
|
|
|
|
static DistributionInfo get instance => DistributionInfo._();
|
|
|
|
Future<String> getDistributionPath() async {
|
|
final isPlayStore = await isInstalledFromPlayStore();
|
|
final distributionPath = _getDistributionPath(isPlayStore);
|
|
|
|
return distributionPath.name;
|
|
}
|
|
|
|
DistributionType _getDistributionPath(bool isPlayStore) {
|
|
if (isPlayStore) {
|
|
return DistributionType.googleplay;
|
|
} else if (Platform.isAndroid) {
|
|
return DistributionType.github;
|
|
} else if (Platform.isIOS) {
|
|
return DistributionType.appstore;
|
|
} else {
|
|
return DistributionType.github;
|
|
}
|
|
}
|
|
|
|
Future<bool> isInstalledFromPlayStore() async {
|
|
try {
|
|
final packageInfo = await PackageInfo.fromPlatform();
|
|
return packageInfo.packageName == 'com.android.vending';
|
|
} catch (e) {
|
|
printV('Error: $e');
|
|
return false;
|
|
}
|
|
}
|
|
}
|