Compare commits
No commits in common. "54275923889a7605a7f9c2d54a9a8eccbca5a81c" and "262548e77c43c05b9280e955417fff9ac0ac8b23" have entirely different histories.
5427592388
...
262548e77c
60 changed files with 369 additions and 1110 deletions
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
|
@ -1,3 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
1
.idea/.name
generated
1
.idea/.name
generated
|
@ -1 +0,0 @@
|
||||||
jetpack-compose-template
|
|
6
.idea/AndroidProjectSystem.xml
generated
6
.idea/AndroidProjectSystem.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="AndroidProjectSystem">
|
|
||||||
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
6
.idea/compiler.xml
generated
6
.idea/compiler.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<bytecodeTargetLevel target="21" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
10
.idea/deploymentTargetSelector.xml
generated
10
.idea/deploymentTargetSelector.xml
generated
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetSelector">
|
|
||||||
<selectionStates>
|
|
||||||
<SelectionState runConfigName="app">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
</selectionStates>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
18
.idea/gradle.xml
generated
18
.idea/gradle.xml
generated
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="GradleSettings">
|
|
||||||
<option name="linkedExternalProjectsSettings">
|
|
||||||
<GradleProjectSettings>
|
|
||||||
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
||||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
|
||||||
<option name="modules">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
<option value="$PROJECT_DIR$/app" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</GradleProjectSettings>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
6
.idea/kotlinc.xml
generated
6
.idea/kotlinc.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="KotlinJpsPluginSettings">
|
|
||||||
<option name="version" value="1.9.10" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
10
.idea/migrations.xml
generated
10
.idea/migrations.xml
generated
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectMigrations">
|
|
||||||
<option name="MigrateToGradleLocalJavaHome">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
10
.idea/misc.xml
generated
10
.idea/misc.xml
generated
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="Android" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
17
.idea/runConfigurations.xml
generated
17
.idea/runConfigurations.xml
generated
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
|
||||||
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
|
||||||
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
|
||||||
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
|
||||||
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
|
||||||
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
13
LICENSE
13
LICENSE
|
@ -1,13 +0,0 @@
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
45
README.md
45
README.md
|
@ -1,45 +0,0 @@
|
||||||
# Jetpack Compose Template
|
|
||||||
|
|
||||||
Welcome to the Jetpack Compose Template! This template provides a structured starting point for building Android applications using the Jetpack Compose UI toolkit. Jetpack Compose simplifies UI development with a declarative approach, allowing you to create interactive and beautiful UIs with less code.
|
|
||||||
|
|
||||||
## Project Overview
|
|
||||||
|
|
||||||
This project demonstrates the use of Jetpack Compose to create a modern Android app with a clean and maintainable architecture.
|
|
||||||
|
|
||||||
### Key Components
|
|
||||||
|
|
||||||
- **Jetpack Compose:** The modern UI toolkit for building native UIs.
|
|
||||||
- **ViewModel:** Manage UI-related data and state using the ViewModel architecture component.
|
|
||||||
- **Hilt:** Use Hilt for dependency injection, ensuring clean and modular code.
|
|
||||||
- **Navigation Component:** Handle navigation between different screens seamlessly.
|
|
||||||
- **Coroutines:** Utilize Kotlin's Coroutines for managing asynchronous tasks.
|
|
||||||
- **Data Persistence:** Leverage Room for local data storage.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
1. **Clone the Repository:** `git clone https://github.com/ferhatozcelik/jetpack-compose-template.git`
|
|
||||||
2. **Open in Android Studio:** Import the project into Android Studio.
|
|
||||||
3. **Build and Run:** Build and run the app to see the Jetpack Compose magic in action.
|
|
||||||
|
|
||||||
## Project Structure
|
|
||||||
|
|
||||||
- `app` module: Contains the main application code.
|
|
||||||
- `src/main/java or src/main/kotlin`: Kotlin source code.
|
|
||||||
- `src/main/res`: Resources like layouts, strings, and drawables.
|
|
||||||
|
|
||||||
## Customize and Extend
|
|
||||||
|
|
||||||
Feel free to customize and extend this template to match the requirements of your specific project. Experiment with different Composables, UI layouts, and navigation flows to create your unique app.
|
|
||||||
|
|
||||||
## Author
|
|
||||||
|
|
||||||
👤 Your Name
|
|
||||||
|
|
||||||
- GitHub: [@ferhatozcelik](https://github.com/ferhatozcelik)
|
|
||||||
- LinkedIn: [Ferhat OZCELIK](https://www.linkedin.com/in/ferhatozcelik/)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
||||||
|
|
||||||
If you find this template helpful, please consider giving it a ⭐️ on GitHub. Your support is greatly appreciated!
|
|
1
app/.gitignore
vendored
1
app/.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
/build
|
/build
|
||||||
/.idea/**
|
|
134
app/build.gradle
134
app/build.gradle
|
@ -1,134 +0,0 @@
|
||||||
plugins {
|
|
||||||
alias(libs.plugins.com.android.application)
|
|
||||||
alias(libs.plugins.org.jetbrains.kotlin.android)
|
|
||||||
alias(libs.plugins.com.google.dagger.hilt.android)
|
|
||||||
alias(libs.plugins.com.google.devtools.ksp)
|
|
||||||
id('kotlin-parcelize')
|
|
||||||
// id("com.google.gms.google-services") // Google Play Services
|
|
||||||
// id("com.google.firebase.crashlytics") // Google Play Services
|
|
||||||
}
|
|
||||||
hilt {
|
|
||||||
enableAggregatingTask = true
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
namespace 'com.ferhatozcelik.jetpackcomposetemplate'
|
|
||||||
compileSdk appCompileSdkVersion
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.ferhatozcelik.jetpackcomposetemplate"
|
|
||||||
minSdk appMinSdkVersion
|
|
||||||
targetSdk appTargetSdkVersion
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
vectorDrawables {
|
|
||||||
useSupportLibrary true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.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.3'
|
|
||||||
}
|
|
||||||
packagingOptions {
|
|
||||||
resources {
|
|
||||||
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
// Kotlin
|
|
||||||
implementation(libs.kotlin.stdlib)
|
|
||||||
implementation(libs.core.ktx)
|
|
||||||
implementation(libs.appcompat)
|
|
||||||
|
|
||||||
// Compose
|
|
||||||
implementation(libs.activity.compose)
|
|
||||||
implementation(platform(libs.compose.bom))
|
|
||||||
implementation(libs.ui)
|
|
||||||
implementation(libs.ui.graphics)
|
|
||||||
implementation(libs.ui.tooling.preview)
|
|
||||||
implementation(libs.material3)
|
|
||||||
|
|
||||||
// JUnit
|
|
||||||
testImplementation(libs.junit)
|
|
||||||
androidTestImplementation(libs.androidx.test.ext.junit)
|
|
||||||
androidTestImplementation(libs.espresso.core)
|
|
||||||
androidTestImplementation(platform(libs.compose.bom))
|
|
||||||
androidTestImplementation(libs.ui.test.junit4)
|
|
||||||
debugImplementation(libs.ui.tooling)
|
|
||||||
debugImplementation(libs.ui.test.manifest)
|
|
||||||
|
|
||||||
// Material Design
|
|
||||||
implementation(libs.material)
|
|
||||||
implementation libs.androidx.viewpager2
|
|
||||||
|
|
||||||
// ConstraintLayout
|
|
||||||
implementation(libs.constraintlayout)
|
|
||||||
|
|
||||||
// Legacy Support Library
|
|
||||||
implementation(libs.androidx.legacy.support.v4)
|
|
||||||
|
|
||||||
// Multidex
|
|
||||||
implementation(libs.androidx.multidex)
|
|
||||||
|
|
||||||
// DeSugar Use Java 8 language features and APIs
|
|
||||||
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
|
||||||
|
|
||||||
// Dagger Hilt
|
|
||||||
implementation(libs.hilt)
|
|
||||||
ksp(libs.hilt.compiler)
|
|
||||||
|
|
||||||
// Room
|
|
||||||
implementation(libs.room)
|
|
||||||
implementation(libs.room.runtime)
|
|
||||||
ksp(libs.room.compiler)
|
|
||||||
|
|
||||||
// Coroutines
|
|
||||||
implementation(libs.kotlinx.coroutines.core)
|
|
||||||
implementation(libs.kotlinx.coroutines.android)
|
|
||||||
|
|
||||||
// Lifecycle Scopes
|
|
||||||
implementation(libs.lifecycle)
|
|
||||||
implementation(libs.lifecycle.runtime)
|
|
||||||
implementation(libs.lifecycle.runtime.ktx)
|
|
||||||
|
|
||||||
// Retrofit
|
|
||||||
implementation(libs.retrofit)
|
|
||||||
implementation(libs.converter.gson)
|
|
||||||
implementation(libs.logging.interceptor)
|
|
||||||
|
|
||||||
// Navigation
|
|
||||||
implementation libs.androidx.hilt.navigation.compose
|
|
||||||
implementation libs.androidx.navigation.compose
|
|
||||||
|
|
||||||
|
|
||||||
// Glide
|
|
||||||
implementation(libs.glide)
|
|
||||||
ksp(libs.ksp)
|
|
||||||
|
|
||||||
// Firebase
|
|
||||||
// implementation(libs.firebase)
|
|
||||||
// implementation(libs.analytics)
|
|
||||||
// implementation(libs.crashlytics)
|
|
||||||
|
|
||||||
}
|
|
59
app/build.gradle.kts
Normal file
59
app/build.gradle.kts
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
|
alias(libs.plugins.kotlin.compose)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "com.example.gyromin"
|
||||||
|
compileSdk = 35
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "com.example.gyromin"
|
||||||
|
minSdk = 21
|
||||||
|
targetSdk = 35
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "11"
|
||||||
|
}
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate
|
package com.example.gyromin
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
@ -19,6 +19,6 @@ class ExampleInstrumentedTest {
|
||||||
fun useAppContext() {
|
fun useAppContext() {
|
||||||
// Context of the app under test.
|
// Context of the app under test.
|
||||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
assertEquals("com.ferhatozcelik.myapplication", appContext.packageName)
|
assertEquals("com.example.gyromin", appContext.packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,10 +2,9 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-feature android:name="android.hardware.sensor.gyroscope" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
<application
|
<application
|
||||||
android:name=".App"
|
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
@ -13,12 +12,13 @@
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.MyApplication"
|
android:theme="@style/Theme.Gyromin"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activitys.MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:theme="@style/Theme.MyApplication">
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/Theme.Gyromin">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
|
113
app/src/main/java/com/example/gyromin/MainActivity.kt
Normal file
113
app/src/main/java/com/example/gyromin/MainActivity.kt
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
package com.example.gyromin
|
||||||
|
|
||||||
|
import android.media.AudioManager
|
||||||
|
import android.media.AudioTrack
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import com.example.gyromin.ui.theme.GyrominTheme
|
||||||
|
import kotlin.math.atan
|
||||||
|
import kotlin.math.sin
|
||||||
|
|
||||||
|
class MainActivity : ComponentActivity() {
|
||||||
|
private lateinit var Track: AudioTrack
|
||||||
|
private var isPlaying: Boolean = false
|
||||||
|
private val Fs: Int = 44100
|
||||||
|
private val buffLength: Int = AudioTrack.getMinBufferSize(Fs, 4, 2)
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContent {
|
||||||
|
GyrominTheme {
|
||||||
|
Scaffold { padding ->
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Button(onClick = {
|
||||||
|
if (!isPlaying)
|
||||||
|
// Create a new thread to play the audio.
|
||||||
|
|
||||||
|
// Performing intensive operations and computations on the main UI thread,
|
||||||
|
// makes the app slow.
|
||||||
|
|
||||||
|
// That is, it is a bad idea to do intensive computations on main UI thread,
|
||||||
|
// so it is recommended to create a new thread to do computations in the background
|
||||||
|
|
||||||
|
Thread {
|
||||||
|
initTrack()
|
||||||
|
startPlaying()
|
||||||
|
playback()
|
||||||
|
}.start()
|
||||||
|
else stopPlaying()
|
||||||
|
}) {
|
||||||
|
Text("Play / Pause", modifier = Modifier.padding(padding))
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
if (isPlaying) "Playing" else "Stopped",
|
||||||
|
modifier = Modifier.padding(padding)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initTrack() {
|
||||||
|
// Very similar to opening a stream in PyAudio
|
||||||
|
// In Android create a AudioTrack instance and initialize it with different parameters
|
||||||
|
|
||||||
|
// AudioTrack is deprecated for some android versions
|
||||||
|
// Please look up for other alternatives if this does not work
|
||||||
|
Track = AudioTrack(
|
||||||
|
AudioManager.MODE_NORMAL, Fs, 4,
|
||||||
|
2, buffLength, AudioTrack.MODE_STREAM
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun playback() {
|
||||||
|
// simple sine wave generator
|
||||||
|
val frame_out = ShortArray(buffLength)
|
||||||
|
val amplitude = 32767
|
||||||
|
val frequency = 440
|
||||||
|
val twopi: Double = 8.0 * atan(1.0)
|
||||||
|
var phase = 0.0
|
||||||
|
|
||||||
|
while (isPlaying) {
|
||||||
|
for (i in 0 until buffLength) {
|
||||||
|
frame_out[i] = (amplitude * sin(phase)).toInt().toShort()
|
||||||
|
phase += twopi * frequency / Fs
|
||||||
|
if (phase > twopi) {
|
||||||
|
phase -= twopi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Track.write(frame_out, 0, buffLength)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startPlaying() {
|
||||||
|
Track.play()
|
||||||
|
isPlaying = true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun stopPlaying() {
|
||||||
|
if (isPlaying) {
|
||||||
|
isPlaying = false
|
||||||
|
// Stop playing the audio data and release the resources
|
||||||
|
Track.stop()
|
||||||
|
Track.release()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.theme
|
package com.example.gyromin.ui.theme
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.theme
|
package com.example.gyromin.ui.theme
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
@ -9,11 +9,7 @@ import androidx.compose.material3.dynamicDarkColorScheme
|
||||||
import androidx.compose.material3.dynamicLightColorScheme
|
import androidx.compose.material3.dynamicLightColorScheme
|
||||||
import androidx.compose.material3.lightColorScheme
|
import androidx.compose.material3.lightColorScheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.SideEffect
|
|
||||||
import androidx.compose.ui.graphics.toArgb
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalView
|
|
||||||
import androidx.core.view.WindowCompat
|
|
||||||
|
|
||||||
private val DarkColorScheme = darkColorScheme(
|
private val DarkColorScheme = darkColorScheme(
|
||||||
primary = Purple80,
|
primary = Purple80,
|
||||||
|
@ -38,7 +34,7 @@ private val LightColorScheme = lightColorScheme(
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MyApplicationTheme(
|
fun GyrominTheme(
|
||||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
// Dynamic color is available on Android 12+
|
// Dynamic color is available on Android 12+
|
||||||
dynamicColor: Boolean = true,
|
dynamicColor: Boolean = true,
|
||||||
|
@ -53,14 +49,6 @@ fun MyApplicationTheme(
|
||||||
darkTheme -> DarkColorScheme
|
darkTheme -> DarkColorScheme
|
||||||
else -> LightColorScheme
|
else -> LightColorScheme
|
||||||
}
|
}
|
||||||
val view = LocalView.current
|
|
||||||
if (!view.isInEditMode) {
|
|
||||||
SideEffect {
|
|
||||||
val window = (view.context as Activity).window
|
|
||||||
window.statusBarColor = colorScheme.primary.toArgb()
|
|
||||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialTheme(
|
MaterialTheme(
|
||||||
colorScheme = colorScheme,
|
colorScheme = colorScheme,
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.theme
|
package com.example.gyromin.ui.theme
|
||||||
|
|
||||||
import androidx.compose.material3.Typography
|
import androidx.compose.material3.Typography
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
|
@ -1,7 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
|
||||||
|
|
||||||
@HiltAndroidApp
|
|
||||||
class App : Application()
|
|
|
@ -1,21 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.dao
|
|
||||||
|
|
||||||
import androidx.room.*
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.entity.ExampleEntity
|
|
||||||
|
|
||||||
@Dao
|
|
||||||
interface ExampleDao {
|
|
||||||
|
|
||||||
@Query("SELECT * FROM example_table")
|
|
||||||
fun getExampleData(): List<ExampleEntity>
|
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
||||||
suspend fun insert(search: ExampleEntity?)
|
|
||||||
|
|
||||||
@Update
|
|
||||||
suspend fun update(search: ExampleEntity)
|
|
||||||
|
|
||||||
@Delete
|
|
||||||
suspend fun delete(search: ExampleEntity)
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.entity
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import androidx.room.Entity
|
|
||||||
import androidx.room.PrimaryKey
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
@Entity(tableName = "example_table")
|
|
||||||
data class ExampleEntity(
|
|
||||||
@PrimaryKey(autoGenerate = true)
|
|
||||||
var id: Int? = null,
|
|
||||||
val title: String?,
|
|
||||||
val description: String?
|
|
||||||
) : Parcelable
|
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.local
|
|
||||||
|
|
||||||
import androidx.room.Database
|
|
||||||
import androidx.room.RoomDatabase
|
|
||||||
import androidx.room.TypeConverters
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.dao.ExampleDao
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.entity.ExampleEntity
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.di.ApplicationScope
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import javax.inject.Inject
|
|
||||||
import javax.inject.Provider
|
|
||||||
|
|
||||||
@Database(entities = [ExampleEntity::class], version = 1)
|
|
||||||
@TypeConverters(Converters::class)
|
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
|
||||||
|
|
||||||
abstract fun getExampleDao(): ExampleDao
|
|
||||||
|
|
||||||
class Callback @Inject constructor(
|
|
||||||
private val database: Provider<AppDatabase>,
|
|
||||||
@ApplicationScope private val applicationScope: CoroutineScope
|
|
||||||
) : RoomDatabase.Callback()
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.local
|
|
||||||
|
|
||||||
import androidx.room.TypeConverter
|
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
class Converters {
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
fun fromTimestamp(value: Long?): Date {
|
|
||||||
return value?.let { Date(it) } ?: Date(System.currentTimeMillis())
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
fun toTimestamp(value: Date?): Long {
|
|
||||||
return value?.let { value.time } ?: System.currentTimeMillis()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.model
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName
|
|
||||||
|
|
||||||
data class ExampleModel(
|
|
||||||
@SerializedName("title")
|
|
||||||
var title: String?,
|
|
||||||
@SerializedName("description")
|
|
||||||
var description: String?
|
|
||||||
)
|
|
|
@ -1,7 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.model
|
|
||||||
|
|
||||||
sealed class Resource<out T : Any> {
|
|
||||||
object Loading : Resource<Nothing>()
|
|
||||||
data class Success<out T : Any>(val data: Any) : Resource<T>()
|
|
||||||
data class Error(val errorMessage: String) : Resource<Nothing>()
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.remote
|
|
||||||
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.model.ExampleModel
|
|
||||||
import retrofit2.Response
|
|
||||||
import retrofit2.http.*
|
|
||||||
|
|
||||||
interface AppApi {
|
|
||||||
|
|
||||||
@GET("/api/v1/example")
|
|
||||||
suspend fun getExampleResult(): Response<List<ExampleModel>>
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.data.repository
|
|
||||||
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.dao.ExampleDao
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.remote.AppApi
|
|
||||||
import javax.inject.Inject
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
class ExampleRepository @Inject constructor(private val appApi: AppApi, private val exampleDao: ExampleDao)
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.di
|
|
||||||
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.remote.AppApi
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.util.BASE_URL
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.hilt.InstallIn
|
|
||||||
import dagger.hilt.components.SingletonComponent
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
|
||||||
import retrofit2.Retrofit
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Module
|
|
||||||
@InstallIn(SingletonComponent::class)
|
|
||||||
object ApiModule {
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideLoggingInterceptor(): HttpLoggingInterceptor {
|
|
||||||
return HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideOkHttpClient(logging: HttpLoggingInterceptor): OkHttpClient {
|
|
||||||
return OkHttpClient.Builder().addInterceptor(logging).build()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideRetrofit(client: OkHttpClient): Retrofit {
|
|
||||||
return Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create()).client(client).build()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideAppApi(retrofit: Retrofit): AppApi {
|
|
||||||
return retrofit.create(AppApi::class.java)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.di
|
|
||||||
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.hilt.InstallIn
|
|
||||||
import dagger.hilt.components.SingletonComponent
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.SupervisorJob
|
|
||||||
import javax.inject.Qualifier
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Module
|
|
||||||
@InstallIn(SingletonComponent::class)
|
|
||||||
object AppModule {
|
|
||||||
|
|
||||||
@ApplicationScope
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideApplicationScope(): CoroutineScope {
|
|
||||||
return CoroutineScope(SupervisorJob())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
|
||||||
@Qualifier
|
|
||||||
annotation class ApplicationScope
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.di
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.room.Room
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.dao.ExampleDao
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.local.AppDatabase
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.hilt.InstallIn
|
|
||||||
import dagger.hilt.components.SingletonComponent
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Module
|
|
||||||
@InstallIn(SingletonComponent::class)
|
|
||||||
object DatabaseModule {
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideDatabase(application: Application, callback: AppDatabase.Callback): AppDatabase {
|
|
||||||
return Room.databaseBuilder(application, AppDatabase::class.java, "local_database").fallbackToDestructiveMigration().addCallback(callback).build()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
fun provideExampleDao(database: AppDatabase): ExampleDao {
|
|
||||||
return database.getExampleDao()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.navigation
|
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.navigation.NavHostController
|
|
||||||
import androidx.navigation.NavType
|
|
||||||
import androidx.navigation.compose.NavHost
|
|
||||||
import androidx.navigation.compose.composable
|
|
||||||
import androidx.navigation.navArgument
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.ui.detail.DetailScreen
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.ui.home.MainScreen
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun NavGraph(navController: NavHostController) {
|
|
||||||
|
|
||||||
NavHost(
|
|
||||||
navController = navController, startDestination = Screen.Main.route
|
|
||||||
) {
|
|
||||||
|
|
||||||
composable(Screen.Main.route) {
|
|
||||||
MainScreen(navController = navController)
|
|
||||||
}
|
|
||||||
composable(
|
|
||||||
"${Screen.Detail.route}/{id}",
|
|
||||||
arguments = listOf(navArgument("id") { type = NavType.IntType })
|
|
||||||
) {
|
|
||||||
DetailScreen(navController = navController, id = it.arguments?.getInt("id") ?: 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.navigation
|
|
||||||
|
|
||||||
sealed class Screen(val route: String) {
|
|
||||||
object Main : Screen("main_screen")
|
|
||||||
object Detail : Screen("detail_screen")
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.activitys
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.activity.ComponentActivity
|
|
||||||
import androidx.activity.compose.setContent
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Surface
|
|
||||||
import androidx.navigation.compose.rememberNavController
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.navigation.NavGraph
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.ui.theme.MyApplicationTheme
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
|
||||||
class MainActivity : ComponentActivity() {
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContent {
|
|
||||||
MyApplicationTheme {
|
|
||||||
val navController = rememberNavController()
|
|
||||||
Surface(color = MaterialTheme.colorScheme.background) {
|
|
||||||
NavGraph(navController = navController)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.detail
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import androidx.compose.foundation.layout.*
|
|
||||||
import androidx.compose.material.*
|
|
||||||
import androidx.compose.material.icons.filled.*
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.navigation.NavController
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
|
||||||
@Composable
|
|
||||||
fun DetailScreen(
|
|
||||||
viewModel: DetailViewModel = hiltViewModel(),
|
|
||||||
navController: NavController,
|
|
||||||
id: Int
|
|
||||||
) {
|
|
||||||
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
verticalArrangement = Arrangement.Center,
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
Text(text = id.toString())
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.detail
|
|
||||||
|
|
||||||
data class DetailScreenState(
|
|
||||||
val isLoading: Boolean = false,
|
|
||||||
)
|
|
|
@ -1,14 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.detail
|
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.repository.ExampleRepository
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
|
|
||||||
@HiltViewModel
|
|
||||||
class DetailViewModel @Inject constructor(private val exampleRepository: ExampleRepository) : ViewModel() {
|
|
||||||
private val TAG = DetailViewModel::class.java.simpleName
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.home
|
|
||||||
|
|
||||||
data class HomeScreenState(
|
|
||||||
val isLoading: Boolean = false,
|
|
||||||
)
|
|
|
@ -1,13 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.home
|
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.data.repository.ExampleRepository
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
|
||||||
class HomeViewModel @Inject constructor(private val exampleRepository: ExampleRepository) : ViewModel() {
|
|
||||||
private val TAG = HomeViewModel::class.java.simpleName
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.ui.home
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import androidx.compose.foundation.layout.*
|
|
||||||
import androidx.compose.material3.Button
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.runtime.*
|
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.navigation.NavHostController
|
|
||||||
import com.ferhatozcelik.jetpackcomposetemplate.navigation.Screen
|
|
||||||
|
|
||||||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
|
||||||
@Composable
|
|
||||||
fun MainScreen(
|
|
||||||
viewModel: HomeViewModel = hiltViewModel(),
|
|
||||||
navController: NavHostController,
|
|
||||||
) {
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
verticalArrangement = Arrangement.Center,
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
|
|
||||||
Button(onClick = {
|
|
||||||
navController.navigate(Screen.Detail.route + "/123")
|
|
||||||
}) {
|
|
||||||
Text(text = "Go to Detail")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.util
|
|
||||||
|
|
||||||
const val BASE_URL = "https://api.ferhatozcelik.com"
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.util
|
|
||||||
|
|
||||||
import android.content.ActivityNotFoundException
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.Toast
|
|
||||||
|
|
||||||
fun View.show() {
|
|
||||||
visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun View.gone() {
|
|
||||||
visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.toast(message: String) {
|
|
||||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun String.debug(message: String) {
|
|
||||||
Log.d(this, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun EditText.modifyText(numberText: String) {
|
|
||||||
this.setText(numberText)
|
|
||||||
this.setSelection(numberText.length)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.goURL(url: String) {
|
|
||||||
try {
|
|
||||||
val myIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
|
||||||
startActivity(myIntent)
|
|
||||||
} catch (e: ActivityNotFoundException) {
|
|
||||||
this.toast("No application can handle this request. Please install a webbrowser")
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate.util
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.ConnectivityManager
|
|
||||||
import android.net.NetworkCapabilities
|
|
||||||
|
|
||||||
class NetworkUtil {
|
|
||||||
companion object {
|
|
||||||
fun hasInternetConnection(context: Context): Boolean {
|
|
||||||
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
||||||
|
|
||||||
val activeNetwork = connectivityManager.activeNetwork ?: return false
|
|
||||||
val capabilities = connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
|
|
||||||
return when {
|
|
||||||
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
|
|
||||||
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
|
|
||||||
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +1,3 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">My Application</string>
|
<string name="app_name">Gyromin</string>
|
||||||
</resources>
|
</resources>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="Theme.MyApplication" parent="android:Theme.Material.Light.NoActionBar" />
|
<style name="Theme.Gyromin" parent="android:Theme.Material.Light.NoActionBar" />
|
||||||
</resources>
|
</resources>
|
|
@ -2,7 +2,7 @@
|
||||||
Sample backup rules file; uncomment and customize as necessary.
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
See https://developer.android.com/guide/topics/data/autobackup
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
for details.
|
for details.
|
||||||
Note: This file is ignored for devices older that API 31
|
Note: This file is ignored for devices older than API 31
|
||||||
See https://developer.android.com/about/versions/12/backup-restore
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
-->
|
-->
|
||||||
<full-backup-content>
|
<full-backup-content>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ferhatozcelik.jetpackcomposetemplate
|
package com.example.gyromin
|
||||||
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
16
build.gradle
16
build.gradle
|
@ -1,16 +0,0 @@
|
||||||
plugins {
|
|
||||||
alias(libs.plugins.com.android.application) apply false
|
|
||||||
alias(libs.plugins.org.jetbrains.kotlin.android) apply false
|
|
||||||
alias(libs.plugins.com.android.library) apply false
|
|
||||||
alias(libs.plugins.com.google.dagger.hilt.android) apply false
|
|
||||||
alias(libs.plugins.org.jetbrains.kotlin.jvm) apply false
|
|
||||||
alias(libs.plugins.com.google.devtools.ksp) apply false
|
|
||||||
// alias(libs.plugins.com.google.gms.google.services) apply false // Google Play Services
|
|
||||||
// alias(libs.plugins.com.google.firebase.crashlytics) apply false // Google Play Services
|
|
||||||
}
|
|
||||||
|
|
||||||
ext {
|
|
||||||
appCompileSdkVersion = 34
|
|
||||||
appTargetSdkVersion = 33
|
|
||||||
appMinSdkVersion = 21
|
|
||||||
}
|
|
6
build.gradle.kts
Normal file
6
build.gradle.kts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application) apply false
|
||||||
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
|
alias(libs.plugins.kotlin.compose) apply false
|
||||||
|
}
|
|
@ -8,8 +8,8 @@
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. For more details, visit
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
# Android operating system, and which are packaged with your app's APK
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
|
|
@ -1,114 +1,32 @@
|
||||||
[versions]
|
[versions]
|
||||||
agp = "8.9.0"
|
agp = "8.9.0"
|
||||||
hilt-navigation-compose = "1.0.0"
|
kotlin = "2.0.21"
|
||||||
navigation-compose = "2.5.3"
|
coreKtx = "1.10.1"
|
||||||
org-jetbrains-kotlin-android = "1.9.10"
|
|
||||||
core-ktx = "1.9.0"
|
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
androidx-test-ext-junit = "1.1.5"
|
junitVersion = "1.1.5"
|
||||||
espresso-core = "3.5.1"
|
espressoCore = "3.5.1"
|
||||||
lifecycle-runtime-ktx = "2.6.2"
|
lifecycleRuntimeKtx = "2.6.1"
|
||||||
activity-compose = "1.8.0"
|
activityCompose = "1.8.0"
|
||||||
compose-bom = "2023.03.00"
|
composeBom = "2024.09.00"
|
||||||
androidx-multidex = "2.0.1"
|
|
||||||
annotation = "1.7.0"
|
|
||||||
desugar_jdk_libs = "2.0.3"
|
|
||||||
glide-ksp = "4.14.2"
|
|
||||||
kotlin-stdlib = "1.9.10"
|
|
||||||
kotlinx-coroutines-core = "1.6.4"
|
|
||||||
legacy-support-v4 = "1.0.0"
|
|
||||||
lifecycle-extensions = "2.2.0"
|
|
||||||
logging-interceptor = "4.7.2"
|
|
||||||
appcompat = "1.6.1"
|
|
||||||
material = "1.9.0"
|
|
||||||
constraintlayout = "2.1.4"
|
|
||||||
preference-ktx = "1.2.1"
|
|
||||||
retrofit = "2.9.0"
|
|
||||||
room = "2.5.2"
|
|
||||||
hilt = "2.48"
|
|
||||||
multidex = "1.0.3"
|
|
||||||
fragment = "1.6.1"
|
|
||||||
lifecycle = "2.6.2"
|
|
||||||
gson = "2.10.1"
|
|
||||||
glide = "4.16.0"
|
|
||||||
google-services = "4.4.0"
|
|
||||||
firebase-bom = "32.3.1"
|
|
||||||
crashlytics = "2.9.9"
|
|
||||||
ksp = "1.9.0-1.0.12"
|
|
||||||
squareup-logging-interceptor = "4.7.2"
|
|
||||||
viewpager2 = "1.0.0"
|
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hilt-navigation-compose" }
|
|
||||||
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" }
|
|
||||||
androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version.ref = "viewpager2" }
|
|
||||||
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin-stdlib" }
|
|
||||||
androidx-legacy-support-v4 = { module = "androidx.legacy:legacy-support-v4", version.ref = "legacy-support-v4" }
|
|
||||||
androidx-multidex = { module = "androidx.multidex:multidex", version.ref = "androidx-multidex" }
|
|
||||||
annotation = { module = "androidx.annotation:annotation", version.ref = "annotation" }
|
|
||||||
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
|
||||||
desugar_jdk_libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar_jdk_libs" }
|
|
||||||
|
|
||||||
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
|
|
||||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||||
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||||
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
|
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
|
||||||
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
|
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||||
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
|
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||||
ui = { group = "androidx.compose.ui", name = "ui" }
|
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||||
ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||||
ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
material3 = { group = "androidx.compose.material3", name = "material3" }
|
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
|
|
||||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
|
||||||
|
|
||||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
|
||||||
fragment = { group = "androidx.fragment", name = "fragment", version.ref = "fragment" }
|
|
||||||
preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "preference-ktx" }
|
|
||||||
|
|
||||||
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines-core" }
|
|
||||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
|
|
||||||
|
|
||||||
lifecycle = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
|
|
||||||
lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
|
|
||||||
lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "lifecycle-extensions" }
|
|
||||||
|
|
||||||
hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
|
|
||||||
hilt-viewmodel = { group = "com.google.dagger", name = "hilt-lifecycle-viewmodel", version.ref = "hilt" }
|
|
||||||
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }
|
|
||||||
|
|
||||||
room = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
|
||||||
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
|
||||||
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
|
|
||||||
|
|
||||||
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
|
|
||||||
converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
|
|
||||||
logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "logging-interceptor" }
|
|
||||||
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
|
||||||
|
|
||||||
glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" }
|
|
||||||
ksp = { module = "com.github.bumptech.glide:ksp", version.ref = "glide-ksp" }
|
|
||||||
|
|
||||||
firebase = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebase-bom" }
|
|
||||||
analytics = { group = "com.google.firebase", name = "firebase-analytics-ktx" }
|
|
||||||
crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics-ktx" }
|
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
com-android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
com-android-library = { id = "com.android.library", version.ref = "agp" }
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
|
|
||||||
com-google-dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
|
||||||
com-google-devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
|
||||||
|
|
||||||
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "org-jetbrains-kotlin-android" }
|
|
||||||
org-jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "core-ktx" }
|
|
||||||
|
|
||||||
com-google-gms-google-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
|
|
||||||
com-google-firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "crashlytics" }
|
|
||||||
|
|
||||||
[bundles]
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +1,6 @@
|
||||||
|
#Tue Mar 11 00:36:37 EDT 2025
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||||
networkTimeout=10000
|
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
285
gradlew
vendored
285
gradlew
vendored
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright 2015 the original author or authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -15,104 +15,69 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
# This is normally unused
|
APP_NAME="Gradle"
|
||||||
# shellcheck disable=SC2034
|
APP_BASE_NAME=`basename "$0"`
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
@ -122,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
@ -133,120 +98,88 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD="java"
|
||||||
if ! command -v java >/dev/null 2>&1
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
then
|
|
||||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
# shellcheck disable=SC2039,SC3045
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
fi
|
||||||
warn "Could not query maximum file descriptor limit"
|
ulimit -n $MAX_FD
|
||||||
esac
|
if [ $? -ne 0 ] ; then
|
||||||
case $MAX_FD in #(
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
'' | soft) :;; #(
|
fi
|
||||||
*)
|
else
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
# shellcheck disable=SC2039,SC3045
|
fi
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
# * args from the command line
|
if $darwin; then
|
||||||
# * the main class name
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
# * -classpath
|
fi
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
for arg do
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
if
|
SEP=""
|
||||||
case $arg in #(
|
for dir in $ROOTDIRSRAW ; do
|
||||||
-*) false ;; # don't mess with options #(
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
SEP="|"
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
||||||
# and any embedded shellness will be escaped.
|
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
||||||
# treated as '${Hostname}' itself on the command line.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|
33
gradlew.bat
vendored
33
gradlew.bat
vendored
|
@ -13,8 +13,6 @@
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
@ -28,7 +26,6 @@ if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
@rem This is normally unused
|
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -59,11 +56,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
@ -78,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
exit /b 1
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencyResolutionManagement {
|
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rootProject.name = "jetpack-compose-template"
|
|
||||||
include ':app'
|
|
23
settings.gradle.kts
Normal file
23
settings.gradle.kts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google {
|
||||||
|
content {
|
||||||
|
includeGroupByRegex("com\\.android.*")
|
||||||
|
includeGroupByRegex("com\\.google.*")
|
||||||
|
includeGroupByRegex("androidx.*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "Gyromin"
|
||||||
|
include(":app")
|
Loading…
Add table
Add a link
Reference in a new issue