Skip to content

Commit 98b0ad1

Browse files
committed
Merge branch 'task/kotlin_conversion' into 'master'
Provisioning app code converted to Kotlin See merge request espressif/esp-idf-provisioning-android!82
2 parents 8db27ba + bfe6567 commit 98b0ad1

Some content is hidden

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

46 files changed

+2825
-3179
lines changed

app/build.gradle

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ def getGitHash = { ->
1212

1313
android {
1414

15-
compileSdkVersion 34
15+
compileSdkVersion 35
1616

1717
defaultConfig {
1818
applicationId "com.espressif.wifi_provisioning"
1919
minSdkVersion 26
2020
targetSdkVersion 35
21-
versionCode 27
22-
versionName "2.3.1 - ${getGitHash()}"
21+
versionCode 29
22+
versionName "2.4.0 - ${getGitHash()}"
2323
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2424
consumerProguardFiles "consumer-proguard-rules.pro"
2525
}
@@ -55,6 +55,15 @@ android {
5555
buildConfig = true
5656
}
5757

58+
compileOptions {
59+
sourceCompatibility JavaVersion.VERSION_17
60+
targetCompatibility JavaVersion.VERSION_17
61+
}
62+
63+
kotlinOptions {
64+
jvmTarget = "17"
65+
}
66+
5867
namespace 'com.espressif.wifi_provisioning'
5968
}
6069

app/src/main/java/com/espressif/AppConstants.java

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.espressif
16+
17+
object AppConstants {
18+
19+
// Keys used to pass data between activities and to store data in SharedPreference.
20+
const val KEY_WIFI_SECURITY_TYPE: String = "wifi_security"
21+
const val KEY_PROOF_OF_POSSESSION: String = "proof_of_possession"
22+
const val KEY_WIFI_DEVICE_NAME_PREFIX: String = "wifi_network_name_prefix"
23+
const val KEY_BLE_DEVICE_NAME_PREFIX: String = "ble_device_name_prefix"
24+
const val KEY_DEVICE_NAME: String = "device_name"
25+
const val KEY_STATUS_MSG: String = "status_msg"
26+
const val KEY_WIFI_SSID: String = "ssid"
27+
const val KEY_WIFI_PASSWORD: String = "password"
28+
const val KEY_DEVICE_TYPES: String = "device_types"
29+
const val KEY_SECURITY_TYPE: String = "security_type"
30+
const val KEY_USER_NAME_WIFI: String = "sec2_username_wifi"
31+
const val KEY_USER_NAME_THREAD: String = "sec2_username_thread"
32+
const val KEY_THREAD_DATASET: String = "thread_dataset"
33+
const val KEY_THREAD_SCAN_AVAILABLE: String = "thread_scan_available"
34+
35+
const val ESP_PREFERENCES: String = "Esp_Preferences"
36+
37+
const val DEVICE_TYPE_SOFTAP: String = "softap"
38+
const val DEVICE_TYPE_BLE: String = "ble"
39+
const val DEVICE_TYPE_BOTH: String = "both"
40+
const val DEVICE_TYPE_DEFAULT: String = DEVICE_TYPE_BOTH
41+
42+
const val SEC_TYPE_0: Int = 0
43+
const val SEC_TYPE_1: Int = 1
44+
const val SEC_TYPE_2: Int = 2
45+
const val SEC_TYPE_DEFAULT: Int = SEC_TYPE_2
46+
const val DEFAULT_USER_NAME_WIFI: String = "wifiprov"
47+
const val DEFAULT_USER_NAME_THREAD: String = "threadprov"
48+
49+
const val CAPABILITY_WIFI_SCAN: String = "wifi_scan"
50+
const val CAPABILITY_THREAD_SCAN: String = "thread_scan"
51+
const val CAPABILITY_THREAD_PROV: String = "thread_prov"
52+
}

app/src/main/java/com/espressif/ui/activities/AddDeviceActivity.kt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import android.view.View
3434
import android.widget.Toast
3535
import androidx.appcompat.app.AlertDialog
3636
import androidx.appcompat.app.AppCompatActivity
37+
import androidx.appcompat.content.res.AppCompatResources
3738
import androidx.camera.lifecycle.ProcessCameraProvider
3839
import androidx.core.app.ActivityCompat
3940
import androidx.core.content.ContextCompat
@@ -339,12 +340,6 @@ class AddDeviceActivity : AppCompatActivity() {
339340
}
340341
}
341342

342-
private val cancelBtnClickListener = View.OnClickListener {
343-
provisionManager.espDevice?.disconnectDevice()
344-
setResult(RESULT_CANCELED, intent)
345-
finish()
346-
}
347-
348343
private val btnGetPermissionClickListener = View.OnClickListener {
349344
buttonClicked = true
350345

@@ -523,11 +518,7 @@ class AddDeviceActivity : AppCompatActivity() {
523518
}
524519

525520
private fun initViews() {
526-
binding.titleBar.mainToolbarTitle.setText(R.string.title_activity_add_device)
527-
binding.titleBar.btnBack.visibility = View.GONE
528-
binding.titleBar.btnCancel.visibility = View.VISIBLE
529-
binding.titleBar.btnCancel.setOnClickListener(cancelBtnClickListener)
530-
521+
setToolbar()
531522
codeScanner = CodeScanner(this, binding.scannerView)
532523

533524
binding.btnAddDeviceManually.textBtn.setText(R.string.btn_no_qr_code)
@@ -551,6 +542,20 @@ class AddDeviceActivity : AppCompatActivity() {
551542
}
552543
}
553544

545+
private fun setToolbar() {
546+
setSupportActionBar(binding.titleBar.toolbar)
547+
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
548+
supportActionBar!!.setDisplayShowHomeEnabled(true)
549+
supportActionBar!!.setTitle(R.string.title_activity_add_device)
550+
binding.titleBar.toolbar.navigationIcon =
551+
AppCompatResources.getDrawable(this, R.drawable.ic_arrow_left)
552+
binding.titleBar.toolbar.setNavigationOnClickListener {
553+
provisionManager.espDevice?.disconnectDevice()
554+
setResult(RESULT_CANCELED, intent)
555+
finish()
556+
}
557+
}
558+
554559
private fun openCamera() {
555560

556561
val isPlayServicesAvailable = Utils.isPlayServicesAvailable(applicationContext)

0 commit comments

Comments
 (0)