Skip to content

Commit 29f5495

Browse files
committed
Update prayers db, dependencies and fixed new lint errors
1 parent 1992852 commit 29f5495

19 files changed

Lines changed: 78 additions & 94 deletions

app/build.gradle

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
apply plugin: 'com.android.application'
1+
plugins {
2+
id 'com.android.application'
3+
}
24

35
android {
4-
compileSdkVersion 30
6+
compileSdkVersion 32
57
buildFeatures.dataBinding = true
68

79
defaultConfig {
810
applicationId 'com.arashpayan.prayerbook'
9-
minSdkVersion 19
10-
targetSdkVersion 30
11-
versionCode 21
12-
versionName '2.1.2'
11+
minSdkVersion 23
12+
targetSdkVersion 32
13+
versionCode 22
14+
versionName '2.2.0'
1315
vectorDrawables.useSupportLibrary = true
1416
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1517
}
@@ -24,27 +26,19 @@ android {
2426
sourceCompatibility JavaVersion.VERSION_1_8
2527
targetCompatibility JavaVersion.VERSION_1_8
2628
}
27-
}
28-
29-
gradle.projectsEvaluated {
30-
tasks.withType(JavaCompile) {
31-
options.deprecation = true
32-
}
33-
}
3429

35-
repositories {
36-
mavenCentral()
30+
namespace 'com.arashpayan.prayerbook'
3731
}
3832

