Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #28 from MarcDonald/feature/githubVersionChecking
Browse files Browse the repository at this point in the history
GitHub Version Checking
  • Loading branch information
MarcDonald authored Jun 18, 2019
2 parents 96bb77c + e14ce6f commit c9a292c
Show file tree
Hide file tree
Showing 34 changed files with 552 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "app.marcdev.hibi"
minSdkVersion 23
targetSdkVersion 28
versionCode 27
versionName "1.0.0"
versionCode 28
versionName "1.1.0"
setProperty("archivesBaseName", "Hibi-v$versionName")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/app/marcdev/hibi/Hibi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import app.marcdev.hibi.data.database.DAO
import app.marcdev.hibi.data.database.ProductionAppDatabase
import app.marcdev.hibi.data.network.ConnectivityInterceptor
import app.marcdev.hibi.data.network.ConnectivityInterceptorImpl
import app.marcdev.hibi.data.network.JishoAPIService
import app.marcdev.hibi.data.network.github.GithubAPIService
import app.marcdev.hibi.data.network.jisho.JishoAPIService
import app.marcdev.hibi.data.repository.*
import app.marcdev.hibi.entryscreens.addentryscreen.AddEntryViewModelFactory
import app.marcdev.hibi.entryscreens.viewentryscreen.ViewEntryViewModelFactory
Expand All @@ -25,6 +26,7 @@ import app.marcdev.hibi.maintabs.mainentries.MainEntriesViewModelFactory
import app.marcdev.hibi.maintabs.searchentries.searchentriesscreen.SearchEntriesViewModelFactory
import app.marcdev.hibi.maintabs.settings.backupdialog.BackupDialogViewModelFactory
import app.marcdev.hibi.maintabs.settings.restoredialog.RestoreDialogViewModelFactory
import app.marcdev.hibi.maintabs.settings.updatedialog.UpdateDialogViewModelFactory
import app.marcdev.hibi.maintabs.tagsfragment.maintagsfragment.TagsFragmentViewModelFactory
import app.marcdev.hibi.maintabs.tagsfragment.taggedentriesfragment.TaggedEntriesViewModelFactory
import app.marcdev.hibi.search.searchmoreinfoscreen.SearchMoreInfoViewModelFactory
Expand Down Expand Up @@ -70,6 +72,7 @@ class Hibi : Application(), KodeinAware {
// <editor-fold desc="Connectivity and Jisho API">
bind<ConnectivityInterceptor>() with singleton { ConnectivityInterceptorImpl(instance()) }
bind<JishoAPIService>() with singleton { JishoAPIService(instance()) }
bind<GithubAPIService>() with singleton { GithubAPIService(instance()) }
// </editor-fold>
// <editor-fold desc="View models">
bind() from provider { MainEntriesViewModelFactory(instance(), instance(), instance()) }
Expand All @@ -94,6 +97,7 @@ class Hibi : Application(), KodeinAware {
bind() from provider { AddMultiEntryToBookViewModelFactory(instance()) }
bind() from provider { BackupDialogViewModelFactory(instance()) }
bind() from provider { RestoreDialogViewModelFactory(instance(), instance()) }
bind() from provider { UpdateDialogViewModelFactory(instance()) }
// </editor-fold>
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package app.marcdev.hibi.data.network.github

import app.marcdev.hibi.data.network.ConnectivityInterceptor
import app.marcdev.hibi.data.network.github.apiresponse.GithubVersionResponse
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET

interface GithubAPIService {

@GET("repos/MarcDonald/Hibi/releases/latest")
suspend fun getNewestVersion(): GithubVersionResponse

companion object {
operator fun invoke(connectivityInterceptor: ConnectivityInterceptor): GithubAPIService {
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(connectivityInterceptor)
.build()

return Retrofit.Builder()
.client(okHttpClient)
.baseUrl("https://api.github.com/")
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(GithubAPIService::class.java)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package app.marcdev.hibi.data.network.github.apiresponse

data class Asset(
val browser_download_url: String,
val content_type: String,
val created_at: String,
val download_count: Int,
val id: Int,
val label: Any,
val name: String,
val node_id: String,
val size: Int,
val state: String,
val updated_at: String,
val uploader: Uploader,
val url: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package app.marcdev.hibi.data.network.github.apiresponse

data class Author(
val avatar_url: String,
val events_url: String,
val followers_url: String,
val following_url: String,
val gists_url: String,
val gravatar_id: String,
val html_url: String,
val id: Int,
val login: String,
val node_id: String,
val organizations_url: String,
val received_events_url: String,
val repos_url: String,
val site_admin: Boolean,
val starred_url: String,
val subscriptions_url: String,
val type: String,
val url: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package app.marcdev.hibi.data.network.github.apiresponse

data class GithubVersionResponse(
val assets: List<Asset>,
val assets_url: String,
val author: Author,
val body: String,
val created_at: String,
val draft: Boolean,
val html_url: String,
val id: Int,
val name: String,
val node_id: String,
val prerelease: Boolean,
val published_at: String,
val tag_name: String,
val tarball_url: String,
val target_commitish: String,
val upload_url: String,
val url: String,
val zipball_url: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package app.marcdev.hibi.data.network.github.apiresponse

data class Uploader(
val avatar_url: String,
val events_url: String,
val followers_url: String,
val following_url: String,
val gists_url: String,
val gravatar_id: String,
val html_url: String,
val id: Int,
val login: String,
val node_id: String,
val organizations_url: String,
val received_events_url: String,
val repos_url: String,
val site_admin: Boolean,
val starred_url: String,
val subscriptions_url: String,
val type: String,
val url: String
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.marcdev.hibi.data.network
package app.marcdev.hibi.data.network.jisho

import app.marcdev.hibi.data.network.apiresponse.SearchResponse
import app.marcdev.hibi.data.network.ConnectivityInterceptor
import app.marcdev.hibi.data.network.jisho.apiresponse.SearchResponse
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.marcdev.hibi.data.network.apiresponse
package app.marcdev.hibi.data.network.jisho.apiresponse

data class Attribution(
val dbpedia: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.marcdev.hibi.data.network.apiresponse
package app.marcdev.hibi.data.network.jisho.apiresponse

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.marcdev.hibi.data.network.apiresponse
package app.marcdev.hibi.data.network.jisho.apiresponse

data class Japanese(
val reading: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package app.marcdev.hibi.data.network.jisho.apiresponse

data class SearchResponse(
val `data`: List<Data>
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.marcdev.hibi.data.network.apiresponse
package app.marcdev.hibi.data.network.jisho.apiresponse

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,5 @@ class AboutFragment : PreferenceFragmentCompat() {
val launchBrowser = Intent(Intent.ACTION_VIEW)
launchBrowser.data = uriUrl
startActivity(launchBrowser)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import app.marcdev.hibi.internal.*
import app.marcdev.hibi.internal.notification.NotificationHelper
import app.marcdev.hibi.maintabs.settings.backupdialog.BackupDialog
import app.marcdev.hibi.maintabs.settings.restoredialog.RestoreDialog
import app.marcdev.hibi.maintabs.settings.updatedialog.UpdateDialog
import app.marcdev.hibi.uicomponents.TimePickerDialog
import com.google.android.material.snackbar.Snackbar
import droidninja.filepicker.FilePickerBuilder
Expand Down Expand Up @@ -64,6 +65,12 @@ class SettingsFragment : PreferenceFragmentCompat(), KodeinAware {

val mainEntryDisplayItems = findPreference(PREF_MAIN_ENTRY_DISPLAY_ITEMS)
mainEntryDisplayItems.onPreferenceClickListener = mainEntryDisplayItemsClickListener

findPreference("pref_app_update").onPreferenceClickListener = Preference.OnPreferenceClickListener {
val dialog = UpdateDialog()
dialog.show(requireFragmentManager(), "Update Dialog")
true
}
}

private val onThemeChangeListener = Preference.OnPreferenceChangeListener { _, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,9 @@ class BackupDialog : HibiDialogFragment(), KodeinAware {

private fun setupObservers() {
viewModel.displayDismiss.observe(this, Observer { value ->
value?.let { display ->
if(display) {
dismissButton.show(true)
isCancelable = true
} else {
dismissButton.show(false)
isCancelable = false
}
value?.let { dismissable ->
dismissButton.show(dismissable)
isCancelable = dismissable
}
})

Expand Down
Loading

0 comments on commit c9a292c

Please sign in to comment.