format code + fix klint/findbugs warnings

remove hardcodings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>

remove hardcodings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-02-01 19:14:21 +01:00
parent 51df0e67f4
commit 7f0980e6d2
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
7 changed files with 78 additions and 107 deletions

View File

@ -377,8 +377,8 @@ public class CallActivity extends CallBaseActivity {
boolean camera2EnumeratorIsSupported = false; boolean camera2EnumeratorIsSupported = false;
try { try {
camera2EnumeratorIsSupported = Camera2Enumerator.isSupported(this); camera2EnumeratorIsSupported = Camera2Enumerator.isSupported(this);
} catch (final Throwable throwable) { } catch (final Throwable t) {
Log.w(TAG, "Camera2Enumerator threw an error"); Log.w(TAG, "Camera2Enumerator threw an error", t);
} }
if (camera2EnumeratorIsSupported) { if (camera2EnumeratorIsSupported) {

View File

@ -65,7 +65,10 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
dialogAudioOutputBinding.audioOutputSpeaker.visibility = View.VISIBLE dialogAudioOutputBinding.audioOutputSpeaker.visibility = View.VISIBLE
} }
if (callActivity.audioManager?.currentAudioDevice?.equals(MagicAudioManager.AudioDevice.WIRED_HEADSET) == true) { if (callActivity.audioManager?.currentAudioDevice?.equals(
MagicAudioManager.AudioDevice.WIRED_HEADSET
) == true
) {
dialogAudioOutputBinding.audioOutputEarspeaker.visibility = View.GONE dialogAudioOutputBinding.audioOutputEarspeaker.visibility = View.GONE
dialogAudioOutputBinding.audioOutputSpeaker.visibility = View.GONE dialogAudioOutputBinding.audioOutputSpeaker.visibility = View.GONE
dialogAudioOutputBinding.audioOutputWiredHeadset.visibility = View.VISIBLE dialogAudioOutputBinding.audioOutputWiredHeadset.visibility = View.VISIBLE
@ -81,15 +84,13 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
MagicAudioManager.AudioDevice.BLUETOOTH -> { MagicAudioManager.AudioDevice.BLUETOOTH -> {
dialogAudioOutputBinding.audioOutputBluetoothIcon.setColorFilter( dialogAudioOutputBinding.audioOutputBluetoothIcon.setColorFilter(
ContextCompat.getColor( ContextCompat.getColor(
context, R.color context,
.colorPrimary R.color.colorPrimary
), android.graphics.PorterDuff.Mode.SRC_IN ),
android.graphics.PorterDuff.Mode.SRC_IN
) )
dialogAudioOutputBinding.audioOutputBluetoothText.setTextColor( dialogAudioOutputBinding.audioOutputBluetoothText.setTextColor(
callActivity.resources.getColor( callActivity.resources.getColor(R.color.colorPrimary)
R.color
.colorPrimary
)
) )
} }
@ -98,9 +99,12 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
ContextCompat.getColor( ContextCompat.getColor(
context, context,
R.color.colorPrimary R.color.colorPrimary
), android.graphics.PorterDuff.Mode.SRC_IN ),
android.graphics.PorterDuff.Mode.SRC_IN
)
dialogAudioOutputBinding.audioOutputSpeakerText.setTextColor(
callActivity.resources.getColor(R.color.colorPrimary)
) )
dialogAudioOutputBinding.audioOutputSpeakerText.setTextColor(callActivity.resources.getColor(R.color.colorPrimary))
} }
MagicAudioManager.AudioDevice.EARPIECE -> { MagicAudioManager.AudioDevice.EARPIECE -> {
@ -108,9 +112,12 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
ContextCompat.getColor( ContextCompat.getColor(
context, context,
R.color.colorPrimary R.color.colorPrimary
), android.graphics.PorterDuff.Mode.SRC_IN ),
android.graphics.PorterDuff.Mode.SRC_IN
)
dialogAudioOutputBinding.audioOutputEarspeakerText.setTextColor(
callActivity.resources.getColor(R.color.colorPrimary)
) )
dialogAudioOutputBinding.audioOutputEarspeakerText.setTextColor(callActivity.resources.getColor(R.color.colorPrimary))
} }
MagicAudioManager.AudioDevice.WIRED_HEADSET -> { MagicAudioManager.AudioDevice.WIRED_HEADSET -> {
@ -118,10 +125,12 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
ContextCompat.getColor( ContextCompat.getColor(
context, context,
R.color.colorPrimary R.color.colorPrimary
), android.graphics.PorterDuff.Mode.SRC_IN ),
android.graphics.PorterDuff.Mode.SRC_IN
)
dialogAudioOutputBinding.audioOutputWiredHeadsetText.setTextColor(
callActivity.resources.getColor(R.color.colorPrimary)
) )
dialogAudioOutputBinding.audioOutputWiredHeadsetText.setTextColor(callActivity.resources.getColor(R.color
.colorPrimary))
} }
else -> Log.d(TAG, "AudioOutputDialog doesn't know this AudioDevice") else -> Log.d(TAG, "AudioOutputDialog doesn't know this AudioDevice")

