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
package com.example.myapplication | |
import android.content.Context | |
import android.content.pm.PackageManager | |
import android.os.Bundle | |
import android.util.Log | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.activity.enableEdgeToEdge | |
import androidx.compose.foundation.layout.Column |
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
import android.os.Build | |
//Ref: https://source.android.com/docs/setup/reference/build-numbers#build-ids-defined | |
object BuildHelper { | |
fun getQprNumber(): Int { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return 0 | |
else { | |
when (Build.ID.substring(1, 2)) { |
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
2021-05-01 19:45:38.015 20205-20205/hk.gov.ogcio.covidresultqrscanner.full D/CODE_SCANNER: QR Code detected: HKSARG|VAC|3|1|TC21221-188-4|****456(8)|CHUK, K** K***|24-01-2021|CoronaVac COVID-19 Vaccine (Vero Cell), Inactivated|2019冠狀病毒病疫苗 (克爾來福)|||21-02-2021|CoronaVac COVID-19 Vaccine (Vero Cell), Inactivated|2019冠狀病毒病疫苗 (克爾來福)|||21-02-2021 02:42|MEYCIQDE5j+yB4HK0ERAtSyKe2Svj+2NQsxBfD1/xTzcjECFsQIhAL+aWsEzqbOh2ZWROfQ4IT7iYxmmntQkpemz/K7pNvMd | |
2021-05-01 19:45:38.015 20205-20205/hk.gov.ogcio.covidresultqrscanner.full D/CODE_SCANNER: digitalSignature: MEYCIQDE5j+yB4HK0ERAtSyKe2Svj+2NQsxBfD1/xTzcjECFsQIhAL+aWsEzqbOh2ZWROfQ4IT7iYxmmntQkpemz/K7pNvMd | |
2021-05-01 19:45:38.016 20205-20205/hk.gov.ogcio.covidresultqrscanner.full D/CODE_SCANNER: stringToBeSigned: HKSARG|VAC|3|1|TC21221-188-4|****456(8)|CHUK, K** K***|24-01-2021|CoronaVac COVID-19 Vaccine (Vero Cell), Inactivated|2019冠狀病毒病疫苗 (克爾來福)|||21-02-2021|CoronaVac COVID-19 Vaccine (Vero Cell), Inactivated|2019冠狀病毒病疫苗 (克爾來福)|||21-02-2021 02:42| | |
2021-05-01 19:45:38.01 |
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
import java.lang.IllegalArgumentException | |
class HkidValidator { | |
private val acceptedChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " | |
private val hkidRegex = Regex("[A-Z]{1,2}\\d{6}") | |
@ExperimentalStdlibApi | |
fun calcCheckDigit(input: String): Char { | |
return if (input.matches(hkidRegex)) { | |
val id = if (input.length == 7) " $input" else input |
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
import android.annotation.SuppressLint | |
import android.content.Intent | |
import android.content.pm.PackageManager | |
import android.os.Build | |
import androidx.annotation.IntDef | |
//Make sure you have the following declared in Manifest when running on Android 11+ | |
//<queries> | |
//<package android:name="com.google.android.tvlauncher" /> | |
//<package android:name="com.google.android.leanbacklauncher" /> |
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
protected open fun AndroidViewModel.getString(@StringRes resId: Int) = | |
getApplication<Application>().resources.getString(resId) | |
protected open fun AndroidViewModel.getStringArray(@ArrayRes resId: Int): Array<String> = | |
getApplication<Application>().resources.getStringArray(resId) |
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
val supportedHardwareAcceleratedDecodeType = MediaCodecList(MediaCodecList.REGULAR_CODECS).codecInfos | |
.filter { !it.isEncoder && it.isHardwareAccelerated } | |
.map { it.supportedTypes.toList() } | |
.flatten() | |
.toSortedSet() |
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
//curl 'https://hkt-mobile-api.nowtv.now.com/09/1/getLiveURL' -H 'Accept: */*' -H 'Referer: https://news.now.com/home/live331a' -H 'Origin: https://news.now.com' -H 'User-Agent: Mozilla/5.0 (X11; CrOS x86_64 12105.75.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.102 Safari/537.36' -H 'Content-Type: application/json' --data-binary '{"channelno":"331","mode":"prod","audioCode":"","format":"HLS","callerReferenceNo":"20140702122500"}' --compressed | |
{"asset":{"hls":{"fix":{"2":["http://ewcdnsite06.nowe.com/session/09-66f7223b8ba659a79719d70a1aeee/Content/HLS/LIVE/Channel(HLS_CH331)/Stream(02)/index.m3u8?token=0425484f980b53d36d0293acc69c55b2_1562399934"],"1":["http://ewcdnsite06.nowe.com/session/09-66f7223b8ba659a79719d70a1aeee/Content/HLS/LIVE/Channel(HLS_CH331)/Stream(01)/index.m3u8?token=d3db0393451ab9b83b4d738376c7e979_1562399934"]},"adaptive":["http://ewcdnsite06.nowe.com/session/09-66f7223b8ba659a79719d70a1aeee/Content/HLS/LIVE/Channel(HLS_CH331)/index.m3u8?token=37c2269e3eff183d98c4c3084ac72060_ |
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
import android.content.Context; | |
import android.graphics.Point; | |
import android.view.Display; | |
import android.view.WindowManager; | |
import android.widget.Toast; | |
/** | |
* A collection of utility methods, all static. | |
*/ | |
public class Utils { |
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
import android.content.Context; | |
import android.graphics.Point; | |
import android.view.Display; | |
import android.view.WindowManager; | |
import android.widget.Toast; | |
/** | |
* A collection of utility methods, all static. | |
*/ | |
public class Utils { |
NewerOlder