Skip to content

Commit 0297549

Browse files
Merge branch 'main' into Search-dynamic
# Conflicts: # gradle/libs.versions.toml
2 parents b315202 + 46bce45 commit 0297549

File tree

107 files changed

+1433
-849
lines changed

Some content is hidden

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

107 files changed

+1433
-849
lines changed

app/build.gradle

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id 'com.android.application'
35
id 'com.google.devtools.ksp'
@@ -18,27 +20,27 @@ static def computeVersionName(versionCode, label) {
1820
return "2.7.${versionCode}-${label}-${(new Date()).format('yyyy-MM-dd')}"
1921
}
2022

21-
final JavaVersion JAVA_VERSION = JavaVersion.VERSION_17
22-
2323
android {
24-
compileSdk 35
24+
compileSdk = 36
2525

2626
compileOptions {
27-
coreLibraryDesugaringEnabled true
27+
coreLibraryDesugaringEnabled = true
2828

29-
sourceCompatibility = JAVA_VERSION
30-
targetCompatibility = JAVA_VERSION
29+
sourceCompatibility = JavaVersion.VERSION_17
30+
targetCompatibility = JavaVersion.VERSION_17
3131
}
3232

33-
kotlinOptions {
34-
jvmTarget = JAVA_VERSION
33+
kotlin {
34+
compilerOptions {
35+
jvmTarget = JvmTarget.JVM_17
36+
}
3537
}
3638

3739
defaultConfig {
3840
applicationId 'org.wikipedia'
39-
minSdk 21
40-
targetSdk 35
41-
versionCode 50544
41+
minSdk = 21
42+
targetSdk = 36
43+
versionCode 50545
4244
testApplicationId 'org.wikipedia.test'
4345
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4446
testInstrumentationRunnerArguments clearPackageData: 'true'

app/src/androidTest/java/org/wikipedia/database/AppDatabaseTests.kt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import androidx.room.Room
55
import androidx.test.core.app.ApplicationProvider
66
import androidx.test.ext.junit.runners.AndroidJUnit4
77
import androidx.test.platform.app.InstrumentationRegistry
8-
import kotlinx.coroutines.*
9-
import kotlinx.coroutines.flow.count
10-
import kotlinx.coroutines.flow.first
11-
import org.hamcrest.CoreMatchers.*
8+
import kotlinx.coroutines.CoroutineExceptionHandler
9+
import kotlinx.coroutines.CoroutineScope
10+
import kotlinx.coroutines.Dispatchers
11+
import kotlinx.coroutines.launch
12+
import kotlinx.coroutines.runBlocking
13+
import kotlinx.coroutines.withContext
14+
import org.hamcrest.CoreMatchers.equalTo
15+
import org.hamcrest.CoreMatchers.notNullValue
16+
import org.hamcrest.CoreMatchers.nullValue
1217
import org.hamcrest.MatcherAssert.assertThat
1318
import org.junit.After
1419
import org.junit.Before
@@ -22,7 +27,7 @@ import org.wikipedia.search.db.RecentSearchDao
2227
import org.wikipedia.talk.db.TalkPageSeen
2328
import org.wikipedia.talk.db.TalkPageSeenDao
2429
import org.wikipedia.util.log.L
25-
import java.util.*
30+
import java.util.Date
2631

2732
@RunWith(AndroidJUnit4::class)
2833
class AppDatabaseTests {
@@ -100,8 +105,8 @@ class AppDatabaseTests {
100105

101106
notificationDao.insertNotifications(notifications)
102107

103-
var enWikiList = notificationDao.getNotificationsByWiki(listOf("enwiki")).first()
104-
val zhWikiList = notificationDao.getNotificationsByWiki(listOf("zhwiki")).first()
108+
var enWikiList = notificationDao.getNotificationsByWiki(listOf("enwiki"))
109+
val zhWikiList = notificationDao.getNotificationsByWiki(listOf("zhwiki"))
105110
assertThat(enWikiList, notNullValue())
106111
assertThat(enWikiList.first().id, equalTo(123759827))
107112
assertThat(zhWikiList.first().id, equalTo(2470933))
@@ -114,18 +119,18 @@ class AppDatabaseTests {
114119
notificationDao.updateNotification(firstEnNotification)
115120

116121
// get updated item
117-
enWikiList = notificationDao.getNotificationsByWiki(listOf("enwiki")).first()
122+
enWikiList = notificationDao.getNotificationsByWiki(listOf("enwiki"))
118123
assertThat(enWikiList.first().id, equalTo(123759827))
119124
assertThat(enWikiList.first().isUnread, equalTo(true))
120125

121126
notificationDao.deleteNotification(firstEnNotification)
122127
assertThat(notificationDao.getAllNotifications().size, equalTo(2))
123-
assertThat(notificationDao.getNotificationsByWiki(listOf("enwiki")).first().size, equalTo(1))
128+
assertThat(notificationDao.getNotificationsByWiki(listOf("enwiki")).size, equalTo(1))
124129

125-
notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf("enwiki")).first().first())
126-
assertThat(notificationDao.getNotificationsByWiki(listOf("enwiki")).first().isEmpty(), equalTo(true))
130+
notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf("enwiki")).first())
131+
assertThat(notificationDao.getNotificationsByWiki(listOf("enwiki")).isEmpty(), equalTo(true))
127132

128-
notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf("zhwiki")).first().first())
133+
notificationDao.deleteNotification(notificationDao.getNotificationsByWiki(listOf("zhwiki")).first())
129134
assertThat(notificationDao.getAllNotifications().isEmpty(), equalTo(true))
130135
}
131136
}

