Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
Update dependencies and set up Jetpack Compose.
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo committed Jul 27, 2021
1 parent 99821fd commit 6caa946
Show file tree
Hide file tree
Showing 21 changed files with 150 additions and 115 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-contributor-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: "Clean & Assemble Debug"
uses: eskatos/gradle-command-action@v1
with:
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: "Test Debug Unit Tests"
uses: eskatos/gradle-command-action@v1
with:
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: "Detekt"
uses: eskatos/gradle-command-action@v1
with:
Expand All @@ -72,7 +72,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: "Ktlint"
uses: eskatos/gradle-command-action@v1
with:
Expand All @@ -91,7 +91,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: "Lint Debug"
uses: eskatos/gradle-command-action@v1
with:
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
arch: x86_64
profile: pixel_2
script:
"./gradlew connectedFocusDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=\
"JAVA_HOME=$JAVA_HOME_11_X64 && ./gradlew connectedFocusDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=\
org.mozilla.focus.activity.ThreeDotMainMenuTest#browserMenuItemsTest"
- name: Upload Test Artifacts
uses: actions/upload-artifact@v2
Expand Down
8 changes: 4 additions & 4 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tasks:
routes: []
payload:
maxRunTime: 7200
image: mozillamobile/focus-android:1.6
image: mozillamobile/focus-android:1.7
command:
- /bin/bash
- --login
Expand Down Expand Up @@ -81,7 +81,7 @@ tasks:
- 'assume:repo:github.com/mozilla-mobile/focus-android:branch:${short_head_branch}'
payload:
maxRunTime: 7200
image: mozillamobile/focus-android:1.6
image: mozillamobile/focus-android:1.7
features:
taskclusterProxy: true
env:
Expand Down Expand Up @@ -143,7 +143,7 @@ tasks:
- statuses # Automatically added by taskcluster-github. It must be explicit because of Chain of Trust
payload:
maxRunTime: 600 # Decision should remain fast enough to schedule a handful of tasks
image: mozillamobile/focus-android:1.6
image: mozillamobile/focus-android:1.7
features:
taskclusterProxy: true
chainOfTrust: true
Expand Down Expand Up @@ -218,7 +218,7 @@ tasks:
- statuses # Automatically added by taskcluster-github. It must be explicit because of Chain of Trust
payload:
maxRunTime: 600 # Decision should remain fast enough to schedule a handful of tasks
image: mozillamobile/focus-android:1.6
image: mozillamobile/focus-android:1.7
features:
taskclusterProxy: true
chainOfTrust: true
Expand Down
30 changes: 19 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ apply from: "$project.rootDir/tools/gradle/versionCode.gradle"
import com.android.build.OutputFile

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
applicationId "org.mozilla"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode 11 // This versionCode is "frozen" for local builds. For "release" builds we
// override this with a generated versionCode at build time.
versionName "8.13.1"
Expand All @@ -30,10 +30,6 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

dexOptions {
preDexLibraries true
}

lintOptions {
lintConfig file("lint.xml")
}
Expand Down Expand Up @@ -66,6 +62,14 @@ android {
}
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion = Versions.compose_version
}

flavorDimensions "product"

