-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mateusz-bak/wip-first-release
Version 0.0.1
- Loading branch information
Showing
76 changed files
with
1,541 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
# myBooks-android | ||
An Android app for keeping tracks of books you have read. | ||
|
||
# myBooks-android | ||
An Android app written in Kotlin for keeping tracks of books you have read. | ||
|
||
## Screenshots | ||
|
||
### List of your books: | ||
<img src="doc/images/screenshot-list.png" alt="drawing" width="300"/> | ||
|
||
### Adding a book: | ||
<img src="doc/images/screenshot-adder.png" alt="drawing" width="300"/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
id 'kotlin-android-extensions' | ||
id 'kotlin-kapt' | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.example.amorgos" | ||
minSdkVersion 21 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "0.0.1" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
implementation 'androidx.core:core-ktx:1.3.2' | ||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.3.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | ||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' | ||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' | ||
|
||
def room_version= "2.3.0" | ||
def kodein_version="6.4.0" | ||
def lifecycle_version="2.2.0" | ||
|
||
// ROOM AND ARCHITECTURAL COMPONENTS | ||
implementation "androidx.room:room-runtime:$room_version" | ||
implementation "androidx.legacy:legacy-support-v4:1.0.0" | ||
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1" | ||
implementation "androidx.room:room-ktx:2.2.6" | ||
kapt "androidx.room:room-compiler:2.2.6" | ||
|
||
// COROUTINES | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3" | ||
|
||
// NEW MATERIAL DESIGN | ||
implementation "com.google.android.material:material:1.3.0" | ||
|
||
// VIEWMODEL | ||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" | ||
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" | ||
|
||
// KODEIN | ||
implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version" | ||
implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/example/mybooks/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.mybooks | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.example.mybooks", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.mybooks"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_green_book" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_green_book_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.MyBooks"> | ||
<activity | ||
android:name=".ui.bookslist.ListActivity" | ||
android:label="@string/app_name" | ||
> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".ui.bookslist.AdderActivity"/> | ||
<activity android:name=".ui.bookslist.AboutActivity"/> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.mybooks.data.db | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.room.* | ||
import com.example.mybooks.data.db.entities.ListElement | ||
|
||
@Dao | ||
interface BooksDao { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun upsert(item: ListElement) | ||
|
||
@Delete | ||
suspend fun delete(item: ListElement) | ||
|
||
@Query("SELECT * FROM read_books") | ||
fun getAllListElements(): LiveData<List<ListElement>> | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/example/mybooks/data/db/BooksDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.mybooks.data.db | ||
|
||
import android.content.Context | ||
import androidx.room.Database | ||
import androidx.room.Room | ||
import androidx.room.RoomDatabase | ||
import com.example.mybooks.data.db.entities.ListElement | ||
|
||
@Database( | ||
entities = [ListElement::class], | ||
version = 1 | ||
) | ||
abstract class BooksDatabase: RoomDatabase() { | ||
|
||
abstract fun getBooksDao(): BooksDao | ||
|
||
companion object { | ||
@Volatile | ||
private var instance: BooksDatabase? = null | ||
private val LOCK = Any() | ||
|
||
operator fun invoke(context: Context) = instance ?: synchronized(LOCK) { | ||
instance ?: createDatabase(context).also { instance = it } | ||
} | ||
|
||
private fun createDatabase(context: Context) = | ||
Room.databaseBuilder(context.applicationContext, | ||
BooksDatabase::class.java, "BooksDB.db").build() | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/mybooks/data/db/entities/ListElement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.mybooks.data.db.entities | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "read_books") | ||
data class ListElement ( | ||
@ColumnInfo(name = "item_bookTitle") | ||
var bookTitle: String, | ||
@ColumnInfo(name = "item_bookAuthor") | ||
var bookAuthor: String, | ||
@ColumnInfo(name = "item_bookRating") | ||
var bookRating: Float | ||
){ | ||
@PrimaryKey(autoGenerate = true) | ||
var id: Int? = null | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/example/mybooks/data/repositories/BooksRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.mybooks.data.repositories | ||
|
||
import com.example.mybooks.data.db.BooksDatabase | ||
import com.example.mybooks.data.db.entities.ListElement | ||
|
||
class BooksRepository ( | ||
private val db: BooksDatabase | ||
) { | ||
suspend fun upsert(item: ListElement) = db.getBooksDao().upsert(item) | ||
|
||
suspend fun delete(item: ListElement) = db.getBooksDao().delete(item) | ||
|
||
fun getAllListElements() = db.getBooksDao().getAllListElements() | ||
} |
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/example/mybooks/other/ListElementAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.example.mybooks.other | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.mybooks.R | ||
import com.example.mybooks.data.db.entities.ListElement | ||
import com.example.mybooks.ui.bookslist.BooksViewModel | ||
import kotlinx.android.synthetic.main.item_list_element.view.* | ||
|
||
class ListElementAdapter( | ||
|
||
var books: List<ListElement>, | ||
private val viewModel: BooksViewModel | ||
|
||
) : RecyclerView.Adapter<ListElementAdapter.ListElementViewHolder>() { | ||
|
||
inner class ListElementViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListElementViewHolder { | ||
return ListElementViewHolder( | ||
LayoutInflater.from(parent.context).inflate( | ||
R.layout.item_list_element, | ||
parent, | ||
false | ||
) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ListElementViewHolder, position: Int) { | ||
val curBook = books[position] | ||
holder.itemView.apply { | ||
tvBookTitle.text = curBook.bookTitle | ||
tvBookAuthor.text = curBook.bookAuthor | ||
rbRatingIndicator.rating = curBook.bookRating | ||
} | ||
|
||
holder.itemView.ivDeleteBook.setOnClickListener{ | ||
viewModel.delete(curBook) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return books.size | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/example/mybooks/ui/bookslist/AboutActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.mybooks.ui.bookslist | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.example.mybooks.R | ||
|
||
class AboutActivity: AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_about) | ||
} | ||
} |
Oops, something went wrong.