Skip to content

Commit 3f4658b

Browse files
authored
Merge pull request #175 from itsdrnoob/dev/2.3.2
Dev/2.3.2
2 parents 587bcfe + a4315c0 commit 3f4658b

File tree

64 files changed

+1849
-348
lines changed

Some content is hidden

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

64 files changed

+1849
-348
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33
All notable changes to Data Monitor will be documented in this file.
44

55

6+
## v2.3.2
7+
8+
Data Monitor v2.3.2 release <br>
9+
This release includes certain changes and improvements.
10+
11+
### What's new?
12+
- Introducing Wall of Thanks, a dedicated space to acknowledge and express gratitude to our amazing supporters.
13+
- Updated translations and added support for Japanese language.
14+
15+
### Fixes and Improvements
16+
- Fixed the crash caused when app language was set to Traditional Chinese.
17+
- Improved exception handling.
18+
- Fixed the issue causing notifications to stop updating after a while.
19+
- Fixed Live network speed count on some VPN connections.
20+
- Resolved duplication of Live network speed notification.
21+
22+
623
## v2.3.1
724

825
Data Monitor v2.3.1 release <br>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[![Version](https://shields.io/badge/version-v2.3.1-087AFF.svg)](https://github.com/itsdrnoob/DataMonitor/tree/dev/2.3.1)
1+
[![Version](https://shields.io/badge/version-v2.3.2-087AFF.svg)](https://github.com/itsdrnoob/DataMonitor/tree/dev/2.3.2)
22
[![Platform](https://shields.io/badge/platform-android-green.svg)](https://github.com/itsdrnoob/DataMonitor)
33
[![License](https://img.shields.io/badge/license-GPL3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
4-
[![Release](https://shields.io/badge/release-v2.3.1-blue.svg)](https://github.com/itsdrnoob/DataMonitor/releases)
4+
[![Release](https://shields.io/badge/release-v2.3.2-blue.svg)](https://github.com/itsdrnoob/DataMonitor/releases)
55
[![Chat](https://img.shields.io/badge/Telegram%20Chat-blue?logo=telegram)](https://t.me/datamonitor)
66
[![Downloads](https://img.shields.io/github/downloads/itsdrnoob/DataMonitor/total)](https://github.com/itsdrnoob/DataMonitor/releases)
77

VERSION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.3.1
1+
v2.3.2

app/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'com.android.application'
3+
id 'kotlin-android'
34
}
45

56
android {
@@ -10,9 +11,9 @@ android {
1011
applicationId "com.drnoob.datamonitor"
1112
minSdkVersion 23
1213
targetSdkVersion 33
13-
versionCode 23
14-
versionName 'v2.3.1'
15-
resConfigs "en", "ar", "cs", "de", "es", "fr", "hi", "in", "it", "ko",
14+
versionCode 24
15+
versionName 'v2.3.2'
16+
resConfigs "en", "ar", "cs", "de", "es", "fr", "hi", "in", "it", "ja", "ko",
1617
"ml", "mr", "nb-rNO", "nl", "pl", "pt-rBR", "ro", "ru", "tr", "uk", "uz", "vi", "zh-rCN", "zh-rTW"
1718

1819
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -57,6 +58,8 @@ dependencies {
5758
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
5859
implementation 'androidx.core:core-splashscreen:1.0.0'
5960
implementation 'com.android.volley:volley:1.2.1'
61+
implementation 'androidx.core:core-ktx:1.10.0'
62+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
6063
testImplementation 'junit:junit:4.+'
6164
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
6265
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
@@ -70,4 +73,5 @@ dependencies {
7073
implementation 'fr.bmartel:jspeedtest:1.32.1'
7174
implementation 'io.ipinfo:ipinfo-api:2.1'
7275
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
76+
implementation 'com.github.bumptech.glide:glide:4.15.1'
7377
}

app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
android:fitsSystemWindows="true"
6666
android:screenOrientation="portrait"
6767
tools:ignore="LockedOrientationActivity" />
68+
<activity
69+
android:name=".ui.activities.WallOfThanksActivity"
70+
android:exported="false"
71+
android:fitsSystemWindows="true"
72+
android:screenOrientation="portrait"
73+
tools:ignore="LockedOrientationActivity"/>
6874

6975
<receiver
7076
android:name=".Widget.DataUsageWidget"
@@ -99,20 +105,6 @@
99105
<action android:name="android.intent.action.BOOT_COMPLETED" />
100106
</intent-filter>
101107
</receiver>
102-
103-
<!-- <service-->
104-
<!-- android:name=".utils.AppDataUsageMonitor"-->
105-
<!-- android:enabled="true"-->
106-
<!-- android:exported="true" />-->
107-
108-
<!-- <receiver-->
109-
<!-- android:name=".utils.AppDataUsageMonitor$AppDataMonitor"-->
110-
<!-- android:exported="true">-->
111-
<!-- <intent-filter>-->
112-
<!-- <action android:name="android.intent.action.SCREEN_ON" />-->
113-
<!-- <action android:name="android.intent.action.BOOT_COMPLETED" />-->
114-
<!-- </intent-filter>-->
115-
<!-- </receiver>-->
116108
<receiver
117109
android:name=".utils.NotificationService$NotificationRemover"
118110
android:exported="true">

app/src/main/java/com/drnoob/datamonitor/Common.java

Lines changed: 88 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import android.Manifest;
3636
import android.annotation.SuppressLint;
3737
import android.app.Activity;
38+
import android.app.ActivityManager;
3839
import android.app.AlarmManager;
3940
import android.app.AppOpsManager;
4041
import android.app.PendingIntent;
@@ -55,9 +56,11 @@
5556
import android.util.Log;
5657
import android.view.View;
5758
import android.view.WindowManager;
59+
import android.widget.Toast;
5860

5961
import androidx.annotation.RequiresApi;
6062
import androidx.appcompat.app.AlertDialog;
63+
import androidx.core.app.ActivityCompat;
6164
import androidx.core.app.NotificationCompat;
6265
import androidx.core.app.NotificationManagerCompat;
6366
import androidx.core.content.ContextCompat;
@@ -120,7 +123,7 @@ public static Boolean isAppInstalled(Context context, String packageName) {
120123
}
121124

122125
public static void setLanguage(Activity activity, String languageCode, String countryCode) {
123-
List<LanguageModel> availableLanguages = refreshAvailableLanguages();
126+
List<LanguageModel> availableLanguages = refreshAvailableLanguages();
124127

125128
if (languageCode.equalsIgnoreCase(LANGUAGE_SYSTEM_DEFAULT)) {
126129
// setting default system language if available
@@ -142,8 +145,7 @@ public static void setLanguage(Activity activity, String languageCode, String co
142145
// System country code available
143146
countryCode = systemCountryCode;
144147
break;
145-
}
146-
else {
148+
} else {
147149
// System country code not available
148150
countryCode = "";
149151
}
@@ -158,11 +160,9 @@ public static void setLanguage(Activity activity, String languageCode, String co
158160
Locale locale;
159161
if (countryCode.equals("rTW")) {
160162
locale = Locale.TAIWAN;
161-
}
162-
else if (countryCode.equals("rCN")) {
163+
} else if (countryCode.equals("rCN")) {
163164
locale = Locale.CHINESE;
164-
}
165-
else {
165+
} else {
166166
locale = new Locale(languageCode, countryCode);
167167
}
168168
conf.locale = locale;
@@ -198,6 +198,7 @@ public static List<LanguageModel> refreshAvailableLanguages() {
198198
list.add(new LanguageModel("Polish", "pl", ""));
199199
list.add(new LanguageModel("Czech", "cs", ""));
200200
list.add(new LanguageModel("Vietnamese", "vi", ""));
201+
list.add(new LanguageModel("Japanese", "ja", ""));
201202

202203
Collections.sort(list, new Comparator<LanguageModel>() {
203204
@Override
@@ -213,18 +214,26 @@ public int compare(LanguageModel languageModel, LanguageModel t1) {
213214

214215
public static void refreshService(Context context) {
215216
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("combine_notifications", false)) {
216-
context.startService(new Intent(context, CompoundNotification.class));
217+
if (!isCombinedNotificationServiceRunning(context)) {
218+
context.startService(new Intent(context, CompoundNotification.class));
219+
}
217220
}
218221
else {
219222
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("network_signal_notification", false)) {
220-
context.startService(new Intent(context, LiveNetworkMonitor.class));
223+
if (!isLiveNetworkServiceRunning(context)) {
224+
context.startService(new Intent(context, LiveNetworkMonitor.class));
225+
}
221226
}
222227
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("setup_notification", false)) {
223-
context.startService(new Intent(context, NotificationService.class));
228+
if (!isNotificationServiceRunning(context)) {
229+
context.startService(new Intent(context, NotificationService.class));
230+
}
224231
}
225232
}
226233
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("data_usage_alert", false)) {
227-
context.startService(new Intent(context, DataUsageMonitor.class));
234+
if (!isDataUsageAlertServiceRunning(context)) {
235+
context.startService(new Intent(context, DataUsageMonitor.class));
236+
}
228237
}
229238

230239
}
@@ -234,8 +243,7 @@ public static void setRefreshAlarm(Context context) {
234243
long wakeupMillis = 0l;
235244
try {
236245
wakeupMillis = getTimePeriod(context, SESSION_CUSTOM, -1)[1];
237-
}
238-
catch (ParseException e) {
246+
} catch (ParseException e) {
239247
e.printStackTrace();
240248
}
241249

@@ -246,18 +254,15 @@ public static void setRefreshAlarm(Context context) {
246254
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
247255
if (alarmManager.canScheduleExactAlarms()) {
248256
alarmManager.setExact(AlarmManager.RTC_WAKEUP, wakeupMillis, pendingIntent);
249-
}
250-
else {
251-
Log.e(TAG, "setRefreshAlarm: permission SCHEDULE_EXACT_ALARM not granted" );
257+
} else {
258+
Log.e(TAG, "setRefreshAlarm: permission SCHEDULE_EXACT_ALARM not granted");
252259
postAlarmPermissionDeniedNotification(context);
253260
}
254-
}
255-
else {
261+
} else {
256262
alarmManager.setExact(AlarmManager.RTC_WAKEUP, wakeupMillis, pendingIntent);
257263
}
258-
Log.d(TAG, "setRefreshAlarm: set" );
259-
}
260-
else {
264+
Log.d(TAG, "setRefreshAlarm: set");
265+
} else {
261266
Log.e(TAG, "setRefreshAlarm: something is wrong here " + wakeupMillis);
262267
}
263268
}
@@ -279,18 +284,15 @@ public static void setDataPlanNotification(Context context) {
279284
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
280285
if (alarmManager.canScheduleExactAlarms()) {
281286
alarmManager.setExact(AlarmManager.RTC_WAKEUP, wakeupMillis, pendingIntent);
282-
}
283-
else {
284-
Log.e(TAG, "setRefreshAlarm: permission SCHEDULE_EXACT_ALARM not granted" );
287+
} else {
288+
Log.e(TAG, "setRefreshAlarm: permission SCHEDULE_EXACT_ALARM not granted");
285289
postAlarmPermissionDeniedNotification(context);
286290
}
287-
}
288-
else {
291+
} else {
289292
alarmManager.setExact(AlarmManager.RTC_WAKEUP, wakeupMillis, pendingIntent);
290293
}
291-
Log.d(TAG, "setDataPlanNotification: set" );
292-
}
293-
else {
294+
Log.d(TAG, "setDataPlanNotification: set");
295+
} else {
294296
Log.e(TAG, "setDataPlanNotification: something is wrong here " + wakeupMillis);
295297
}
296298
}
@@ -390,7 +392,7 @@ public static void postAlarmPermissionDeniedNotification(Context context) {
390392
.setOnlyAlertOnce(true)
391393
.setPriority(NotificationCompat.PRIORITY_MAX);
392394
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(context);
393-
managerCompat.notify(OTHER_NOTIFICATION_ID, builder.build());
395+
postNotification(context, managerCompat, builder, OTHER_NOTIFICATION_ID);
394396
}
395397

396398
@SuppressLint("SimpleDateFormat")
@@ -449,4 +451,60 @@ else if (date.endsWith("3")) {
449451
}
450452
return suffix;
451453
}
454+
455+
private static boolean isLiveNetworkServiceRunning(Context context) {
456+
// Check if the service is already running
457+
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
458+
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
459+
if (LiveNetworkMonitor.class.getName().equals(service.service.getClassName()) ||
460+
LiveNetworkMonitor.isServiceRunning) {
461+
return true;
462+
}
463+
}
464+
return false;
465+
}
466+
467+
private static boolean isCombinedNotificationServiceRunning(Context context) {
468+
// Check if the service is already running
469+
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
470+
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
471+
if (CompoundNotification.class.getName().equals(service.service.getClassName()) ||
472+
CompoundNotification.isServiceRunning) {
473+
return true;
474+
}
475+
}
476+
return false;
477+
}
478+
479+
private static boolean isNotificationServiceRunning(Context context) {
480+
// Check if the service is already running
481+
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
482+
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
483+
if (NotificationService.class.getName().equals(service.service.getClassName())) {
484+
return true;
485+
}
486+
}
487+
return false;
488+
}
489+
490+
private static boolean isDataUsageAlertServiceRunning(Context context) {
491+
// Check if the service is already running
492+
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
493+
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
494+
if (DataUsageMonitor.class.getName().equals(service.service.getClassName())) {
495+
return true;
496+
}
497+
}
498+
return false;
499+
}
500+
501+
public static void postNotification(Context context, NotificationManagerCompat notificationManager,
502+
NotificationCompat.Builder builder, int notificationId) {
503+
if (notificationManager != null && builder != null) {
504+
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) ==
505+
PackageManager.PERMISSION_GRANTED) {
506+
notificationManager.notify(notificationId, builder.build());
507+
}
508+
}
509+
}
452510
}

0 commit comments

Comments
 (0)