Skip to content

Commit c795ea7

Browse files
Merge branch 'main' into Notification_time_ago
2 parents 5a956d2 + 6f779e8 commit c795ea7

File tree

258 files changed

+9236
-2316
lines changed

Some content is hidden

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

258 files changed

+9236
-2316
lines changed

app/build.gradle

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737
applicationId 'org.wikipedia'
3838
minSdkVersion 21
3939
targetSdkVersion 33
40-
versionCode 50444
40+
versionCode 50448
4141
testApplicationId 'org.wikipedia.test'
4242
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4343
testInstrumentationRunnerArguments clearPackageData: 'true'
@@ -56,6 +56,10 @@ android {
5656
buildConfigField "String", "META_WIKI_BASE_URI", '"https://meta.wikimedia.org"'
5757
buildConfigField "String", "EVENTGATE_ANALYTICS_EXTERNAL_BASE_URI", '"https://intake-analytics.wikimedia.org"'
5858
buildConfigField "String", "EVENTGATE_LOGGING_EXTERNAL_BASE_URI", '"https://intake-logging.wikimedia.org"'
59+
def TEST_LOGIN_USERNAME = System.getenv('TEST_LOGIN_USERNAME')
60+
def TEST_LOGIN_PASSWORD = System.getenv('TEST_LOGIN_PASSWORD')
61+
buildConfigField "String", "TEST_LOGIN_USERNAME", TEST_LOGIN_USERNAME != null ? "\"${TEST_LOGIN_USERNAME}\"" : '"Foo"'
62+
buildConfigField "String", "TEST_LOGIN_PASSWORD", TEST_LOGIN_PASSWORD != null ? "\"${TEST_LOGIN_PASSWORD}\"" : '"Bar"'
5963
}
6064

