Skip to content

Commit

Permalink
v 0.6.5
Browse files Browse the repository at this point in the history
- Added Support for IPv6 Trackers Support.
- Updated ZeroNet Core to Latest rev 4496.
- Check whether App is Installed from PlayStore, this solves binary downloads for github and other store releases.
  • Loading branch information
canewsin committed Jul 27, 2020
1 parent fbe5958 commit a81280d
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 16 deletions.
30 changes: 17 additions & 13 deletions android/app/src/main/kotlin/in/canews/zeronet/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,20 @@ import androidx.annotation.NonNull
import androidx.core.app.ShareCompat
import androidx.core.content.FileProvider
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.play.core.splitinstall.SplitInstallManager
import com.google.android.play.core.splitinstall.SplitInstallRequest
import com.google.android.play.core.splitinstall.model.SplitInstallSessionStatus
import com.jeppeman.locallydynamic.LocallyDynamicSplitInstallManagerFactory
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.EventChannel.StreamHandler
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant
import java.io.File
import java.io.IOException
import java.io.InputStream
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.play.core.splitinstall.SplitInstallManager
import com.google.android.play.core.splitinstall.SplitInstallManagerFactory
import com.google.android.play.core.splitinstall.SplitInstallRequest
import com.google.android.play.core.splitinstall.SplitInstallSessionState
import com.google.android.play.core.splitinstall.model.SplitInstallSessionStatus
import com.jeppeman.locallydynamic.LocallyDynamicSplitInstallManagerFactory
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.EventChannel.StreamHandler
import io.flutter.plugin.common.JSONMessageCodec
import java.lang.IllegalStateException


const val BATTERY_OPTIMISATION_RESULT_CODE = 1001
Expand All @@ -47,14 +43,15 @@ class MainActivity : FlutterActivity() {
private var archName = ""
private var splitInstallManager: SplitInstallManager? = null
private lateinit var result: MethodChannel.Result
private var mSessionId = -1;
private var mSessionId = -1

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MethodChannel(flutterEngine?.dartExecutor, CHANNEL).setMethodCallHandler { call, result ->
when (call.method) {
"batteryOptimisations" -> getBatteryOptimizations(result)
"isBatteryOptimized" -> isBatteryOptimized(result)
"isPlayStoreInstall" -> result.success(isPlayStoreInstall(this))
"initSplitInstall" -> {
if (splitInstallManager == null)
splitInstallManager = LocallyDynamicSplitInstallManagerFactory.create(this)
Expand Down Expand Up @@ -85,7 +82,7 @@ class MainActivity : FlutterActivity() {
GeneratedPluginRegistrant.registerWith(flutterEngine)
EventChannel(flutterEngine.dartExecutor, EVENT_CHANNEL).setStreamHandler(
object : StreamHandler {
lateinit var events: EventChannel.EventSink;
lateinit var events: EventChannel.EventSink
override fun onListen(arguments: Any?, events: EventChannel.EventSink?) {
getArchName()
loadAndLaunchModule(archName, events)
Expand All @@ -98,6 +95,13 @@ class MainActivity : FlutterActivity() {
)
}

private fun isPlayStoreInstall(context: Context): Boolean {
val validInstallers: List<String> = listOf("com.android.vending", "com.google.android.feedback")
val installer = context.packageManager.getInstallerPackageName(context.packageName)

return installer != null && validInstallers.contains(installer)
}

private fun isBatteryOptimized(result: MethodChannel.Result) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val packageName = packageName
Expand Down
Binary file modified android/arm/src/main/assets/python38_arm.zip
Binary file not shown.
Binary file modified android/arm64/src/main/assets/python38_arm64.zip
Binary file not shown.
Binary file modified android/common/src/main/assets/zeronet_py3.zip
Binary file not shown.
Binary file modified android/nativelibs/src/main/jniLibs/arm64-v8a/libopenssl.so
Binary file not shown.
Binary file modified android/nativelibs/src/main/jniLibs/arm64-v8a/libpython3.8.so
Binary file not shown.
Binary file modified android/nativelibs/src/main/jniLibs/armeabi-v7a/libopenssl.so
Binary file not shown.
Binary file modified android/nativelibs/src/main/jniLibs/armeabi-v7a/libpython3.8.so
Binary file not shown.
Binary file modified android/nativelibs/src/main/jniLibs/x86_64/libopenssl.so
Binary file not shown.
Binary file modified android/nativelibs/src/main/jniLibs/x86_64/libpython3.8.so
Binary file not shown.
4 changes: 2 additions & 2 deletions android/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
flutter.versionName=0.6.3
flutter.versionCode=4078
flutter.versionName=0.6.5
flutter.versionCode=4083
Binary file modified android/x86/src/main/assets/python38_x86.zip
Binary file not shown.
Binary file modified android/x86_64/src/main/assets/python38_x86_64.zip
Binary file not shown.
26 changes: 26 additions & 0 deletions buildtools/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,37 @@ main(List<String> args) {
case 'compile':
compile();
break;
case 'update':
updateZeroNetCode();
break;
default:
compile();
}
}

updateZeroNetCode() {
var zeronetPath = Directory.current.path + '/build/ZeroNet-py3';
if (Directory(zeronetPath).existsSync()) {
print('Deleting ZeroNet Git Repo');
Directory(zeronetPath).deleteSync(recursive: true);
}
var process = Process.runSync('git', [
'clone',
'https://github.com/HelloZeroNet/ZeroNet.git',
'--depth=1',
zeronetPath,
]);
if (process.exitCode == 0) {
print('Successfully downloaded Zeronet Repo');

print('Deleting git history');
Directory(zeronetPath + '/.git').deleteSync(recursive: true);

Process.runSync('cd', ['build']);
Process.runSync('7z', ['a', '-tzip', 'zeronet_py3.zip', 'ZeroNet']);
}
}

compile() {
String versionProp = '';
var content = File('android/version.properties').readAsStringSync();
Expand Down
4 changes: 3 additions & 1 deletion lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ check() async {
} else {
varStore.setLoadingStatus(downloading);
if (!isDownloadExec) {
if (await isModuleInstallSupported() && kEnableDynamicModules) {
if (await isModuleInstallSupported() &&
kEnableDynamicModules &&
await isPlayStoreInstall()) {
await initSplitInstall();
printOut(
'PlayStore Module Install Supported',
Expand Down
3 changes: 3 additions & 0 deletions lib/native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const EventChannel _events_channel =
Future<bool> askBatteryOptimisation() async =>
await _channel.invokeMethod('batteryOptimisations');

Future<bool> isPlayStoreInstall() async =>
await _channel.invokeMethod('isPlayStoreInstall');

Future<bool> isBatteryOptimised() async =>
await _channel.invokeMethod('isBatteryOptimized');

Expand Down

0 comments on commit a81280d

Please sign in to comment.