mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2024-11-09 12:01:01 +00:00
2. add peer form. iteration 2
This commit is contained in:
parent
599c79eca9
commit
f00d8b8af9
@ -2,14 +2,17 @@ package io.github.chronosx88.yggdrasil
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.ListView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.hbb20.CCPCountry
|
||||
@ -25,7 +28,9 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.lang.reflect.Type
|
||||
import java.net.*
|
||||
import java.net.InetAddress
|
||||
import java.net.URI
|
||||
import java.net.URL
|
||||
import java.nio.charset.Charset
|
||||
|
||||
|
||||
@ -118,6 +123,12 @@ class PeerListActivity : AppCompatActivity() {
|
||||
|
||||
private fun addNewPeer() {
|
||||
val view: View = LayoutInflater.from(this).inflate(R.layout.new_peer_dialog, null)
|
||||
val countryCode: String = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
this.resources.configuration.locales[0].country
|
||||
} else {
|
||||
this.resources.configuration.locale.country
|
||||
}
|
||||
view.findViewById<com.hbb20.CountryCodePicker>(R.id.ccp).setCountryForNameCode(countryCode)
|
||||
val ab: AlertDialog.Builder = AlertDialog.Builder(this)
|
||||
ab.setCancelable(true).setView(view)
|
||||
ab.show()
|
||||
|
16
app/src/main/res/drawable/add_peer_panel.xml
Normal file
16
app/src/main/res/drawable/add_peer_panel.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/grey" />
|
||||
|
||||
<solid android:color="@color/dark_30" />
|
||||
|
||||
<padding
|
||||
android:left="1dp"
|
||||
android:right="1dp"
|
||||
android:bottom="1dp"
|
||||
android:top="1dp" />
|
||||
|
||||
<corners android:radius="15dp" />
|
||||
</shape>
|
15
app/src/main/res/drawable/button_background.xml
Normal file
15
app/src/main/res/drawable/button_background.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/green" />
|
||||
<solid android:color="@color/green" />
|
||||
|
||||
<padding
|
||||
android:left="1dp"
|
||||
android:right="1dp"
|
||||
android:bottom="1dp"
|
||||
android:top="1dp" />
|
||||
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
6
app/src/main/res/drawable/button_selector.xml
Normal file
6
app/src/main/res/drawable/button_selector.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/button_background" android:state_focused="true" />
|
||||
<item android:drawable="@drawable/button_background" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/button_background" />
|
||||
</selector>
|
@ -23,7 +23,7 @@
|
||||
android:hint="Schema"
|
||||
android:textColor="@color/white"
|
||||
android:inputType="text"
|
||||
/>
|
||||
android:textCursorDrawable="@null"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
@ -42,9 +42,10 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:digits="0123456789."
|
||||
android:hint="IP address"
|
||||
android:hint="IP/domain"
|
||||
android:inputType="number"
|
||||
mask:mask="###.###.###.###" />
|
||||
android:textColor="@color/white"
|
||||
android:textCursorDrawable="@null"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
@ -64,6 +65,38 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:digits="0123456789"
|
||||
android:hint="Port"
|
||||
android:inputType="number" />
|
||||
android:textColor="@color/white"
|
||||
android:inputType="number"
|
||||
android:textCursorDrawable="@null"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.hbb20.CountryCodePicker
|
||||
android:id="@+id/ccp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_margin="10dp"
|
||||
app:ccp_contentColor="@color/white"
|
||||
app:ccp_showFullName="true"
|
||||
app:ccp_showPhoneCode="false"
|
||||
app:ccp_showNameCode="false"
|
||||
app:layout_constraintEnd_toEndOf="@+id/schema"
|
||||
app:layout_constraintTop_toBottomOf="@+id/port"
|
||||
android:background="@drawable/edit_text_rounded_corner"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/add"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/schema"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ccp"
|
||||
android:background="@drawable/button_selector"
|
||||
app:backgroundTint="@null"
|
||||
android:text="ADD"
|
||||
android:textColor="@color/white"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user