mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Finish Android Regist Form
This commit is contained in:
parent
5279868ba0
commit
5e82c45278
7 changed files with 118 additions and 18 deletions
|
@ -28,6 +28,14 @@ import kotlinx.android.synthetic.main.activity_regist.*
|
|||
|
||||
class RegistActivity: AppCompatActivity(), RevealActivity
|
||||
{
|
||||
companion object
|
||||
{
|
||||
const val EXTRA_HOST = "regist_host"
|
||||
const val EXTRA_BROADCAST = "regist_broadcast"
|
||||
|
||||
private const val PIN_LENGTH = 8
|
||||
}
|
||||
|
||||
override val revealWindow: Window get() = window
|
||||
override val revealIntent: Intent get() = intent
|
||||
override val revealRootLayout: View get() = rootLayout
|
||||
|
@ -37,5 +45,30 @@ class RegistActivity: AppCompatActivity(), RevealActivity
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_regist)
|
||||
handleReveal()
|
||||
|
||||
hostEditText.setText(intent.getStringExtra(EXTRA_HOST) ?: "255.255.255.255")
|
||||
broadcastCheckBox.isChecked = intent.getBooleanExtra(EXTRA_BROADCAST, true)
|
||||
|
||||
registButton.setOnClickListener { doRegist() }
|
||||
}
|
||||
|
||||
private fun doRegist()
|
||||
{
|
||||
val host = hostEditText.text.toString().trim()
|
||||
val hostValid = host.isNotEmpty()
|
||||
val broadcast = broadcastCheckBox.isChecked
|
||||
val psnId = psnIdEditText.text.toString().trim()
|
||||
val psnIdValid = psnId.isNotEmpty()
|
||||
val pin = pinEditText.text.toString()
|
||||
val pinValid = pin.length == PIN_LENGTH
|
||||
|
||||
hostEditText.error = if(!hostValid) "Please enter a valid host name" else null
|
||||
psnIdEditText.error = if(!psnIdValid) "Please enter a valid PSN ID" else null
|
||||
pinEditText.error = if(!pinValid) "Please enter a valid 8-digit PIN" else null
|
||||
|
||||
if(!hostValid || !psnIdValid || ! pinValid)
|
||||
return
|
||||
|
||||
// TODO
|
||||
}
|
||||
}
|
9
android/app/src/main/res/drawable/ic_host.xml
Normal file
9
android/app/src/main/res/drawable/ic_host.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.2,5.9l0.8,-0.8C19.6,3.7 17.8,3 16,3s-3.6,0.7 -5,2.1l0.8,0.8C13,4.8 14.5,4.2 16,4.2s3,0.6 4.2,1.7zM19.3,6.7c-0.9,-0.9 -2.1,-1.4 -3.3,-1.4s-2.4,0.5 -3.3,1.4l0.8,0.8c0.7,-0.7 1.6,-1 2.5,-1 0.9,0 1.8,0.3 2.5,1l0.8,-0.8zM19,13h-2L17,9h-2v4L5,13c-1.1,0 -2,0.9 -2,2v4c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2v-4c0,-1.1 -0.9,-2 -2,-2zM8,18L6,18v-2h2v2zM11.5,18h-2v-2h2v2zM15,18h-2v-2h2v2z"/>
|
||||
</vector>
|
9
android/app/src/main/res/drawable/ic_pin.xml
Normal file
9
android/app/src/main/res/drawable/ic_pin.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M5.5,10.5h2v1h-2zM20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM9,11.5c0,0.85 -0.65,1.5 -1.5,1.5h-2v2L4,15L4,9h3.5c0.85,0 1.5,0.65 1.5,1.5v1zM12.5,15L11,15L11,9h1.5v6zM20,15h-1.2l-2.55,-3.5L16.25,15L15,15L15,9h1.25l2.5,3.5L18.75,9L20,9v6z"/>
|
||||
</vector>
|
9
android/app/src/main/res/drawable/ic_psn_id.xml
Normal file
9
android/app/src/main/res/drawable/ic_psn_id.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
|
||||
</vector>
|
|
@ -30,8 +30,8 @@
|
|||
android:id="@+id/titleTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Register Console"
|
||||
android:textSize="32dp"
|
||||
android:text="@string/title_regist"
|
||||
android:textSize="32sp"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/iconImageView"
|
||||
|
@ -41,13 +41,16 @@
|
|||
android:id="@+id/hostTextInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Host"
|
||||
app:startIconDrawable="@drawable/ic_register"
|
||||
android:hint="@string/hint_regist_host"
|
||||
app:startIconDrawable="@drawable/ic_host"
|
||||
app:layout_constraintTop_toBottomOf="@id/titleTextView"
|
||||
android:layout_marginTop="32dp">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/hostEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textNoSuggestions|textVisiblePassword"
|
||||
android:maxLines="1"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
|
@ -56,52 +59,79 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/hostTextInputLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:text="Broadcast"/>
|
||||
android:text="@string/regist_broadcast"/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/psnIdTextInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="PSN ID (username, case-sensitive)"
|
||||
app:startIconDrawable="@drawable/ic_register"
|
||||
android:hint="@string/hint_regist_psn_id"
|
||||
app:startIconDrawable="@drawable/ic_psn_id"
|
||||
app:layout_constraintTop_toBottomOf="@id/broadcastCheckBox"
|
||||
android:layout_marginTop="16dp">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/psnIdEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textNoSuggestions|textVisiblePassword"
|
||||
android:maxLines="1"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/pinHelpTextView"
|
||||
android:id="@+id/pinHelpBeforeTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Navigate to Settings -> Whatever to obtain the PIN"
|
||||
android:gravity="center"
|
||||
android:text="@string/regist_pin_instructions_before"
|
||||
app:layout_constraintTop_toBottomOf="@id/psnIdTextInputLayout"
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:layout_marginTop="32dp"/>
|
||||
android:layout_marginTop="32dp"
|
||||
android:alpha="0.6"/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/pinHelpNavigationTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/regist_pin_instructions_navigation"
|
||||
app:layout_constraintTop_toBottomOf="@id/pinHelpBeforeTextView"
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/pinHelpAfterTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/regist_pin_instructions_after"
|
||||
app:layout_constraintTop_toBottomOf="@id/pinHelpNavigationTextView"
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:alpha="0.6"/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/pinTextInputLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="PIN"
|
||||
app:startIconDrawable="@drawable/ic_register"
|
||||
app:layout_constraintTop_toBottomOf="@id/pinHelpTextView"
|
||||
android:hint="@string/hint_regist_pin"
|
||||
app:startIconDrawable="@drawable/ic_pin"
|
||||
app:layout_constraintTop_toBottomOf="@id/pinHelpAfterTextView"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/pinEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:maxLength="8" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/registButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/pinTextInputLayout"
|
||||
style="@style/MageTheme.Button"
|
||||
android:text="Register"
|
||||
android:text="@string/action_regist"
|
||||
android:layout_marginTop="32dp" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -14,4 +14,13 @@
|
|||
<string name="display_host_id">ID: %s</string>
|
||||
<string name="action_register">Register Console</string>
|
||||
<string name="action_add_manual">Add Console Manually</string>
|
||||
<string name="regist_pin_instructions_before">On the PS4, navigate to</string>
|
||||
<string name="regist_pin_instructions_navigation">Settings →\nRemote Play Connection Settings →\nAdd Device</string>
|
||||
<string name="regist_pin_instructions_after">to obtain the PIN</string>
|
||||
<string name="title_regist">Register Console</string>
|
||||
<string name="hint_regist_host">Host</string>
|
||||
<string name="regist_broadcast">Broadcast</string>
|
||||
<string name="hint_regist_psn_id">PSN ID (username, case-sensitive)</string>
|
||||
<string name="hint_regist_pin">PIN</string>
|
||||
<string name="action_regist">Register</string>
|
||||
</resources>
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<item name="boxCornerRadiusTopStart">16dp</item>
|
||||
<item name="boxCornerRadiusTopEnd">16dp</item>
|
||||
<item name="boxStrokeColor">@color/mage_text_input_box_stroke</item>
|
||||
<item name="boxBackgroundColor">?attr/colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="MageTheme.Button" parent="Widget.MaterialComponents.Button">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue