Skip to content

Commit

Permalink
Update 1.3_r1.
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Sep 5, 2022
1 parent f290f93 commit 29b5ccb
Show file tree
Hide file tree
Showing 40 changed files with 210 additions and 300 deletions.
7 changes: 5 additions & 2 deletions .idea/misc.xml

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

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Version 1.3_r1:
- Added language preferences (Android 13+);
- Fixed Firebase crashes;
- Fixed splash screen;
- Removed language section from settings;
- Removed unused resources;
- Bug fixes;
- Tweaks;
- Under the hood improvements.

# Version 1.2_r1:
- Added Romanian language;
- Added monochrome icon;
Expand Down
18 changes: 7 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,24 @@ plugins {
}
android {
compileSdk 33
def tagName = '1.2_r1'
def tagName = '1.3_r1'
defaultConfig {
applicationId "com.d4rk.lowbrightness"
minSdk 26
targetSdk 33
versionCode 8
versionCode 10
versionName tagName
multiDexEnabled true
buildConfigField "String", "VERSION_NAME", "\"${tagName}\""
archivesBaseName = "com.d4rk.lowbrightness-v${tagName}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
shrinkResources true
multiDexEnabled true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand All @@ -44,9 +41,9 @@ android {
}
}
dependencies {
implementation 'com.google.firebase:firebase-crashlytics:18.2.12'
implementation 'com.google.firebase:firebase-analytics:21.1.0'
implementation 'com.google.firebase:firebase-perf:20.1.0'
implementation 'com.google.firebase:firebase-crashlytics:18.2.13'
implementation 'com.google.firebase:firebase-analytics:21.1.1'
implementation 'com.google.firebase:firebase-perf:20.1.1'
implementation 'com.google.android.gms:play-services-ads:21.1.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
Expand All @@ -71,7 +68,6 @@ dependencies {
implementation 'androidx.core:core-splashscreen:1.0.0'
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'com.airbnb.android:lottie:5.2.0'
implementation 'com.github.KieronQuinn:MonetCompat:0.4.1'
implementation 'com.thebluealliance:spectrum:0.7.1'
implementation 'com.intuit.sdp:sdp-android:1.1.0'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
Expand Down
12 changes: 3 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:resizeableActivity="true"
android:theme="@style/AppThemeActionBar">
android:theme="@style/AppThemeActionBar"
android:localeConfig="@xml/locales_config"
tools:targetApi="33">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down Expand Up @@ -66,14 +68,6 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="ui.permissions.PermissionsActivity"/>
</activity>
<activity
android:name=".ui.language.LanguageActivity"
android:exported="true"
android:label="@string/language">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.language.LanguageActivity"/>
</activity>
<activity
android:name=".ui.settings.SettingsActivity"
android:exported="false"
Expand Down
30 changes: 24 additions & 6 deletions app/src/main/java/com/d4rk/lowbrightness/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,30 @@
import com.d4rk.lowbrightness.notifications.SchedulerDisabledFragment;
import com.d4rk.lowbrightness.notifications.SchedulerEnabledFragment;
import com.d4rk.lowbrightness.services.OverlayService;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.FirebaseApp;
public class MainActivity extends AppCompatActivity implements IShowHideScheduler{
private AppBarConfiguration mAppBarConfiguration;
private RequestDrawOverAppsPermission permissionRequester;
private SharedPreferences sp;
private SharedPreferences sharedPreferences;
private AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@SuppressWarnings("unused")
SplashScreen splashScreen = SplashScreen.installSplashScreen(this);
SplashScreen.installSplashScreen(this);
MobileAds.initialize(this);
FirebaseApp.initializeApp(this);
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
sp = Prefs.get(getBaseContext());
setSupportActionBar(binding.appBarMain.toolbar);
sharedPreferences = Prefs.get(getBaseContext());
adView = findViewById(R.id.ad_view);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
DrawerLayout drawer = binding.drawerLayout;
NavigationView navigationView = binding.navView;
mAppBarConfiguration = new AppBarConfiguration.Builder(R.id.nav_home, R.id.nav_about, R.id.nav_settings).setOpenableLayout(drawer).build();
Expand All @@ -44,12 +53,15 @@ protected void onCreate(Bundle savedInstanceState) {
protected void onResume() {
super.onResume();
permissionRequester = new RequestDrawOverAppsPermission(this);
if (adView != null) {
adView.resume();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (permissionRequester.requestCodeMatches(requestCode)) {
if (permissionRequester.canDrawOverlays()) {
sp.edit().putBoolean(Constants.PREF_LOW_BRIGHTNESS_ENABLED, true).apply();
sharedPreferences.edit().putBoolean(Constants.PREF_LOW_BRIGHTNESS_ENABLED, true).apply();
getBaseContext().startService(new Intent(getBaseContext(), OverlayService.class));
Snackbar.make(findViewById(android.R.id.content), "Done! It was that easy.", Snackbar.LENGTH_LONG).show();
recreate();
Expand All @@ -61,11 +73,17 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
@Override
protected void onPause() {
super.onPause();
Application.refreshServices(getBaseContext());
if (adView != null) {
adView.pause();
}
super.onPause();
}
@Override
protected void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstan
});
reloadButtonUIs();
binding.bFrom.setOnClickListener(v -> {
final SharedPreferences sp = Prefs.get(requireContext());
final int scheduleFromHour = sp.getInt("scheduleFromHour", 20);
final int scheduleFromMinute = sp.getInt("scheduleFromMinute", 0);
final SharedPreferences sharedPreferences = Prefs.get(requireContext());
final int scheduleFromHour = sharedPreferences.getInt("scheduleFromHour", 20);
final int scheduleFromMinute = sharedPreferences.getInt("scheduleFromMinute", 0);
TimePickerDialog dpd = TimePickerDialog.newInstance(
(view12, hourOfDay, minute, seconds) -> {
Context ctx = view12.getContext();
final SharedPreferences sp12 = Prefs.get(ctx);
final SharedPreferences sp12 = Prefs.get(requireContext());
sp12.edit().putInt("scheduleFromHour", hourOfDay).putInt("scheduleFromMinute", minute).apply();
reloadButtonUIs();
},
Expand All @@ -61,13 +60,12 @@ public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstan
dpd.show(getFragmentManager(), "timepicker_dialog");
});
binding.bTo.setOnClickListener(v -> {
final SharedPreferences sp = Prefs.get(requireContext());
final int scheduleToHour = sp.getInt("scheduleToHour", 6);
final int scheduleToMinute = sp.getInt("scheduleToMinute", 0);
final SharedPreferences sharedPreferences = Prefs.get(requireContext());
final int scheduleToHour = sharedPreferences.getInt("scheduleToHour", 6);
final int scheduleToMinute = sharedPreferences.getInt("scheduleToMinute", 0);
TimePickerDialog dpd = TimePickerDialog.newInstance(
(view1, hourOfDay, minute, seconds) -> {
Context ctx = view1.getContext();
final SharedPreferences sp1 = Prefs.get(ctx);
final SharedPreferences sp1 = Prefs.get(requireContext());
sp1.edit().putInt("scheduleToHour", hourOfDay).putInt("scheduleToMinute", minute).apply();
reloadButtonUIs();
},
Expand All @@ -88,11 +86,11 @@ public void onPause() {
}
private void reloadButtonUIs() {
if (getView() == null) return;
final SharedPreferences sp = Prefs.get(requireContext());
final int scheduleFromHour = sp.getInt("scheduleFromHour", 20);
final int scheduleFromMinute = sp.getInt("scheduleFromMinute", 0);
final int scheduleToHour = sp.getInt("scheduleToHour", 6);
final int scheduleToMinute = sp.getInt("scheduleToMinute", 0);
final SharedPreferences sharedPreferences = Prefs.get(requireContext());
final int scheduleFromHour = sharedPreferences.getInt("scheduleFromHour", 20);
final int scheduleFromMinute = sharedPreferences.getInt("scheduleFromMinute", 0);
final int scheduleToHour = sharedPreferences.getInt("scheduleToHour", 6);
final int scheduleToMinute = sharedPreferences.getInt("scheduleToMinute", 0);
Calendar cNow = Calendar.getInstance();
Calendar cStart = SchedulerService._getCalendarForStart(getContext());
final Calendar cEnd = SchedulerService._getCalendarForEnd(getContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public IBinder onBind(Intent intent) {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
final SharedPreferences sp = Prefs.get(getBaseContext());
final SharedPreferences sharedPreferences = Prefs.get(getBaseContext());
if (!OverlayService.isEnabled(getBaseContext())) {
stopSelf();
return START_NOT_STICKY;
Expand All @@ -38,8 +38,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
stopSelf();
return START_NOT_STICKY;
}
int opacityPercent = sp.getInt(Constants.PREF_DIM_LEVEL, 20);
int color = sp.getInt(Constants.PREF_OVERLAY_COLOR, Color.BLACK);
int opacityPercent = sharedPreferences.getInt(Constants.PREF_DIM_LEVEL, 20);
int color = sharedPreferences.getInt(Constants.PREF_OVERLAY_COLOR, Color.BLACK);
if (mView == null) {
mView = new OverlayView(this);
mView.setOpacityPercent(opacityPercent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
}
}
private void startOrStopScreenDim() {
final SharedPreferences sp = Prefs.get(getBaseContext());
if (sp.getBoolean(Constants.PREF_LOW_BRIGHTNESS_ENABLED, false)) {
final SharedPreferences sharedPreferences = Prefs.get(getBaseContext());
if (sharedPreferences.getBoolean(Constants.PREF_LOW_BRIGHTNESS_ENABLED, false)) {
final Calendar cBegin = _getCalendarForStart(getBaseContext());
final Calendar cEnd = _getCalendarForEnd(getBaseContext());
Calendar calendar = Calendar.getInstance();
Expand All @@ -58,19 +58,19 @@ public void onDestroy() {
super.onDestroy();
}
public static Calendar _getCalendarForStart(Context context) {
final SharedPreferences sp = Prefs.get(context);
final int scheduleFromHour = sp.getInt("scheduleFromHour", 20);
final int scheduleFromMinute = sp.getInt("scheduleFromMinute", 0);
final SharedPreferences sharedPreferences = Prefs.get(context);
final int scheduleFromHour = sharedPreferences.getInt("scheduleFromHour", 20);
final int scheduleFromMinute = sharedPreferences.getInt("scheduleFromMinute", 0);
final Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, scheduleFromHour);
c.set(Calendar.MINUTE, scheduleFromMinute);
c.clear(Calendar.SECOND);
return c;
}
public static Calendar _getCalendarForEnd(Context context) {
final SharedPreferences sp = Prefs.get(context);
final int hour = sp.getInt("scheduleToHour", 6);
final int minute = sp.getInt("scheduleToMinute", 0);
final SharedPreferences sharedPreferences = Prefs.get(context);
final int hour = sharedPreferences.getInt("scheduleToHour", 6);
final int minute = sharedPreferences.getInt("scheduleToMinute", 0);
final Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minute);
Expand Down
Loading

0 comments on commit 29b5ccb

Please sign in to comment.