6165
testOptions {
@@ -110,11 +114,6 @@ android {
110114
buildConfigField "String", "META_WIKI_BASE_URI", '"https://meta.wikimedia.beta.wmflabs.org"'
111115
buildConfigField "String", "EVENTGATE_ANALYTICS_EXTERNAL_BASE_URI", '"https://intake-analytics.wikimedia.beta.wmflabs.org"'
112116
buildConfigField "String", "EVENTGATE_LOGGING_EXTERNAL_BASE_URI", '"https://intake-logging.wikimedia.beta.wmflabs.org"'
113-
114-
def TEST_LOGIN_USERNAME = System.getenv('TEST_LOGIN_USERNAME')
115-
def TEST_LOGIN_PASSWORD = System.getenv('TEST_LOGIN_PASSWORD')
116-
buildConfigField "String", "TEST_LOGIN_USERNAME", TEST_LOGIN_USERNAME != null ? "\"${TEST_LOGIN_USERNAME}\"" : '"Foo"'
117-
buildConfigField "String", "TEST_LOGIN_PASSWORD", TEST_LOGIN_PASSWORD != null ? "\"${TEST_LOGIN_PASSWORD}\"" : '"Bar"'
118117
}
119118
prod {
120119
versionName computeVersionName(defaultConfig.versionCode, 'r')
@@ -172,15 +171,16 @@ dependencies {
172171

173172
String okHttpVersion = '4.10.0'
174173
String retrofitVersion = '2.9.0'
175-
String glideVersion = '4.13.2'
174+
String glideVersion = '4.15.1'
176175
String mockitoVersion = '5.2.0'
177-
String leakCanaryVersion = '2.10'
178-
String kotlinCoroutinesVersion = '1.3.9'
176+
String leakCanaryVersion = '2.11'
177+
String kotlinCoroutinesVersion = '1.7.1'
179178
String firebaseMessagingVersion = '23.1.2'
180179
String mlKitVersion = '17.0.4'
181180
String roomVersion = "2.5.1"
182181
String espressoVersion = '3.5.1'
183-
String serialization_version = '1.4.0'
182+
String serialization_version = '1.5.1'
183+
String metricsVersion = '1.12'
184184

185185
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
186186

@@ -204,6 +204,7 @@ dependencies {
204204
implementation 'com.android.installreferrer:installreferrer:2.2'
205205
implementation 'androidx.drawerlayout:drawerlayout:1.2.0'
206206
implementation 'androidx.work:work-runtime-ktx:2.8.1'
207+
implementation "org.wikimedia.metrics:metrics-platform:$metricsVersion"
207208

208209
implementation ('com.github.michael-rapp:chrome-like-tab-switcher:0.4.6') {
209210
exclude group: 'org.jetbrains'
@@ -219,10 +220,10 @@ dependencies {
219220
implementation "io.reactivex.rxjava3:rxjava:3.1.6"
220221
implementation "io.reactivex.rxjava3:rxandroid:3.0.2"
221222
implementation 'org.apache.commons:commons-lang3:3.12.0'
222-
implementation 'org.jsoup:jsoup:1.15.4'
223+
implementation 'org.jsoup:jsoup:1.16.1'
223224
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
224-
implementation "com.github.skydoves:balloon:1.3.4"
225-
implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0"
225+
implementation "com.github.skydoves:balloon:1.5.3"
226+
implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0"
226227

227228
implementation("androidx.room:room-runtime:$roomVersion")
228229
annotationProcessor "androidx.room:room-compiler:$roomVersion"
@@ -249,7 +250,7 @@ dependencies {
249250

250251
testImplementation 'junit:junit:4.13.2'
251252
testImplementation "org.mockito:mockito-inline:$mockitoVersion"
252-
testImplementation 'org.robolectric:robolectric:4.9.2'
253+
testImplementation 'org.robolectric:robolectric:4.10.3'
253254
testImplementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
254255
testImplementation "com.squareup.okhttp3:mockwebserver:$okHttpVersion"
255256
testImplementation 'org.hamcrest:hamcrest:2.2'

app/proguard-rules.pro

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@
4141
}
4242
-keepclasseswithmembers class org.wikipedia.** {
4343
kotlinx.serialization.KSerializer serializer(...);
44-
}
44+
}
45+
46+
# --- Metrics Platform ---
47+
-dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings
48+
-dontwarn java.beans.ConstructorProperties
49+
-dontwarn lombok.Generated
50+
# --- /Metrics Platform ---

app/src/androidTest/java/org/wikipedia/main/LoggedInTests.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.hamcrest.Matchers.allOf
1212
import org.junit.Rule
1313
import org.junit.Test
1414
import org.junit.runner.RunWith
15+
import org.wikipedia.BuildConfig
1516
import org.wikipedia.R
1617
import org.wikipedia.TestUtil
1718

@@ -52,10 +53,10 @@ class LoggedInTests {
5253

5354
// Type in an incorrect username and password
5455
onView(allOf(TestUtil.withGrandparent(withId(R.id.login_username_text)), withClassName(`is`("org.wikipedia.views.PlainPasteEditText"))))
55-
.perform(replaceText("Foo"), closeSoftKeyboard())
56+
.perform(replaceText(BuildConfig.TEST_LOGIN_USERNAME), closeSoftKeyboard())
5657

5758
onView(allOf(TestUtil.withGrandparent(withId(R.id.login_password_input)), withClassName(`is`("org.wikipedia.views.PlainPasteEditText"))))
58-
.perform(replaceText("Bar"), closeSoftKeyboard())
59+
.perform(replaceText(BuildConfig.TEST_LOGIN_PASSWORD), closeSoftKeyboard())
5960

6061
// Click the login button
6162
onView(withId(R.id.login_button))

app/src/androidTest/java/org/wikipedia/main/SmokeTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class SmokeTests {
477477
TestUtil.delay(1)
478478

479479
// Go to Saved tab
480-
onView(withId(NavTab.READING_LISTS.id())).perform(click())
480+
onView(withId(NavTab.READING_LISTS.id)).perform(click())
481481

482482
TestUtil.delay(1)
483483

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@
305305
<activity
306306
android:name=".diff.ArticleEditDetailsActivity" />
307307

308+
<activity
309+
android:name=".activity.SingleWebViewActivity"
310+
android:theme="@style/AppTheme.ActionBar" />
311+
308312
<activity
309313
android:name=".page.customize.CustomizeToolbarActivity"
310314
android:label="@string/customize_toolbar_title"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ object Constants {
2121
const val ACTIVITY_REQUEST_VOICE_SEARCH = 45
2222
const val ACTIVITY_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 44
2323

24+
const val ARG_TITLE = "title"
25+
const val ARG_WIKISITE = "wikiSite"
2426
const val INTENT_APP_SHORTCUT_CONTINUE_READING = "appShortcutContinueReading"
2527
const val INTENT_APP_SHORTCUT_RANDOMIZER = "appShortcutRandomizer"
2628
const val INTENT_APP_SHORTCUT_SEARCH = "appShortcutSearch"

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class WikipediaApp : Application() {
150150

151151
WikiSite.setDefaultBaseUrl(Prefs.mediaWikiBaseUrl)
152152

153-
connectionStateMonitor.enable(this)
153+
connectionStateMonitor.enable()
154154

155155
setupLeakCanary()
156156

@@ -187,8 +187,10 @@ class WikipediaApp : Application() {
187187
*/
188188
fun getAcceptLanguage(wiki: WikiSite?): String {
189189
val wikiLang = if (wiki == null || "meta" == wiki.languageCode) "" else wiki.languageCode
190-
return AcceptLanguageUtil.getAcceptLanguage(wikiLang, languageState.appLanguageCode,
191-
languageState.systemLanguageCode)
190+
return AcceptLanguageUtil.getAcceptLanguage(
191+
languageState.getBcp47LanguageCode(wikiLang),
192+
languageState.getBcp47LanguageCode(languageState.appLanguageCode),
193+
languageState.getBcp47LanguageCode(languageState.systemLanguageCode))
192194
}
193195

194196
fun constrainFontSizeMultiplier(mult: Int): Int {
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package org.wikipedia.activity
2+
3+
import android.annotation.SuppressLint
4+
import android.content.Context
5+
import android.content.Intent
6+
import android.graphics.Bitmap
7+
import android.os.Bundle
8+
import android.view.ViewGroup
9+
import android.webkit.WebView
10+
import androidx.core.view.isVisible
11+
import org.wikipedia.WikipediaApp
12+
import org.wikipedia.databinding.ActivitySingleWebViewBinding
13+
import org.wikipedia.dataclient.WikiSite
14+
import org.wikipedia.dataclient.okhttp.OkHttpWebViewClient
15+
import org.wikipedia.page.LinkHandler
16+
import org.wikipedia.page.PageTitle
17+
import org.wikipedia.page.PageViewModel
18+
19+
class SingleWebViewActivity : BaseActivity() {
20+
private lateinit var binding: ActivitySingleWebViewBinding
21+
private lateinit var blankLinkHandler: LinkHandler
22+
private lateinit var targetUrl: String
23+
val blankModel = PageViewModel()
24+
25+
@SuppressLint("SetJavaScriptEnabled")
26+
public override fun onCreate(savedInstanceState: Bundle?) {
27+
super.onCreate(savedInstanceState)
28+
binding = ActivitySingleWebViewBinding.inflate(layoutInflater)
29+
setContentView(binding.root)
30+
31+
supportActionBar?.title = ""
32+
33+
targetUrl = intent.getStringExtra(EXTRA_URL)!!
34+
blankLinkHandler = EditLinkHandler(this, WikipediaApp.instance.wikiSite)
35+
36+
binding.webView.settings.javaScriptEnabled = true
37+
binding.webView.settings.mediaPlaybackRequiresUserGesture = false
38+
binding.webView.webViewClient = object : OkHttpWebViewClient() {
39+
override val model get() = blankModel
40+
override val linkHandler get() = blankLinkHandler
41+
42+
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
43+
super.onPageStarted(view, url, favicon)
44+
binding.progressBar.isVisible = true
45+
}
46+
47+
override fun onPageFinished(view: WebView?, url: String?) {
48+
super.onPageFinished(view, url)
49+
binding.progressBar.isVisible = false
50+
}
51+
}
52+
53+
if (savedInstanceState == null) {
54+
binding.webView.loadUrl(targetUrl)
55+
}
56+
}
57+
58+
override fun onDestroy() {
59+
binding.webView.clearAllListeners()
60+
(binding.webView.parent as ViewGroup).removeView(binding.webView)
61+
super.onDestroy()
62+
}
63+
64+
override fun onBackPressed() {
65+
if (binding.webView.canGoBack()) {
66+
binding.webView.goBack()
67+
return
68+
}
69+
super.onBackPressed()
70+
}
71+
72+
inner class EditLinkHandler constructor(context: Context, override var wikiSite: WikiSite) : LinkHandler(context) {
73+
override fun onPageLinkClicked(anchor: String, linkText: String) { }
74+
override fun onInternalLinkClicked(title: PageTitle) { }
75+
override fun onMediaLinkClicked(title: PageTitle) { }
76+
override fun onDiffLinkClicked(title: PageTitle, revisionId: Long) { }
77+
}
78+
79+
companion object {
80+
const val EXTRA_URL = "url"
81+
82+
fun newIntent(context: Context, url: String): Intent {
83+
return Intent(context, SingleWebViewActivity::class.java)
84+
.putExtra(EXTRA_URL, url)
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)