Skip to content

Instantly share code, notes, and snippets.

View dturner's full-sized avatar
🎧

Don Turner dturner

🎧
  • Google
  • London
  • 15:30 (UTC)
View GitHub Profile
qtconnectivity$ git diff
diff --git a/src/bluetooth/qbluetoothserver_android.cpp b/src/bluetooth/qbluetoothserver_android.cpp
index ff100d3..a2d0875 100644
--- a/src/bluetooth/qbluetoothserver_android.cpp
+++ b/src/bluetooth/qbluetoothserver_android.cpp
@@ -145,7 +145,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &localAdapter, quint16 por
}
if (!found) {
- qWarning(QT_BT_ANDROID) << localAdapter.toString() << "is not a valid local Bt adapter";
@dturner
dturner / audio_decode_speeds.csv
Last active March 19, 2019 18:47
FFmpeg vs Android NDK decode speeds
Compression format Decode time (seconds) NDKMediaCodec Decode time (seconds) FFmpeg
MP3 16.7 1.2
AAC (with M4A container) 18.8 0.7
@dturner
dturner / ffmpeg-build.sh
Last active June 14, 2022 07:03
FFmpeg configure options
#!/bin/bash
if [ -z "$ANDROID_NDK" ]; then
echo "Please set ANDROID_NDK to the Android NDK folder"
exit 1
fi
#Change to your local machine's architecture
HOST_OS_ARCH=darwin-x86_64
function configure_ffmpeg {
#!/bin/bash
# Script which copies libraries from the FFmpeg build folder to a
# folder within an Android Studio project in the correct structure
# Should be run from the FFmpeg root folder.
# Check that a target directory has been supplied
if [ -z "$1" ]
then
echo "Usage: copy_to_project.sh <target directory>. Example: copy_to_project.sh \${ANDROID_PROJECT}/app/libs"
@dturner
dturner / OptimalVideoSettings.kt
Created March 24, 2022 16:01
Example of using performance class to determine video encoding settings
class OptimalVideoSettings(context: Context){
private val devicePerf: DevicePerformance = DevicePerformance.create(context)
val encodeHeight by lazy {
when (devicePerf.mediaPerformanceClass) {
Build.VERSION_CODES.S -> 1080 // On performance class 12 use 1080p
Build.VERSION_CODES.R -> 720 // On performance class 11 use 720p
else -> 480
}
@dturner
dturner / MyApplication.kt
Created March 24, 2022 16:02
Reporting performance class to Firebase analytics
class MyApplication : Application() {
private lateinit var devicePerf: DevicePerformance
private lateinit var firebaseAnalytics: FirebaseAnalytics
override fun onCreate() {
devicePerf = DevicePerformance.create(this)
firebaseAnalytics = Firebase.analytics
firebaseAnalytics.setUserProperty(
@dturner
dturner / BookmarksViewModel.kt
Created December 13, 2022 11:07
BookmarksViewModel - Before adding domain layer
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class BookmarksViewModel @Inject constructor(
newsRepository: NewsRepository,
private val userDataRepository: UserDataRepository
) : ViewModel() {
// #1. Obtain a list of bookmarks.
private val bookmarks: StateFlow<Set<String>> =
@dturner
dturner / GetSaveableNewsResourcesUseCase.kt
Created December 13, 2022 11:09
Adding GetSaveableNewsResourcesUseCase
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class GetSaveableNewsResourcesUseCase @Inject constructor(
private val newsRepository: NewsRepository,
userDataRepository: UserDataRepository
) {
private val bookmarks = userDataRepository.userDataStream.map { userData ->
userData.bookmarkedNewsResources
}
@dturner
dturner / BookmarksViewModel.kt
Created December 13, 2022 11:11
BookmarksViewModel - After adding domain layer
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class BookmarksViewModel @Inject constructor(
getSaveableNewsResources: GetSaveableNewsResourcesUseCase
) : ViewModel() {
val feedState: StateFlow<NewsFeedUiState> = getSaveableNewsResources()
.map { newsResources ->
newsResources.filter(SaveableNewsResource::isSaved)
@dturner
dturner / nav_uri_parameters.md
Last active September 13, 2024 14:04
AndroidX Navigation URI parameters
Path parameter Query parameter
Used for required arguments optional arguments
collections (arrays and lists)
Example fields val id: String
val code: Int?
val color: String? = null
val variants: List<String> = emptyList()
Generated URL format /{id}/{code} ?color={color}&variants={variant1}&variants={variant2}
Example URL product/ABC/123 product?color=red&amp;variants=small&amp;variants=medium