diff --git a/android/app/src/main/java/com/metallic/chiaki/regist/RegistActivity.kt b/android/app/src/main/java/com/metallic/chiaki/regist/RegistActivity.kt
index 3b14852..a67e2cd 100644
--- a/android/app/src/main/java/com/metallic/chiaki/regist/RegistActivity.kt
+++ b/android/app/src/main/java/com/metallic/chiaki/regist/RegistActivity.kt
@@ -22,6 +22,8 @@ import android.os.Bundle
import android.view.View
import android.view.Window
import androidx.appcompat.app.AppCompatActivity
+import androidx.lifecycle.Observer
+import androidx.lifecycle.ViewModelProviders
import com.metallic.chiaki.R
import com.metallic.chiaki.common.ext.RevealActivity
import com.metallic.chiaki.lib.RegistInfo
@@ -41,16 +43,43 @@ class RegistActivity: AppCompatActivity(), RevealActivity
override val revealIntent: Intent get() = intent
override val revealRootLayout: View get() = rootLayout
+ private lateinit var viewModel: RegistViewModel
+
override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_regist)
handleReveal()
+ viewModel = ViewModelProviders.of(this).get(RegistViewModel::class.java)
+
hostEditText.setText(intent.getStringExtra(EXTRA_HOST) ?: "255.255.255.255")
broadcastCheckBox.isChecked = intent.getBooleanExtra(EXTRA_BROADCAST, true)
registButton.setOnClickListener { doRegist() }
+
+ ps4VersionRadioGroup.check(when(viewModel.ps4Version.value ?: RegistViewModel.PS4Version.GE_7) {
+ RegistViewModel.PS4Version.GE_7 -> R.id.ps4VersionGE7RadioButton
+ RegistViewModel.PS4Version.LT_7 -> R.id.ps4VersionLT7RadioButton
+ })
+
+ ps4VersionRadioGroup.setOnCheckedChangeListener { _, checkedId ->
+ viewModel.ps4Version.value = when(checkedId)
+ {
+ R.id.ps4VersionGE7RadioButton -> RegistViewModel.PS4Version.GE_7
+ R.id.ps4VersionLT7RadioButton -> RegistViewModel.PS4Version.LT_7
+ else -> RegistViewModel.PS4Version.GE_7
+ }
+ }
+
+ viewModel.ps4Version.observe(this, Observer {
+ psnAccountIdHelpGroup.visibility = if(it == RegistViewModel.PS4Version.GE_7) View.VISIBLE else View.GONE
+ psnIdTextInputLayout.hint = getString(when(it)
+ {
+ RegistViewModel.PS4Version.GE_7 -> R.string.hint_regist_psn_account_id
+ RegistViewModel.PS4Version.LT_7 -> R.string.hint_regist_psn_online_id
+ })
+ })
}
private fun doRegist()
@@ -64,7 +93,15 @@ class RegistActivity: AppCompatActivity(), RevealActivity
val pinValid = pin.length == PIN_LENGTH
hostEditText.error = if(!hostValid) getString(R.string.regist_host_invalid) else null
- psnIdEditText.error = if(!psnIdValid) getString(R.string.regist_psn_id_invalid) else null
+ psnIdEditText.error =
+ if(!psnIdValid)
+ getString(when(viewModel.ps4Version.value ?: RegistViewModel.PS4Version.GE_7)
+ {
+ RegistViewModel.PS4Version.GE_7 -> R.string.regist_psn_account_id_invalid
+ RegistViewModel.PS4Version.LT_7 -> R.string.regist_psn_online_id_invalid
+ })
+ else
+ null
pinEditText.error = if(!pinValid) getString(R.string.regist_pin_invalid, PIN_LENGTH) else null
if(!hostValid || !psnIdValid || !pinValid)
diff --git a/android/app/src/main/java/com/metallic/chiaki/regist/RegistViewModel.kt b/android/app/src/main/java/com/metallic/chiaki/regist/RegistViewModel.kt
new file mode 100644
index 0000000..873008e
--- /dev/null
+++ b/android/app/src/main/java/com/metallic/chiaki/regist/RegistViewModel.kt
@@ -0,0 +1,31 @@
+/*
+ * This file is part of Chiaki.
+ *
+ * Chiaki is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chiaki is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Chiaki. If not, see .
+ */
+
+package com.metallic.chiaki.regist
+
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+
+class RegistViewModel: ViewModel()
+{
+ enum class PS4Version {
+ GE_7,
+ LT_7
+ }
+
+ val ps4Version = MutableLiveData(PS4Version.GE_7)
+}
\ No newline at end of file
diff --git a/android/app/src/main/res/layout/activity_regist.xml b/android/app/src/main/res/layout/activity_regist.xml
index aa47b88..40ac926 100644
--- a/android/app/src/main/res/layout/activity_regist.xml
+++ b/android/app/src/main/res/layout/activity_regist.xml
@@ -11,7 +11,8 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="16dp">
+ android:padding="16dp"
+ android:animateLayoutChanges="true">
+
+
+
+
+
+
+
+
+
+
+
+
Register Console
Host
Broadcast
- PSN ID (username, case-sensitive)
+ PS4 < 7.0
+ PS4 ≥ 7.0
+ About obtaining your Account ID, see
+ https://github.com/thestr4ng3r/chiaki/blob/master/README.md#obtaining-your-psn-accountid
+ PSN Online ID (username, case-sensitive)
+ PSN Account ID (8 bytes, base64)
PIN
Register
Please enter a valid host name
- Please enter a valid PSN ID
+ Please enter a valid PSN ID
+ Please enter a valid 8-byte Account ID in Base64
Please enter a valid %d-digit PIN
Share Log
Regist successful.