Skip to content

Commit

Permalink
Merge branch 'main' into Notification_time_ago
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne authored Jul 26, 2023
2 parents 5a956d2 + 6f779e8 commit c795ea7
Show file tree
Hide file tree
Showing 258 changed files with 9,236 additions and 2,316 deletions.
29 changes: 15 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
applicationId 'org.wikipedia'
minSdkVersion 21
targetSdkVersion 33
versionCode 50444
versionCode 50448
testApplicationId 'org.wikipedia.test'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
Expand All @@ -56,6 +56,10 @@ android {
buildConfigField "String", "META_WIKI_BASE_URI", '"https://meta.wikimedia.org"'
buildConfigField "String", "EVENTGATE_ANALYTICS_EXTERNAL_BASE_URI", '"https://intake-analytics.wikimedia.org"'
buildConfigField "String", "EVENTGATE_LOGGING_EXTERNAL_BASE_URI", '"https://intake-logging.wikimedia.org"'
def TEST_LOGIN_USERNAME = System.getenv('TEST_LOGIN_USERNAME')
def TEST_LOGIN_PASSWORD = System.getenv('TEST_LOGIN_PASSWORD')
buildConfigField "String", "TEST_LOGIN_USERNAME", TEST_LOGIN_USERNAME != null ? "\"${TEST_LOGIN_USERNAME}\"" : '"Foo"'
buildConfigField "String", "TEST_LOGIN_PASSWORD", TEST_LOGIN_PASSWORD != null ? "\"${TEST_LOGIN_PASSWORD}\"" : '"Bar"'
}

