This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
// Wait up to 2 seconds for the element be displayed on screen | |
val networkAndInternet = device.wait(Until.findObject(By.text("Network & internet")), 2000) | |
networkAndInternet.click() | |
// Click on element with text "Wi‑Fi" | |
val wifi = device.wait(Until.findObject(By.text("Wi‑Fi")), 2000) | |
wifi.click() | |
// Click on element with text "Add network" | |
val addNetwork = device.wait(Until.findObject(By.text("Add network")), 2000) | |
addNetwork.click() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
// Obtain an instance of UiObject2 of the text field | |
val ssidField = device.wait(Until.findObject(By.res("com.android.settings:id/ssid")), 2000) | |
// Call the setText method using Kotlin's property access syntax | |
val ssid = "AndroidWifi" | |
ssidField.text = ssid | |
//Click on Save button | |
device.findObject(By.res("android:id/button1").text("Save")).click() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun validateWifi() { | |
// Open apps list by scrolling on home screen | |
val workspace = device.findObject( | |
By.res("com.google.android.apps.nexuslauncher:id/workspace") | |
) | |
workspace.scroll(Direction.DOWN, 1.0f) | |
// Click on Settings icon to launch the app | |
val settings = device.findObject( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sourceSets { | |
androidTest { | |
java.srcDir 'src/main/java' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'com.android.application' | |
id 'kotlin-android' | |
} | |
android { | |
compileSdkPreview "android-Tiramisu" | |
defaultConfig { | |
applicationId "com.paceli.sampleperapplanguage" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<TextView | |
android:layout_width="wrap_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun initLocalePicker() { | |
val systemLocale = getString(R.string.system_locale) | |
val spinner: Spinner = findViewById(R.id.localePicker) | |
val locales = listOf(systemLocale, "en-US", "es-ES", "iw-IL", "ja-JP", "uk-UA") | |
spinner.adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, locales) | |
spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { | |
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { | |
val selectedLocale = spinner.adapter.getItem(position) as String | |
if (selectedLocale != systemLocale) { | |
updateAppLocales(Locale.forLanguageTag(selectedLocale)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun updateAppLocales(vararg locales: Locale) { | |
val localeManager = getSystemService(LocaleManager::class.java) | |
localeManager.applicationLocales = LocaleList(*locales) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun updateActivityTitle() { | |
val localeManager = getSystemService(LocaleManager::class.java) | |
val appLocales = localeManager.applicationLocales | |
title = if (appLocales.isEmpty) { | |
getString(R.string.system_locale) | |
} else { | |
appLocales.get(0).displayName | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.paceli.sampleperapplanguage | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.view.View | |
import android.widget.AdapterView | |
import android.widget.ArrayAdapter | |
import android.widget.Spinner | |
import android.app.LocaleManager | |
import android.os.Build |
OlderNewer