diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 4efe995..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -jetpack-compose-template \ No newline at end of file diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml deleted file mode 100644 index 4a53bee..0000000 --- a/.idea/AndroidProjectSystem.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index b86273d..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml deleted file mode 100644 index b268ef3..0000000 --- a/.idea/deploymentTargetSelector.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 97f0a8e..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index f8467b4..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml deleted file mode 100644 index f8051a6..0000000 --- a/.idea/migrations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 74dd639..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 16660f1..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 56e179d..0000000 --- a/LICENSE +++ /dev/null @@ -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. diff --git a/README.md b/README.md deleted file mode 100644 index ada133d..0000000 --- a/README.md +++ /dev/null @@ -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! diff --git a/app/.gitignore b/app/.gitignore index d22744b..42afabf 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,2 +1 @@ -/build -/.idea/** \ No newline at end of file +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index c7a3e79..0000000 --- a/app/build.gradle +++ /dev/null @@ -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) - -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..1c030e6 --- /dev/null +++ b/app/build.gradle.kts @@ -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) +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/ferhatozcelik/jetpackcomposetemplate/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/gyromin/ExampleInstrumentedTest.kt similarity index 81% rename from app/src/androidTest/java/com/ferhatozcelik/jetpackcomposetemplate/ExampleInstrumentedTest.kt rename to app/src/androidTest/java/com/example/gyromin/ExampleInstrumentedTest.kt index 47e0ca6..2e9af28 100644 --- a/app/src/androidTest/java/com/ferhatozcelik/jetpackcomposetemplate/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/example/gyromin/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.ferhatozcelik.jetpackcomposetemplate +package com.example.gyromin import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -19,6 +19,6 @@ class ExampleInstrumentedTest { fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.ferhatozcelik.myapplication", appContext.packageName) + assertEquals("com.example.gyromin", appContext.packageName) } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cda27f9..286cd44 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,10 +2,9 @@ - - + + + android:label="@string/app_name" + android:theme="@style/Theme.Gyromin"> diff --git a/app/src/main/java/com/example/gyromin/MainActivity.kt b/app/src/main/java/com/example/gyromin/MainActivity.kt new file mode 100644 index 0000000..1aa6ab4 --- /dev/null +++ b/app/src/main/java/com/example/gyromin/MainActivity.kt @@ -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() + } + } +} diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Color.kt b/app/src/main/java/com/example/gyromin/ui/theme/Color.kt similarity index 71% rename from app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Color.kt rename to app/src/main/java/com/example/gyromin/ui/theme/Color.kt index e672e68..d6b69b7 100644 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Color.kt +++ b/app/src/main/java/com/example/gyromin/ui/theme/Color.kt @@ -1,4 +1,4 @@ -package com.ferhatozcelik.jetpackcomposetemplate.ui.theme +package com.example.gyromin.ui.theme import androidx.compose.ui.graphics.Color diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Theme.kt b/app/src/main/java/com/example/gyromin/ui/theme/Theme.kt similarity index 73% rename from app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Theme.kt rename to app/src/main/java/com/example/gyromin/ui/theme/Theme.kt index 5ce5f8c..b5a564c 100644 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Theme.kt +++ b/app/src/main/java/com/example/gyromin/ui/theme/Theme.kt @@ -1,4 +1,4 @@ -package com.ferhatozcelik.jetpackcomposetemplate.ui.theme +package com.example.gyromin.ui.theme import android.app.Activity import android.os.Build @@ -9,11 +9,7 @@ import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme 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.LocalView -import androidx.core.view.WindowCompat private val DarkColorScheme = darkColorScheme( primary = Purple80, @@ -38,7 +34,7 @@ private val LightColorScheme = lightColorScheme( ) @Composable -fun MyApplicationTheme( +fun GyrominTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, @@ -53,14 +49,6 @@ fun MyApplicationTheme( darkTheme -> DarkColorScheme 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( colorScheme = colorScheme, diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Type.kt b/app/src/main/java/com/example/gyromin/ui/theme/Type.kt similarity index 94% rename from app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Type.kt rename to app/src/main/java/com/example/gyromin/ui/theme/Type.kt index 8deb4de..ce261e7 100644 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/theme/Type.kt +++ b/app/src/main/java/com/example/gyromin/ui/theme/Type.kt @@ -1,4 +1,4 @@ -package com.ferhatozcelik.jetpackcomposetemplate.ui.theme +package com.example.gyromin.ui.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/App.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/App.kt deleted file mode 100644 index 451718a..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/App.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.ferhatozcelik.jetpackcomposetemplate - -import android.app.Application -import dagger.hilt.android.HiltAndroidApp - -@HiltAndroidApp -class App : Application() \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/dao/ExampleDao.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/dao/ExampleDao.kt deleted file mode 100644 index 08c806b..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/dao/ExampleDao.kt +++ /dev/null @@ -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 - - @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun insert(search: ExampleEntity?) - - @Update - suspend fun update(search: ExampleEntity) - - @Delete - suspend fun delete(search: ExampleEntity) - -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/entity/ExampleEntity.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/entity/ExampleEntity.kt deleted file mode 100644 index e6b2483..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/entity/ExampleEntity.kt +++ /dev/null @@ -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 - - diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/local/AppDatabase.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/local/AppDatabase.kt deleted file mode 100644 index 739255b..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/local/AppDatabase.kt +++ /dev/null @@ -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, - @ApplicationScope private val applicationScope: CoroutineScope - ) : RoomDatabase.Callback() -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/local/Converters.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/local/Converters.kt deleted file mode 100644 index 97a5756..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/local/Converters.kt +++ /dev/null @@ -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() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/model/ExampleModel.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/model/ExampleModel.kt deleted file mode 100644 index 4f9c26b..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/model/ExampleModel.kt +++ /dev/null @@ -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? -) diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/model/Resource.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/model/Resource.kt deleted file mode 100644 index 3e9d944..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/model/Resource.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.ferhatozcelik.jetpackcomposetemplate.data.model - -sealed class Resource { - object Loading : Resource() - data class Success(val data: Any) : Resource() - data class Error(val errorMessage: String) : Resource() -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/remote/AppApi.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/remote/AppApi.kt deleted file mode 100644 index bb7a6aa..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/remote/AppApi.kt +++ /dev/null @@ -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> - -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/repository/ExampleRepository.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/repository/ExampleRepository.kt deleted file mode 100644 index d72cc6a..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/data/repository/ExampleRepository.kt +++ /dev/null @@ -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) \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/ApiModule.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/ApiModule.kt deleted file mode 100644 index 26a1a09..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/ApiModule.kt +++ /dev/null @@ -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) - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/AppModule.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/AppModule.kt deleted file mode 100644 index dca3462..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/AppModule.kt +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/DatabaseModule.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/DatabaseModule.kt deleted file mode 100644 index 5624553..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/di/DatabaseModule.kt +++ /dev/null @@ -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() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/navigation/NavGraph.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/navigation/NavGraph.kt deleted file mode 100644 index 74cce5d..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/navigation/NavGraph.kt +++ /dev/null @@ -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) - } - } -} diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/navigation/Screen.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/navigation/Screen.kt deleted file mode 100644 index c16a1c7..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/navigation/Screen.kt +++ /dev/null @@ -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") -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/activitys/MainActivity.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/activitys/MainActivity.kt deleted file mode 100644 index 94c7849..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/activitys/MainActivity.kt +++ /dev/null @@ -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) - } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailScreen.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailScreen.kt deleted file mode 100644 index 2266d5a..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailScreen.kt +++ /dev/null @@ -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()) - - } - -} - - - diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailScreenState.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailScreenState.kt deleted file mode 100644 index 400bbe0..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailScreenState.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.ferhatozcelik.jetpackcomposetemplate.ui.detail - -data class DetailScreenState( - val isLoading: Boolean = false, -) \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailViewModel.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailViewModel.kt deleted file mode 100644 index 63f1f73..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/detail/DetailViewModel.kt +++ /dev/null @@ -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 - - -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/HomeScreenState.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/HomeScreenState.kt deleted file mode 100644 index a6dcd18..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/HomeScreenState.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.ferhatozcelik.jetpackcomposetemplate.ui.home - -data class HomeScreenState( - val isLoading: Boolean = false, -) \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/HomeViewModel.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/HomeViewModel.kt deleted file mode 100644 index 64285b4..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/HomeViewModel.kt +++ /dev/null @@ -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 - - -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/MainScreen.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/MainScreen.kt deleted file mode 100644 index 0674fd9..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/ui/home/MainScreen.kt +++ /dev/null @@ -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") - } - } -} - diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/Constants.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/Constants.kt deleted file mode 100644 index 15539fa..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/Constants.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.ferhatozcelik.jetpackcomposetemplate.util - -const val BASE_URL = "https://api.ferhatozcelik.com" diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/Extensions.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/Extensions.kt deleted file mode 100644 index 5fe62bd..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/Extensions.kt +++ /dev/null @@ -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() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/NetworkUtil.kt b/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/NetworkUtil.kt deleted file mode 100644 index 504b7a4..0000000 --- a/app/src/main/java/com/ferhatozcelik/jetpackcomposetemplate/util/NetworkUtil.kt +++ /dev/null @@ -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 - } - } -} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3de1a39..355af28 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - My Application + Gyromin \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index e48770a..fc496bd 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,5 +1,5 @@ -