Android: Minor clean for qtquickview_kotlin example

Remove unused android.view.View import from MainActivity.kt.

Synchronize activity_main.xml widget ids with the qtquickview_java
example.

Pick-to: 6.8
Change-Id: I4bcf6c78fac095232b69ca15f2061db884aedd09
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This commit is contained in:
Konsta Alajärvi 2024-08-16 14:19:41 +03:00
parent 8ff616c78c
commit f9dc5415a1
2 changed files with 12 additions and 13 deletions

View File

@ -7,7 +7,6 @@ import android.graphics.Color
import android.os.Bundle
import android.util.DisplayMetrics
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.LinearLayout
@ -46,7 +45,7 @@ class MainActivity : AppCompatActivity(), QtQmlStatusChangeListener {
setContentView(view)
//! [binding]
m_binding.signalSwitch.setOnClickListener { switchListener() }
m_binding.disconnectQmlListenerSwitch.setOnClickListener { switchListener() }
//! [m_qtQuickView]
m_qtQuickView = QtQuickView(this)
@ -69,7 +68,7 @@ class MainActivity : AppCompatActivity(), QtQmlStatusChangeListener {
m_qtQuickView!!.loadComponent(m_mainQmlComponent)
//! [loadComponent]
m_binding.changeColorButton.setOnClickListener { onClickListener() }
m_binding.changeQmlColorButton.setOnClickListener { onClickListener() }
m_binding.loadMainQml.setOnClickListener { loadMainQml() }
m_binding.loadSecondQml.setOnClickListener { loadSecondQml() }
m_binding.rotateQmlGridButton.setOnClickListener { rotateQmlGrid() }
@ -122,7 +121,7 @@ class MainActivity : AppCompatActivity(), QtQmlStatusChangeListener {
// Display the QML View background color in a view
// if qmlBackgroundColor is not null
if (qmlBackgroundColor != null) {
m_binding.colorBox.setBackgroundColor(Color.parseColor(qmlBackgroundColor))
m_binding.qmlColorBox.setBackgroundColor(Color.parseColor(qmlBackgroundColor))
}
}
//! [onClickListener]
@ -130,7 +129,7 @@ class MainActivity : AppCompatActivity(), QtQmlStatusChangeListener {
private fun switchListener() {
// Disconnect QML button signal listener if switch is On using the saved signal listener Id
// and connect it again if switch is turned off
if (m_binding.signalSwitch.isChecked) {
if (m_binding.disconnectQmlListenerSwitch.isChecked) {
Log.v(TAG, "QML button onClicked signal listener disconnected")
m_binding.switchText.setText(R.string.connect_qml_button_signal_listener)
//! [disconnect qml signal listener]
@ -159,12 +158,12 @@ class MainActivity : AppCompatActivity(), QtQmlStatusChangeListener {
+ m_statusNames[status])
// Show current QML View status in a textview
m_binding.qmlStatus.text = qmlStatus
m_binding.qmlStatusText.text = qmlStatus
// Connect signal listener to "onClicked" signal from main.qml
// addSignalListener returns int which can be used later to identify the listener
//! [qml signal listener]
if (status == QtQmlStatus.READY && !m_binding.signalSwitch.isChecked) {
if (status == QtQmlStatus.READY && !m_binding.disconnectQmlListenerSwitch.isChecked) {
m_qmlButtonSignalListenerId =
m_mainQmlComponent.connectOnClickedListener { _: String, _: Void? ->
Log.i(TAG, "QML button clicked")
@ -183,7 +182,7 @@ class MainActivity : AppCompatActivity(), QtQmlStatusChangeListener {
m_qtQuickView!!.loadComponent(m_secondQmlComponent)
// Reset box color and color text after component reload
m_binding.colorBox.setBackgroundColor(Color.parseColor("#00ffffff"))
m_binding.qmlColorBox.setBackgroundColor(Color.parseColor("#00ffffff"))
m_binding.getPropertyValueText.text = ""
}
@ -191,7 +190,7 @@ class MainActivity : AppCompatActivity(), QtQmlStatusChangeListener {
m_qtQuickView!!.loadComponent(m_mainQmlComponent)
// Reset box color and color text after component reload
m_binding.colorBox.setBackgroundColor(Color.parseColor("#00ffffff"))
m_binding.qmlColorBox.setBackgroundColor(Color.parseColor("#00ffffff"))
m_binding.getPropertyValueText.text = ""
}
//! [switchLoadedComponent]

View File

@ -40,7 +40,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/qmlStatus"
android:id="@+id/qmlStatusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@ -79,7 +79,7 @@
android:textSize="@dimen/other_text_size"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/changeColorButton"
android:id="@+id/changeQmlColorButton"
android:layout_width="@dimen/change_color_button_width"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@ -108,7 +108,7 @@
android:textSize="@dimen/other_text_size"/>
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/signalSwitch"
android:id="@+id/disconnectQmlListenerSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@ -160,7 +160,7 @@
</LinearLayout>
<View
android:id="@+id/colorBox"
android:id="@+id/qmlColorBox"
android:layout_width="@dimen/color_box_width"
android:layout_height="@dimen/color_box_height"
android:layout_gravity="center_horizontal"