Skip to content

Commit

Permalink
Added hilt,
Browse files Browse the repository at this point in the history
Migrated to view binding,
Updated dependencies,
Changed adapter callbacks,
Refactored UI,
Added extension functions,
Migrated from glide to coil,
Added separate dialogs for add and edit,
Removed useless code,
Fixed lint checks,
Moved modules.
  • Loading branch information
Sharkaboi committed Mar 19, 2021
1 parent dce8c6a commit b8c7bb2
Show file tree
Hide file tree
Showing 45 changed files with 758 additions and 877 deletions.
16 changes: 16 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a href="https://github.com/Sharkaboi/LinkManager/actions?query=workflow%3A%22Gradle+Build%22" alt="Gradle Build">
<img src="https://github.com/Sharkaboi/LinkManager/workflows/Gradle%20Build/badge.svg?branch=master" /></a>
<a href="https://github.com/JetBrains/kotlin/releases/tag/v1.3.72" alt="Kotlin">
<img src="https://img.shields.io/badge/Kotlin-1.3.72-blue" /></a>
<img src="https://img.shields.io/badge/Kotlin-1.4.31-blue" /></a>
<a href="https://github.com/Sharkaboi/LinkManager/blob/master/LICENSE" alt="License">
<img src="https://img.shields.io/badge/License-MIT-orange" /></a>
<a href="https://github.com/Sharkaboi/LinkManager/graphs/contributors" alt="Contributors">
Expand All @@ -21,7 +21,7 @@ An app to keep track of all your links.
* Upcoming : Have multiple lists of links.

## Screenshots
![Showcase](https://i.imgur.com/ljlpUTR.png)
![Showcase](https://i.imgur.com/zgHcydn.png)

## Releases
Check out all the releases [here](https://github.com/Sharkaboi/LinkManager/releases)
63 changes: 36 additions & 27 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.cybershark.linkmanager"
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionName "1.1"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
arguments = [
arguments += [
"room.schemaLocation":"$projectDir/schemas".toString(),
"room.incremental":"true",
"room.expandProjection":"true"]
Expand All @@ -44,39 +44,48 @@ android {
jvmTarget = "1.8"
}


buildFeatures {
viewBinding true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//core dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation "androidx.multidex:multidex:2.0.1"

// coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
//lifecycle dependencies
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.0"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.preference:preference:1.1.1'
//Hilt dependencies
implementation "com.google.dagger:hilt-android:2.33-beta"
kapt "com.google.dagger:hilt-android-compiler:2.33-beta"
//jetpack nav dependencies
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
//design dependencies
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'it.xabaras.android:recyclerview-swipedecorator:1.2.2'
//room
def room_version = "2.2.5"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-runtime:2.2.6"
kapt "androidx.room:room-compiler:2.2.6"
implementation "androidx.room:room-ktx:2.2.6"
//glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'io.coil-kt:coil:0.12.0'
//api
//testing dependencies
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation "androidx.room:room-testing:$room_version"
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
18 changes: 2 additions & 16 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
package="com.cybershark.linkmanager">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name=".LinkManager"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ui.SettingsActivity"
android:label="@string/settings"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ui.SplashActivity"
android:theme="@style/splashStyle">
Expand All @@ -28,17 +24,7 @@
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.cybershark.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
android:theme="@style/AppTheme" />
</application>

</manifest>
7 changes: 7 additions & 0 deletions app/src/main/java/com/cybershark/linkmanager/LinkManager.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.cybershark.linkmanager

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class LinkManager : Application()
38 changes: 38 additions & 0 deletions app/src/main/java/com/cybershark/linkmanager/di/AppModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.cybershark.linkmanager.di

import android.content.Context
import androidx.room.Room
import com.cybershark.linkmanager.repository.Repository
import com.cybershark.linkmanager.repository.room.dao.LinkDao
import com.cybershark.linkmanager.repository.room.db.LinksDB
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AppModule {

@Singleton
@Provides
fun getRoomDB(@ApplicationContext context: Context): LinksDB {
return Room.databaseBuilder(context, LinksDB::class.java, "links")
.fallbackToDestructiveMigration()
.build()
}

@Singleton
@Provides
fun getRoomDao(linksDB: LinksDB): LinkDao {
return linksDB.getDAO()
}

@Singleton
@Provides
fun getRepository(linkDao: LinkDao): Repository {
return Repository(linkDao)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class Repository(private val linksDao: LinkDao) {

suspend fun updateLink(linkEntity: LinkEntity) = linksDao.updateLink(linkEntity)

suspend fun deleteLink(linkEntity: LinkEntity) = linksDao.deleteLink(linkEntity)
suspend fun deleteLinkById(linkId: Int) = linksDao.deleteLinkById(linkId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,13 @@ interface LinkDao {
suspend fun insertLink(linkEntity: LinkEntity)

//delete link entity
@Delete
suspend fun deleteLink(linkEntity: LinkEntity)
@Query("delete from links where pk=:linkId")
suspend fun deleteLinkById(linkId: Int)

//update link entity
@Update
suspend fun updateLink(linkEntity: LinkEntity)

//get link by name
@Query("select * from links where linkName like '%' || :linkName || '%'")
suspend fun getLinkByName(linkName: String): LinkEntity

//get link by pk
@Query("select * from links where pk=:pk")
suspend fun getLinkByName(pk: Int): LinkEntity

//get all links
@Query("select * from links")
fun getAllLinks(): LiveData<List<LinkEntity>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.cybershark.linkmanager.repository.room.db

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.cybershark.linkmanager.repository.room.dao.LinkDao
import com.cybershark.linkmanager.repository.room.entities.LinkEntity
Expand All @@ -11,28 +9,4 @@ import com.cybershark.linkmanager.repository.room.entities.LinkEntity
abstract class LinksDB : RoomDatabase() {

abstract fun getDAO(): LinkDao

companion object {

@Volatile
private var linksSQLiteDB: LinksDB? = null

fun getDatabaseInstance(applicationContext: Context): LinksDB {
val tempInstance = linksSQLiteDB
if (tempInstance != null) {
return tempInstance
}
synchronized(this) {
val instance =
Room.databaseBuilder(applicationContext, LinksDB::class.java, "links").build()
linksSQLiteDB = instance
return instance
}
}

fun closeDB() {
linksSQLiteDB?.close()
linksSQLiteDB = null
}
}
}
Loading

0 comments on commit b8c7bb2

Please sign in to comment.