Use view binding in main activity
This commit is contained in:
@@ -31,6 +31,9 @@ android {
|
|||||||
'proguard-rules.pro'
|
'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding true
|
||||||
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
import com.tutpro.baresip.databinding.ActivityMainBinding
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
internal lateinit var layout: RelativeLayout
|
internal lateinit var layout: RelativeLayout
|
||||||
internal lateinit var baresipService: Intent
|
|
||||||
private lateinit var callTitle: TextView
|
private lateinit var callTitle: TextView
|
||||||
private lateinit var callUri: AutoCompleteTextView
|
private lateinit var callUri: AutoCompleteTextView
|
||||||
private lateinit var securityButton: ImageButton
|
private lateinit var securityButton: ImageButton
|
||||||
@@ -46,7 +46,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private var dtmfWatcher: TextWatcher? = null
|
private var dtmfWatcher: TextWatcher? = null
|
||||||
private lateinit var infoButton: ImageButton
|
private lateinit var infoButton: ImageButton
|
||||||
private lateinit var uaAdapter: UaSpinnerAdapter
|
private lateinit var uaAdapter: UaSpinnerAdapter
|
||||||
internal lateinit var aorSpinner: Spinner
|
private lateinit var aorSpinner: Spinner
|
||||||
private lateinit var imm: InputMethodManager
|
private lateinit var imm: InputMethodManager
|
||||||
private lateinit var nm: NotificationManager
|
private lateinit var nm: NotificationManager
|
||||||
private lateinit var am: AudioManager
|
private lateinit var am: AudioManager
|
||||||
@@ -56,6 +56,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
internal lateinit var stopState: String
|
internal lateinit var stopState: String
|
||||||
private lateinit var speakerIcon: MenuItem
|
private lateinit var speakerIcon: MenuItem
|
||||||
private lateinit var swipeRefresh: SwipeRefreshLayout
|
private lateinit var swipeRefresh: SwipeRefreshLayout
|
||||||
|
private lateinit var binding: ActivityMainBinding
|
||||||
|
|
||||||
|
internal lateinit var baresipService: Intent
|
||||||
|
|
||||||
internal var restart = false
|
internal var restart = false
|
||||||
private var atStartup = false
|
private var atStartup = false
|
||||||
@@ -63,6 +66,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
val intentAction = intent.getStringExtra("action")
|
val intentAction = intent.getStringExtra("action")
|
||||||
|
|
||||||
@@ -73,27 +77,27 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES)
|
window.addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES)
|
||||||
|
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(binding.root)
|
||||||
|
|
||||||
layout = findViewById(R.id.mainActivityLayout) as RelativeLayout
|
layout = binding.mainActivityLayout
|
||||||
aorSpinner = findViewById(R.id.AoRList)
|
aorSpinner = binding.aorSpinner
|
||||||
callTitle = findViewById(R.id.callTitle) as TextView
|
callTitle = binding.callTitle
|
||||||
callUri = findViewById(R.id.callUri) as AutoCompleteTextView
|
callUri = binding.callUri
|
||||||
securityButton = findViewById(R.id.securityButton) as ImageButton
|
securityButton = binding.securityButton
|
||||||
callButton = findViewById(R.id.callButton) as ImageButton
|
callButton = binding.callButton
|
||||||
hangupButton = findViewById(R.id.hangupButton) as ImageButton
|
hangupButton = binding.hangupButton
|
||||||
answerButton = findViewById(R.id.answerButton) as ImageButton
|
answerButton = binding.answerButton
|
||||||
rejectButton = findViewById(R.id.rejectButton) as ImageButton
|
rejectButton = binding.rejectButton
|
||||||
holdButton = findViewById(R.id.holdButton) as ImageButton
|
holdButton = binding.holdButton
|
||||||
transferButton = findViewById(R.id.transferButton) as ImageButton
|
transferButton = binding.transferButton
|
||||||
dtmf = findViewById(R.id.dtmf) as EditText
|
dtmf = binding.dtmf
|
||||||
infoButton = findViewById(R.id.info) as ImageButton
|
infoButton = binding.info
|
||||||
voicemailButton = findViewById(R.id.voicemailButton) as ImageButton
|
voicemailButton = binding.voicemailButton
|
||||||
contactsButton = findViewById(R.id.contactsButton) as ImageButton
|
contactsButton = binding.contactsButton
|
||||||
messagesButton = findViewById(R.id.messagesButton) as ImageButton
|
messagesButton = binding.messagesButton
|
||||||
callsButton = findViewById(R.id.callsButton) as ImageButton
|
callsButton = binding.callsButton
|
||||||
dialpadButton = findViewById(R.id.dialpadButton) as ImageButton
|
dialpadButton = binding.dialpadButton
|
||||||
swipeRefresh = findViewById(R.id.swipeRefresh) as SwipeRefreshLayout
|
swipeRefresh = binding.swipeRefresh
|
||||||
|
|
||||||
imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
nm = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
nm = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||||
@@ -1088,7 +1092,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun callTransfer(ua: UserAgent) {
|
private fun callTransfer(ua: UserAgent) {
|
||||||
val layout = LayoutInflater.from(this)
|
val layout = LayoutInflater.from(this)
|
||||||
.inflate(R.layout.call_transfer_dialog, findViewById<ViewGroup>(android.R.id.content),
|
.inflate(R.layout.call_transfer_dialog, findViewById(android.R.id.content),
|
||||||
false)
|
false)
|
||||||
val titleView = layout.findViewById(R.id.title) as TextView
|
val titleView = layout.findViewById(R.id.title) as TextView
|
||||||
titleView.text = getString(R.string.call_transfer)
|
titleView.text = getString(R.string.call_transfer)
|
||||||
@@ -1138,7 +1142,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun askPassword(title: String, ua: UserAgent? = null) {
|
private fun askPassword(title: String, ua: UserAgent? = null) {
|
||||||
val layout = LayoutInflater.from(this)
|
val layout = LayoutInflater.from(this)
|
||||||
.inflate(R.layout.password_dialog, findViewById(android.R.id.content) as ViewGroup,
|
.inflate(R.layout.password_dialog, findViewById(android.R.id.content),
|
||||||
false)
|
false)
|
||||||
val titleView = layout.findViewById(R.id.title) as TextView
|
val titleView = layout.findViewById(R.id.title) as TextView
|
||||||
titleView.text = title
|
titleView.text = title
|
||||||
@@ -1196,7 +1200,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
(Utils.paramValue(params, "auth_pass") == "")) {
|
(Utils.paramValue(params, "auth_pass") == "")) {
|
||||||
val aor = account.substringAfter("<").substringBefore(">")
|
val aor = account.substringAfter("<").substringBefore(">")
|
||||||
val layout = LayoutInflater.from(this)
|
val layout = LayoutInflater.from(this)
|
||||||
.inflate(R.layout.password_dialog, findViewById(android.R.id.content) as ViewGroup,
|
.inflate(R.layout.password_dialog, findViewById(android.R.id.content),
|
||||||
false)
|
false)
|
||||||
val titleView = layout.findViewById(R.id.title) as TextView
|
val titleView = layout.findViewById(R.id.title) as TextView
|
||||||
titleView.text = getString(R.string.authentication_password)
|
titleView.text = getString(R.string.authentication_password)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
android:paddingTop="@dimen/activity_vertical_margin">
|
android:paddingTop="@dimen/activity_vertical_margin">
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/AoRList"
|
android:id="@+id/aorSpinner"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:drawable/btn_dropdown"
|
android:background="@android:drawable/btn_dropdown"
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
android:id="@+id/callTitle"
|
android:id="@+id/callTitle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/AoRList"
|
android:layout_below="@id/aorSpinner"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingStart="3dp"
|
android:paddingStart="3dp"
|
||||||
android:paddingEnd="0dp"
|
android:paddingEnd="0dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user