app/src/androidTest/java/org/wikipedia/database/UpgradeFromPreRoomTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import androidx.room.Room
44
import androidx.room.testing.MigrationTestHelper
55
import androidx.test.core.app.ApplicationProvider
66
import androidx.test.platform.app.InstrumentationRegistry
7-
import kotlinx.coroutines.flow.first
87
import kotlinx.coroutines.runBlocking
98
import org.hamcrest.CoreMatchers.equalTo
109
import org.hamcrest.CoreMatchers.nullValue
@@ -123,7 +122,7 @@ class UpgradeFromPreRoomTest(private val fromVersion: Int) {
123122
val historyEntry = historyDao.findEntryBy("ru.wikipedia.org", "ru", "Обама,_Барак")!!
124123
assertThat(historyEntry.displayTitle, equalTo("Обама, Барак"))
125124

126-
val talkPageSeen = talkPageSeenDao.getAll().first()
125+
val talkPageSeen = talkPageSeenDao.getAll()
127126
if (fromVersion == 22) {
128127
assertThat(talkPageSeen.count(), equalTo(2))
129128
assertThat(offlineObjectDao.getOfflineObject("https://en.wikipedia.org/api/rest_v1/page/summary/Joe_Biden")!!.path, equalTo("/data/user/0/org.wikipedia.dev/files/offline_files/481b1ef996728fd9994bd97ab19733d8"))

app/src/extra/java/org/wikipedia/donate/GooglePayActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class GooglePayActivity : BaseActivity() {
100100
}
101101

102102
binding.errorView.backClickListener = View.OnClickListener {
103-
onBackPressed()
103+
onBackPressedDispatcher.onBackPressed()
104104
}
105105

106106
binding.payButton.setOnClickListener {

app/src/main/java/org/wikipedia/WikipediaApp.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ class WikipediaApp : Application() {
258258
Prefs.tempAccountCreateDay = 0L
259259
Prefs.tempAccountDialogShown = false
260260
SharedPreferenceCookieManager.instance.clearAllCookies()
261-
AppDatabase.instance.notificationDao().deleteAll()
261+
MainScope().launch {
262+
AppDatabase.instance.notificationDao().deleteAll()
263+
}
262264
FlowEventBus.post(LoggedOutEvent())
263265
L.d("Logout complete.")
264266
}

app/src/main/java/org/wikipedia/activity/BaseActivity.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,13 @@ abstract class BaseActivity : AppCompatActivity(), ConnectionStateMonitor.Callba
188188
override fun onOptionsItemSelected(item: MenuItem): Boolean {
189189
return when (item.itemId) {
190190
android.R.id.home -> {
191-
onBackPressed()
191+
onBackPressedDispatcher.onBackPressed()
192192
true
193193
}
194194
else -> false
195195
}
196196
}
197197

198-
override fun onBackPressed() {
199-
super.onBackPressed()
200-
BreadCrumbLogEvent.logBackPress(this)
201-
}
202-
203198
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
204199
if (event.actionMasked == MotionEvent.ACTION_DOWN ||
205200
event.actionMasked == MotionEvent.ACTION_POINTER_DOWN) {

app/src/main/java/org/wikipedia/activity/SingleWebViewActivity.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import android.webkit.WebChromeClient
1515
import android.webkit.WebResourceRequest
1616
import android.webkit.WebResourceResponse
1717
import android.webkit.WebView
18+
import androidx.activity.addCallback
1819
import androidx.core.view.isVisible
1920
import com.google.android.material.dialog.MaterialAlertDialogBuilder
2021
import org.wikipedia.Constants
@@ -62,6 +63,14 @@ class SingleWebViewActivity : BaseActivity() {
6263
pageTitleToLoadOnBackPress = intent.parcelableExtra(Constants.ARG_TITLE)
6364
blankLinkHandler = SingleWebViewLinkHandler(this, WikipediaApp.instance.wikiSite)
6465

66+
onBackPressedDispatcher.addCallback(this) {
67+
if (!isWebForm && binding.webView.canGoBack()) {
68+
binding.webView.goBack()
69+
return@addCallback
70+
}
71+
goBack()
72+
}
73+
6574
binding.backButton.isVisible = showBackButton
6675
binding.backButton.setOnClickListener {
6776
goBack()
@@ -167,15 +176,6 @@ class SingleWebViewActivity : BaseActivity() {
167176
super.onDestroy()
168177
}
169178

170-
override fun onBackPressed() {
171-
if (!isWebForm && binding.webView.canGoBack()) {
172-
binding.webView.goBack()
173-
return
174-
}
175-
goBack()
176-
super.onBackPressed()
177-
}
178-
179179
private fun goBack() {
180180
if (intent.getStringExtra(EXTRA_PAGE_CONTENT_INFO).orEmpty() == PAGE_CONTENT_SOURCE_DONOR_EXPERIENCE) {
181181
DonorExperienceEvent.logAction("article_return_click", "webpay_processed")

app/src/main/java/org/wikipedia/analytics/eventplatform/CreateAccountEvent.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class CreateAccountEvent(private val requestSource: String) {
1717
submitEvent("success")
1818
}
1919

20+
fun logVanish() {
21+
submitEvent("vanish_account")
22+
}
23+
2024
private fun submitEvent(action: String, errorText: String = "") {
2125
EventPlatformClient.submit(CreateAccountEventImpl(action, requestSource, errorText))
2226
}

app/src/main/java/org/wikipedia/createaccount/CreateAccountActivity.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import android.text.TextWatcher
99
import android.util.Patterns
1010
import android.view.KeyEvent
1111
import android.view.View
12+
import androidx.activity.addCallback
1213
import androidx.activity.viewModels
14+
import androidx.core.net.toUri
1315
import androidx.core.view.isVisible
1416
import androidx.core.widget.doOnTextChanged
1517
import androidx.lifecycle.Lifecycle
@@ -70,6 +72,16 @@ class CreateAccountActivity : BaseActivity() {
7072
binding.footerContainer.tempAccountInfoContainer.isVisible = false
7173
}
7274

75+
onBackPressedDispatcher.addCallback(this) {
76+
if (captchaHandler.isActive) {
77+
captchaHandler.cancelCaptcha()
78+
showProgressBar(false)
79+
return@addCallback
80+
}
81+
DeviceUtil.hideSoftKeyboard(this@CreateAccountActivity)
82+
finish()
83+
}
84+
7385
// Set default result to failed, so we can override if it did not
7486
setResult(RESULT_ACCOUNT_NOT_CREATED)
7587
lifecycleScope.launch {
@@ -154,7 +166,7 @@ class CreateAccountActivity : BaseActivity() {
154166
FeedbackUtil.showPrivacyPolicy(this)
155167
}
156168
binding.footerContainer.forgotPasswordLink.setOnClickListener {
157-
visitInExternalBrowser(this, Uri.parse(PageTitle("Special:PasswordReset", wiki).uri))
169+
visitInExternalBrowser(this, PageTitle("Special:PasswordReset", wiki).uri.toUri())
158170
}
159171
// Add listener so that when the user taps enter, it submits the captcha
160172
binding.captchaContainer.captchaText.setOnKeyListener { _: View, keyCode: Int, event: KeyEvent ->
@@ -192,16 +204,6 @@ class CreateAccountActivity : BaseActivity() {
192204
viewModel.doCreateAccount(token, captchaHandler.captchaId().toString(), captchaHandler.captchaWord().toString(), userName, password, repeat, email)
193205
}
194206

195-
override fun onBackPressed() {
196-
if (captchaHandler.isActive) {
197-
captchaHandler.cancelCaptcha()
198-
showProgressBar(false)
199-
return
200-
}
201-
DeviceUtil.hideSoftKeyboard(this)
202-
super.onBackPressed()
203-
}
204-
205207
public override fun onStop() {
206208
showProgressBar(false)
207209
super.onStop()

app/src/main/java/org/wikipedia/database/AppDatabase.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ abstract class AppDatabase : RoomDatabase() {
354354
MIGRATION_23_24, MIGRATION_24_25, MIGRATION_25_26, MIGRATION_26_27,
355355
MIGRATION_26_28, MIGRATION_27_28, MIGRATION_28_29, MIGRATION_29_30,
356356
MIGRATION_30_31)
357-
.allowMainThreadQueries() // TODO: remove after resolving main thread issues in DAO classes
358357
.fallbackToDestructiveMigration(false)
359358
.build()
360359
}

0 commit comments

Comments
 (0)