Skip to content

Commit ebf20e2

Browse files
committed
v 0.7.5 - beta 1
- 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.
1 parent 7daf953 commit ebf20e2

31 files changed

+835
-330
lines changed

README.md

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,74 @@
1-
# zeronet
1+
# ZeroNet Mobile
2+
[![Codemagic build status](https://api.codemagic.io/apps/5f755f0647fecf7a4f25751a/5f75609747fecf958ea171b0/status_badge.svg)](https://codemagic.io/apps/5f755f0647fecf7a4f25751a/5f75609747fecf958ea171b0/latest_build)
23

3-
A new Flutter project.
4+
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/.
45

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

7-
This project is a starting point for a Flutter application.
10+
## Installation
811

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

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

14-
For help getting started with Flutter, view our
15-
[online documentation](https://flutter.dev/docs), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
19+
You need Flutter Framework to compile this App from Source.
20+
21+
#### Installing Flutter : https://flutter.dev/docs/get-started/install
22+
23+
```
24+
git clone https://github.com/canewsin/zeronet_mobile.git
25+
cd zeronet_mobile
26+
flutter packages get
27+
```
28+
29+
After that create a file named `key.properties` in `android` directory
30+
and fill the below details, which are in capital letters, with your details.
31+
```
32+
storeFile=ANDROID_KEY_STORE_FILE_PATH
33+
storePassword=KEY_STORE_PASSWORD
34+
keyAlias=KEY_ALIAS
35+
keyPassword=KEY_PASSWORD
36+
```
37+
38+
in root folder
39+
40+
to build apk
41+
```
42+
flutter build apk --no-shrink
43+
```
44+
45+
to build appbundle
46+
```
47+
flutter build appbundle --no-shrink
48+
```
49+
50+
to run the app in Android Device / Emulator
51+
52+
```
53+
flutter run
54+
```
55+
56+
## Donate
57+
BTC(Preferred) :
58+
59+
`35NgjpB3pzkdHkAPrNh2EMERGxnXgwCb6G`
60+
61+
ETH :
62+
63+
`0xa81a32dcce8e5bcb9792daa19ae7f964699ee536`
64+
65+
UPI(Indian Users) :
66+
67+
`pramukesh@upi`
68+
69+
Liberapay :
70+
71+
`https://liberapay.com/canews.in/donate`
72+
73+
## Contribute
74+
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.

android/app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ flutter {
9494

9595
dependencies {
9696
def billing_version = "3.0.0"
97-
implementation 'com.android.billingclient:billing:$billing_version'
97+
implementation "com.android.billingclient:billing:$billing_version"
9898

9999
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
100100
implementation 'com.google.android.gms:play-services-base:17.2.0'
101+
102+
//Duplicate Classes Issue https://stackoverflow.com/a/60492942
103+
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
101104

102105
debugImplementation 'com.jeppeman.locallydynamic:locallydynamic-debug:0.3'
103106
releaseImplementation 'com.jeppeman.locallydynamic:locallydynamic:0.3'

android/app/src/main/kotlin/in/canews/zeronet/MainActivity.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ class MainActivity : FlutterActivity() {
5656

5757
override fun onCreate(savedInstanceState: Bundle?) {
5858
super.onCreate(savedInstanceState)
59-
if(intent.getStringExtra("LAUNCH_SHORTCUT_URL") != null){
59+
if(intent.getStringExtra("LAUNCH_SHORTCUT_URL") != null) {
6060
mLaunchShortcutUrl = intent.getStringExtra("LAUNCH_SHORTCUT_URL")
6161
}
62+
}
63+
64+
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
65+
GeneratedPluginRegistrant.registerWith(flutterEngine)
6266
MethodChannel(flutterEngine?.dartExecutor, CHANNEL).setMethodCallHandler { call, result ->
6367
when (call.method) {
6468
"addToHomeScreen" -> addShortcutToHomeScreen(context, result,
@@ -95,10 +99,6 @@ class MainActivity : FlutterActivity() {
9599
"uninstallModules" -> uninstallModules()
96100
}
97101
}
98-
}
99-
100-
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
101-
GeneratedPluginRegistrant.registerWith(flutterEngine)
102102
EventChannel(flutterEngine.dartExecutor, EVENT_CHANNEL).setStreamHandler(
103103
object : StreamHandler {
104104
lateinit var events: EventChannel.EventSink
@@ -234,7 +234,9 @@ class MainActivity : FlutterActivity() {
234234
}
235235

236236
private fun resultSuccess(msg : Any) {
237-
result.success(msg).runCatching{}.onFailure {
237+
result.runCatching {
238+
success(msg)
239+
}.onFailure {
238240
if (it is IllegalStateException) {
239241
Log.e("MainActivity>resultSuc>", it.message)
240242
}
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
package `in`.canews.zeronet
22

3+
import android.app.Activity
34
import android.content.Context
4-
import io.flutter.app.FlutterApplication
55
import com.google.android.play.core.splitcompat.SplitCompat
66
import com.google.android.play.core.splitcompat.SplitCompatApplication
7+
import io.flutter.FlutterInjector
78

89

9-
internal class MyApplication : SplitCompatApplication(){
10+
internal class MyApplication : SplitCompatApplication() {
11+
12+
override fun onCreate() {
13+
super.onCreate()
14+
FlutterInjector.instance().flutterLoader().startInitialization(this)
15+
}
16+
17+
private var mCurrentActivity: Activity? = null
18+
19+
fun getCurrentActivity(): Activity? {
20+
return mCurrentActivity
21+
}
22+
23+
fun setCurrentActivity(mCurrentActivity: Activity?) {
24+
this.mCurrentActivity = mCurrentActivity
25+
}
26+
1027
override fun attachBaseContext(base: Context?) {
1128
super.attachBaseContext(base)
1229
SplitCompat.install(base!!)
1330
}
31+
1432
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<vector android:height="24dp" android:viewportHeight="512"
2+
android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<group>
4+
<clip-path android:pathData="M0,0h512v512h-512z"/>
5+
<path android:fillColor="#8663ff"
6+
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"/>
7+
<path android:fillColor="#8663ff"
8+
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"/>
9+
<path android:fillColor="#8663ff"
10+
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"/>
11+
<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"/>
12+
</group>
13+
</vector>
Loading
Loading
Loading
Loading
-795 Bytes
Loading

android/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
flutter.versionName=0.7.3
2-
flutter.versionCode=4125
1+
flutter.versionName=v 0.7.5 - beta 1
2+
flutter.versionCode=4149

assets/logo.png

-795 Bytes
Loading

lib/core/site/site.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ class Site {
6969
downloaded = jsonStr['downloaded']?.toInt();
7070
modified = jsonStr['modified']?.toInt();
7171
optionalDownloaded = jsonStr['optional_downloaded'];
72-
optionalHelp = jsonStr['optional_help'] != null
73-
? json.decode(jsonStr['optional_help'])
74-
: null;
72+
optionalHelp =
73+
jsonStr['optional_help'] != null ? jsonStr['optional_help'] : null;
7574
own = jsonStr['own'];
7675
peers = jsonStr['peers'];
7776
permissions = jsonStr['permissions'].cast<String>();

lib/imports.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ export 'package:flutter/gestures.dart';
99
export 'package:flutter/material.dart';
1010
export 'package:flutter/services.dart';
1111

12+
export 'package:clipboard/clipboard.dart';
1213
export 'package:crypto/crypto.dart';
1314
export 'package:device_info/device_info.dart';
1415
export 'package:equatable/equatable.dart';
1516
export 'package:file_picker/file_picker.dart';
1617
export 'package:flutter_absolute_path/flutter_absolute_path.dart';
18+
export 'package:flutter_background_service/flutter_background_service.dart';
1719
export 'package:flutter_downloader/flutter_downloader.dart';
18-
export 'package:flutter_local_notifications/flutter_local_notifications.dart';
1920
export 'package:flutter_mobx/flutter_mobx.dart';
2021
export 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
2122
export 'package:google_fonts/google_fonts.dart';
@@ -39,8 +40,10 @@ export 'models/enums.dart';
3940
export 'models/models.dart';
4041
export 'mobx/uistore.dart';
4142
export 'mobx/varstore.dart';
43+
export 'mobx/purchasesstore.dart';
4244
export 'others/common.dart';
4345
export 'others/constants.dart';
46+
export 'others/donation_const.dart';
4447
export 'others/extensions.dart';
4548
export 'others/native.dart';
4649
export 'others/utils.dart';

lib/main.dart

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ import 'imports.dart';
33
Future main() async {
44
WidgetsFlutterBinding.ensureInitialized();
55
await init();
6-
//TODO: Check For Google Play Store Install.
7-
InAppPurchaseConnection.enablePendingPurchases();
6+
if (kEnableInAppPurchases) {
7+
InAppPurchaseConnection.enablePendingPurchases();
8+
final Stream purchaseUpdates =
9+
InAppPurchaseConnection.instance.purchaseUpdatedStream;
10+
purchaseUpdates.listen((purchases) => listenToPurchaseUpdated(purchases));
11+
}
812
launchUrl = await launchZiteUrl();
913
runApp(MyApp());
1014
}
@@ -31,12 +35,18 @@ class MyApp extends StatelessWidget {
3135
body: Observer(
3236
builder: (context) {
3337
if (varStore.zeroNetInstalled) {
38+
scaffoldState = Scaffold.of(context);
3439
if (firstTime) {
3540
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
3641
uiStore.updateCurrentAppRoute(AppRoute.Settings);
37-
makeExecHelper();
42+
if (!isExecPermitted)
43+
makeExecHelper().then(
44+
(value) => isExecPermitted = value,
45+
);
46+
firstTime = false;
3847
}
39-
if (uiStore.zeroNetStatus == ZeroNetStatus.NOT_RUNNING) {
48+
if (uiStore.zeroNetStatus == ZeroNetStatus.NOT_RUNNING &&
49+
!manuallyStoppedZeroNet) {
4050
checkInitStatus();
4151
}
4252
if (launchUrl.isNotEmpty) {
@@ -54,13 +64,15 @@ class MyApp extends StatelessWidget {
5464
switch (uiStore.currentAppRoute) {
5565
case AppRoute.AboutPage:
5666
return WillPopScope(
57-
onWillPop: () {
58-
uiStore.updateCurrentAppRoute(AppRoute.Home);
59-
return Future.value(false);
60-
},
61-
child: AboutPage());
67+
onWillPop: () {
68+
uiStore.updateCurrentAppRoute(AppRoute.Home);
69+
return Future.value(false);
70+
},
71+
child: AboutPage(),
72+
);
6273
break;
6374
case AppRoute.Home:
75+
getInAppPurchases();
6476
return HomePage();
6577
break;
6678
case AppRoute.Settings:

lib/mobx/purchasesstore.dart

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import 'package:mobx/mobx.dart';
2+
import 'package:purchases_flutter/purchases_flutter.dart' as purchases_flutter;
3+
4+
// Include generated file
5+
part 'purchasesstore.g.dart';
6+
7+
// This is the class used by rest of your codebase
8+
final purchasesStore = PurchasesStore();
9+
10+
class PurchasesStore = _PurchasesStore with _$PurchasesStore;
11+
12+
// The store-class
13+
abstract class _PurchasesStore with Store {
14+
@observable
15+
ObservableList<purchases_flutter.Package> oneTimePurchases =
16+
ObservableList<purchases_flutter.Package>();
17+
18+
@observable
19+
ObservableList<purchases_flutter.Package> subscriptions =
20+
ObservableList<purchases_flutter.Package>();
21+
22+
@action
23+
void addOneTimePuchases(List<purchases_flutter.Package> details) {
24+
for (var item in details) {
25+
bool exists = oneTimePurchases
26+
.any((element) => element.identifier == item.identifier);
27+
if (!exists) {
28+
oneTimePurchases.add(item);
29+
}
30+
}
31+
}
32+
33+
@action
34+
void addSubscriptions(List<purchases_flutter.Package> details) {
35+
for (var item in details) {
36+
bool exists =
37+
subscriptions.any((element) => element.identifier == item.identifier);
38+
if (!exists) {
39+
subscriptions.add(item);
40+
}
41+
}
42+
}
43+
44+
@observable
45+
ObservableList<String> purchases = ObservableList();
46+
47+
@action
48+
void addPurchases(String purchaseIds) {
49+
if (!purchases.contains(purchaseIds)) {
50+
purchases.add(purchaseIds);
51+
}
52+
}
53+
54+
@observable
55+
ObservableList<String> consumedPurchases = ObservableList();
56+
57+
@action
58+
void addConsumedPurchases(String purchaseIds) {
59+
if (!consumedPurchases.contains(purchaseIds)) {
60+
consumedPurchases.add(purchaseIds);
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)