Skip to content

Commit

Permalink
v 0.7.5 - beta 1
Browse files Browse the repository at this point in the history
  - Run ZeroNet on Seperate Service.
  - Bug Fixed for UI lag on initial setup of App Settings.
  - Packages Upgrade to latest versions.
  - Added Third Party Purchase Manager.
  - InApp Purchases Fix.
  - Bug Fixes and UX changes.
  • Loading branch information
canewsin committed Oct 25, 2020
1 parent 7daf953 commit ebf20e2
Show file tree
Hide file tree
Showing 31 changed files with 835 additions and 330 deletions.
78 changes: 68 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,74 @@
# zeronet
# ZeroNet Mobile
[![Codemagic build status](https://api.codemagic.io/apps/5f755f0647fecf7a4f25751a/5f75609747fecf958ea171b0/status_badge.svg)](https://codemagic.io/apps/5f755f0647fecf7a4f25751a/5f75609747fecf958ea171b0/latest_build)

A new Flutter project.
ZeroNet Mobile is an Android Client for [ZeroNet](https://zeronet.io), a platform for decentralized websites using Bitcoin crypto and the BitTorrent network. you can learn more about ZeroNet at https://zeronet.io/.

## Getting Started
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png"
alt="Download from Google Play"
height="80">](https://play.google.com/store/apps/details?id=in.canews.zeronet)

This project is a starting point for a Flutter application.
## Installation

A few resources to get you started if this is your first Flutter project:
### From Google PlayStore :
#### Android (arm, arm64, x86)
- minimum Android version supported 16 (JellyBean).
- Google Play Store Link https://play.google.com/store/apps/details?id=in.canews.zeronet

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
#### Compiling Source :

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
You need Flutter Framework to compile this App from Source.

#### Installing Flutter : https://flutter.dev/docs/get-started/install

```
git clone https://github.com/canewsin/zeronet_mobile.git
cd zeronet_mobile
flutter packages get
```

After that create a file named `key.properties` in `android` directory
and fill the below details, which are in capital letters, with your details.
```
storeFile=ANDROID_KEY_STORE_FILE_PATH
storePassword=KEY_STORE_PASSWORD
keyAlias=KEY_ALIAS
keyPassword=KEY_PASSWORD
```

in root folder

to build apk
```
flutter build apk --no-shrink
```

to build appbundle
```
flutter build appbundle --no-shrink
```

to run the app in Android Device / Emulator

```
flutter run
```

## Donate
BTC(Preferred) :

`35NgjpB3pzkdHkAPrNh2EMERGxnXgwCb6G`

ETH :

`0xa81a32dcce8e5bcb9792daa19ae7f964699ee536`

UPI(Indian Users) :

`pramukesh@upi`

Liberapay :

`https://liberapay.com/canews.in/donate`

## Contribute
If you want to support project's further development, you can contribute your time or money, If you want to contribute money you can send bitcoin or other supported crypto currencies to above addresses or buy in-app purchases, if want to contribute translations or code.
5 changes: 4 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ flutter {

dependencies {
def billing_version = "3.0.0"
implementation 'com.android.billingclient:billing:$billing_version'
implementation "com.android.billingclient:billing:$billing_version"

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.android.gms:play-services-base:17.2.0'

//Duplicate Classes Issue https://stackoverflow.com/a/60492942
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

debugImplementation 'com.jeppeman.locallydynamic:locallydynamic-debug:0.3'
releaseImplementation 'com.jeppeman.locallydynamic:locallydynamic:0.3'
Expand Down
14 changes: 8 additions & 6 deletions android/app/src/main/kotlin/in/canews/zeronet/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ class MainActivity : FlutterActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if(intent.getStringExtra("LAUNCH_SHORTCUT_URL") != null){
if(intent.getStringExtra("LAUNCH_SHORTCUT_URL") != null) {
mLaunchShortcutUrl = intent.getStringExtra("LAUNCH_SHORTCUT_URL")
}
}

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine)
MethodChannel(flutterEngine?.dartExecutor, CHANNEL).setMethodCallHandler { call, result ->
when (call.method) {
"addToHomeScreen" -> addShortcutToHomeScreen(context, result,
Expand Down Expand Up @@ -95,10 +99,6 @@ class MainActivity : FlutterActivity() {
"uninstallModules" -> uninstallModules()
}
}
}

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine)
EventChannel(flutterEngine.dartExecutor, EVENT_CHANNEL).setStreamHandler(
object : StreamHandler {
lateinit var events: EventChannel.EventSink
Expand Down Expand Up @@ -234,7 +234,9 @@ class MainActivity : FlutterActivity() {
}

private fun resultSuccess(msg : Any) {
result.success(msg).runCatching{}.onFailure {
result.runCatching {
success(msg)
}.onFailure {
if (it is IllegalStateException) {
Log.e("MainActivity>resultSuc>", it.message)
}
Expand Down
22 changes: 20 additions & 2 deletions android/app/src/main/kotlin/in/canews/zeronet/MyApplication.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
package `in`.canews.zeronet

import android.app.Activity
import android.content.Context
import io.flutter.app.FlutterApplication
import com.google.android.play.core.splitcompat.SplitCompat
import com.google.android.play.core.splitcompat.SplitCompatApplication
import io.flutter.FlutterInjector


internal class MyApplication : SplitCompatApplication(){
internal class MyApplication : SplitCompatApplication() {

override fun onCreate() {
super.onCreate()
FlutterInjector.instance().flutterLoader().startInitialization(this)
}

private var mCurrentActivity: Activity? = null

fun getCurrentActivity(): Activity? {
return mCurrentActivity
}

fun setCurrentActivity(mCurrentActivity: Activity?) {
this.mCurrentActivity = mCurrentActivity
}

override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
SplitCompat.install(base!!)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector android:height="24dp" android:viewportHeight="512"
android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<clip-path android:pathData="M0,0h512v512h-512z"/>
<path android:fillColor="#8663ff"
android:pathData="M79.443,144.457C77.102,162.428 119.095,235.227 234.554,305.703C341.917,371.238 417.752,375.869 432.208,366.721C434.549,348.749 392.556,275.95 277.097,205.474C169.734,139.94 93.899,135.309 79.443,144.457M43.51,124.185C68.586,78.947 181.959,99.367 298.459,170.479C416.115,242.296 492.407,338.621 468.861,385.626C468.63,386.088 468.39,386.543 468.141,386.992C443.065,432.23 329.693,411.81 213.192,340.699C95.536,268.881 19.244,172.557 42.79,125.552C43.021,125.09 43.262,124.634 43.51,124.185Z" android:strokeColor="#00000000"/>
<path android:fillColor="#8663ff"
android:pathData="M260.204,47.135C243.6,54.383 202.852,127.849 201.923,263.062C201.06,388.795 236.142,456.153 251.424,463.827C268.028,456.579 308.776,383.114 309.704,247.901C310.568,122.168 275.485,54.81 260.204,47.135M259.069,5.91C310.74,4.1 351.624,111.75 350.688,248.182C349.742,385.969 306.499,500.935 254.101,504.966C253.586,505.006 253.072,505.035 252.559,505.053C200.888,506.863 160.004,399.213 160.94,262.78C161.886,124.994 205.129,10.028 257.527,5.996C258.041,5.957 258.556,5.928 259.069,5.91Z" android:strokeColor="#00000000"/>
<path android:fillColor="#8663ff"
android:pathData="M436.391,150.75C422.423,141.092 346.225,143.081 236.355,204.938C117.586,271.806 73.069,343.715 75.207,360.39C89.023,370.093 165.281,368.184 275.301,306.242C393.821,239.515 438.4,167.768 436.391,150.75M472.89,131.633C473.121,132.087 473.342,132.544 473.555,133.009C495.419,180.715 415.663,274.27 295.415,341.969C176.342,409.007 62.209,425.554 38.766,379.547C38.535,379.094 38.314,378.637 38.101,378.171C16.238,330.465 95.994,236.911 216.241,169.211C335.314,102.173 449.447,85.626 472.89,131.633Z" android:strokeColor="#00000000"/>
<path android:fillColor="#9963f9" android:pathData="M256.188,314.308 L217,288.662L217,268.515L235.975,257.602 276.256,233.09 256.188,220.834 235.975,233.09L235.975,253.741L217,265.157L217,222.177L256.188,198 295.231,222.177L295.231,243.667L235.975,277.749 255.283,289.67 276.256,277.749l-0,-21.49L295.231,247.025L295.231,288.662Z"/>
</group>
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/drawable/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.7.3
flutter.versionCode=4125
flutter.versionName=v 0.7.5 - beta 1
flutter.versionCode=4149
Binary file modified assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions lib/core/site/site.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ class Site {
downloaded = jsonStr['downloaded']?.toInt();
modified = jsonStr['modified']?.toInt();
optionalDownloaded = jsonStr['optional_downloaded'];
optionalHelp = jsonStr['optional_help'] != null
? json.decode(jsonStr['optional_help'])
: null;
optionalHelp =
jsonStr['optional_help'] != null ? jsonStr['optional_help'] : null;
own = jsonStr['own'];
peers = jsonStr['peers'];
permissions = jsonStr['permissions'].cast<String>();
Expand Down
5 changes: 4 additions & 1 deletion lib/imports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ export 'package:flutter/gestures.dart';
export 'package:flutter/material.dart';
export 'package:flutter/services.dart';

export 'package:clipboard/clipboard.dart';
export 'package:crypto/crypto.dart';
export 'package:device_info/device_info.dart';
export 'package:equatable/equatable.dart';
export 'package:file_picker/file_picker.dart';
export 'package:flutter_absolute_path/flutter_absolute_path.dart';
export 'package:flutter_background_service/flutter_background_service.dart';
export 'package:flutter_downloader/flutter_downloader.dart';
export 'package:flutter_local_notifications/flutter_local_notifications.dart';
export 'package:flutter_mobx/flutter_mobx.dart';
export 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
export 'package:google_fonts/google_fonts.dart';
Expand All @@ -39,8 +40,10 @@ export 'models/enums.dart';
export 'models/models.dart';
export 'mobx/uistore.dart';
export 'mobx/varstore.dart';
export 'mobx/purchasesstore.dart';
export 'others/common.dart';
export 'others/constants.dart';
export 'others/donation_const.dart';
export 'others/extensions.dart';
export 'others/native.dart';
export 'others/utils.dart';
Expand Down
30 changes: 21 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import 'imports.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await init();
//TODO: Check For Google Play Store Install.
InAppPurchaseConnection.enablePendingPurchases();
if (kEnableInAppPurchases) {
InAppPurchaseConnection.enablePendingPurchases();
final Stream purchaseUpdates =
InAppPurchaseConnection.instance.purchaseUpdatedStream;
purchaseUpdates.listen((purchases) => listenToPurchaseUpdated(purchases));
}
launchUrl = await launchZiteUrl();
runApp(MyApp());
}
Expand All @@ -31,12 +35,18 @@ class MyApp extends StatelessWidget {
body: Observer(
builder: (context) {
if (varStore.zeroNetInstalled) {
scaffoldState = Scaffold.of(context);
if (firstTime) {
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
uiStore.updateCurrentAppRoute(AppRoute.Settings);
makeExecHelper();
if (!isExecPermitted)
makeExecHelper().then(
(value) => isExecPermitted = value,
);
firstTime = false;
}
if (uiStore.zeroNetStatus == ZeroNetStatus.NOT_RUNNING) {
if (uiStore.zeroNetStatus == ZeroNetStatus.NOT_RUNNING &&
!manuallyStoppedZeroNet) {
checkInitStatus();
}
if (launchUrl.isNotEmpty) {
Expand All @@ -54,13 +64,15 @@ class MyApp extends StatelessWidget {
switch (uiStore.currentAppRoute) {
case AppRoute.AboutPage:
return WillPopScope(
onWillPop: () {
uiStore.updateCurrentAppRoute(AppRoute.Home);
return Future.value(false);
},
child: AboutPage());
onWillPop: () {
uiStore.updateCurrentAppRoute(AppRoute.Home);
return Future.value(false);
},
child: AboutPage(),
);
break;
case AppRoute.Home:
getInAppPurchases();
return HomePage();
break;
case AppRoute.Settings:
Expand Down
63 changes: 63 additions & 0 deletions lib/mobx/purchasesstore.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:mobx/mobx.dart';
import 'package:purchases_flutter/purchases_flutter.dart' as purchases_flutter;

// Include generated file
part 'purchasesstore.g.dart';

// This is the class used by rest of your codebase
final purchasesStore = PurchasesStore();

class PurchasesStore = _PurchasesStore with _$PurchasesStore;

// The store-class
abstract class _PurchasesStore with Store {
@observable
ObservableList<purchases_flutter.Package> oneTimePurchases =
ObservableList<purchases_flutter.Package>();

@observable
ObservableList<purchases_flutter.Package> subscriptions =
ObservableList<purchases_flutter.Package>();

@action
void addOneTimePuchases(List<purchases_flutter.Package> details) {
for (var item in details) {
bool exists = oneTimePurchases
.any((element) => element.identifier == item.identifier);
if (!exists) {
oneTimePurchases.add(item);
}
}
}

@action
void addSubscriptions(List<purchases_flutter.Package> details) {
for (var item in details) {
bool exists =
subscriptions.any((element) => element.identifier == item.identifier);
if (!exists) {
subscriptions.add(item);
}
}
}

@observable
ObservableList<String> purchases = ObservableList();

@action
void addPurchases(String purchaseIds) {
if (!purchases.contains(purchaseIds)) {
purchases.add(purchaseIds);
}
}

@observable
ObservableList<String> consumedPurchases = ObservableList();

@action
void addConsumedPurchases(String purchaseIds) {
if (!consumedPurchases.contains(purchaseIds)) {
consumedPurchases.add(purchaseIds);
}
}
}
Loading

0 comments on commit ebf20e2

Please sign in to comment.