View File

@ -41,8 +41,10 @@ import android.media.AudioDeviceInfo;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import com.nextcloud.talk.events.PeerConnectionEvent; import com.nextcloud.talk.events.PeerConnectionEvent;
import com.nextcloud.talk.utils.power.PowerManagerUtils; import com.nextcloud.talk.utils.power.PowerManagerUtils;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.webrtc.ThreadUtils; import org.webrtc.ThreadUtils;
@ -114,8 +116,8 @@ public class MagicAudioManager {
} }
/** /**
* This method is called when the proximity sensor reports a state change, * This method is called when the proximity sensor reports a state change, e.g. from "NEAR to FAR" or from "FAR to
* e.g. from "NEAR to FAR" or from "FAR to NEAR". * NEAR".
*/ */
private void onProximitySensorChangedState() { private void onProximitySensorChangedState() {
if (!useProximitySensor) { if (!useProximitySensor) {
@ -128,14 +130,14 @@ public class MagicAudioManager {
if (proximitySensor.sensorReportsNearState()) { if (proximitySensor.sensorReportsNearState()) {
setAudioDeviceInternal(AudioDevice.EARPIECE); setAudioDeviceInternal(AudioDevice.EARPIECE);
Log.d(TAG,"switched to EARPIECE because userSelectedAudioDevice was SPEAKER_PHONE and proximity=near"); Log.d(TAG, "switched to EARPIECE because userSelectedAudioDevice was SPEAKER_PHONE and proximity=near");
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
.SENSOR_NEAR, null, null, null, null)); .SENSOR_NEAR, null, null, null, null));
} else { } else {
setAudioDeviceInternal(MagicAudioManager.AudioDevice.SPEAKER_PHONE); setAudioDeviceInternal(MagicAudioManager.AudioDevice.SPEAKER_PHONE);
Log.d(TAG,"switched to SPEAKER_PHONE because userSelectedAudioDevice was SPEAKER_PHONE and proximity=far"); Log.d(TAG, "switched to SPEAKER_PHONE because userSelectedAudioDevice was SPEAKER_PHONE and proximity=far");
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
.SENSOR_FAR, null, null, null, null)); .SENSOR_FAR, null, null, null, null));
@ -311,15 +313,7 @@ public class MagicAudioManager {
if (!audioDevices.contains(device)) { if (!audioDevices.contains(device)) {
Log.e(TAG, "Can not select " + device + " from available " + audioDevices); Log.e(TAG, "Can not select " + device + " from available " + audioDevices);
} }
userSelectedAudioDevice = device; userSelectedAudioDevice = device;
// if (device == AudioDevice.SPEAKER_PHONE) {
// controlSpeakerByProximitySensor = true;
// } else {
// controlSpeakerByProximitySensor = false;
// }
updateAudioDeviceState(); updateAudioDeviceState();
} }
@ -383,11 +377,9 @@ public class MagicAudioManager {
} }
/** /**
* Checks whether a wired headset is connected or not. * Checks whether a wired headset is connected or not. This is not a valid indication that audio playback is
* This is not a valid indication that audio playback is actually over * actually over the wired headset as audio routing depends on other conditions. We only use it as an early
* the wired headset as audio routing depends on other conditions. We * indicator (during initialization) of an attached wired headset.
* only use it as an early indicator (during initialization) of an attached
* wired headset.
*/ */
@Deprecated @Deprecated
private boolean hasWiredHeadset() { private boolean hasWiredHeadset() {
@ -447,7 +439,6 @@ public class MagicAudioManager {
audioDevices = newAudioDevices; audioDevices = newAudioDevices;
// Correct user selected audio devices if needed. // Correct user selected audio devices if needed.
if (userSelectedAudioDevice == AudioDevice.BLUETOOTH if (userSelectedAudioDevice == AudioDevice.BLUETOOTH
&& bluetoothManager.getState() == MagicBluetoothManager.State.HEADSET_UNAVAILABLE) { && bluetoothManager.getState() == MagicBluetoothManager.State.HEADSET_UNAVAILABLE) {
@ -461,8 +452,6 @@ public class MagicAudioManager {
} }
// Need to start Bluetooth if it is available and user either selected it explicitly or // Need to start Bluetooth if it is available and user either selected it explicitly or
// user did not select any output device. // user did not select any output device.
boolean needBluetoothAudioStart = boolean needBluetoothAudioStart =
@ -537,8 +526,7 @@ public class MagicAudioManager {
} }
/** /**
* AudioDevice is the names of possible audio devices that we currently * AudioDevice is the names of possible audio devices that we currently support.
* support.
*/ */
public enum AudioDevice { public enum AudioDevice {
SPEAKER_PHONE, WIRED_HEADSET, EARPIECE, BLUETOOTH, NONE SPEAKER_PHONE, WIRED_HEADSET, EARPIECE, BLUETOOTH, NONE

View File

@ -1,26 +0,0 @@
<!--
@author Google LLC
Copyright (C) 2021 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M2,12.5C2,9.46 4.46,7 7.5,7H18c2.21,0 4,1.79 4,4s-1.79,4 -4,4H9.5C8.12,15 7,13.88 7,12.5S8.12,10 9.5,10H17v2H9.41c-0.55,0 -0.55,1 0,1H18c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2H7.5C5.57,9 4,10.57 4,12.5S5.57,16 7.5,16H17v2H7.5C4.46,18 2,15.54 2,12.5z"/>
</vector>

View File

@ -2,9 +2,7 @@
~ Nextcloud Talk application ~ Nextcloud Talk application
~ ~
~ @author Marcel Hibbe ~ @author Marcel Hibbe
~ @author Andy Scherzinger ~ Copyright (C) 2022 Marcel Hibbe <marcel.hibbe@nextcloud.com>
~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2021 Marcel Hibbe <marcel.hibbe@nextcloud.com>
~ ~
~ 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
@ -25,7 +23,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#121212" android:background="@color/bg_call_screen_dialog"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/standard_padding"> android:paddingBottom="@dimen/standard_padding">
@ -36,7 +34,7 @@
android:padding="@dimen/standard_padding" android:padding="@dimen/standard_padding"
android:text="@string/audio_output_dialog_headline" android:text="@string/audio_output_dialog_headline"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="#99ffffff" android:textColor="@color/grey_600"
android:textSize="@dimen/bottom_sheet_text_size" /> android:textSize="@dimen/bottom_sheet_text_size" />
<LinearLayout <LinearLayout
@ -57,7 +55,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="#99ffffff" /> app:tint="@color/grey_600" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/audio_output_bluetooth_text" android:id="@+id/audio_output_bluetooth_text"
@ -67,7 +65,7 @@
android:layout_marginStart="@dimen/standard_margin" android:layout_marginStart="@dimen/standard_margin"
android:text="@string/audio_output_bluetooth" android:text="@string/audio_output_bluetooth"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="#99ffffff" android:textColor="@color/call_screen_text"
android:textSize="@dimen/bottom_sheet_text_size" /> android:textSize="@dimen/bottom_sheet_text_size" />
</LinearLayout> </LinearLayout>
@ -90,7 +88,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="#99ffffff" /> app:tint="@color/grey_600" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/audio_output_speaker_text" android:id="@+id/audio_output_speaker_text"
@ -100,7 +98,7 @@
android:layout_marginStart="@dimen/standard_margin" android:layout_marginStart="@dimen/standard_margin"
android:text="@string/audio_output_speaker" android:text="@string/audio_output_speaker"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="#99ffffff" android:textColor="@color/call_screen_text"
android:textSize="@dimen/bottom_sheet_text_size" /> android:textSize="@dimen/bottom_sheet_text_size" />
</LinearLayout> </LinearLayout>
@ -123,7 +121,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="#99ffffff" /> app:tint="@color/grey_600" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/audio_output_earspeaker_text" android:id="@+id/audio_output_earspeaker_text"
@ -133,7 +131,7 @@
android:layout_marginStart="@dimen/standard_margin" android:layout_marginStart="@dimen/standard_margin"
android:text="@string/audio_output_phone" android:text="@string/audio_output_phone"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="#99ffffff" android:textColor="@color/call_screen_text"
android:textSize="@dimen/bottom_sheet_text_size" /> android:textSize="@dimen/bottom_sheet_text_size" />
</LinearLayout> </LinearLayout>
@ -156,7 +154,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null" android:contentDescription="@null"
android:src="@drawable/ic_baseline_headset_mic_24" android:src="@drawable/ic_baseline_headset_mic_24"
app:tint="#99ffffff" /> app:tint="@color/grey_600" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/audio_output_wired_headset_text" android:id="@+id/audio_output_wired_headset_text"
@ -166,7 +164,7 @@
android:layout_marginStart="@dimen/standard_margin" android:layout_marginStart="@dimen/standard_margin"
android:text="@string/audio_output_wired_headset" android:text="@string/audio_output_wired_headset"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="#99ffffff" android:textColor="@color/call_screen_text"
android:textSize="@dimen/bottom_sheet_text_size" /> android:textSize="@dimen/bottom_sheet_text_size" />
</LinearLayout> </LinearLayout>

View File

@ -78,6 +78,8 @@
<color name="bg_message_list_outcoming_bubble_deleted">#800082C9</color> <color name="bg_message_list_outcoming_bubble_deleted">#800082C9</color>
<color name="bg_bottom_sheet">#46ffffff</color> <color name="bg_bottom_sheet">#46ffffff</color>
<color name="bg_call_screen_dialog">#121212</color>
<color name="call_screen_text">#ffffffff</color>
<color name="call_buttons_background">#BF999999</color> <color name="call_buttons_background">#BF999999</color>
<color name="favorite_icon_tint">#FFCC00</color> <color name="favorite_icon_tint">#FFCC00</color>

View File

@ -1 +1 @@
554 552