-
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #41 from roozbehzarei/dev
Release v2.3.1
- Loading branch information
Showing
21 changed files
with
196 additions
and
139 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
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
44 changes: 42 additions & 2 deletions
44
app/src/main/java/com/roozbehzarei/filester/BaseApplication.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 |
---|---|---|
@@ -1,13 +1,53 @@ | ||
package com.roozbehzarei.filester | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import com.aptabase.Aptabase | ||
import com.roozbehzarei.filester.database.FileDatabase | ||
import org.acra.config.mailSender | ||
import org.acra.config.notification | ||
import org.acra.data.StringFormat | ||
import org.acra.ktx.initAcra | ||
|
||
private const val APTABASE_KEY = "A-EU-5566501326" | ||
|
||
class BaseApplication : Application() { | ||
// Using by lazy so the database is only created when needed | ||
// rather than when the application starts | ||
// Create database when needed | ||
val database: FileDatabase by lazy { | ||
FileDatabase.getDatabase(this) | ||
} | ||
|
||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
// Initialize Aptabase SDK | ||
Aptabase.instance.initialize(applicationContext, APTABASE_KEY) | ||
// Track app launch on startup | ||
Aptabase.instance.trackEvent("app_started") | ||
} | ||
|
||
/** | ||
* Configure ACRA | ||
*/ | ||
override fun attachBaseContext(base: Context?) { | ||
super.attachBaseContext(base) | ||
initAcra { | ||
buildConfigClass = BuildConfig::class.java | ||
reportFormat = StringFormat.KEY_VALUE_LIST | ||
notification { | ||
title = getString(R.string.crash_notification_title) | ||
text = getString(R.string.crash_notification_text) | ||
channelName = getString(R.string.notification_channel_id) | ||
resIcon = R.drawable.ic_notification | ||
sendButtonText = getString(R.string.send) | ||
discardButtonText = getString(R.string.button_cancel) | ||
sendOnClick = true | ||
} | ||
mailSender { | ||
mailTo = "contact@roozbehzarei.me" | ||
subject = getString(R.string.crash_mail_subject) | ||
body = getString(R.string.crash_mail_body) | ||
} | ||
} | ||
} | ||
} |
53 changes: 0 additions & 53 deletions
53
app/src/main/java/com/roozbehzarei/filester/FilesterFirebaseMsgService.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
app/src/main/java/com/roozbehzarei/filester/database/FirebaseUpdateMessage.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
app/src/main/java/com/roozbehzarei/filester/database/MainUiState.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.roozbehzarei.filester.database | ||
|
||
data class MainUiState( | ||
// A pair of file name and its deletion status | ||
val appVersion: Version? = null, | ||
val isFileDeleted: Boolean = false | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/roozbehzarei/filester/database/Version.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,8 @@ | ||
package com.roozbehzarei.filester.database | ||
|
||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class Version( | ||
val code: Int, val url: String | ||
) |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/roozbehzarei/filester/network/FilesterApiService.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,34 @@ | ||
package com.roozbehzarei.filester.network | ||
|
||
import com.roozbehzarei.filester.database.Version | ||
import com.squareup.moshi.Moshi | ||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory | ||
import retrofit2.Response | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.moshi.MoshiConverterFactory | ||
import retrofit2.http.GET | ||
|
||
private const val BASE_URL = "https://api.roozbehzarei.me/filester/" | ||
|
||
private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build() | ||
|
||
/** | ||
* The Retrofit object with [moshi] converter | ||
*/ | ||
private val retrofit: Retrofit = | ||
Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.addConverterFactory(MoshiConverterFactory.create(moshi)) | ||
.build() | ||
|
||
interface FilesterApiService { | ||
@GET("version.json") | ||
suspend fun getVersion(): Response<Version> | ||
} | ||
|
||
/** | ||
* A public Api object that exposes the lazy-initialized Retrofit service | ||
*/ | ||
object FilesterApi { | ||
val retrofitService: FilesterApiService by lazy { retrofit.create(FilesterApiService::class.java) } | ||
} |
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
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
Oops, something went wrong.