Skip to content

Commit

Permalink
Update 4.0_r1
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Jun 23, 2023
1 parent ee86cf2 commit aa5e1ea
Show file tree
Hide file tree
Showing 59 changed files with 2,295 additions and 2,125 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Version 4.0_r1:
- Added a new GDPR message to comply with Google Play policy.
- Added a new help center, with more comprehensive documentation and support options.
- Added snack bars instead of toasts for all notifications.
- Added tooltips to help users understand what is happening in the app.
- Fixed various bugs and improved readability, consistency, app performance, and responsiveness by optimizing and styling the outdated code.
- Made minor improvements to user interface.
- Made various improvements to colors and languages.
- Made various project structure enhancements for better readability and maintainability.
- Made various under-the-hood improvements for a better overall app experience.

# Version 3.0_r1:
- Added language support for Hungarian.
- Reworked language system, making it more accurate and user-friendly.
Expand Down
21 changes: 10 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId 'com.d4rk.lowbrightness'
minSdk 26
targetSdk 33
versionCode 32
versionName '3.0_r1'
versionCode 34
versionName '4.0_r1'
archivesBaseName = "${applicationId}-v${versionName}"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
resourceConfigurations += ['en', 'de', 'es', 'fr', 'hi', 'hu', 'in', 'it', 'ja', 'ro', 'ru', 'tr', 'sv', 'bg', 'pl', 'uk']
Expand Down Expand Up @@ -53,32 +53,31 @@ android {
}
dependencies {
implementation 'com.google.firebase:firebase-crashlytics:18.3.7'
implementation 'com.google.firebase:firebase-analytics:21.2.2'
implementation 'com.google.firebase:firebase-perf:20.3.2'
implementation 'com.google.firebase:firebase-analytics:21.3.0'
implementation 'com.google.firebase:firebase-perf:20.3.3'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.1'
implementation 'com.google.android.gms:play-services-ads:22.0.0'
implementation 'com.google.android.gms:play-services-ads:22.1.0'
implementation 'com.google.android.play:review-ktx:2.0.1'
implementation 'com.google.android.play:app-update-ktx:2.0.1'
implementation 'com.google.android.play:app-update-ktx:2.1.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core:1.10.0'
implementation 'androidx.core:core:1.10.1'
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
implementation 'androidx.navigation:navigation-fragment:2.6.0'
implementation 'androidx.navigation:navigation-ui:2.6.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.6.1'
implementation 'androidx.lifecycle:lifecycle-livedata:2.6.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-process:2.6.1'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'com.airbnb.android:lottie:6.0.0'
implementation 'com.airbnb.android:lottie:6.0.1'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
implementation 'com.thebluealliance:spectrum:0.7.1'
implementation 'me.zhanghai.android.fastscroll:library:1.2.0'
implementation 'me.zhanghai.android.materialratingbar:library:1.4.0'
implementation 'org.adw.library:discrete-seekbar:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
13 changes: 4 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</intent>
</queries>
<application
android:name=".ads.Ads"
android:name=".ads.managers.AppOpenAd"
android:appCategory="productivity"
android:description="@string/app_description"
android:icon="@mipmap/ic_launcher"
Expand Down Expand Up @@ -78,15 +78,10 @@
android:label="@string/permissions"
android:parentActivityName=".ui.settings.permissions.PermissionsActivity"/>
<activity
android:name=".ui.settings.faq.FaqActivity"
android:name=".ui.help.HelpActivity"
android:exported="false"
android:label="@string/faq"
android:parentActivityName=".ui.settings.faq.FaqActivity"/>
<activity
android:name=".ui.settings.feedback.FeedbackActivity"
android:exported="true"
android:label="@string/feedback"
android:parentActivityName=".ui.settings.feedback.FeedbackActivity"/>
android:label="@string/help"
android:parentActivityName=".ui.help.HelpActivity"/>
<service
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
android:enabled="false"
Expand Down
70 changes: 23 additions & 47 deletions app/src/main/java/com/d4rk/lowbrightness/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.d4rk.lowbrightness;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;

import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.NotificationCompat;
import androidx.core.os.LocaleListCompat;
import androidx.core.splashscreen.SplashScreen;
import androidx.drawerlayout.widget.DrawerLayout;
Expand All @@ -20,21 +16,22 @@
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import androidx.preference.PreferenceManager;

import com.d4rk.lowbrightness.base.Application;
import com.d4rk.lowbrightness.base.Constants;
import com.d4rk.lowbrightness.base.Prefs;
import com.d4rk.lowbrightness.databinding.ActivityMainBinding;
import com.d4rk.lowbrightness.helpers.AppUpdateNotificationsManager;
import com.d4rk.lowbrightness.helpers.AppUsageNotificationsManager;
import com.d4rk.lowbrightness.helpers.IShowHideScheduler;
import com.d4rk.lowbrightness.helpers.RequestDrawOverAppsPermission;
import com.d4rk.lowbrightness.notifications.SchedulerDisabledFragment;
import com.d4rk.lowbrightness.notifications.SchedulerEnabledFragment;
import com.d4rk.lowbrightness.services.OverlayService;
import com.d4rk.lowbrightness.ui.startup.StartupActivity;
import com.google.android.gms.tasks.Task;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.play.core.appupdate.AppUpdateInfo;
import com.google.android.play.core.appupdate.AppUpdateManager;
import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
import com.google.android.play.core.install.model.AppUpdateType;
Expand All @@ -54,6 +51,7 @@ protected void onCreate(Bundle savedInstanceState) {
SplashScreen.installSplashScreen(this);
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
appSettings();
setSupportActionBar(binding.appBarMain.toolbar);
appUpdateManager = AppUpdateManagerFactory.create(this);
sharedPreferences = Prefs.get(this);
Expand All @@ -63,40 +61,13 @@ protected void onCreate(Bundle savedInstanceState) {
navController = Navigation.findNavController(this, R.id.navigation_content_main);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
AppUpdateNotificationsManager appUpdateNotificationsManager = new AppUpdateNotificationsManager(this);
appUpdateNotificationsManager.checkAndSendUpdateNotification();
}
public void appSettings() {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String languageCode = sharedPreferences.getString(getString(R.string.key_language), getString(R.string.default_value_language));
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(languageCode));
SharedPreferences prefs = getSharedPreferences("app_usage", MODE_PRIVATE);
long lastUsedTimestamp = prefs.getLong("last_used", 0);
long currentTimestamp = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (currentTimestamp - lastUsedTimestamp > 3 * 24 * 60 * 60 * 1000) {
String channelId = "app_usage_channel";
NotificationChannel channel = new NotificationChannel(channelId, getString(R.string.app_usage_notifications), NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(getString(R.string.notification_last_time_used_title))
.setContentText(getString(R.string.summary_notification_last_time_used))
.setAutoCancel(true);
notificationManager.notify(0, builder.build());
}
prefs.edit().putLong("last_used", currentTimestamp).apply();
AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(this);
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
String updateChannelId = "update_channel";
NotificationChannel updateChannel = new NotificationChannel(updateChannelId, getString(R.string.update_notifications), NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(updateChannel);
NotificationCompat.Builder updateBuilder = new NotificationCompat.Builder(this, updateChannelId)
.setSmallIcon(R.drawable.ic_notification_update)
.setContentTitle(getString(R.string.notification_update_title))
.setContentText(getString(R.string.summary_notification_update))
.setAutoCancel(true)
.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())), PendingIntent.FLAG_IMMUTABLE));
notificationManager.notify(0, updateBuilder.build());
}
});
}
@Override
public void onBackPressed() {
Expand All @@ -110,16 +81,12 @@ public void onBackPressed() {
builder.setNegativeButton(android.R.string.no, null);
builder.show();
}
@SuppressWarnings("deprecation")
@Override
public void onResume() {
super.onResume();
SharedPreferences preferences = getSharedPreferences("prefs", MODE_PRIVATE);
if (preferences.getBoolean("value", true)) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("value", false);
editor.apply();
startActivity(new Intent(this, StartupActivity.class));
}
AppUsageNotificationsManager appUsageNotificationsManager = new AppUsageNotificationsManager(this);
appUsageNotificationsManager.checkAndSendAppUsageNotification();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean preferenceFirebase = sharedPreferences.getBoolean(getString(R.string.key_firebase), true);
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(preferenceFirebase);
Expand All @@ -134,7 +101,16 @@ public void onResume() {
}
}
});
startupScreen();
}
private void startupScreen() {
SharedPreferences startupPreference = getSharedPreferences("startup", MODE_PRIVATE);
if (startupPreference.getBoolean("value", true)) {
startupPreference.edit().putBoolean("value", false).apply();
startActivity(new Intent(this, StartupActivity.class));
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (permissionRequester.requestCodeMatches(requestCode)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.d4rk.lowbrightness.ads;
package com.d4rk.lowbrightness.ads.managers;
import android.app.Activity;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
Expand All @@ -15,11 +15,10 @@
import com.google.android.gms.ads.FullScreenContentCallback;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.appopen.AppOpenAd;
import com.google.android.gms.ads.appopen.AppOpenAd.AppOpenAdLoadCallback;
import java.util.Date;
@SuppressWarnings("ALL")
public class Ads extends Application implements ActivityLifecycleCallbacks, LifecycleObserver {
public class AppOpenAd extends Application implements ActivityLifecycleCallbacks, LifecycleObserver {
private AppOpenAdManager appOpenAdManager;
private Activity currentActivity;
@Override
Expand Down Expand Up @@ -60,7 +59,7 @@ public interface OnShowAdCompleteListener {
}
private static class AppOpenAdManager {
private static final String AD_UNIT_ID = "ca-app-pub-5294151573817700/5249073936";
private AppOpenAd appOpenAd = null;
private com.google.android.gms.ads.appopen.AppOpenAd appOpenAd = null;
private boolean isLoadingAd = false;
private boolean isShowingAd = false;
private long loadTime = 0;
Expand All @@ -71,9 +70,9 @@ private void loadAd(Context context) {
}
isLoadingAd = true;
AdRequest request = new AdRequest.Builder().build();
AppOpenAd.load(context, AD_UNIT_ID, request, AppOpenAd.APP_OPEN_AD_ORIENTATION_PORTRAIT, new AppOpenAdLoadCallback() {
com.google.android.gms.ads.appopen.AppOpenAd.load(context, AD_UNIT_ID, request, com.google.android.gms.ads.appopen.AppOpenAd.APP_OPEN_AD_ORIENTATION_PORTRAIT, new AppOpenAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull AppOpenAd ad) {
public void onAdLoaded(@NonNull com.google.android.gms.ads.appopen.AppOpenAd ad) {
appOpenAd = ad;
isLoadingAd = false;
loadTime = (new Date()).getTime();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.d4rk.lowbrightness.helpers
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.core.app.NotificationCompat
import com.d4rk.lowbrightness.R
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.UpdateAvailability
class AppUpdateNotificationsManager(private val context: Context) {
private val updateChannelId = "update_channel"
private val updateNotificationId = 0
fun checkAndSendUpdateNotification() {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val appUpdateInfoTask = AppUpdateManagerFactory.create(context).appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
val updateChannel = NotificationChannel(updateChannelId, context.getString(R.string.update_notifications), NotificationManager.IMPORTANCE_HIGH)
notificationManager.createNotificationChannel(updateChannel)
val updateBuilder = NotificationCompat.Builder(context, updateChannelId)
.setSmallIcon(R.drawable.ic_notification_update)
.setContentTitle(context.getString(R.string.notification_update_title))
.setContentText(context.getString(R.string.summary_notification_update))
.setAutoCancel(true)
.setContentIntent(PendingIntent.getActivity(context, 0, Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=${context.packageName}")), PendingIntent.FLAG_IMMUTABLE))
notificationManager.notify(updateNotificationId, updateBuilder.build())
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.d4rk.lowbrightness.helpers
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import androidx.core.app.NotificationCompat
import com.d4rk.lowbrightness.R
class AppUsageNotificationsManager(private val context: Context) {
private val appUsageChannelId = "app_usage_channel"
private val appUsageNotificationId = 0
fun checkAndSendAppUsageNotification() {
val prefs = context.getSharedPreferences("app_usage", Context.MODE_PRIVATE)
val lastUsedTimestamp = prefs.getLong("last_used", 0)
val currentTimestamp = System.currentTimeMillis()
val notificationThreshold = 3 * 24 * 60 * 60 * 1000
if (currentTimestamp - lastUsedTimestamp > notificationThreshold) {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val appUsageChannel = NotificationChannel(appUsageChannelId, context.getString(R.string.app_usage_notifications),NotificationManager.IMPORTANCE_HIGH)
notificationManager.createNotificationChannel(appUsageChannel)
val notificationBuilder = NotificationCompat.Builder(context, appUsageChannelId)
.setSmallIcon(R.drawable.ic_notification_important)
.setContentTitle(context.getString(R.string.notification_last_time_used_title))
.setContentText(context.getString(R.string.summary_notification_last_time_used))
.setAutoCancel(true)
notificationManager.notify(appUsageNotificationId, notificationBuilder.build())
}
prefs.edit().putLong("last_used", currentTimestamp).apply()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void createNotificationChannel() {
}
private void showNotification() {
createNotificationChannel();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID).setSmallIcon(R.drawable.ic_eye).setContentTitle(getResources().getString(R.string.notification_title)).setContentText(getResources().getString(R.string.notification_context));
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID).setSmallIcon(R.drawable.ic_eye).setContentTitle(getResources().getString(R.string.notification_color_light_filter_active_title)).setContentText(getResources().getString(R.string.notification_context));
mBuilder.setOngoing(true);
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
Expand Down
Loading

0 comments on commit aa5e1ea

Please sign in to comment.