Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit d36369f

Browse files
committed
* [M] Adding audio state and microphone controls
1 parent c28e212 commit d36369f

7 files changed

Lines changed: 82 additions & 15 deletions

File tree

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "io.qtalk.qgamejsinterfacetester"
1111
minSdkVersion 21
1212
targetSdkVersion 28
13-
versionCode 13 // cause version name started as 1.0 and version code as 1
14-
versionName "2.4"
13+
versionCode 14 // cause version name started as 1.0 and version code as 1
14+
versionName "2.5"
1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
vectorDrawables.useSupportLibrary = true
1717
}
@@ -45,7 +45,7 @@ dependencies {
4545
implementation 'com.google.firebase:firebase-database:19.2.0'
4646
implementation 'androidx.core:core-ktx:1.2.0-rc01'
4747
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
48-
implementation 'com.google.android.material:material:1.2.0-alpha02'
48+
implementation 'com.google.android.material:material:1.2.0-alpha03'
4949
implementation 'com.afollestad.material-dialogs:core:3.0.2'
5050
implementation 'com.afollestad.material-dialogs:input:3.0.1'
5151
testImplementation 'junit:junit:4.12'

app/src/main/java/io/qtalk/qgamejsinterfacetester/WebViewFragment.kt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.qtalk.qgamejsinterfacetester
22

3+
import android.content.Context
4+
import android.media.AudioManager
35
import android.net.Uri
46
import android.os.Bundle
57
import android.util.Log
@@ -26,7 +28,9 @@ class WebViewFragment : PermissionAwareWebViewFragment(), JSInterface.JSInterfac
2628
private const val JS_INTERFACE_OBJECT_NAME = "QTalkApp"
2729

2830
private const val TEST_TOKEN =
29-
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
31+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" +
32+
".eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ" +
33+
".SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
3034

3135
private const val ARG_URL_STRING = "arg-url"
3236
private const val ARG_INTERACTION_TYPE = "arg-interaction-type"
@@ -157,13 +161,30 @@ class WebViewFragment : PermissionAwareWebViewFragment(), JSInterface.JSInterfac
157161
// write to QTalks RTDB here as participant information needs to be added in the array.
158162
writeParticipantInfoAndCallDetailsToRTDB()
159163

160-
endCallButton.visibility = View.VISIBLE
164+
webShareCallButtons.visibility = View.VISIBLE
165+
166+
val audioManager = context?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
167+
audioManager.isSpeakerphoneOn = true
168+
audioManager.isMicrophoneMute = false
169+
170+
audioStateButton.isSelected = true
171+
muteCallButton.isSelected = false
161172

162173
endCallButton.setOnClickListener {
163174
rtdbReference.child(RTDB_CHILD_CALL_DETAILS).child(RTDB_VALUE_CALL_ENDED_AT)
164175
.setValue(System.currentTimeMillis())
165176
activity?.finish()
166177
}
178+
179+
audioStateButton.setOnClickListener {
180+
audioManager.isSpeakerphoneOn = !audioManager.isSpeakerphoneOn
181+
audioStateButton.isSelected = audioManager.isSpeakerphoneOn
182+
}
183+
184+
muteCallButton.setOnClickListener {
185+
audioManager.isMicrophoneMute = !audioManager.isMicrophoneMute
186+
muteCallButton.isSelected = audioManager.isMicrophoneMute
187+
}
167188
}
168189

169190
jsInterface = JSInterface(this)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:color="@android:color/white" android:state_selected="true" />
4+
<item android:color="@android:color/darker_gray" android:state_selected="false" />
5+
</selector>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<shape xmlns:android="http://schemas.android.com/apk/res/android">
33
<solid android:color="@color/colorPrimary"/>
4-
<corners android:radius="8dp"/>
4+
<corners android:radius="16dp"/>
55
</shape>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<solid android:color="@android:color/holo_red_dark"/>
4+
<corners android:radius="8dp"/>
5+
</shape>

