Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View File

@ -0,0 +1,165 @@
package tech.kinc
import android.app.NativeActivity
import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Message
import android.os.Vibrator
import android.os.VibrationEffect
import android.os.Build
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import kotlin.system.exitProcess
class KincActivity: NativeActivity(), KeyEvent.Callback {
companion object {
var instance: KincActivity? = null
@JvmStatic
fun showKeyboard() {
instance!!.inputManager!!.showSoftInput(instance!!.window.decorView, 0)
}
@JvmStatic
fun hideKeyboard() {
instance!!.inputManager!!.hideSoftInputFromWindow(instance!!.window.decorView.windowToken, 0)
instance!!.delayedHideSystemUI()
}
@JvmStatic
fun loadURL(url: String) {
val i = Intent(Intent.ACTION_VIEW, Uri.parse(url))
instance!!.startActivity(i)
}
@JvmStatic
fun getLanguage(): String {
return java.util.Locale.getDefault().language
}
@JvmStatic
fun vibrate(ms: Int) {
val v: Vibrator = instance!!.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
v.vibrate(VibrationEffect.createOneShot(ms.toLong(), VibrationEffect.DEFAULT_AMPLITUDE))
}
else {
// deprecated in API 26
v.vibrate(ms.toLong())
}
}
@JvmStatic
fun getRotation(): Int {
val context: Context = instance!!.applicationContext
val manager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
return manager.defaultDisplay.rotation
}
@JvmStatic
fun getScreenDpi(): Int {
val context: Context = instance!!.applicationContext
val manager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val metrics: android.util.DisplayMetrics = android.util.DisplayMetrics()
manager.defaultDisplay.getMetrics(metrics)
return metrics.xdpi.toInt()
}
@JvmStatic
fun getRefreshRate(): Int {
val context: Context = instance!!.applicationContext
val manager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
return manager.defaultDisplay.refreshRate.toInt()
}
@JvmStatic
fun getDisplayWidth(): Int {
val context: Context = instance!!.applicationContext
val manager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val size: android.graphics.Point = android.graphics.Point()
manager.defaultDisplay.getRealSize(size)
return size.x
}
@JvmStatic
fun getDisplayHeight(): Int {
val context: Context = instance!!.applicationContext
val manager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val size: android.graphics.Point = android.graphics.Point()
manager.defaultDisplay.getRealSize(size)
return size.y
}
@JvmStatic
fun stop() {
instance!!.runOnUiThread {
fun run() {
instance!!.finish()
exitProcess(0)
}
}
}
class MyHandler(private val kincActivity: KincActivity) : Handler() {
override fun handleMessage(msg: Message) {
kincActivity.hideSystemUI()
}
}
}
var inputManager: InputMethodManager? = null
private var isDisabledStickyImmersiveMode = false
private val hideSystemUIHandler = MyHandler(this)
override fun onCreate(state: Bundle?) {
super.onCreate(state)
hideSystemUI()
instance = this
inputManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
isDisabledStickyImmersiveMode = try {
val ai: ApplicationInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
val bundle: Bundle = ai.metaData
bundle.getBoolean("disableStickyImmersiveMode")
} catch (e: PackageManager.NameNotFoundException) {
false
} catch (e: NullPointerException) {
false
}
}
private fun hideSystemUI() {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
}
private fun delayedHideSystemUI() {
hideSystemUIHandler.removeMessages(0)
if (!isDisabledStickyImmersiveMode) {
hideSystemUIHandler.sendEmptyMessageDelayed(0, 300)
}
}
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
delayedHideSystemUI()
}
else {
hideSystemUIHandler.removeMessages(0)
}
}
override fun onKeyMultiple(keyCode: Int, count: Int, event: KeyEvent): Boolean {
this.nativeKincKeyPress(event.characters)
return false
}
private external fun nativeKincKeyPress(chars: String)
}

View File

@ -0,0 +1,50 @@
package tech.kinc
import java.util.ArrayList
import android.view.Surface
class KincMoviePlayer(var path: String) {
companion object {
var players = ArrayList<KincMoviePlayer?>()
@JvmStatic
fun updateAll() {
for (player in KincMoviePlayer.players) {
player!!.update()
}
}
fun remove(id: Int) {
players[id] = null
}
}
private var movieTexture: KincMovieTexture? = null
var id: Int = players.size
init {
players.add(this)
}
fun init() {
movieTexture = KincMovieTexture()
val surface = Surface(movieTexture!!.surfaceTexture)
nativeCreate(path, surface, id)
surface.release()
}
fun getMovieTexture(): KincMovieTexture? {
return movieTexture
}
fun update(): Boolean {
return movieTexture!!.update()
}
fun getTextureId(): Int {
return movieTexture!!.textureId
}
private external fun nativeCreate(path: String, surface: Surface, id: Int)
}

View File

@ -0,0 +1,62 @@
package tech.kinc
import android.graphics.SurfaceTexture
import android.graphics.SurfaceTexture.OnFrameAvailableListener
import android.opengl.GLES20
class KincMovieTexture: OnFrameAvailableListener {
private val GL_TEXTURE_EXTERNAL_OES: Int = 0x8D65
var textureId: Int = 0
init {
val textures = IntArray(1)
GLES20.glGenTextures(1, textures, 0)
textureId = textures[0]
GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureId)
GLES20.glTexParameteri(
GL_TEXTURE_EXTERNAL_OES,
GLES20.GL_TEXTURE_MIN_FILTER,
GLES20.GL_NEAREST
)
GLES20.glTexParameteri(
GL_TEXTURE_EXTERNAL_OES,
GLES20.GL_TEXTURE_MAG_FILTER,
GLES20.GL_LINEAR
)
GLES20.glTexParameteri(
GL_TEXTURE_EXTERNAL_OES,
GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_CLAMP_TO_EDGE
)
GLES20.glTexParameteri(
GL_TEXTURE_EXTERNAL_OES,
GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_CLAMP_TO_EDGE
)
}
var surfaceTexture = SurfaceTexture(textureId)
init {
surfaceTexture.setOnFrameAvailableListener(this)
}
private var updateTexture = false
fun update(): Boolean {
val ret = updateTexture
if (updateTexture) {
surfaceTexture.updateTexImage()
updateTexture = false
}
return ret
}
override fun onFrameAvailable(surface: SurfaceTexture) {
if (surfaceTexture == surface) {
updateTexture = true
}
}
}