Skip to content

Commit 215d16e

Browse files
authored
Merge pull request #9 from SmartWalkieOrg/develop
Merge develop to master
2 parents 71d546a + 67c9345 commit 215d16e

File tree

14 files changed

+115
-42
lines changed

14 files changed

+115
-42
lines changed

app/build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@ android {
1919
minSdkVersion 16
2020
targetSdkVersion 30
2121
versionCode 1
22-
versionName "1.0"
22+
versionName "1.1"
2323
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
2424
setProperty("archivesBaseName", "vpdemo-$versionName-$versionCode-${getGitHash()}")
2525
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
2626
}
27+
signingConfigs {
28+
development {
29+
storeFile file("development.keystore")
30+
storePassword "voicepingdemo"
31+
keyAlias "voicepingdemo"
32+
keyPassword "voicepingdemo"
33+
}
34+
}
2735
buildTypes {
2836
release {
37+
// Uncomment the following code to sign a development release build
38+
//signingConfig signingConfigs.development
2939
minifyEnabled false
3040
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3141
}

app/development.keystore

2.47 KB
Binary file not shown.

app/src/main/java/com/smartwalkie/voicepingdemo/LoginActivity.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class LoginActivity : AppCompatActivity(), PermissionCallbacks {
2323
super.onCreate(savedInstanceState)
2424
binding = ActivityLoginBinding.inflate(layoutInflater)
2525
setContentView(binding.root)
26-
initToolbar()
26+
supportActionBar?.title = getString(R.string.app_name)
27+
binding.editServerUrl.setText(MyPrefs.serverUrl ?: "")
2728
binding.buttonConnect.setOnClickListener {
2829
EasyPermissions.requestPermissions(
2930
this@LoginActivity,
@@ -34,16 +35,12 @@ class LoginActivity : AppCompatActivity(), PermissionCallbacks {
3435
}
3536
}
3637

37-
private fun initToolbar() {
38-
supportActionBar?.title = getString(R.string.app_name)
39-
supportActionBar?.subtitle = "Server: " + VoicePingClientApp.SERVER_URL
40-
}
41-
4238
override fun onStart() {
4339
super.onStart()
4440
val userId = MyPrefs.userId ?: ""
4541
val company = MyPrefs.company ?: ""
46-
if (userId.isNotBlank() && company.isNotBlank()) {
42+
val serverUrl = MyPrefs.serverUrl ?: ""
43+
if (userId.isNotBlank() && company.isNotBlank() && serverUrl.isNotBlank()) {
4744
startActivity(Intent(this, MainActivity::class.java))
4845
finish()
4946
}
@@ -74,10 +71,12 @@ class LoginActivity : AppCompatActivity(), PermissionCallbacks {
7471
// Reset errors.
7572
binding.editUserId.error = null
7673
binding.editCompany.error = null
74+
binding.editServerUrl.error = null
7775

7876
// Store values at the time of the connect attempt.
7977
val userId = binding.editUserId.text.toString().trim { it <= ' ' }
8078
val company = binding.editCompany.text.toString().trim { it <= ' ' }
79+
val serverUrl = binding.editServerUrl.text.toString().trim { it <= ' ' }
8180

8281
when {
8382
userId.isEmpty() -> {
@@ -88,16 +87,21 @@ class LoginActivity : AppCompatActivity(), PermissionCallbacks {
8887
binding.editCompany.error = getString(R.string.cannot_be_blank)
8988
binding.editCompany.requestFocus()
9089
}
90+
serverUrl.isEmpty() -> {
91+
binding.editServerUrl.error = getString(R.string.cannot_be_blank)
92+
binding.editServerUrl.requestFocus()
93+
}
9194
else -> {
9295
// Show a progress spinner, and kick off a background task to perform the user connect attempt.
9396
Utils.closeKeyboard(this, currentFocus)
9497
showProgress(true)
95-
VoicePing.connect(userId, company, object : ConnectCallback {
98+
VoicePing.connect(serverUrl, userId, company, object : ConnectCallback {
9699
override fun onConnected() {
97100
Log.v(TAG, "onConnected")
98101
showProgress(false)
99102
MyPrefs.userId = userId
100103
MyPrefs.company = company
104+
MyPrefs.serverUrl = serverUrl
101105
startActivity(Intent(this@LoginActivity, MainActivity::class.java))
102106
finish()
103107
}

app/src/main/java/com/smartwalkie/voicepingdemo/MainActivity.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener,
3939

4040
val userId = MyPrefs.userId ?: ""
4141
val company = MyPrefs.company ?: ""
42-
if (userId.isBlank() || company.isBlank()) {
42+
val serverUrl = MyPrefs.serverUrl ?: ""
43+
if (userId.isBlank() || company.isBlank() || serverUrl.isBlank()) {
4344
finish()
4445
return
4546
}
4647
initToolbar(userId, company)
48+
binding.textServerUrl.text = serverUrl
4749
val channelTypes = arrayOf("GROUP", "PRIVATE")
4850
val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, channelTypes)
4951
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
@@ -83,7 +85,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener,
8385
updateConnectionState(VoicePing.getConnectionState())
8486
VoicePing.setConnectionStateListener(this)
8587
if (VoicePing.getConnectionState() == ConnectionState.DISCONNECTED) {
86-
VoicePing.connect(userId, company, object : ConnectCallback {
88+
VoicePing.connect(serverUrl, userId, company, object : ConnectCallback {
8789
override fun onConnected() {
8890
// Ignored
8991
}

app/src/main/java/com/smartwalkie/voicepingdemo/MyPrefs.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ object MyPrefs {
99

1010
private const val USER_ID = "user_id"
1111
private const val COMPANY = "company"
12+
private const val SERVER_URL = "server_url"
1213

1314
var userId: String?
1415
get() = sharedPrefs.getString(USER_ID, "")
@@ -22,6 +23,12 @@ object MyPrefs {
2223
sharedPrefs.edit().putString(COMPANY, value).apply()
2324
}
2425

26+
var serverUrl: String?
27+
get() = sharedPrefs.getString(SERVER_URL, "wss://router-lite.voiceping.info")
28+
set(value) {
29+
sharedPrefs.edit().putString(SERVER_URL, value).apply()
30+
}
31+
2532
fun clear() {
2633
sharedPrefs.edit().clear().apply()
2734
}

app/src/main/java/com/smartwalkie/voicepingdemo/VoicePingClientApp.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class VoicePingClientApp : Application() {
2020
.build()
2121
val audioSourceText = AudioSourceConfig.getAudioSourceText(audioParam.audioSource)
2222
Log.d(TAG, "Manufacturer: ${Build.MANUFACTURER}, audio source: $audioSourceText")
23-
VoicePing.init(this, SERVER_URL, audioParam)
23+
VoicePing.init(this, audioParam)
2424
}
2525

2626
companion object {
27-
const val SERVER_URL: String = "wss://router-lite.voiceping.info"
2827
lateinit var context: Context
2928
}
3029
}

app/src/main/res/layout/activity_login.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@
4444

4545
</com.google.android.material.textfield.TextInputLayout>
4646

47+
<com.google.android.material.textfield.TextInputLayout
48+
android:layout_width="match_parent"
49+
android:layout_height="wrap_content">
50+
51+
<EditText
52+
android:id="@+id/edit_server_url"
53+
android:layout_width="match_parent"
54+
android:layout_height="wrap_content"
55+
android:hint="@string/server_url"
56+
android:maxLines="1" />
57+
58+
</com.google.android.material.textfield.TextInputLayout>
59+
4760
<TextView
4861
android:layout_width="wrap_content"
4962
android:layout_height="wrap_content"

app/src/main/res/layout/activity_main.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99
android:orientation="vertical"
1010
android:padding="16dp">
1111

12+
<TextView
13+
style="@style/InputLabel"
14+
android:layout_width="match_parent"
15+
android:layout_height="wrap_content"
16+
android:text="Server URL" />
17+
18+
<TextView
19+
android:id="@+id/text_server_url"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
22+
android:layout_marginTop="4dp"
23+
android:layout_marginBottom="24dp"
24+
android:padding="4dp"
25+
android:text="Server URL"
26+
android:textColor="@color/black"
27+
android:textSize="16sp" />
28+
1229
<TextView
1330
style="@style/InputLabel"
1431
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<string name="user_id">User ID</string>
55
<string name="company">Company</string>
6+
<string name="server_url">Server URL</string>
67
<string name="caution_same_company">You can only talk to other users in the same company.</string>
78
<string name="sign_in">Enter</string>
89
<string name="failed_to_sign_in">Failed to enter, please try again later</string>

voiceping-sdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
minSdkVersion 16
1212
targetSdkVersion 30
1313
versionCode 1
14-
versionName "1.0.0"
14+
versionName "1.1.0"
1515
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1616
setProperty("archivesBaseName", "voiceping-sdk-$versionName")
1717
}

0 commit comments

Comments
 (0)