Skip to content

Commit ec2bcc3

Browse files
committed
Merge branch 'dev'
# Conflicts: # app/build.gradle.kts # app/src/main/java/org/nsh07/wikireader/ui/homeScreen/AppSearchBar.kt
2 parents f69296a + 328397a commit ec2bcc3

File tree

99 files changed

+10719
-7243
lines changed

Some content is hidden

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

99 files changed

+10719
-7243
lines changed

.github/repo_photos/bmc_qr.png

89.9 KB
Loading

.github/repo_photos/sponsors.png

88 KB
Loading

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,19 @@ translating this project into languages you know.
118118
> The SHA256 and MD5 hashes of the individual APK files are also available in the `checksum.txt`
119119
> file for each release.
120120
121+
## Donate
122+
123+
You can support WikiReader's development
124+
through [my GitHub Sponsors page](https://github.com/sponsors/nsh07)
125+
or [my BuyMeACoffee page](https://coff.ee/nsh07):
126+
127+
<a href="https://github.com/sponsors/nsh07">
128+
<img src=".github/repo_photos/sponsors.png" width="128px">
129+
</a>
130+
<a href="https://coff.ee/nsh07">
131+
<img src=".github/repo_photos/bmc_qr.png" width="128px">
132+
</a>
133+
121134
## Special Thanks
122135
123136
- [Wikimedia Foundation](https://wikimediafoundation.org/): For

app/build.gradle.kts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
alias(libs.plugins.android.application)
3-
alias(libs.plugins.jetbrains.kotlin.android)
5+
alias(libs.plugins.baselineprofile)
46
alias(libs.plugins.jetbrains.compose.compiler)
7+
alias(libs.plugins.jetbrains.kotlin.android)
58
alias(libs.plugins.jetbrains.kotlin.serialization)
6-
alias(libs.plugins.baselineprofile)
9+
alias(libs.plugins.ksp)
710
}
811

912
android {
@@ -14,8 +17,8 @@ android {
1417
applicationId = "org.nsh07.wikireader"
1518
minSdk = 26
1619
targetSdk = 36
17-
versionCode = 43
18-
versionName = "2.3.1"
20+
versionCode = 44
21+
versionName = "2.4.0"
1922

2023
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2124
vectorDrawables {
@@ -40,8 +43,13 @@ android {
4043
sourceCompatibility = JavaVersion.VERSION_17
4144
targetCompatibility = JavaVersion.VERSION_17
4245
}
43-
kotlinOptions {
44-
jvmTarget = "17"
46+
kotlin {
47+
compilerOptions {
48+
jvmTarget.set(JvmTarget.JVM_17) // Use the enum for target JVM version
49+
}
50+
}
51+
ksp {
52+
arg("room.schemaLocation", "$projectDir/schemas")
4553
}
4654
buildFeatures {
4755
compose = true
@@ -74,6 +82,10 @@ dependencies {
7482
implementation(libs.androidx.ui.tooling.preview)
7583

7684
implementation(libs.androidx.datastore.preferences)
85+
implementation(libs.androidx.room.runtime)
86+
implementation(libs.androidx.room.ktx)
87+
ksp(libs.androidx.room.compiler)
88+
7789
implementation(libs.coil3.coil.gif)
7890
implementation(libs.coil3.coil.svg)
7991
implementation(libs.coil3.compose)
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 1,
5+
"identityHash": "c4f8fe03acfaf9d5b3884866f1c9506f",
6+
"entities": [
7+
{
8+
"tableName": "search_history",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`time` INTEGER NOT NULL, `query` TEXT NOT NULL, `lang` TEXT NOT NULL, PRIMARY KEY(`time`))",
10+
"fields": [
11+
{
12+
"fieldPath": "time",
13+
"columnName": "time",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "query",
19+
"columnName": "query",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "lang",
25+
"columnName": "lang",
26+
"affinity": "TEXT",
27+
"notNull": true
28+
}
29+
],
30+
"primaryKey": {
31+
"autoGenerate": false,
32+
"columnNames": [
33+
"time"
34+
]
35+
}
36+
},
37+
{
38+
"tableName": "view_history",
39+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`time` INTEGER NOT NULL, `thumbnail` TEXT, `title` TEXT NOT NULL, `description` TEXT, `lang` TEXT NOT NULL, PRIMARY KEY(`time`))",
40+
"fields": [
41+
{
42+
"fieldPath": "time",
43+
"columnName": "time",
44+
"affinity": "INTEGER",
45+
"notNull": true
46+
},
47+
{
48+
"fieldPath": "thumbnail",
49+
"columnName": "thumbnail",
50+
"affinity": "TEXT"
51+
},
52+
{
53+
"fieldPath": "title",
54+
"columnName": "title",
55+
"affinity": "TEXT",
56+
"notNull": true
57+
},
58+
{
59+
"fieldPath": "description",
60+
"columnName": "description",
61+
"affinity": "TEXT"
62+
},
63+
{
64+
"fieldPath": "lang",
65+
"columnName": "lang",
66+
"affinity": "TEXT",
67+
"notNull": true
68+
}
69+
],
70+
"primaryKey": {
71+
"autoGenerate": false,
72+
"columnNames": [
73+
"time"
74+
]
75+
}
76+
},
77+
{
78+
"tableName": "saved_article",
79+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`pageId` INTEGER NOT NULL, `lang` TEXT NOT NULL, `langName` TEXT NOT NULL, `title` TEXT NOT NULL, `thumbnail` TEXT, `description` TEXT, `apiResponse` TEXT NOT NULL, `pageContent` TEXT NOT NULL, PRIMARY KEY(`pageId`))",
80+
"fields": [
81+
{
82+
"fieldPath": "pageId",
83+
"columnName": "pageId",
84+
"affinity": "INTEGER",
85+
"notNull": true
86+
},
87+
{
88+
"fieldPath": "lang",
89+
"columnName": "lang",
90+
"affinity": "TEXT",
91+
"notNull": true
92+
},
93+
{
94+
"fieldPath": "langName",
95+
"columnName": "langName",
96+
"affinity": "TEXT",
97+
"notNull": true
98+
},
99+
{
100+
"fieldPath": "title",
101+
"columnName": "title",
102+
"affinity": "TEXT",
103+
"notNull": true
104+
},
105+
{
106+
"fieldPath": "thumbnail",
107+
"columnName": "thumbnail",
108+
"affinity": "TEXT"
109+
},
110+
{
111+
"fieldPath": "description",
112+
"columnName": "description",
113+
"affinity": "TEXT"
114+
},
115+
{
116+
"fieldPath": "apiResponse",
117+
"columnName": "apiResponse",
118+
"affinity": "TEXT",
119+
"notNull": true
120+
},
121+
{
122+
"fieldPath": "pageContent",
123+
"columnName": "pageContent",
124+
"affinity": "TEXT",
125+
"notNull": true
126+
}
127+
],
128+
"primaryKey": {
129+
"autoGenerate": false,
130+
"columnNames": [
131+
"pageId"
132+
]
133+
}
134+
},
135+
{
136+
"tableName": "user_language",
137+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`lang` TEXT NOT NULL, `langName` TEXT NOT NULL, `selected` INTEGER NOT NULL, PRIMARY KEY(`lang`))",
138+
"fields": [
139+
{
140+
"fieldPath": "lang",
141+
"columnName": "lang",
142+
"affinity": "TEXT",
143+
"notNull": true
144+
},
145+
{
146+
"fieldPath": "langName",
147+
"columnName": "langName",
148+
"affinity": "TEXT",
149+
"notNull": true
150+
},
151+
{
152+
"fieldPath": "selected",
153+
"columnName": "selected",
154+
"affinity": "INTEGER",
155+
"notNull": true
156+
}
157+
],
158+
"primaryKey": {
159+
"autoGenerate": false,
160+
"columnNames": [
161+
"lang"
162+
]
163+
}
164+
},
165+
{
166+
"tableName": "string_preference",
167+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `value` TEXT NOT NULL, PRIMARY KEY(`key`))",
168+
"fields": [
169+
{
170+
"fieldPath": "key",
171+
"columnName": "key",
172+
"affinity": "TEXT",
173+
"notNull": true
174+
},
175+
{
176+
"fieldPath": "value",
177+
"columnName": "value",
178+
"affinity": "TEXT",
179+
"notNull": true
180+
}
181+
],
182+
"primaryKey": {
183+
"autoGenerate": false,
184+
"columnNames": [
185+
"key"
186+
]
187+
}
188+
},
189+
{
190+
"tableName": "int_preference",
191+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `value` INTEGER NOT NULL, PRIMARY KEY(`key`))",
192+
"fields": [
193+
{
194+
"fieldPath": "key",
195+
"columnName": "key",
196+
"affinity": "TEXT",
197+
"notNull": true
198+
},
199+
{
200+
"fieldPath": "value",
201+
"columnName": "value",
202+
"affinity": "INTEGER",
203+
"notNull": true
204+
}
205+
],
206+
"primaryKey": {
207+
"autoGenerate": false,
208+
"columnNames": [
209+
"key"
210+
]
211+
}
212+
},
213+
{
214+
"tableName": "boolean_preference",
215+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `value` INTEGER NOT NULL, PRIMARY KEY(`key`))",
216+
"fields": [
217+
{
218+
"fieldPath": "key",
219+
"columnName": "key",
220+
"affinity": "TEXT",
221+
"notNull": true
222+
},
223+
{
224+
"fieldPath": "value",
225+
"columnName": "value",
226+
"affinity": "INTEGER",
227+
"notNull": true
228+
}
229+
],
230+
"primaryKey": {
231+
"autoGenerate": false,
232+
"columnNames": [
233+
"key"
234+
]
235+
}
236+
}
237+
],
238+
"setupQueries": [
239+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
240+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c4f8fe03acfaf9d5b3884866f1c9506f')"
241+
]
242+
}
243+
}