productFlavors {
Expand Down Expand Up @@ -156,6 +160,10 @@ dependencies {
implementation Dependencies.androidx_appcompat
implementation Dependencies.androidx_browser
implementation Dependencies.androidx_cardview
implementation Dependencies.androidx_compose_ui
implementation Dependencies.androidx_compose_ui_tooling
implementation Dependencies.androidx_compose_foundation
implementation Dependencies.androidx_compose_material
implementation Dependencies.androidx_core_ktx
implementation Dependencies.androidx_lifecycle_extensions
implementation Dependencies.androidx_palette
Expand Down Expand Up @@ -199,8 +207,8 @@ dependencies {

implementation project(':service-telemetry')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${coroutines_version}"
implementation Dependencies.kotlin_stdlib
implementation Dependencies.kotlin_coroutines

focusImplementation 'com.adjust.sdk:adjust-android:4.11.4'
focusImplementation 'com.android.installreferrer:installreferrer:1.1' // Required by Adjust
Expand All @@ -214,8 +222,8 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-params:5.3.1"
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.3.1"
testImplementation "org.robolectric:robolectric:4.4" // required to support api level 28
testImplementation "org.mockito:mockito-core:3.11.0"
testImplementation Dependencies.testing_robolectric
testImplementation Dependencies.testing_mockito
testImplementation Dependencies.androidx_arch_core_testing

androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version", {
Expand Down Expand Up @@ -256,7 +264,7 @@ android.applicationVariants.all { variant ->

println("----------------------------------------------")
println("Variant name: " + variant.name)
println("Application ID: " + [variant.mergedFlavor.applicationId, variant.buildType.applicationIdSuffix].findAll().join())
println("Application ID: " + [variant.applicationId, variant.buildType.applicationIdSuffix].findAll().join())
println("Build type: " + variant.buildType.name)
println("Flavor: " + variant.flavorName)

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/mozilla/focus/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package org.mozilla.focus
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import mozilla.components.browser.state.engine.EngineMiddleware
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.DefaultSettings
Expand Down Expand Up @@ -43,6 +45,7 @@ import org.mozilla.focus.engine.ClientWrapper
import org.mozilla.focus.engine.LocalizedContentInterceptor
import org.mozilla.focus.engine.SanityCheckMiddleware
import org.mozilla.focus.exceptions.ExceptionMigrationMiddleware
import org.mozilla.focus.ext.components
import org.mozilla.focus.locale.LocaleManager
import org.mozilla.focus.notification.PrivateNotificationMiddleware
import org.mozilla.focus.search.SearchFilterMiddleware
Expand Down Expand Up @@ -225,3 +228,10 @@ private fun getLocaleTag(context: Context): String {
Locale.getDefault().toLanguageTag()
}
}

/**
* Returns the [Components] object from within a [Composable].
*/
val components: Components
@Composable
get() = LocalContext.current.components
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CustomTabActivity : LocaleAwareAppCompatActivity() {

this.customTabId = customTabId

@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/5016
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

setContentView(R.layout.activity_customtab)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ open class MainActivity : LocaleAwareAppCompatActivity() {
}
}

@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/5016
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

setContentView(R.layout.activity_main)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AutocompleteAddFragment : BaseSettingsLikeFragment(), CoroutineScope {

val domain = domainView.text.toString()
.trim()
.toLowerCase()
.lowercase()

launch(IO) {
val domains = CustomDomains.load(requireActivity())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class FullScreenIntegration(
private fun switchToImmersiveMode() {
val window = activity.window
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/5016
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
Expand All @@ -90,6 +91,7 @@ class FullScreenIntegration(

val window = activity.window
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@Suppress("DEPRECATION") // https://github.com/mozilla-mobile/focus-android/issues/5016
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/org/mozilla/focus/ext/String.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ fun String.beautifyUrl(): String {
*/
fun String.removePrefixesIgnoreCase(vararg prefixes: String): String {
var value = this
var lower = this.toLowerCase()
var lower = this.lowercase()

prefixes.forEach {
if (lower.startsWith(it.toLowerCase())) {
if (lower.startsWith(it.lowercase())) {
value = value.substring(it.length)
lower = lower.substring(it.length)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FirstrunPagerAdapter(
if (position == pages.size - 1) {
buttonView.setText(R.string.firstrun_close_button)
buttonView.id = R.id.finish
buttonView.contentDescription = buttonView.text.toString().toLowerCase()
buttonView.contentDescription = buttonView.text.toString().lowercase()
} else {
buttonView.setText(R.string.firstrun_next_button)
buttonView.id = R.id.next
Expand Down
Loading

0 comments on commit 6caa946

Please sign in to comment.