This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun toggleFlash() { | |
when (flashMode) { | |
FlashMode.FLASH_MODE_AUTO -> { | |
flashMode = | |
FlashMode.FLASH_MODE_OFF | |
ivFlash.setImageResource(R.drawable.ic_baseline_flash_off_24) | |
} | |
FlashMode.FLASH_MODE_ON -> { | |
flashMode = | |
FlashMode.FLASH_MODE_AUTO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class FlashMode { | |
FLASH_MODE_AUTO, | |
FLASH_MODE_ON, | |
FLASH_MODE_OFF | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Listener { | |
fun toggleCamera() | |
fun toggleFlash(flashMode: FlashMode) | |
fun capturePhoto() | |
fun startVideoCapturing() | |
fun stopVideoCapturing() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ControlView : LinearLayout { | |
private var isLongPressed: Boolean = false | |
private var flashMode: FlashMode = FlashMode.FLASH_MODE_OFF | |
private var listener: Listener? = null | |
private val timerView = TimerView(context) | |
.apply { | |
layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) | |
visibility = View.INVISIBLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimerView : LinearLayout { | |
private var startTime = 0L | |
private var timerHandler = Handler() | |
private val timerThread = object : Runnable { | |
override fun run() { | |
tvTimer.text = (SystemClock.uptimeMillis() - startTime).toDuration() | |
timerHandler.postDelayed(this, 0) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimberFirestoreTree(private val deviceDetails: DeviceDetails) : Timber.DebugTree() { | |
private val dateFormat = SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()) | |
private val timeFormat = SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS a zzz", Locale.getDefault()) | |
private val date = dateFormat.format(Date(System.currentTimeMillis())) | |
private val logRef = Firebase.firestore.collection("logs/10-06-2020/${deviceDetails.deviceId}") | |
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { | |
if (BuildConfig.REMOTE_LOG_ENABLED) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
// Add this line | |
apply plugin: 'com.google.gms.google-services' | |
dependencies { | |
// add SDKs for desired Firebase products | |
implementation 'com.google.firebase:firebase-database-ktx:19.3.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
// Check that you have the following line (if not, add it): | |
google() // Google's Maven repository | |
} | |
dependencies { | |
... | |
// Add this line | |
classpath 'com.google.gms:google-services:4.3.3' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class RemoteLog( | |
var priority: String, | |
var tag: String?, | |
var message: String, | |
var throwable: String?, | |
val time : String | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class DeviceDetails( | |
val deviceId: String, | |
val osVersion: String = Build.VERSION.RELEASE, | |
val manufacturer: String = Build.MANUFACTURER, | |
val brand: String = Build.BRAND, | |
val device: String = Build.DEVICE, | |
val model: String = Build.MODEL, | |
val appVersionName: String = BuildConfig.VERSION_NAME, | |
val appVersionCode: Int = BuildConfig.VERSION_CODE | |
) |