Skip to content

Commit 0ca3dba

Browse files
committed
feat: upgraded dependencies, updated Gradle, improved language switching, refactoring, improved accessibility
1 parent 6ff9b92 commit 0ca3dba

38 files changed

+343
-209
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# DeadPix
2+
23
DeadPix for Android!
34

45
This app can be used to locate and fix dead or stuck pixels on your screen. No advertisements, no tracking code, no special permissions required!
56

67
# Requirements
8+
79
* Android 28+
810
* Android Studio
911

1012
## Translations
13+
1114
- Portuguese (Brazil) - [SnwMds](https://github.com/SnwMds)
1215

1316
## About
1417

1518
This library is maintained by CodeDead. You can find more about us using the following links:
16-
* [Website](https://codedead.com/)
17-
* [Twitter](https://twitter.com/C0DEDEAD/)
18-
* [Facebook](https://facebook.com/deadlinecodedead/)
19+
* [Website](https://codedead.com)
20+
* [Bluesky](https://bsky.app/profile/codedead.com)
21+
* [Facebook](https://facebook.com/deadlinecodedead)
1922

20-
Copyright © 2023 CodeDead
23+
Copyright © 2025 CodeDead

app/build.gradle

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apply plugin: 'com.android.application'
22

33
android {
44
namespace "com.codedead.deadpix"
5-
compileSdk 34
5+
compileSdk 35
66
defaultConfig {
77
applicationId "com.codedead.deadpix"
8-
minSdk 28
9-
targetSdkVersion 34
8+
minSdk 29
9+
targetSdk 35
1010
versionCode 10
1111
versionName '1.10.0'
1212
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
@@ -24,17 +24,22 @@ android {
2424
sourceCompatibility JavaVersion.VERSION_17
2525
targetCompatibility JavaVersion.VERSION_17
2626
}
27-
buildToolsVersion '34.0.0'
27+
dependenciesInfo {
28+
includeInApk = false
29+
includeInBundle = false
30+
}
31+
buildToolsVersion '35.0.1'
2832
}
2933

3034
dependencies {
3135
implementation fileTree(include: ['*.jar'], dir: 'libs')
32-
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1', {
36+
androidTestImplementation('androidx.test.espresso:espresso-core:3.6.1', {
3337
exclude group: 'com.android.support', module: 'support-annotations'
3438
})
35-
implementation 'androidx.appcompat:appcompat:1.6.1'
36-
implementation 'com.google.android.material:material:1.10.0'
37-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
39+
implementation 'androidx.appcompat:appcompat:1.7.0'
40+
implementation 'com.google.android.material:material:1.12.0'
41+
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
3842
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
43+
implementation 'androidx.preference:preference:1.2.1'
3944
testImplementation 'junit:junit:4.13.2'
4045
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<application
77
android:name=".main.Runner"
88
android:allowBackup="true"
9+
android:dataExtractionRules="@xml/data_extraction_rules"
910
android:fullBackupContent="@xml/backup_descriptor"
1011
android:icon="@mipmap/ic_launcher"
1112
android:label="@string/app_name"

app/src/main/java/com/codedead/deadpix/domain/LocaleHelper.java

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,70 @@
11
package com.codedead.deadpix.domain;
22

3+
import android.annotation.SuppressLint;
34
import android.content.Context;
45
import android.content.SharedPreferences;
56
import android.content.res.Configuration;
6-
import android.preference.PreferenceManager;
7+
8+
import androidx.preference.PreferenceManager;
79

810
import java.util.Locale;
911

1012
public class LocaleHelper {
1113

1214
/**
13-
* Method that is called when a Context object is going to be attached
15+
* Method that is called when a Context object is attached
1416
*
15-
* @param context The Context object that is going to be attached
16-
* @return The Context object that should be attached
17+
* @param context The Context object that is attached
18+
* @return The Context object containing correct resource properties
1719
*/
18-
public static Context onAttach(Context context) {
20+
public static Context onAttach(final Context context) {
1921
final String lang = getPersistedData(context, Locale.getDefault().getLanguage());
2022
return setLocale(context, lang);
2123
}
2224

2325
/**
24-
* Method that is called when a Context object is going to be attached
26+
* Method that is called when a Context object is attached
2527
*
26-
* @param context The Context object that is going to be attached
27-
* @param defaultLanguage The default language
28-
* @return The Context object that should be attached
28+
* @param context The Context object that is attached
29+
* @param defaultLanguage The default language code
30+
* @return The Context object containing correct resource properties
2931
*/
30-
public static Context onAttach(Context context, String defaultLanguage) {
32+
public static Context onAttach(final Context context, final String defaultLanguage) {
3133
final String lang = getPersistedData(context, defaultLanguage);
3234
return setLocale(context, lang);
3335
}
3436

3537
/**
36-
* Set the locale
38+
* Set the Locale depending on the language
3739
*
38-
* @param context The Context object that should be updated with the latest language
39-
* @param language The language that should be applied to the Context object
40-
* @return The updated Context object
40+
* @param context The Context object that can be used to change resource properties
41+
* @param language The language that should be attached
42+
* @return The Context object containing correct resource properties
4143
*/
42-
public static Context setLocale(Context context, String language) {
44+
public static Context setLocale(final Context context, final String language) {
4345
persist(context, language);
4446
return updateResources(context, language);
4547
}
4648

4749
/**
48-
* Get the language from the shared preferences
50+
* Get the language code that is stored in the shared preferences
4951
*
50-
* @param context The Context object that can be used to store shared preferences
51-
* @param defaultLanguage The default language
52-
* @return The language from the shared preferences
52+
* @param context The Context object that can be used to load the preferences
53+
* @param defaultLanguage The default language code
54+
* @return The language code that is stored in the shared preferences
5355
*/
54-
private static String getPersistedData(Context context, String defaultLanguage) {
55-
final SharedPreferences preferences = context.getSharedPreferences("deadpixsettings", Context.MODE_PRIVATE);
56+
private static String getPersistedData(final Context context, final String defaultLanguage) {
57+
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
5658
return preferences.getString("language", defaultLanguage);
5759
}
5860

5961
/**
60-
* Store the language in the shared preferences
62+
* Store the language code in the shared preferences
6163
*
62-
* @param context The Context object that can be used to store the shared preferences
63-
* @param language The language that should be stored
64+
* @param context The Context object that can be used to store preferences
65+
* @param language The language code that should be stored
6466
*/
65-
private static void persist(Context context, String language) {
67+
private static void persist(final Context context, final String language) {
6668
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
6769
final SharedPreferences.Editor editor = preferences.edit();
6870

@@ -71,13 +73,14 @@ private static void persist(Context context, String language) {
7173
}
7274

7375
/**
74-
* Update the context with the latest language
76+
* Update the resources of a Context object
7577
*
76-
* @param context The Context object that should be updated
77-
* @param language The language that should be applied to the Context object
78-
* @return The updated Context object
78+
* @param context The Context object that should be configured
79+
* @param language The language code that should be applied to the Context object
80+
* @return The Context object containing correct resource properties
7981
*/
80-
private static Context updateResources(Context context, String language) {
82+
@SuppressLint("AppBundleLocaleChanges")
83+
private static Context updateResources(final Context context, final String language) {
8184
final Locale locale = new Locale(language);
8285
Locale.setDefault(locale);
8386

app/src/main/java/com/codedead/deadpix/gui/FixActivity.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import androidx.annotation.NonNull;
1111
import androidx.appcompat.app.ActionBar;
1212
import androidx.appcompat.app.AppCompatActivity;
13+
1314
import android.os.Bundle;
1415
import android.os.Handler;
1516
import android.view.MenuItem;
@@ -73,18 +74,18 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
7374
};
7475

7576
@Override
76-
public void onConfigurationChanged(@NonNull Configuration newConfig) {
77+
public void onConfigurationChanged(@NonNull final Configuration newConfig) {
7778
super.onConfigurationChanged(newConfig);
7879
LocaleHelper.onAttach(getBaseContext());
7980
}
8081

8182
@Override
82-
protected void attachBaseContext(Context base) {
83+
protected void attachBaseContext(final Context base) {
8384
super.attachBaseContext(LocaleHelper.onAttach(base));
8485
}
8586

8687
@Override
87-
protected void onCreate(Bundle savedInstanceState) {
88+
protected void onCreate(final Bundle savedInstanceState) {
8889
final SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
8990
LocaleHelper.setLocale(this, sharedPreferences.getString("language", "en"));
9091

@@ -122,10 +123,8 @@ protected void onCreate(Bundle savedInstanceState) {
122123
frameLayout.setBackgroundColor(getIntent().getIntExtra("color", 0));
123124
}
124125

125-
if (getIntent().getStringExtra("action") != null) {
126-
if (getIntent().getStringExtra("action").equals("fix")) {
127-
fix();
128-
}
126+
if (getIntent() != null && getIntent().getStringExtra("action") != null && getIntent().getStringExtra("action").equals("fix")) {
127+
fix();
129128
}
130129
}
131130

@@ -142,7 +141,7 @@ private void fix() {
142141
new CountDownTimer(fixDelay, 1000) {
143142

144143
@Override
145-
public void onTick(long millisUntilFinished) {
144+
public void onTick(final long millisUntilFinished) {
146145
}
147146

148147
@Override
@@ -157,7 +156,7 @@ public void onFinish() {
157156
}
158157

159158
@Override
160-
protected void onPostCreate(Bundle savedInstanceState) {
159+
protected void onPostCreate(final Bundle savedInstanceState) {
161160
super.onPostCreate(savedInstanceState);
162161
delayedHide(300);
163162
}
@@ -193,7 +192,12 @@ private void show() {
193192
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
194193
}
195194

196-
private void delayedHide(int delayMillis) {
195+
/**
196+
* Delay the hiding of the UI
197+
*
198+
* @param delayMillis The delay in milliseconds
199+
*/
200+
private void delayedHide(final int delayMillis) {
197201
mHideHandler.removeCallbacks(mHideRunnable);
198202
mHideHandler.postDelayed(mHideRunnable, delayMillis);
199203
}

0 commit comments

Comments
 (0)