Skip to content

Commit e0e3ae3

Browse files
authored
Merge branch 'develop' into Issue-101
2 parents 7ffa030 + d96ae7a commit e0e3ae3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+6719
-260
lines changed

.github/workflows/dart.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- run: flutter pub get
2222
# - run: flutter analyze
2323
- run: flutter format -n --set-exit-if-changed .
24+
- run: flutter test
2425
- run: flutter build apk
2526

2627
- uses: actions/upload-artifact@v1

android/app/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,23 @@ apply plugin: 'com.android.application'
2525
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2626

2727
android {
28-
compileSdkVersion 31
29-
28+
compileSdkVersion 33
29+
3030
defaultConfig {
3131
multiDexEnabled true
3232
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
33+
multiDexEnabled true
3334
applicationId "com.hustlecreatives.flood_mobile"
3435
minSdkVersion 21
3536
targetSdkVersion 31
3637
versionCode flutterVersionCode.toInteger()
3738
versionName flutterVersionName
3839
}
3940

41+
dependencies {
42+
implementation 'com.android.support:multidex:1.0.3'
43+
}
44+
4045
buildTypes {
4146
release {
4247
// TODO: Add your own signing config for the release build.
@@ -48,4 +53,4 @@ android {
4853

4954
flutter {
5055
source '../..'
51-
}
56+
}
Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.hustlecreatives.flood_mobile">
2+
package="com.hustlecreatives.flood_mobile">
33

44
<uses-permission android:name="android.permission.INTERNET"/>
55
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
@@ -13,53 +13,64 @@
1313
</queries>
1414

1515
<application
16-
android:requestLegacyExternalStorage="true"
17-
android:label="Flood"
18-
android:usesCleartextTraffic="true"
19-
android:icon="@mipmap/ic_launcher">
16+
android:requestLegacyExternalStorage="true"
17+
android:label="Flood"
18+
android:usesCleartextTraffic="true"
19+
android:icon="@mipmap/ic_launcher">
2020
<provider
21-
android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
22-
android:authorities="${applicationId}.flutter_downloader.provider"
23-
android:exported="false"
24-
android:grantUriPermissions="true">
21+
android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
22+
android:authorities="${applicationId}.flutter_downloader.provider"
23+
android:exported="false"
24+
android:grantUriPermissions="true">
2525
<meta-data
26-
android:name="android.support.FILE_PROVIDER_PATHS"
27-
android:resource="@xml/provider_paths"/>
26+
android:name="android.support.FILE_PROVIDER_PATHS"
27+
android:resource="@xml/provider_paths"/>
2828
</provider>
2929
<activity
30-
android:exported="true"
31-
android:name=".MainActivity"
32-
android:launchMode="singleTop"
33-
android:theme="@style/LaunchTheme"
34-
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
35-
android:hardwareAccelerated="true"
36-
android:windowSoftInputMode="adjustResize">
30+
android:exported="true"
31+
android:name=".MainActivity"
32+
android:launchMode="singleTop"
33+
android:theme="@style/LaunchTheme"
34+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
35+
android:hardwareAccelerated="true"
36+
android:windowSoftInputMode="adjustResize">
3737
<!-- Specifies an Android theme to apply to this Activity as soon as
3838
the Android process has started. This theme is visible to the user
3939
while the Flutter UI initializes. After that, this theme continues
4040
to determine the Window background behind the Flutter UI. -->
4141
<meta-data
42-
android:name="io.flutter.embedding.android.NormalTheme"
43-
android:resource="@style/NormalTheme"
44-
/>
42+
android:name="io.flutter.embedding.android.NormalTheme"
43+
android:resource="@style/NormalTheme"
44+
/>
4545
<!-- Displays an Android View that continues showing the launch screen
4646
Drawable until Flutter paints its first frame, then this splash
4747
screen fades out. A splash screen is useful to avoid any visual
4848
gap between the end of Android's launch screen and the painting of
4949
Flutter's first frame. -->
5050
<meta-data
51-
android:name="io.flutter.embedding.android.SplashScreenDrawable"
52-
android:resource="@drawable/launch_background"
53-
/>
51+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
52+
android:resource="@drawable/launch_background"
53+
/>
5454
<intent-filter>
5555
<action android:name="android.intent.action.MAIN"/>
5656
<category android:name="android.intent.category.LAUNCHER"/>
5757
</intent-filter>
58+
<intent-filter android:icon="@mipmap/ic_launcher"
59+
android:label="Flood"
60+
android:priority="1">
61+
<action android:name="android.intent.action.VIEW"/>
62+
<category android:name="android.intent.category.DEFAULT"/>
63+
<category android:name="android.intent.category.BROWSABLE"/>
64+
<data android:scheme="content" />
65+
<data android:scheme="http" />
66+
<data android:scheme="file" />
67+
<data android:mimeType="application/x-bittorrent" />
68+
</intent-filter>
5869
</activity>
5970
<!-- Don't delete the meta-data below.
6071
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
6172
<meta-data
62-
android:name="flutterEmbedding"
63-
android:value="2"/>
73+
android:name="flutterEmbedding"
74+
android:value="2"/>
6475
</application>
65-
</manifest>
76+
</manifest>
40.1 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'dart:convert';
2+
3+
import 'package:dio/dio.dart';
4+
import 'package:flutter/material.dart';
5+
import 'package:provider/provider.dart';
6+
import '../Provider/api_provider.dart';
7+
import '../Provider/user_detail_provider.dart';
8+
9+
class DeleteFeedOrRulesApi {
10+
static Future<void> deleteFeedsOrRules(
11+
{required BuildContext context, required String id}) async {
12+
try {
13+
Response response;
14+
Dio dio = new Dio();
15+
String url = Provider.of<ApiProvider>(context, listen: false).baseUrl +
16+
ApiProvider.listAllFeedsAndRules +
17+
"/" +
18+
id;
19+
dio.options.headers['Accept'] = "application/json";
20+
dio.options.headers['Content-Type'] = "application/json";
21+
dio.options.headers['Connection'] = "keep-alive";
22+
dio.options.headers['Cookie'] =
23+
Provider.of<UserDetailProvider>(context, listen: false).token;
24+
Map<String, dynamic> mp = Map();
25+
mp['id'] = id;
26+
String rawBody = json.encode(mp);
27+
response = await dio.delete(
28+
url,
29+
data: rawBody,
30+
);
31+
if (response.statusCode == 200) {
32+
print("Feeds or Rules Deleted");
33+
} else {
34+
print("There is some problem status code not 200");
35+
}
36+
} catch (e) {
37+
print('Exception caught in Api Request ' + e.toString());
38+
}
39+
}
40+
}

lib/Api/event_handler_api.dart

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:convert';
2-
2+
import 'package:awesome_notifications/awesome_notifications.dart';
3+
import 'package:duration/duration.dart';
34
import 'package:flood_mobile/Model/download_rate_model.dart';
45
import 'package:flood_mobile/Model/torrent_model.dart';
56
import 'package:flood_mobile/Provider/home_provider.dart';
@@ -8,6 +9,10 @@ import 'package:flutter/cupertino.dart';
89
import 'package:flutter_client_sse/flutter_client_sse.dart';
910
import 'package:json_patch/json_patch.dart';
1011
import 'package:provider/provider.dart';
12+
import '../Constants/notification_keys.dart';
13+
import '../Provider/filter_provider.dart';
14+
15+
String torrentLength = '';
1116

1217
class EventHandlerApi {
1318
//Sets the transfer rate if the event returned is TRANSFER_SUMMARY_FULL_UPDATE
@@ -46,6 +51,7 @@ class EventHandlerApi {
4651
//Setting the full list of torrent
4752
Provider.of<HomeProvider>(context, listen: false)
4853
.setTorrentList(torrentList);
54+
filterDataRephrasor(torrentList, context);
4955
}
5056
}
5157

@@ -98,8 +104,155 @@ class EventHandlerApi {
98104
print(e.toString());
99105
}
100106
}
107+
108+
if (torrentList.length > int.parse(torrentLength) ||
109+
torrentList.length < int.parse(torrentLength)) {
110+
filterDataRephrasor(torrentList, context);
111+
}
112+
101113
//Setting the full list of torrent
102114
Provider.of<HomeProvider>(context, listen: false)
103115
.setTorrentList(torrentList);
104116
}
117+
118+
static Future<void> showNotification(int id, BuildContext context) async {
119+
late bool displayNotification;
120+
late bool isPaused;
121+
isPaused = true;
122+
HomeProvider homeModel = Provider.of<HomeProvider>(context, listen: false);
123+
124+
// Skip finished torrents
125+
if (homeModel.torrentList[id].status.contains('complete')) {
126+
displayNotification = false;
127+
} else {
128+
displayNotification = true;
129+
}
130+
131+
// Torrent not being downloaded
132+
if (homeModel.torrentList[id].status.contains('downloading')) {
133+
// Change to the 'RESUME' action
134+
isPaused = false;
135+
}
136+
137+
// Torrent Paused
138+
else {
139+
isPaused = true;
140+
}
141+
142+
// Create notification for unfinished downloads
143+
if (displayNotification) {
144+
AwesomeNotifications().createNotification(
145+
content: NotificationContent(
146+
id: id,
147+
actionType: ActionType.Default,
148+
channelKey: NotificationConstants.DOWNLOADS_CHANNEL_KEY,
149+
category: NotificationCategory.Progress,
150+
notificationLayout: NotificationLayout.ProgressBar,
151+
title: homeModel.torrentList[id].name,
152+
body: isPaused
153+
? "Stopped ETA: ∞"
154+
: "Downloading ETA: " +
155+
prettyDuration(
156+
Duration(
157+
seconds: homeModel.torrentList[id].eta.toInt(),
158+
),
159+
abbreviated: true,
160+
),
161+
progress: homeModel.torrentList[id].percentComplete.round(),
162+
summary: isPaused ? 'Paused' : 'Downloading',
163+
locked: true,
164+
autoDismissible: false,
165+
showWhen: false,
166+
),
167+
actionButtons: [
168+
NotificationActionButton(
169+
key: isPaused
170+
? NotificationConstants.RESUME_ACTION_KEY
171+
: NotificationConstants.PAUSE_ACTION_KEY,
172+
label: isPaused ? 'Resume' : 'Pause',
173+
actionType: ActionType.KeepOnTop,
174+
enabled: true,
175+
autoDismissible: false,
176+
),
177+
],
178+
);
179+
}
180+
}
181+
182+
static Future<void> showEventNotification(
183+
int id, BuildContext context) async {
184+
HomeProvider homeModel = Provider.of<HomeProvider>(context, listen: false);
185+
AwesomeNotifications().createNotification(
186+
content: NotificationContent(
187+
id: id,
188+
autoDismissible: false,
189+
channelKey: NotificationConstants.PUSH_NOTIFICATION_CHANNEL_KEY,
190+
category: NotificationCategory.Event,
191+
notificationLayout: NotificationLayout.Default,
192+
title: homeModel.torrentList[id].name,
193+
body: "Download Finished",
194+
));
195+
}
196+
static Future<void> filterDataRephrasor(
197+
List<TorrentModel> torrentList, context) async {
198+
var maptrackerURIs = {};
199+
var mapStatus = {};
200+
List<String> statusList = [];
201+
torrentLength = torrentList.length.toString();
202+
try {
203+
for (int i = 0; i < torrentList.length; i++) {
204+
for (int j = 0; j < torrentList[i].trackerURIs.length; j++) {
205+
Provider.of<FilterProvider>(context, listen: false)
206+
.trackerURIsListMain
207+
.add(torrentList[i].trackerURIs[j].toString());
208+
Provider.of<FilterProvider>(context, listen: false)
209+
.settrackerURIsListMain(
210+
Provider.of<FilterProvider>(context, listen: false)
211+
.trackerURIsListMain);
212+
}
213+
}
214+
} catch (e) {
215+
print(e);
216+
}
217+
try {
218+
Provider.of<FilterProvider>(context, listen: false)
219+
.trackerURIsListMain
220+
.forEach((element) {
221+
if (!maptrackerURIs.containsKey(element)) {
222+
maptrackerURIs[element] = 1;
223+
} else {
224+
maptrackerURIs[element] += 1;
225+
}
226+
});
227+
Provider.of<FilterProvider>(context, listen: false)
228+
.setmaptrackerURIs(maptrackerURIs);
229+
} catch (e) {
230+
print(e);
231+
}
232+
try {
233+
for (int i = 0; i < torrentList.length; i++) {
234+
for (int j = 0; j < torrentList[i].status.length; j++) {
235+
statusList.add(torrentList[i].status[j].toString());
236+
}
237+
}
238+
Provider.of<FilterProvider>(context, listen: false)
239+
.setstatusList(statusList);
240+
} catch (e) {
241+
print(e);
242+
}
243+
244+
try {
245+
statusList.forEach((element) {
246+
if (!mapStatus.containsKey(element)) {
247+
mapStatus[element] = 1;
248+
} else {
249+
mapStatus[element] += 1;
250+
}
251+
});
252+
Provider.of<FilterProvider>(context, listen: false)
253+
.setmapStatus(mapStatus);
254+
} catch (error) {
255+
print(error);
256+
}
257+
}
105258
}

0 commit comments

Comments
 (0)