app/src/main/res/layout/content_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
android:id="@+id/selectUserButton"
3030
android:padding="8dp"
3131
android:textColor="@android:color/white"
32-
android:background="@drawable/custom_bg_8dp_primary"
32+
android:background="@drawable/custom_bg_16dp_primary"
3333
/>
3434
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/layout/webview_fragment.xml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
app:headerTextStyle="@style/MediumTextStyle"
1919
app:iconSize="16dp"
2020
app:iconLabelText="Expand"
21-
app:headerBackground="@drawable/custom_bg_8dp_primary"
21+
app:headerBackground="@drawable/custom_bg_16dp_primary"
2222
app:autoGenerateSubtitleText="false"
2323
android:layout_height="wrap_content">
2424

@@ -64,21 +64,57 @@
6464
android:layout_height="0dp"
6565
app:layout_constraintTop_toBottomOf="@id/logView"
6666
app:layout_constraintBottom_toBottomOf="parent"/>
67-
<androidx.appcompat.widget.AppCompatImageButton
67+
68+
<androidx.constraintlayout.widget.Group
6869
android:layout_width="wrap_content"
70+
tools:visibility="visible"
71+
android:visibility="gone"
72+
android:id="@+id/webShareCallButtons"
73+
app:constraint_referenced_ids="endCallButton,muteCallButton,audioStateButton"
74+
android:layout_height="wrap_content"/>
75+
<androidx.appcompat.widget.AppCompatImageButton
76+
android:layout_width="48dp"
77+
app:layout_constraintBottom_toTopOf="@id/muteCallButton"
78+
app:layout_constraintEnd_toEndOf="parent"
79+
android:layout_marginBottom="20dp"
80+
android:layout_marginTop="16dp"
81+
android:layout_marginEnd="20dp"
82+
android:id="@+id/audioStateButton"
83+
android:elevation="0dp"
84+
android:padding="4dp"
85+
android:src="@android:drawable/stat_sys_speakerphone"
86+
android:tint="@color/call_buttons_state"
87+
android:background="@drawable/custom_bg_16dp_primary"
88+
android:layout_height="48dp"/>
89+
90+
<androidx.appcompat.widget.AppCompatImageButton
91+
android:layout_width="48dp"
92+
app:layout_constraintBottom_toTopOf="@id/endCallButton"
93+
app:layout_constraintEnd_toEndOf="parent"
94+
android:layout_marginBottom="22dp"
95+
android:layout_marginTop="16dp"
96+
android:layout_marginEnd="20dp"
97+
android:id="@+id/muteCallButton"
98+
android:elevation="0dp"
99+
android:padding="4dp"
100+
android:src="@android:drawable/stat_notify_call_mute"
101+
android:tint="@color/call_buttons_state"
102+
android:background="@drawable/custom_bg_16dp_primary"
103+
android:layout_height="48dp"/>
104+
105+
<androidx.appcompat.widget.AppCompatImageButton
106+
android:layout_width="48dp"
69107
app:layout_constraintBottom_toBottomOf="parent"
70108
app:layout_constraintEnd_toEndOf="parent"
71109
android:layout_margin="16dp"
72-
tools:visibility="visible"
73-
android:visibility="gone"
74110
android:id="@+id/endCallButton"
75-
android:rotation="45"
111+
android:rotation="135"
76112
android:elevation="0dp"
77113
android:padding="6dp"
78-
android:src="@android:drawable/ic_menu_call"
114+
android:src="@android:drawable/stat_sys_phone_call"
79115
android:tint="@android:color/white"
80-
android:background="@drawable/custom_bg_8dp_primary"
81-
android:layout_height="wrap_content"/>
116+
android:background="@drawable/custom_bg_8dp_red"
117+
android:layout_height="48dp"/>
82118
<ProgressBar
83119
app:layout_constraintStart_toStartOf="parent"
84120
app:layout_constraintEnd_toEndOf="parent"

0 commit comments

Comments
 (0)