This commit is contained in:
Inderpal Singh Aulakh 2022-02-11 13:44:14 -08:00 коммит произвёл GitHub
Родитель 55d79f144c
Коммит 9b9d5e3d82
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 85 добавлений и 13 удалений

Просмотреть файл

@ -11,6 +11,7 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.azure.android.communication.ui.callingcompositedemoapp.databinding.ActivityCallLauncherBinding
import com.azure.android.communication.ui.callingcompositedemoapp.diagnostics.FpsDiagnostics
import com.azure.android.communication.ui.callingcompositedemoapp.diagnostics.MemoryViewer
import com.azure.android.communication.ui.callingcompositedemoapp.launcher.CallingCompositeLauncher
import java.util.UUID
@ -113,12 +114,19 @@ class CallLauncherActivity : AppCompatActivity() {
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
memoryDiagnosticsCheckBox.visibility = View.VISIBLE
memoryDiagnosticsCheckBox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
MemoryViewer.getMemoryViewer(application).show()
} else {
MemoryViewer.getMemoryViewer(application).hide()
val diagnostics =
applicationContext.resources.getBoolean(R.bool.diagnostics)
if (diagnostics) {
diagnosticsCheckBox.visibility = View.VISIBLE
diagnosticsCheckBox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
MemoryViewer.getMemoryViewer(application).show()
FpsDiagnostics.getFpsDiagnostics(application).start()
} else {
MemoryViewer.getMemoryViewer(application).hide()
FpsDiagnostics.getFpsDiagnostics(application).stop()
}
}
}
}
@ -148,9 +156,10 @@ class CallLauncherActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
// helps to turn on memory profiling when permissions change
if (binding.memoryDiagnosticsCheckBox.isChecked) {
// helps to turn on memory, fps profiling when permissions change
if (binding.diagnosticsCheckBox.isChecked) {
MemoryViewer.getMemoryViewer(application).show()
FpsDiagnostics.getFpsDiagnostics(application).start()
}
}
@ -216,7 +225,10 @@ class CallLauncherActivity : AppCompatActivity() {
}
private fun saveState(outState: Bundle?) {
outState?.putBoolean(isTokenFunctionOptionSelected, callLauncherViewModel.isTokenFunctionOptionSelected)
outState?.putBoolean(
isTokenFunctionOptionSelected,
callLauncherViewModel.isTokenFunctionOptionSelected
)
outState?.putBoolean(isKotlinLauncherOptionSelected, callLauncherViewModel.isKotlinLauncher)
}
}

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.android.communication.ui.callingcompositedemoapp.diagnostics
import android.app.Application
import com.microsoft.office.outlook.magnifierlib.Magnifier
import com.microsoft.office.outlook.magnifierlib.frame.FPSMonitorConfig
class FpsDiagnostics private constructor(
private val context: Application,
) {
companion object {
private lateinit var fpsDiagnostics: FpsDiagnostics
fun getFpsDiagnostics(context: Application): FpsDiagnostics {
if (!::fpsDiagnostics.isInitialized) {
fpsDiagnostics = FpsDiagnostics(context)
}
return fpsDiagnostics
}
}
fun start() {
Magnifier.startMonitorFPS(
FPSMonitorConfig.Builder(context)
.lowPercentage(40 / 60f) // show red tips, (2.0f / 3.0f) by default
.mediumPercentage(50 / 60f) // show yellow tips, (5.0f / 6.0f) by default
.refreshRate(60f) // defaultDisplay.refreshRate by default
.build()
)
}
fun stop() {
Magnifier.stopMonitorFPS()
}
}

Просмотреть файл

@ -138,9 +138,9 @@
</RadioGroup>
<CheckBox
android:id="@+id/memoryDiagnosticsCheckBox"
android:id="@+id/diagnosticsCheckBox"
android:layout_width="wrap_content"
android:text="@string/memoryDiagnostics"
android:text="@string/diagnostics"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -154,7 +154,7 @@
android:text="@string/launchButtonText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/memoryDiagnosticsCheckBox"
app:layout_constraintTop_toBottomOf="@id/diagnosticsCheckBox"
/>

Просмотреть файл

@ -1,3 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
-->
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MeetingUI" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
-->
<resources>
<bool name="diagnostics">false</bool>
</resources>

Просмотреть файл

@ -1,3 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
-->
<resources>
<string name="app_name">Communication UI Demo</string>
<string name="tokenUrlHint">Token function URL</string>
@ -12,5 +17,5 @@
<string name="launchTypeText">Launch In:</string>
<string name="tokenFunctionRadioButtonText">Token Function</string>
<string name="acsTokenRadioButtonText">@string/acsTokenHint</string>
<string name="memoryDiagnostics">Memory Diagnostics</string>
<string name="diagnostics">FPS, Memory Diagnostics</string>
</resources>

Просмотреть файл

@ -1,3 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
-->
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MeetingUI" parent="Theme.MaterialComponents.DayNight.DarkActionBar">