testOptions {
Expand Down Expand Up @@ -110,11 +114,6 @@ android {
buildConfigField "String", "META_WIKI_BASE_URI", '"https://meta.wikimedia.beta.wmflabs.org"'
buildConfigField "String", "EVENTGATE_ANALYTICS_EXTERNAL_BASE_URI", '"https://intake-analytics.wikimedia.beta.wmflabs.org"'
buildConfigField "String", "EVENTGATE_LOGGING_EXTERNAL_BASE_URI", '"https://intake-logging.wikimedia.beta.wmflabs.org"'

def TEST_LOGIN_USERNAME = System.getenv('TEST_LOGIN_USERNAME')
def TEST_LOGIN_PASSWORD = System.getenv('TEST_LOGIN_PASSWORD')
buildConfigField "String", "TEST_LOGIN_USERNAME", TEST_LOGIN_USERNAME != null ? "\"${TEST_LOGIN_USERNAME}\"" : '"Foo"'
buildConfigField "String", "TEST_LOGIN_PASSWORD", TEST_LOGIN_PASSWORD != null ? "\"${TEST_LOGIN_PASSWORD}\"" : '"Bar"'
}
prod {
versionName computeVersionName(defaultConfig.versionCode, 'r')
Expand Down Expand Up @@ -172,15 +171,16 @@ dependencies {

String okHttpVersion = '4.10.0'
String retrofitVersion = '2.9.0'
String glideVersion = '4.13.2'
String glideVersion = '4.15.1'
String mockitoVersion = '5.2.0'
String leakCanaryVersion = '2.10'
String kotlinCoroutinesVersion = '1.3.9'
String leakCanaryVersion = '2.11'
String kotlinCoroutinesVersion = '1.7.1'
String firebaseMessagingVersion = '23.1.2'
String mlKitVersion = '17.0.4'
String roomVersion = "2.5.1"
String espressoVersion = '3.5.1'
String serialization_version = '1.4.0'
String serialization_version = '1.5.1'
String metricsVersion = '1.12'

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

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

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

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

testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:$mockitoVersion"
testImplementation 'org.robolectric:robolectric:4.9.2'
testImplementation 'org.robolectric:robolectric:4.10.3'
testImplementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
testImplementation "com.squareup.okhttp3:mockwebserver:$okHttpVersion"
testImplementation 'org.hamcrest:hamcrest:2.2'
Expand Down
8 changes: 7 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@
}
-keepclasseswithmembers class org.wikipedia.** {
kotlinx.serialization.KSerializer serializer(...);
}
}

# --- Metrics Platform ---
-dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings
-dontwarn java.beans.ConstructorProperties
-dontwarn lombok.Generated
# --- /Metrics Platform ---
5 changes: 3 additions & 2 deletions app/src/androidTest/java/org/wikipedia/main/LoggedInTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.hamcrest.Matchers.allOf
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.wikipedia.BuildConfig
import org.wikipedia.R
import org.wikipedia.TestUtil

Expand Down Expand Up @@ -52,10 +53,10 @@ class LoggedInTests {

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

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

// Click the login button
onView(withId(R.id.login_button))
Expand Down
2 changes: 1 addition & 1 deletion app/src/androidTest/java/org/wikipedia/main/SmokeTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ class SmokeTests {
TestUtil.delay(1)

// Go to Saved tab
onView(withId(NavTab.READING_LISTS.id())).perform(click())
onView(withId(NavTab.READING_LISTS.id)).perform(click())

TestUtil.delay(1)

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@
<activity
android:name=".diff.ArticleEditDetailsActivity" />

<activity
android:name=".activity.SingleWebViewActivity"
android:theme="@style/AppTheme.ActionBar" />

<activity
android:name=".page.customize.CustomizeToolbarActivity"
android:label="@string/customize_toolbar_title"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/wikipedia/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ object Constants {
const val ACTIVITY_REQUEST_VOICE_SEARCH = 45
const val ACTIVITY_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 44

const val ARG_TITLE = "title"
const val ARG_WIKISITE = "wikiSite"
const val INTENT_APP_SHORTCUT_CONTINUE_READING = "appShortcutContinueReading"
const val INTENT_APP_SHORTCUT_RANDOMIZER = "appShortcutRandomizer"
const val INTENT_APP_SHORTCUT_SEARCH = "appShortcutSearch"
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/java/org/wikipedia/WikipediaApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class WikipediaApp : Application() {

WikiSite.setDefaultBaseUrl(Prefs.mediaWikiBaseUrl)

connectionStateMonitor.enable(this)
connectionStateMonitor.enable()

setupLeakCanary()

Expand Down Expand Up @@ -187,8 +187,10 @@ class WikipediaApp : Application() {
*/
fun getAcceptLanguage(wiki: WikiSite?): String {
val wikiLang = if (wiki == null || "meta" == wiki.languageCode) "" else wiki.languageCode
return AcceptLanguageUtil.getAcceptLanguage(wikiLang, languageState.appLanguageCode,
languageState.systemLanguageCode)
return AcceptLanguageUtil.getAcceptLanguage(
languageState.getBcp47LanguageCode(wikiLang),
languageState.getBcp47LanguageCode(languageState.appLanguageCode),
languageState.getBcp47LanguageCode(languageState.systemLanguageCode))
}

fun constrainFontSizeMultiplier(mult: Int): Int {
Expand Down
87 changes: 87 additions & 0 deletions app/src/main/java/org/wikipedia/activity/SingleWebViewActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.wikipedia.activity

import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle
import android.view.ViewGroup
import android.webkit.WebView
import androidx.core.view.isVisible
import org.wikipedia.WikipediaApp
import org.wikipedia.databinding.ActivitySingleWebViewBinding
import org.wikipedia.dataclient.WikiSite
import org.wikipedia.dataclient.okhttp.OkHttpWebViewClient
import org.wikipedia.page.LinkHandler
import org.wikipedia.page.PageTitle
import org.wikipedia.page.PageViewModel

class SingleWebViewActivity : BaseActivity() {
private lateinit var binding: ActivitySingleWebViewBinding
private lateinit var blankLinkHandler: LinkHandler
private lateinit var targetUrl: String
val blankModel = PageViewModel()

@SuppressLint("SetJavaScriptEnabled")
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySingleWebViewBinding.inflate(layoutInflater)
setContentView(binding.root)

supportActionBar?.title = ""

targetUrl = intent.getStringExtra(EXTRA_URL)!!
blankLinkHandler = EditLinkHandler(this, WikipediaApp.instance.wikiSite)

binding.webView.settings.javaScriptEnabled = true
binding.webView.settings.mediaPlaybackRequiresUserGesture = false
binding.webView.webViewClient = object : OkHttpWebViewClient() {
override val model get() = blankModel
override val linkHandler get() = blankLinkHandler

override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
binding.progressBar.isVisible = true
}

override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
binding.progressBar.isVisible = false
}
}

if (savedInstanceState == null) {
binding.webView.loadUrl(targetUrl)
}
}

override fun onDestroy() {
binding.webView.clearAllListeners()
(binding.webView.parent as ViewGroup).removeView(binding.webView)
super.onDestroy()
}

override fun onBackPressed() {
if (binding.webView.canGoBack()) {
binding.webView.goBack()
return
}
super.onBackPressed()
}

inner class EditLinkHandler constructor(context: Context, override var wikiSite: WikiSite) : LinkHandler(context) {
override fun onPageLinkClicked(anchor: String, linkText: String) { }
override fun onInternalLinkClicked(title: PageTitle) { }
override fun onMediaLinkClicked(title: PageTitle) { }
override fun onDiffLinkClicked(title: PageTitle, revisionId: Long) { }
}

companion object {
const val EXTRA_URL = "url"

fun newIntent(context: Context, url: String): Intent {
return Intent(context, SingleWebViewActivity::class.java)
.putExtra(EXTRA_URL, url)
}
}
}
Loading

0 comments on commit c795ea7

Please sign in to comment.