-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tile service with tinymix command
- Loading branch information
0 parents
commit d86a954
Showing
31 changed files
with
673 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
} | ||
|
||
android { | ||
namespace = "com.rlabs.dakc" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.rlabs.dakc" | ||
minSdk = 24 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.1" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.ui) | ||
implementation(libs.androidx.ui.graphics) | ||
implementation(libs.androidx.ui.tooling.preview) | ||
implementation(libs.androidx.material3) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.androidx.junit) | ||
androidTestImplementation(libs.androidx.espresso.core) | ||
androidTestImplementation(platform(libs.androidx.compose.bom)) | ||
androidTestImplementation(libs.androidx.ui.test.junit4) | ||
debugImplementation(libs.androidx.ui.tooling) | ||
debugImplementation(libs.androidx.ui.test.manifest) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/rlabs/dakc/ExampleInstrumentedTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.rlabs.dakc | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.rlabs.dakc", appContext.packageName) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@drawable/audiodack" | ||
android:label="@string/app_name" | ||
android:roundIcon="@drawable/audiodack" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.DAKC" | ||
tools:targetApi="31"> | ||
<service | ||
android:name=".DakcTileService" | ||
android:enabled="true" | ||
android:exported="true" | ||
android:icon="@drawable/audiodack" | ||
android:label="DAkC it" | ||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> | ||
<intent-filter> | ||
<action android:name="android.service.quicksettings.action.QS_TILE" /> | ||
</intent-filter> | ||
</service> | ||
|
||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.DAKC"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.rlabs.dakc | ||
|
||
import android.service.quicksettings.TileService | ||
import android.util.Log | ||
import java.io.BufferedReader | ||
import java.io.InputStreamReader | ||
|
||
|
||
class DakcTileService : TileService() { | ||
|
||
|
||
// Called when the user adds your tile. | ||
override fun onTileAdded() { | ||
super.onTileAdded() | ||
} | ||
|
||
// Called when your app can update your tile. | ||
override fun onStartListening() { | ||
super.onStartListening() | ||
} | ||
|
||
// Called when your app can no longer update your tile. | ||
override fun onStopListening() { | ||
super.onStopListening() | ||
} | ||
|
||
// Called when the user taps on your tile in an active or inactive state. | ||
override fun onClick() { | ||
super.onClick() | ||
Log.d("QS", "Tile tapped") | ||
runAsRoot(arrayOf("tinymix -D 2 3 120")) | ||
} | ||
|
||
// Called when the user removes your tile. | ||
override fun onTileRemoved() { | ||
super.onTileRemoved() | ||
} | ||
} | ||
|
||
fun runAsRoot(commands: Array<String>) { | ||
|
||
try { | ||
for (command in commands) { | ||
val processBuilder = ProcessBuilder("su", "-c", command) | ||
val process = processBuilder.start() | ||
|
||
// Read the output | ||
val reader = BufferedReader(InputStreamReader(process.inputStream)) | ||
val errorReader = BufferedReader(InputStreamReader(process.errorStream)) | ||
val output = StringBuilder() | ||
val errorOutput = StringBuilder() | ||
|
||
var line: String? | ||
while (reader.readLine().also { line = it } != null) { | ||
output.append(line).append("\n") | ||
} | ||
while (errorReader.readLine().also { line = it } != null) { | ||
errorOutput.append(line).append("\n") | ||
} | ||
|
||
process.waitFor() | ||
|
||
// Log the output | ||
if (output.isNotEmpty()) { | ||
Log.d("Command Output", output.toString()) | ||
} | ||
if (errorOutput.isNotEmpty()) { | ||
Log.e("Command Error", errorOutput.toString()) | ||
} | ||
|
||
|
||
} | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.rlabs.dakc | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.rlabs.dakc.ui.theme.DAKCTheme | ||
|
||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
enableEdgeToEdge() | ||
setContent { | ||
DAKCTheme { | ||
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> | ||
Greeting( | ||
name = "DAkC", | ||
modifier = Modifier.padding(innerPadding) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun Greeting(name: String, modifier: Modifier = Modifier) { | ||
Text( | ||
text = "Hello $name!", | ||
modifier = modifier | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun GreetingPreview() { | ||
DAKCTheme { | ||
Greeting("Android") | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.rlabs.dakc.ui.theme | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
val Purple80 = Color(0xFFD0BCFF) | ||
val PurpleGrey80 = Color(0xFFCCC2DC) | ||
val Pink80 = Color(0xFFEFB8C8) | ||
|
||
val Purple40 = Color(0xFF6650a4) | ||
val PurpleGrey40 = Color(0xFF625b71) | ||
val Pink40 = Color(0xFF7D5260) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.rlabs.dakc.ui.theme | ||
|
||
import android.app.Activity | ||
import android.os.Build | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.dynamicDarkColorScheme | ||
import androidx.compose.material3.dynamicLightColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
|
||
private val DarkColorScheme = darkColorScheme( | ||
primary = Purple80, | ||
secondary = PurpleGrey80, | ||
tertiary = Pink80 | ||
) | ||
|
||
private val LightColorScheme = lightColorScheme( | ||
primary = Purple40, | ||
secondary = PurpleGrey40, | ||
tertiary = Pink40 | ||
|
||
/* Other default colors to override | ||
background = Color(0xFFFFFBFE), | ||
surface = Color(0xFFFFFBFE), | ||
onPrimary = Color.White, | ||
onSecondary = Color.White, | ||
onTertiary = Color.White, | ||
onBackground = Color(0xFF1C1B1F), | ||
onSurface = Color(0xFF1C1B1F), | ||
*/ | ||
) | ||
|
||
@Composable | ||
fun DAKCTheme( | ||
darkTheme: Boolean = isSystemInDarkTheme(), | ||
// Dynamic color is available on Android 12+ | ||
dynamicColor: Boolean = true, | ||
content: @Composable () -> Unit | ||
) { | ||
val colorScheme = when { | ||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { | ||
val context = LocalContext.current | ||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | ||
} | ||
|
||
darkTheme -> DarkColorScheme | ||
else -> LightColorScheme | ||
} | ||
|
||
MaterialTheme( | ||
colorScheme = colorScheme, | ||
typography = Typography, | ||
content = content | ||
) | ||
} |
Oops, something went wrong.