From a08cea9df8afab4bf2dee89ed84b4277203b1063 Mon Sep 17 00:00:00 2001 From: len Date: Wed, 25 May 2016 16:29:22 +0200 Subject: [PATCH] Show changelog when new version is installed --- app/build.gradle | 3 ++ .../data/preference/PreferencesHelper.kt | 2 + .../injection/component/AppComponent.kt | 6 +-- .../ui/main/ChangelogDialogFragment.kt | 43 +++++++++++++++++++ .../kanade/tachiyomi/ui/main/MainActivity.kt | 8 ++++ .../res/layout/changelog_header_layout.xml | 26 +++++++++++ .../main/res/layout/changelog_row_layout.xml | 37 ++++++++++++++++ app/src/main/res/raw/changelog_debug.xml | 16 +++++++ app/src/main/res/raw/changelog_release.xml | 4 ++ app/src/main/res/values/colors.xml | 2 +- 10 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt create mode 100644 app/src/main/res/layout/changelog_header_layout.xml create mode 100644 app/src/main/res/layout/changelog_row_layout.xml create mode 100644 app/src/main/res/raw/changelog_debug.xml create mode 100644 app/src/main/res/raw/changelog_release.xml diff --git a/app/build.gradle b/app/build.gradle index 705a276fcc..de1b97230b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -143,6 +143,9 @@ dependencies { // Parse HTML compile 'org.jsoup:jsoup:1.9.1' + // Changelog + compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0' + // Database compile "com.pushtorefresh.storio:sqlite:$STORIO_VERSION" compile "com.pushtorefresh.storio:sqlite-annotations:$STORIO_VERSION" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index fd47d8323f..91d926e28d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -99,6 +99,8 @@ class PreferencesHelper(private val context: Context) { fun lastUsedCategory() = rxPrefs.getInteger(keys.lastUsedCategory, 0) + fun lastVersionCode() = rxPrefs.getInteger("last_version_code", 0) + fun seamlessMode() = prefs.getBoolean(keys.seamlessMode, true) fun catalogueAsList() = rxPrefs.getBoolean(keys.catalogueAsList, false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/injection/component/AppComponent.kt b/app/src/main/java/eu/kanade/tachiyomi/injection/component/AppComponent.kt index 8c9e8f91bf..65ca31cc53 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/injection/component/AppComponent.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/injection/component/AppComponent.kt @@ -8,8 +8,8 @@ import eu.kanade.tachiyomi.data.glide.MangaModelLoader import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.mangasync.UpdateMangaSyncService import eu.kanade.tachiyomi.data.mangasync.base.MangaSyncService -import eu.kanade.tachiyomi.data.source.base.Source import eu.kanade.tachiyomi.data.source.base.OnlineSource +import eu.kanade.tachiyomi.data.source.base.Source import eu.kanade.tachiyomi.data.updater.UpdateDownloader import eu.kanade.tachiyomi.injection.module.AppModule import eu.kanade.tachiyomi.injection.module.DataModule @@ -18,7 +18,7 @@ import eu.kanade.tachiyomi.ui.catalogue.CataloguePresenter import eu.kanade.tachiyomi.ui.category.CategoryPresenter import eu.kanade.tachiyomi.ui.download.DownloadPresenter import eu.kanade.tachiyomi.ui.library.LibraryPresenter -import eu.kanade.tachiyomi.ui.manga.MangaActivity +import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.manga.MangaPresenter import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersPresenter import eu.kanade.tachiyomi.ui.manga.info.MangaInfoPresenter @@ -44,7 +44,7 @@ interface AppComponent { fun inject(recentChaptersPresenter: RecentChaptersPresenter) fun inject(backupPresenter: BackupPresenter) - fun inject(mangaActivity: MangaActivity) + fun inject(mainActivity: MainActivity) fun inject(settingsActivity: SettingsActivity) fun inject(source: Source) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt new file mode 100644 index 0000000000..f9816152d9 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt @@ -0,0 +1,43 @@ +package eu.kanade.tachiyomi.ui.main + +import android.app.Dialog +import android.content.Context +import android.os.Bundle +import android.support.v4.app.DialogFragment +import android.support.v4.app.FragmentManager +import android.util.AttributeSet +import com.afollestad.materialdialogs.MaterialDialog +import eu.kanade.tachiyomi.BuildConfig +import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.tachiyomi.data.preference.getOrDefault +import it.gmariotti.changelibs.library.view.ChangeLogRecyclerView + +class ChangelogDialogFragment : DialogFragment() { + + companion object { + fun show(preferences: PreferencesHelper, fragmentManager: FragmentManager) { + if (preferences.lastVersionCode().getOrDefault() < BuildConfig.VERSION_CODE) { + preferences.lastVersionCode().set(BuildConfig.VERSION_CODE) + ChangelogDialogFragment().show(fragmentManager, "changelog") + } + } + } + + override fun onCreateDialog(savedState: Bundle?): Dialog { + val view = WhatsNewRecyclerView(context) + return MaterialDialog.Builder(activity) + .title("Changelog") + .customView(view, false) + .positiveText(android.R.string.yes) + .build() + } + + class WhatsNewRecyclerView(context: Context) : ChangeLogRecyclerView(context) { + override fun initAttrs(attrs: AttributeSet?, defStyle: Int) { + mRowLayoutId = R.layout.changelog_row_layout + mRowHeaderLayoutId = R.layout.changelog_header_layout + mChangeLogFileResourceId = if (BuildConfig.DEBUG) R.raw.changelog_debug else R.raw.changelog_release + } + } +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index e6f67e9032..300cef6a42 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -5,7 +5,9 @@ import android.os.Bundle import android.support.v4.app.Fragment import android.support.v4.view.GravityCompat import android.view.MenuItem +import eu.kanade.tachiyomi.App import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.backup.BackupFragment import eu.kanade.tachiyomi.ui.base.activity.BaseActivity import eu.kanade.tachiyomi.ui.catalogue.CatalogueFragment @@ -15,9 +17,12 @@ import eu.kanade.tachiyomi.ui.recent.RecentChaptersFragment import eu.kanade.tachiyomi.ui.setting.SettingsActivity import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.toolbar.* +import javax.inject.Inject class MainActivity : BaseActivity() { + @Inject lateinit var preferences: PreferencesHelper + override fun onCreate(savedState: Bundle?) { setAppTheme() super.onCreate(savedState) @@ -28,6 +33,8 @@ class MainActivity : BaseActivity() { return } + App.get(this).component.inject(this) + // Inflate activity_main.xml. setContentView(R.layout.activity_main) @@ -54,6 +61,7 @@ class MainActivity : BaseActivity() { if (savedState == null) { setFragment(LibraryFragment.newInstance()) + ChangelogDialogFragment.show(preferences, supportFragmentManager) } } diff --git a/app/src/main/res/layout/changelog_header_layout.xml b/app/src/main/res/layout/changelog_header_layout.xml new file mode 100644 index 0000000000..e4c10220b5 --- /dev/null +++ b/app/src/main/res/layout/changelog_header_layout.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/changelog_row_layout.xml b/app/src/main/res/layout/changelog_row_layout.xml new file mode 100644 index 0000000000..244da6845c --- /dev/null +++ b/app/src/main/res/layout/changelog_row_layout.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/raw/changelog_debug.xml b/app/src/main/res/raw/changelog_debug.xml new file mode 100644 index 0000000000..f3d4393462 --- /dev/null +++ b/app/src/main/res/raw/changelog_debug.xml @@ -0,0 +1,16 @@ + + + + + [b]Important![/b] Now chapters follow the order of the sources. [b]It's required that you update your entire library + before reading in order for them to be synced.[/b] Old behavior can be restored for a manga in the overflow menu of the chapters tab. + + + + + Kissmanga covers may not load anymore. The only workaround is to update the details of the manga + from the info tab, or clearing the database (the latter won't fix covers from library manga). + + + + \ No newline at end of file diff --git a/app/src/main/res/raw/changelog_release.xml b/app/src/main/res/raw/changelog_release.xml new file mode 100644 index 0000000000..61a9efd9ca --- /dev/null +++ b/app/src/main/res/raw/changelog_release.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 44d0061b28..46f099f12d 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -21,7 +21,7 @@ @color/md_blue_A400_38 - @color/md_blue_A200 + #3399ff @color/md_white_1000 @color/md_white_1000_70 @color/md_white_1000_50