mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
highlight active audio output
use layout weight Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
78b29082bf
commit
ffb223a66f
@ -173,6 +173,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
public static final String TAG = "CallActivity";
|
public static final String TAG = "CallActivity";
|
||||||
|
|
||||||
|
public MagicAudioManager audioManager;
|
||||||
|
|
||||||
private static final String[] PERMISSIONS_CALL = {
|
private static final String[] PERMISSIONS_CALL = {
|
||||||
android.Manifest.permission.CAMERA,
|
android.Manifest.permission.CAMERA,
|
||||||
android.Manifest.permission.RECORD_AUDIO,
|
android.Manifest.permission.RECORD_AUDIO,
|
||||||
@ -198,7 +200,6 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
private MediaConstraints videoConstraints;
|
private MediaConstraints videoConstraints;
|
||||||
private MediaConstraints sdpConstraints;
|
private MediaConstraints sdpConstraints;
|
||||||
private MediaConstraints sdpConstraintsForMCU;
|
private MediaConstraints sdpConstraintsForMCU;
|
||||||
private MagicAudioManager audioManager;
|
|
||||||
private VideoSource videoSource;
|
private VideoSource videoSource;
|
||||||
private VideoTrack localVideoTrack;
|
private VideoTrack localVideoTrack;
|
||||||
private AudioSource audioSource;
|
private AudioSource audioSource;
|
||||||
@ -369,33 +370,6 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAudioOutputChannel(MagicAudioManager.AudioDevice audioDevice) {
|
|
||||||
if (audioManager == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
audioManager.selectAudioDevice(audioDevice);
|
|
||||||
|
|
||||||
switch (audioManager.getResultingAudioDevice()) {
|
|
||||||
case BLUETOOTH:
|
|
||||||
binding.audioOutputButton.getHierarchy().setPlaceholderImage(
|
|
||||||
AppCompatResources.getDrawable(context, R.drawable.ic_baseline_bluetooth_audio_24));
|
|
||||||
break;
|
|
||||||
case SPEAKER_PHONE:
|
|
||||||
binding.audioOutputButton.getHierarchy().setPlaceholderImage(
|
|
||||||
AppCompatResources.getDrawable(context, R.drawable.ic_volume_up_white_24dp));
|
|
||||||
break;
|
|
||||||
case EARPIECE:
|
|
||||||
binding.audioOutputButton.getHierarchy().setPlaceholderImage(
|
|
||||||
AppCompatResources.getDrawable(context, R.drawable.ic_baseline_phone_in_talk_24));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Log.e(TAG, "Invalid audio device selection");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DrawableCompat.setTint(binding.audioOutputButton.getDrawable(), Color.WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createCameraEnumerator() {
|
private void createCameraEnumerator() {
|
||||||
boolean camera2EnumeratorIsSupported = false;
|
boolean camera2EnumeratorIsSupported = false;
|
||||||
try {
|
try {
|
||||||
@ -441,6 +415,12 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
Log.d(TAG, "Starting the audio manager...");
|
Log.d(TAG, "Starting the audio manager...");
|
||||||
audioManager.start(this::onAudioManagerDevicesChanged);
|
audioManager.start(this::onAudioManagerDevicesChanged);
|
||||||
|
|
||||||
|
if (isVoiceOnlyCall) {
|
||||||
|
setAudioOutputChannel(MagicAudioManager.AudioDevice.EARPIECE);
|
||||||
|
} else {
|
||||||
|
setAudioOutputChannel(MagicAudioManager.AudioDevice.SPEAKER_PHONE);
|
||||||
|
}
|
||||||
|
|
||||||
iceServers = new ArrayList<>();
|
iceServers = new ArrayList<>();
|
||||||
|
|
||||||
//create sdpConstraints
|
//create sdpConstraints
|
||||||
@ -471,6 +451,33 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
microphoneInitialization();
|
microphoneInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAudioOutputChannel(MagicAudioManager.AudioDevice selectedAudioDevice) {
|
||||||
|
if (audioManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
audioManager.selectAudioDevice(selectedAudioDevice);
|
||||||
|
|
||||||
|
switch (audioManager.getResultingAudioDevice()) {
|
||||||
|
case BLUETOOTH:
|
||||||
|
binding.audioOutputButton.getHierarchy().setPlaceholderImage(
|
||||||
|
AppCompatResources.getDrawable(context, R.drawable.ic_baseline_bluetooth_audio_24));
|
||||||
|
break;
|
||||||
|
case SPEAKER_PHONE:
|
||||||
|
binding.audioOutputButton.getHierarchy().setPlaceholderImage(
|
||||||
|
AppCompatResources.getDrawable(context, R.drawable.ic_volume_up_white_24dp));
|
||||||
|
break;
|
||||||
|
case EARPIECE:
|
||||||
|
binding.audioOutputButton.getHierarchy().setPlaceholderImage(
|
||||||
|
AppCompatResources.getDrawable(context, R.drawable.ic_baseline_phone_in_talk_24));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Icon for audio output not available");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawableCompat.setTint(binding.audioOutputButton.getDrawable(), Color.WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
private void handleFromNotification() {
|
private void handleFromNotification() {
|
||||||
int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{ApiUtils.APIv4, 1});
|
int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{ApiUtils.APIv4, 1});
|
||||||
|
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
* Nextcloud Talk application
|
* Nextcloud Talk application
|
||||||
*
|
*
|
||||||
* @author Marcel Hibbe
|
* @author Marcel Hibbe
|
||||||
* @author Andy Scherzinger
|
* Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
|
||||||
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
|
|
||||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -23,8 +21,10 @@
|
|||||||
package com.nextcloud.talk.ui.dialog
|
package com.nextcloud.talk.ui.dialog
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
@ -42,7 +42,52 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
|
|||||||
setContentView(dialogAudioOutputBinding.root)
|
setContentView(dialogAudioOutputBinding.root)
|
||||||
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
|
||||||
|
highlightActiveOutputChannel()
|
||||||
|
initClickListeners()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun highlightActiveOutputChannel() {
|
||||||
|
when (callActivity.audioManager?.resultingAudioDevice) {
|
||||||
|
MagicAudioManager.AudioDevice.BLUETOOTH -> {
|
||||||
|
dialogAudioOutputBinding.audioOutputBluetoothIcon.setColorFilter(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
context, R.color
|
||||||
|
.colorPrimary
|
||||||
|
), android.graphics.PorterDuff.Mode.SRC_IN
|
||||||
|
)
|
||||||
|
dialogAudioOutputBinding.audioOutputBluetoothText.setTextColor(
|
||||||
|
callActivity.resources.getColor(
|
||||||
|
R.color
|
||||||
|
.colorPrimary
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
MagicAudioManager.AudioDevice.SPEAKER_PHONE -> {
|
||||||
|
dialogAudioOutputBinding.audioOutputSpeakerIcon.setColorFilter(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
context,
|
||||||
|
R.color.colorPrimary
|
||||||
|
), android.graphics.PorterDuff.Mode.SRC_IN
|
||||||
|
)
|
||||||
|
dialogAudioOutputBinding.audioOutputSpeakerText.setTextColor(callActivity.resources.getColor(R.color.colorPrimary))
|
||||||
|
}
|
||||||
|
|
||||||
|
MagicAudioManager.AudioDevice.EARPIECE -> {
|
||||||
|
dialogAudioOutputBinding.audioOutputEarspeakerIcon.setColorFilter(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
context,
|
||||||
|
R.color.colorPrimary
|
||||||
|
), android.graphics.PorterDuff.Mode.SRC_IN
|
||||||
|
)
|
||||||
|
dialogAudioOutputBinding.audioOutputEarspeakerText.setTextColor(callActivity.resources.getColor(R.color.colorPrimary))
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> Log.d(TAG, "AudioOutputDialog doesn't know this AudioDevice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initClickListeners() {
|
||||||
dialogAudioOutputBinding.audioOutputBluetooth.setOnClickListener {
|
dialogAudioOutputBinding.audioOutputBluetooth.setOnClickListener {
|
||||||
callActivity.setAudioOutputChannel(MagicAudioManager.AudioDevice.BLUETOOTH)
|
callActivity.setAudioOutputChannel(MagicAudioManager.AudioDevice.BLUETOOTH)
|
||||||
dismiss()
|
dismiss()
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:src="@drawable/ic_baseline_bluetooth_audio_24"
|
android:src="@drawable/ic_baseline_bluetooth_audio_24"
|
||||||
app:tint="@color/colorPrimary" />
|
app:tint="#99ffffff" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/audio_output_bluetooth_text"
|
android:id="@+id/audio_output_bluetooth_text"
|
||||||
@ -90,7 +90,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:src="@drawable/ic_volume_up_white_24dp"
|
android:src="@drawable/ic_volume_up_white_24dp"
|
||||||
app:tint="@color/colorPrimary" />
|
app:tint="#99ffffff" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/audio_output_speaker_text"
|
android:id="@+id/audio_output_speaker_text"
|
||||||
@ -123,7 +123,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:src="@drawable/ic_baseline_phone_in_talk_24"
|
android:src="@drawable/ic_baseline_phone_in_talk_24"
|
||||||
app:tint="@color/colorPrimary" />
|
app:tint="#99ffffff" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/audio_output_earspeaker_text"
|
android:id="@+id/audio_output_earspeaker_text"
|
||||||
|
Loading…
Reference in New Issue
Block a user