3933
dependencies {
4034
implementation fileTree(dir: 'libs', include: ['*.jar'])
41-
implementation 'androidx.appcompat:appcompat:1.3.1'
35+
implementation 'androidx.appcompat:appcompat:1.4.1'
4236
implementation 'androidx.recyclerview:recyclerview:1.2.1'
43-
implementation 'com.google.android.material:material:1.4.0'
44-
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
37+
implementation 'com.google.android.material:material:1.6.0'
38+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
4539
implementation 'com.samskivert:jmustache:1.14'
4640

47-
testImplementation 'junit:junit:4.12'
41+
testImplementation 'junit:junit:4.13.2'
4842
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
4943
androidTestImplementation 'androidx.test:rules:1.4.0'
5044
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools"
3-
package="com.arashpayan.prayerbook">
2+
xmlns:tools="http://schemas.android.com/tools">
43

54
<application
65
android:allowBackup="true"
@@ -13,7 +12,8 @@
1312
tools:ignore="GoogleAppIndexingWarning">
1413
<activity
1514
android:name=".MainActivity"
16-
android:label="@string/app_name" >
15+
android:label="@string/app_name"
16+
android:exported="true">
1717
<intent-filter>
1818
<action android:name="android.intent.action.MAIN" />
1919
<category android:name="android.intent.category.LAUNCHER" />

app/src/main/assets/pbdb.jet

76 KB
Binary file not shown.

app/src/main/java/com/arashpayan/prayerbook/App.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class App extends Application {
3232
private ExecutorService mExecutor;
3333

3434
private static volatile App app;
35-
private static final int LatestDatabaseVersion = 22;
35+
private static final int LatestDatabaseVersion = 23;
3636

3737
@Override
3838
public void onCreate() {
@@ -45,7 +45,6 @@ public void onCreate() {
4545

4646
Prefs.init(this);
4747
UserDB.set(new UserDB(this, false));
48-
UserDB.get().addBookmark(44);
4948
copyDatabaseFile();
5049

5150
// Load as much of the webview libraries as much as possible in the background

app/src/main/java/com/arashpayan/prayerbook/BookmarksAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public PrayerSummaryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
8787
itemView.setOnClickListener(new View.OnClickListener() {
8888
@Override
8989
public void onClick(View v) {
90-
int pos = holder.getAdapterPosition();
90+
int pos = holder.getAbsoluteAdapterPosition();
9191
listener.onPrayerSelected(bookmarks.get(pos));
9292
}
9393
});

app/src/main/java/com/arashpayan/prayerbook/CategoriesAdapter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
5151
itemView.setOnClickListener(new View.OnClickListener() {
5252
@Override
5353
public void onClick(View v) {
54-
int pos = holder.getAdapterPosition();
54+
int pos = holder.getAbsoluteAdapterPosition();
5555
CategoryItem item = items.get(pos);
5656
listener.onCategorySelected(item.text, item.language);
5757
}
@@ -77,6 +77,13 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
7777
App.runInBackground(new WorkerRunnable() {
7878
@Override
7979
public void run() {
80+
// This only executes for actual category view holders, but because the headers
81+
// are also represented by CategoryItems, the 'text' property can be null.
82+
// To keep the linter quiet, we'll check that the 'text' property is not null.
83+
// When we eventually switch to Jetpack Compose, this problem should disappear.
84+
if (item.text == null) {
85+
return;
86+
}
8087
int count = PrayersDB.get().getPrayerCountForCategory(item.text, item.language.code);
8188
App.runOnUiThread(new UiRunnable() {
8289
@Override

app/src/main/java/com/arashpayan/prayerbook/CategoryPrayersAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public PrayerSummaryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
4646
itemView.setOnClickListener(new View.OnClickListener() {
4747
@Override
4848
public void onClick(View v) {
49-
int pos = holder.getAdapterPosition();
49+
int pos = holder.getAbsoluteAdapterPosition();
5050
listener.onPrayerSelected(getItemId(pos));
5151
}
5252
});

app/src/main/java/com/arashpayan/prayerbook/Language.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
package com.arashpayan.prayerbook;
77

8-
import android.os.Build;
98
import android.os.Parcel;
109
import android.os.Parcelable;
1110

@@ -37,25 +36,7 @@ public enum Language implements Parcelable {
3736
this.code = code;
3837
this.humanName = humanName;
3938
this.rightToLeft = rightToLeft;
40-
41-
final Locale[] availableLocales = Locale.getAvailableLocales();
42-
Locale matchingLocale = null;
43-
if (Build.VERSION.SDK_INT >= 21) {
44-
matchingLocale = Locale.forLanguageTag(code);
45-
} else {
46-
for (Locale l : availableLocales) {
47-
if (l.getLanguage().equals(code)) {
48-
matchingLocale = l;
49-
break;
50-
}
51-
}
52-
}
53-
54-
if (matchingLocale != null) {
55-
this.locale = matchingLocale;
56-
} else {
57-
this.locale = Locale.US;
58-
}
39+
this.locale = Locale.forLanguageTag(code);
5940
}
6041

6142
public static Language get(String code) {

app/src/main/java/com/arashpayan/prayerbook/LanguagesAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public LanguagesFragment.LanguageViewHolder onCreateViewHolder(@NonNull ViewGrou
3838
itemView.setOnClickListener(new View.OnClickListener() {
3939
@Override
4040
public void onClick(View v) {
41-
int pos = holder.getAdapterPosition();
41+
int pos = holder.getAbsoluteAdapterPosition();
4242
boolean shouldEnable = !holder.checkBox.isChecked();
4343
holder.checkBox.setChecked(shouldEnable);
4444
prefs.setLanguageEnabled(languages[pos], shouldEnable);
@@ -47,7 +47,7 @@ public void onClick(View v) {
4747
holder.checkBox.setOnClickListener(new View.OnClickListener() {
4848
@Override
4949
public void onClick(View v) {
50-
int pos = holder.getAdapterPosition();
50+
int pos = holder.getAbsoluteAdapterPosition();
5151
// by the time onClick is called, the check box state has already changed,
5252
// so we don't need to ! (not) the isChecked value
5353
boolean shouldEnable = holder.checkBox.isChecked();

app/src/main/java/com/arashpayan/prayerbook/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void onCreate(Bundle savedInstanceState) {
3232
int headerColor = ContextCompat.getColor(this, R.color.task_header);
3333
if (Build.VERSION.SDK_INT > 27) {
3434
setTaskDescription(new ActivityManager.TaskDescription(appName, R.mipmap.ic_launcher, headerColor));
35-
} else if (Build.VERSION.SDK_INT > 20) {
35+
} else {
3636
Bitmap appIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
3737
setTaskDescription(new ActivityManager.TaskDescription(appName, appIcon, headerColor));
3838
}

0 commit comments

Comments
 (0)