app/src/main/java/org/nsh07/wikireader/MainActivity.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import androidx.compose.foundation.layout.fillMaxSize
1010
import androidx.compose.material3.MaterialTheme.colorScheme
1111
import androidx.compose.material3.MaterialTheme.typography
1212
import androidx.compose.runtime.CompositionLocalProvider
13-
import androidx.compose.runtime.collectAsState
1413
import androidx.compose.runtime.getValue
1514
import androidx.compose.ui.Modifier
1615
import androidx.compose.ui.platform.LocalLayoutDirection
1716
import androidx.compose.ui.unit.LayoutDirection
1817
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
18+
import androidx.lifecycle.compose.collectAsStateWithLifecycle
1919
import org.nsh07.wikireader.data.isRtl
2020
import org.nsh07.wikireader.data.toColor
2121
import org.nsh07.wikireader.ui.AppScreen
@@ -29,12 +29,14 @@ class MainActivity : ComponentActivity() {
2929
override fun onCreate(savedInstanceState: Bundle?) {
3030
super.onCreate(savedInstanceState)
3131
installSplashScreen().setKeepOnScreenCondition { !viewModel.isReady }
32+
3233
viewModel.setFilesDir(filesDir.path)
3334
viewModel.migrateArticles()
35+
3436
enableEdgeToEdge()
3537

3638
setContent {
37-
val preferencesState by viewModel.preferencesState.collectAsState()
39+
val preferencesState by viewModel.preferencesState.collectAsStateWithLifecycle()
3840

3941
val darkTheme = when (preferencesState.theme) {
4042
"dark" -> true

app/src/main/java/org/nsh07/wikireader/data/AppContainer.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface AppContainer {
1515
val interceptor: HostSelectionInterceptor
1616
val wikipediaRepository: WikipediaRepository
1717
val appPreferencesRepository: AppPreferencesRepository
18+
val appDatabaseRepository: AppDatabaseRepository
1819
}
1920

2021
class DefaultAppContainer(context: Context) : AppContainer {
@@ -58,6 +59,19 @@ class DefaultAppContainer(context: Context) : AppContainer {
5859
}
5960

6061
override val appPreferencesRepository: AppPreferencesRepository by lazy {
61-
AppPreferencesRepository(context, Dispatchers.IO)
62+
AppPreferencesRepository(
63+
context,
64+
Dispatchers.IO,
65+
AppDatabase.getDatabase(context).preferenceDao()
66+
)
67+
}
68+
69+
override val appDatabaseRepository: AppDatabaseRepository by lazy {
70+
AppDatabaseRepository(
71+
searchHistoryDao = AppDatabase.getDatabase(context).searchHistoryDao(),
72+
savedArticleDao = AppDatabase.getDatabase(context).savedArticleDao(),
73+
viewHistoryDao = AppDatabase.getDatabase(context).viewHistoryDao(),
74+
userLanguageDao = AppDatabase.getDatabase(context).userLanguageDao()
75+
)
6276
}
6377
}

0 commit comments

Comments
 (0)