Initial commit

This commit is contained in:
2024-01-17 11:29:40 +08:00
commit 1f33887a95
41 changed files with 1280 additions and 0 deletions

63
app/build.gradle.kts Normal file
View File

@@ -0,0 +1,63 @@
plugins {
autowire(libs.plugins.android.application)
autowire(libs.plugins.kotlin.android)
}
android {
namespace = property.project.app.packageName
compileSdk = property.project.android.compileSdk
defaultConfig {
applicationId = property.project.app.packageName
minSdk = property.project.android.minSdk
targetSdk = property.project.android.targetSdk
versionName = property.project.app.versionName
versionCode = property.project.app.versionCode
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf(
"-Xno-param-assertions",
"-Xno-call-assertions",
"-Xno-receiver-assertions"
)
}
composeOptions {
kotlinCompilerExtensionVersion = property.project.android.compose.kotlinCompilerExtensionVersion
}
buildFeatures {
buildConfig = true
compose = true
}
}
dependencies {
implementation(com.highcapable.flexiui.core.android)
implementation(com.highcapable.betterandroid.ui.component)
implementation(com.highcapable.betterandroid.ui.extension)
implementation(com.highcapable.betterandroid.system.extension)
implementation(com.highcapable.betterandroid.compose.extension)
implementation(androidx.activity.activity)
implementation(androidx.activity.activity.compose)
implementation(platform(androidx.compose.compose.bom))
implementation(androidx.compose.ui.ui)
implementation(androidx.compose.ui.ui.graphics)
implementation(androidx.compose.ui.ui.tooling)
implementation(androidx.compose.ui.ui.tooling.preview)
implementation(androidx.compose.foundation.foundation)
implementation(androidx.navigation.navigation.compose)
testImplementation(junit.junit)
androidTestImplementation(androidx.test.ext.junit)
androidTestImplementation(androidx.test.espresso.espresso.core)
}

32
app/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,32 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# 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
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
public static *** throwUninitializedProperty(...);
public static *** throwUninitializedPropertyAccessException(...);
}
-keep class * extends android.app.Activity
-keep class * implements androidx.viewbinding.ViewBinding {
<init>();
*** inflate(android.view.LayoutInflater);
}

View File

@@ -0,0 +1,24 @@
package __PACKAGE_NAME__
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("__PACKAGE_NAME__", appContext.packageName)
}
}

View File

@@ -0,0 +1,24 @@
<?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:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.DefaultAppTheme"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,85 @@
package __PACKAGE_NAME__
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.highcapable.betterandroid.ui.component.activity.AppComponentActivity
import com.highcapable.betterandroid.ui.component.systembar.style.SystemBarStyle
import com.highcapable.betterandroid.ui.component.systembar.type.SystemBars
import com.highcapable.flexiui.component.AreaColumn
import com.highcapable.flexiui.component.Button
import com.highcapable.flexiui.component.PrimaryAppBar
import com.highcapable.flexiui.component.Scaffold
import com.highcapable.flexiui.component.Text
import __PACKAGE_NAME__.theme.MyApplicationTheme
class MainActivity : AppComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val currentDarkMode = isSystemInDarkTheme()
systemBars.setStyle(
if (currentDarkMode)
SystemBarStyle.DarkTransparent
else SystemBarStyle.LightTransparent
)
// Generated by https://github.com/BetterAndroid/android-compose-app-template
// You can visit https://github.com/BetterAndroid/FlexiUI to learn how to use Flexi UI.
MyApplicationTheme(darkTheme = currentDarkMode) {
MainScreen()
}
}
}
@Composable
fun MainScreen() {
Scaffold(
appBar = {
PrimaryAppBar(
title = { Text("__APP_NAME__") }
)
}
) { innerPadding ->
var hideOrShowBars by remember { mutableStateOf(false) }
var greeting by remember { mutableStateOf("Hello World!") }
AreaColumn(
modifier = Modifier.fillMaxWidth().padding(innerPadding),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = greeting)
NecessarySpacer()
Button(
onClick = { greeting = "Hello Android!" }
) { Text("Greeting") }
NecessarySpacer()
Button(
onClick = { hideOrShowBars = !hideOrShowBars }
) { Text("Trigger SystemBars") }
}
LaunchedEffect(hideOrShowBars) {
if (hideOrShowBars)
systemBars.hide(SystemBars.ALL)
else systemBars.show(SystemBars.ALL)
}
}
}
@Composable
private fun NecessarySpacer() {
Spacer(Modifier.height(20.dp))
}
}

View File

@@ -0,0 +1,19 @@
package __PACKAGE_NAME__.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import com.highcapable.flexiui.FlexiTheme
import com.highcapable.flexiui.defaultColors
@Composable
fun MyApplicationTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val colorScheme = defaultColors(darkTheme)
// Customize Flexi UI theme styles.
FlexiTheme(
colors = colorScheme,
content = content
)
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="48"
android:viewportHeight="48">
<group
android:scaleX="0.4686"
android:scaleY="0.4686"
android:translateX="12.7536"
android:translateY="12.4412">
<path
android:fillColor="@android:color/white"
android:pathData="M43.901,36H4.099C5.102,25.893 13.629,18 24,18C34.371,18 42.898,25.893 43.901,36Z"
android:strokeWidth="4"
android:strokeColor="@android:color/white"
android:strokeLineJoin="round" />
<path
android:pathData="M14,20L10,13"
android:strokeWidth="4"
android:strokeColor="@android:color/white"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:pathData="M33,20L37,13"
android:strokeWidth="4"
android:strokeColor="@android:color/white"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</group>
</vector>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@@ -0,0 +1,7 @@
<resources>
<!-- Base application theme. -->
<style name="Base.Theme.DefaultAppTheme" parent="android:Theme.Material.NoActionBar">
<item name="android:statusBarColor">@color/black</item>
<item name="android:navigationBarColor">@color/black</item>
</style>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FF639F70</color>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">__APP_NAME__</string>
</resources>

View File

@@ -0,0 +1,9 @@
<resources>
<!-- Base application theme. -->
<style name="Base.Theme.DefaultAppTheme" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">@color/white</item>
<item name="android:navigationBarColor">@color/white</item>
</style>
<style name="Theme.DefaultAppTheme" parent="Base.Theme.DefaultAppTheme" />
</resources>

View File

@@ -0,0 +1,17 @@
package __PACKAGE_NAME__
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}