From ec560bc4e8b4e4fb2cef3b1f58be4442ff764eaa Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Mon, 26 Feb 2018 20:45:22 +0300 Subject: [PATCH 01/29] Add gallery item to topic fab menu --- .../features/topic/ChosenTopicFragment.kt | 30 +++++++++++++++-- .../features/topic/ChosenTopicPresenter.kt | 5 +++ .../res/layout/include_topic_fab_menu.xml | 33 +++++++++++++++++++ app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 67 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicFragment.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicFragment.kt index ae8dd989..42ff5e62 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicFragment.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicFragment.kt @@ -41,8 +41,23 @@ import com.sedsoftware.yaptalker.presentation.model.YapEntity import com.uber.autodispose.kotlin.autoDisposable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -import kotlinx.android.synthetic.main.fragment_chosen_topic.* -import kotlinx.android.synthetic.main.include_topic_fab_menu.* +import kotlinx.android.synthetic.main.fragment_chosen_topic.topic_posts_list +import kotlinx.android.synthetic.main.fragment_chosen_topic.topic_refresh_layout +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_bookmark +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_bookmark_block +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_gallery +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_gallery_block +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_karma +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_karma_block +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_main_button_block +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_menu +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_new_message +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_new_message_label +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_overlay +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_refresh +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_refresh_block +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_share +import kotlinx.android.synthetic.main.include_topic_fab_menu.fab_share_block import org.jetbrains.anko.browse import org.jetbrains.anko.share import timber.log.Timber @@ -398,13 +413,21 @@ class ChosenTopicFragment : BaseFragment(), ChosenTopicView, ChosenTopicElements } RxView - .clicks(fab_share) + .clicks(fab_share) .autoDisposable(event(FragmentLifecycle.DESTROY)) .subscribe { collapseMenu() presenter.shareCurrentTopic() } + RxView + .clicks(fab_gallery) + .autoDisposable(event(FragmentLifecycle.DESTROY)) + .subscribe { + collapseMenu() + presenter.openTopicGallery() + } + RxView .clicks(fab_karma) .autoDisposable(event(FragmentLifecycle.DESTROY)) @@ -461,5 +484,6 @@ class ChosenTopicFragment : BaseFragment(), ChosenTopicView, ChosenTopicElements } fabMenu.add(FabMenuItemSecondary(context, fab_share_block)) + fabMenu.add(FabMenuItemSecondary(context, fab_gallery_block)) } } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt index 92f4e474..70c6d63c 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt @@ -192,6 +192,11 @@ class ChosenTopicPresenter @Inject constructor( viewState.shareTopic(currentTitle, startingPost) } + + fun openTopicGallery() { + // TODO Implement this + } + fun showPostKarmaMenuIfAvailable(postId: Int) { if (postId == 0 || authKey.isEmpty()) { return diff --git a/app/src/main/res/layout/include_topic_fab_menu.xml b/app/src/main/res/layout/include_topic_fab_menu.xml index e1d23e95..906d95f2 100644 --- a/app/src/main/res/layout/include_topic_fab_menu.xml +++ b/app/src/main/res/layout/include_topic_fab_menu.xml @@ -214,4 +214,37 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 5140e019..b34f2af2 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -47,6 +47,7 @@ Новое сообщение Обновить Поделиться + Галерея Введите сообщение… diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79be799a..f0e43a79 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,6 +59,7 @@ New message Refresh Share + Gallery Enter your message… From b45befa7745f2b145403219ecd4b93d676bc208a Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Tue, 27 Feb 2018 21:59:44 +0300 Subject: [PATCH 02/29] Define base mvp stuff for topic gallery --- .../features/gallery/TopicGalleryActivity.kt | 59 +++++++++++++++++++ .../features/gallery/TopicGalleryPresenter.kt | 6 ++ .../features/gallery/TopicGalleryView.kt | 5 ++ .../gallery/di/TopicGalleryActivityModule.kt | 6 ++ 4 files changed, 76 insertions(+) create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt new file mode 100644 index 00000000..6a375f47 --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt @@ -0,0 +1,59 @@ +package com.sedsoftware.yaptalker.presentation.features.gallery + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import com.arellomobile.mvp.presenter.InjectPresenter +import com.arellomobile.mvp.presenter.ProvidePresenter +import com.sedsoftware.yaptalker.R +import com.sedsoftware.yaptalker.commons.annotation.LayoutResource +import com.sedsoftware.yaptalker.presentation.base.BaseActivity +import com.sedsoftware.yaptalker.presentation.extensions.toastError +import timber.log.Timber +import javax.inject.Inject + +@LayoutResource(R.layout.activity_topic_gallery) +class TopicGalleryActivity : BaseActivity(), TopicGalleryView { + + companion object { + fun getIntent(ctx: Context, triple: Triple): Intent { + val intent = Intent(ctx, TopicGalleryActivity::class.java) + intent.putExtra(FORUM_ID_KEY, triple.first) + intent.putExtra(TOPIC_ID_KEY, triple.second) + intent.putExtra(CURRENT_PAGE_KEY, triple.third) + return intent + } + + private const val FORUM_ID_KEY = "FORUM_ID_KEY" + private const val TOPIC_ID_KEY = "TOPIC_ID_KEY" + private const val CURRENT_PAGE_KEY = "CURRENT_PAGE_KEY" + } + + @Inject + @InjectPresenter + lateinit var presenter: TopicGalleryPresenter + + @ProvidePresenter + fun provideGalleryPresenter() = presenter + + private val forumId: Int by lazy { + intent.getIntExtra(FORUM_ID_KEY, 0) + } + + private val topicId: Int by lazy { + intent.getIntExtra(TOPIC_ID_KEY, 0) + } + + private val currentPage: Int by lazy { + intent.getIntExtra(CURRENT_PAGE_KEY, 0) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + Timber.d("forumId = $forumId, topicId = $topicId, currentPage = $currentPage") + } + + override fun showErrorMessage(message: String) { + toastError(message) + } +} diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt new file mode 100644 index 00000000..da89b82c --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt @@ -0,0 +1,6 @@ +package com.sedsoftware.yaptalker.presentation.features.gallery + +import com.sedsoftware.yaptalker.presentation.base.BasePresenter +import javax.inject.Inject + +class TopicGalleryPresenter @Inject constructor() : BasePresenter() diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt new file mode 100644 index 00000000..43f8e8fd --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt @@ -0,0 +1,5 @@ +package com.sedsoftware.yaptalker.presentation.features.gallery + +import com.sedsoftware.yaptalker.presentation.base.BaseView + +interface TopicGalleryView : BaseView diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt new file mode 100644 index 00000000..2b6309c8 --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt @@ -0,0 +1,6 @@ +package com.sedsoftware.yaptalker.presentation.features.gallery.di + +import dagger.Module + +@Module +abstract class TopicGalleryActivityModule From f6fb52829f0ca6cd5c956e44f590093f41daf7fc Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Tue, 27 Feb 2018 21:59:59 +0300 Subject: [PATCH 03/29] Implement gallery adapter --- .../gallery/adapter/TopicGalleryAdapter.kt | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt new file mode 100644 index 00000000..e9e2631b --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt @@ -0,0 +1,45 @@ +package com.sedsoftware.yaptalker.presentation.features.gallery.adapter + +import android.support.v7.widget.RecyclerView +import android.support.v7.widget.RecyclerView.ViewHolder +import android.view.ViewGroup +import com.sedsoftware.yaptalker.R +import com.sedsoftware.yaptalker.presentation.extensions.inflate +import com.sedsoftware.yaptalker.presentation.extensions.loadFromUrl +import kotlinx.android.synthetic.main.activity_topic_gallery_item.view.gallery_image +import java.util.ArrayList +import javax.inject.Inject + +class TopicGalleryAdapter @Inject constructor() : RecyclerView.Adapter() { + + private var items: ArrayList = ArrayList() + + init { + setHasStableIds(true) + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = ImageViewHolder(parent) + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + holder as ImageViewHolder + holder.bind(items[position]) + } + + override fun getItemId(position: Int) = position.toLong() + + override fun getItemCount(): Int = items.size + + fun setList(images: List) { + items.clear() + items.addAll(images) + notifyDataSetChanged() + } + + inner class ImageViewHolder(parent: ViewGroup) : + RecyclerView.ViewHolder(parent.inflate(R.layout.activity_topic_gallery_item)) { + + fun bind(url: String) { + itemView.gallery_image.loadFromUrl(url) + } + } +} From 97667d14261f3702f786be83011402c465b2d884 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Tue, 27 Feb 2018 22:00:19 +0300 Subject: [PATCH 04/29] Add gallery activity to navigation --- app/src/main/AndroidManifest.xml | 9 +++++++++ .../base/enums/navigation/NavigationScreen.kt | 1 + .../features/navigation/MainActivityNavigator.kt | 4 +++- .../features/topic/ChosenTopicPresenter.kt | 2 +- app/src/main/res/layout/activity_topic_gallery.xml | 12 ++++++++++++ .../res/layout/activity_topic_gallery_item.xml | 14 ++++++++++++++ 6 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/layout/activity_topic_gallery.xml create mode 100644 app/src/main/res/layout/activity_topic_gallery_item.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1cc9117b..338093d1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -112,6 +112,15 @@ android:value=".presentation.features.navigation.MainActivity" /> + + + + ImageDisplayActivity.getIntent(activity, data as String) NavigationScreen.VIDEO_DISPLAY_SCREEN -> VideoDisplayActivity.getIntent(activity, data as String) NavigationScreen.GIF_DISPLAY_SCREEN -> GifDisplayActivity.getIntent(activity, data as String) + NavigationScreen.TOPIC_GALLERY -> TopicGalleryActivity.getIntent(activity, data as Triple) else -> null } - @Suppress("UNCHECKED_CAST") override fun createFragment(screenKey: String?, data: Any?): Fragment? = when (screenKey) { NavigationScreen.NEWS_SCREEN -> NewsFragment.getNewInstance() NavigationScreen.ACTIVE_TOPICS_SCREEN -> ActiveTopicsFragment.getNewInstance() diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt index 70c6d63c..a9ded422 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt @@ -194,7 +194,7 @@ class ChosenTopicPresenter @Inject constructor( fun openTopicGallery() { - // TODO Implement this + router.navigateTo(NavigationScreen.TOPIC_GALLERY, Triple(currentForumId, currentTopicId, currentPage)) } fun showPostKarmaMenuIfAvailable(postId: Int) { diff --git a/app/src/main/res/layout/activity_topic_gallery.xml b/app/src/main/res/layout/activity_topic_gallery.xml new file mode 100644 index 00000000..77efa571 --- /dev/null +++ b/app/src/main/res/layout/activity_topic_gallery.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_gallery_item.xml b/app/src/main/res/layout/activity_topic_gallery_item.xml new file mode 100644 index 00000000..2cacd7dd --- /dev/null +++ b/app/src/main/res/layout/activity_topic_gallery_item.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file From 6ad7e6679a3572551563edda5351cf091d5801e8 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Tue, 27 Feb 2018 22:00:37 +0300 Subject: [PATCH 05/29] Define activity contrib injector --- .../di/modules/contribution/ActivityContributionModule.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/di/modules/contribution/ActivityContributionModule.kt b/app/src/main/java/com/sedsoftware/yaptalker/di/modules/contribution/ActivityContributionModule.kt index 755f42b1..0b4848bb 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/di/modules/contribution/ActivityContributionModule.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/di/modules/contribution/ActivityContributionModule.kt @@ -1,6 +1,8 @@ package com.sedsoftware.yaptalker.di.modules.contribution import com.sedsoftware.yaptalker.di.scopes.ActivityScope +import com.sedsoftware.yaptalker.presentation.features.gallery.TopicGalleryActivity +import com.sedsoftware.yaptalker.presentation.features.gallery.di.TopicGalleryActivityModule import com.sedsoftware.yaptalker.presentation.features.gifdisplay.GifDisplayActivity import com.sedsoftware.yaptalker.presentation.features.gifdisplay.di.GifDisplayActivityModule import com.sedsoftware.yaptalker.presentation.features.imagedisplay.ImageDisplayActivity @@ -37,4 +39,8 @@ interface ActivityContributionModule { @ActivityScope @ContributesAndroidInjector(modules = [(GifDisplayActivityModule::class)]) fun gifActivityInjector(): GifDisplayActivity + + @ActivityScope + @ContributesAndroidInjector(modules = [(TopicGalleryActivityModule::class)]) + fun galleryActivityInjector(): TopicGalleryActivity } From ba78af69e856d45bbcc263554dba1abe9c7860bb Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 14:03:07 +0300 Subject: [PATCH 06/29] Update dependencies --- build.gradle | 2 +- buildsystem/dependencies.gradle | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 2857c380..c0900912 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { maven { url "https://maven.fabric.io/public" } } dependencies { - classpath "com.android.tools.build:gradle:3.2.0-alpha02" + classpath "com.android.tools.build:gradle:3.2.0-alpha04" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.gms:google-services:$goole_play_services_version" classpath "io.fabric.tools:gradle:$fabric_version" diff --git a/buildsystem/dependencies.gradle b/buildsystem/dependencies.gradle index 1b965e03..5a55e3fc 100644 --- a/buildsystem/dependencies.gradle +++ b/buildsystem/dependencies.gradle @@ -6,18 +6,18 @@ allprojects { ext { // Android - final KOTLIN_VERSION = "1.2.21" - final SUPPORT_LIBRARY_VERSION = "27.0.2" + final KOTLIN_VERSION = "1.2.30" + final SUPPORT_LIBRARY_VERSION = "27.1.0" final CONSTRAINT_LAYOUT_VERSION = "1.1.0-beta5" // Rx - final RX_ANDROID_VERSION = "2.0.1" - final RX_JAVA_VERSION = "2.1.9" + final RX_ANDROID_VERSION = "2.0.2" + final RX_JAVA_VERSION = "2.1.10" final RX_KOTLIN_VERSION = "2.2.0" final RX_RELAY_VERSION = "2.0.0" - final RX_LINT_VERSION = "1.6" + final RX_LINT_VERSION = "1.6.1" final RX_BINDING_VERSION = "2.1.0" - final AUTO_DISPOSE_VERSION = "0.6.0" + final AUTO_DISPOSE_VERSION = "0.6.1" // Core final DAGGER_VERSION = "2.14.1" @@ -27,14 +27,14 @@ ext { final PICASSO_VERSION = "2.5.2" final CICERONE_VERSION = "3.0.0" final RETROFIT_VERSION = "2.3.0" - final JSPOON_VERSION = "1.2.1" + final JSPOON_VERSION = "1.2.2" final MOSHI_VERSION = "1.5.0" - final OKHTTP_VERSION = "3.9.1" + final OKHTTP_VERSION = "3.10.0" // UI final MATERIAL_VALUES_VERSION = "1.1.1" final MATERIAL_DRAWER_VERSION = "6.0.6@aar" - final ICONICS_VERSION = "3.0.2@aar" + final ICONICS_VERSION = "3.0.3@aar" final COMMUNITY_MATERIAL_ICONS_VERSION = "2.0.46.1@aar" final MATERIAL_DIALOGUES_VERSION = "0.9.6.0" final TOASTY_VERSION = "1.2.8" @@ -43,16 +43,16 @@ ext { // Testing final ESPRESSO_VERSION = "3.0.2-alpha1" final JUNIT_VERSION = "4.12" - final MOCKITO_VERSION = "2.13.0" + final MOCKITO_VERSION = "2.15.0" final MOCKITO_KOTLIN_VERSION = "1.5.0" final EXPEKT_VERSION = "0.5.0" // Supporting tools - final ANDROID_CRASHALYTICS_VERSION = "2.9.0@aar" + final ANDROID_CRASHALYTICS_VERSION = "2.9.1@aar" final FIREBASE_CORE_VERSION = "11.8.0" // Development tools - final TIMBER_VERSION = "4.6.0" + final TIMBER_VERSION = "4.6.1" final LEAK_CANARY_VERSION = "1.5.4" domainDependencies = [ From d3a12754f0e2c3d71dc85c4d8a5e296aa1bcbb14 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 15:38:24 +0300 Subject: [PATCH 07/29] Implement topic gallery layouts --- app/src/main/res/drawable/bg_load_more.xml | 8 +++++++ .../res/layout/activity_topic_gallery.xml | 5 +++++ .../layout/activity_topic_gallery_item.xml | 13 ++++++++--- .../activity_topic_gallery_item_load_more.xml | 22 +++++++++++++++++++ app/src/main/res/values-ru/strings.xml | 4 ++-- app/src/main/res/values/colors.xml | 2 ++ app/src/main/res/values/dimens.xml | 4 +++- app/src/main/res/values/strings.xml | 3 ++- 8 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/bg_load_more.xml create mode 100644 app/src/main/res/layout/activity_topic_gallery_item_load_more.xml diff --git a/app/src/main/res/drawable/bg_load_more.xml b/app/src/main/res/drawable/bg_load_more.xml new file mode 100644 index 00000000..bfdb2f3a --- /dev/null +++ b/app/src/main/res/drawable/bg_load_more.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_gallery.xml b/app/src/main/res/layout/activity_topic_gallery.xml index 77efa571..a6c7d461 100644 --- a/app/src/main/res/layout/activity_topic_gallery.xml +++ b/app/src/main/res/layout/activity_topic_gallery.xml @@ -9,4 +9,9 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_gallery_item.xml b/app/src/main/res/layout/activity_topic_gallery_item.xml index 2cacd7dd..c5764d3a 100644 --- a/app/src/main/res/layout/activity_topic_gallery_item.xml +++ b/app/src/main/res/layout/activity_topic_gallery_item.xml @@ -4,11 +4,18 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + + + android:layout_margin="@dimen/load_more_padding" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml b/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml new file mode 100644 index 00000000..8ace8143 --- /dev/null +++ b/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index b34f2af2..ed8b0975 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -26,12 +26,12 @@ Комментариев: %s - + %d из %d Перейти на страницу Введите номер страницы… Страница %d недоступна - + Загрузить\nеще… Логин Пароль diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 9bd43fd8..11af4cd2 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -49,4 +49,6 @@ @color/material_color_blue_500 @color/material_color_green_500 @color/material_color_teal_500 + + #64ffffff diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 34b14868..9117859d 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -14,8 +14,10 @@ 8dp 4dp - + 54dp + 8dp + 8dp 4dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f0e43a79..d691738e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,7 +31,7 @@ {cmd-lock} %s {cmd-lock} {cmd-pin} %s - + %d of %d Go to page Enter page number… @@ -40,6 +40,7 @@ > << >> + Load\nmore… Login From 241e171b2aaf72dbd36ecde2487f37fbc2db1f99 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 15:47:09 +0300 Subject: [PATCH 08/29] Tweak gallery item model and mapper --- .../mappers/TopicGalleryModelMapper.kt | 75 +++++++++++++++++++ .../presentation/model/YapEntityTypes.kt | 3 +- .../model/base/SinglePostGalleryImageModel.kt | 12 +++ .../domain/entity/base/SinglePostImages.kt | 10 +++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/model/base/SinglePostGalleryImageModel.kt create mode 100644 domain/src/main/java/com/sedsoftware/yaptalker/domain/entity/base/SinglePostImages.kt diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt new file mode 100644 index 00000000..3c5e3041 --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt @@ -0,0 +1,75 @@ +package com.sedsoftware.yaptalker.presentation.mappers + +import com.sedsoftware.yaptalker.domain.entity.BaseEntity +import com.sedsoftware.yaptalker.domain.entity.base.NavigationPanel +import com.sedsoftware.yaptalker.domain.entity.base.SinglePost +import com.sedsoftware.yaptalker.domain.entity.base.TopicInfoBlock +import com.sedsoftware.yaptalker.presentation.extensions.validateUrl +import com.sedsoftware.yaptalker.presentation.mappers.util.TextTransformer +import com.sedsoftware.yaptalker.presentation.model.YapEntity +import com.sedsoftware.yaptalker.presentation.model.base.NavigationPanelModel +import com.sedsoftware.yaptalker.presentation.model.base.SinglePostGalleryImageModel +import com.sedsoftware.yaptalker.presentation.model.base.TopicInfoBlockModel +import io.reactivex.functions.Function +import java.util.ArrayList +import javax.inject.Inject + +/** + * Mapper class used to transform single topic image list entities from the domain layer into YapEntity list + * in the presentation layer. + */ +class TopicGalleryModelMapper @Inject constructor( + private val textTransformer: TextTransformer +) : Function, List> { + + override fun apply(items: List): List { + + val result: MutableList = ArrayList() + val imagesList: MutableList = ArrayList() + var currentPage = 0 + var totalPage = 0 + + items.forEach { item -> + when (item) { + is TopicInfoBlock -> result.add( + TopicInfoBlockModel( + topicTitle = item.topicTitle, + isClosed = item.isClosed, + authKey = item.authKey, + topicRating = item.topicRating, + topicRatingPlusAvailable = item.topicRatingPlusAvailable, + topicRatingMinusAvailable = item.topicRatingMinusAvailable, + topicRatingPlusClicked = item.topicRatingPlusClicked, + topicRatingMinusClicked = item.topicRatingMinusClicked, + topicRatingTargetId = item.topicRatingTargetId + ) + ) + + is NavigationPanel -> { + currentPage = item.currentPage + totalPage = item.totalPages + result.add( + NavigationPanelModel( + currentPage = item.currentPage, + totalPages = item.totalPages, + navigationLabel = textTransformer.createNavigationLabel(item.currentPage, item.totalPages) + ) + ) + } + + is SinglePost -> imagesList.addAll(item.postContentParsed.images.map { url -> url.validateUrl() }) + } + } + + imagesList.forEachIndexed { index, imageUrl -> + result.add( + SinglePostGalleryImageModel( + url = imageUrl, + showLoadMore = index == imagesList.lastIndex && currentPage != totalPage + ) + ) + } + + return result + } +} diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/model/YapEntityTypes.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/model/YapEntityTypes.kt index 5189cf4f..55d2666f 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/model/YapEntityTypes.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/model/YapEntityTypes.kt @@ -19,5 +19,6 @@ object YapEntityTypes { const val EDITED_POST_TEXT = 16 const val EMOJI = 17 const val SEARCH_TOPIC_ITEM = 18 - const val SEARCH_PAGE_INFO = 18 + const val SEARCH_PAGE_INFO = 19 + const val TOPIC_PAGE_IMAGES = 20 } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/model/base/SinglePostGalleryImageModel.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/model/base/SinglePostGalleryImageModel.kt new file mode 100644 index 00000000..b1caa23c --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/model/base/SinglePostGalleryImageModel.kt @@ -0,0 +1,12 @@ +package com.sedsoftware.yaptalker.presentation.model.base + +import com.sedsoftware.yaptalker.presentation.model.YapEntity +import com.sedsoftware.yaptalker.presentation.model.YapEntityTypes + +class SinglePostGalleryImageModel( + val url: String, + val showLoadMore: Boolean +) : YapEntity { + + override fun getBaseEntityType(): Int = YapEntityTypes.TOPIC_PAGE_IMAGES +} diff --git a/domain/src/main/java/com/sedsoftware/yaptalker/domain/entity/base/SinglePostImages.kt b/domain/src/main/java/com/sedsoftware/yaptalker/domain/entity/base/SinglePostImages.kt new file mode 100644 index 00000000..88d3fe0e --- /dev/null +++ b/domain/src/main/java/com/sedsoftware/yaptalker/domain/entity/base/SinglePostImages.kt @@ -0,0 +1,10 @@ +package com.sedsoftware.yaptalker.domain.entity.base + +import com.sedsoftware.yaptalker.domain.entity.BaseEntity + +/** + * Class which represents single topic post images list in domain layer. + */ +class SinglePostImages( + val urls: List +) : BaseEntity From 3ff1387e8cd536977ae7306a73bc677c6a2824bf Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 19:47:00 +0300 Subject: [PATCH 09/29] Type tweaks for newest kapt update --- .../presentation/base/BaseActivity.kt | 4 +-- .../presentation/base/BaseFragment.kt | 4 +-- .../presentation/base/BasePresenter.kt | 8 ++--- .../base/enums/ConnectionState.kt | 8 ++--- .../base/enums/lifecycle/ActivityLifecycle.kt | 12 ++++---- .../base/enums/lifecycle/FragmentLifecycle.kt | 16 +++++----- .../enums/lifecycle/PresenterLifecycle.kt | 8 ++--- .../enums/navigation/NavigationSection.kt | 18 +++++------ .../presentation/base/events/AppEvent.kt | 4 +-- .../incubator/adapter/IncubatorAdapter.kt | 2 +- .../features/navigation/MainActivity.kt | 30 +++++++++---------- .../features/navigation/MainActivityView.kt | 2 +- .../navigation/NavigationPresenter.kt | 2 +- .../features/news/adapter/NewsAdapter.kt | 2 +- .../features/posting/AddMessagePresenter.kt | 6 ++-- .../features/posting/tags/MessageTagCodes.kt | 10 +++---- .../features/search/SearchRequest.kt | 2 +- .../features/search/options/TargetPeriod.kt | 16 +++++----- .../mappers/TopicGalleryModelMapper.kt | 3 +- 19 files changed, 78 insertions(+), 79 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt index a1e9b504..20abed7b 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt @@ -32,7 +32,7 @@ abstract class BaseActivity : MvpAppCompatActivity(), HasSupportFragmentInjector protected lateinit var backPressFragment: BaseFragment - private val lifecycle: BehaviorRelay = BehaviorRelay.create() + private val lifecycle: BehaviorRelay = BehaviorRelay.create() override fun onCreate(savedInstanceState: Bundle?) { AndroidInjection.inject(this) @@ -92,7 +92,7 @@ abstract class BaseActivity : MvpAppCompatActivity(), HasSupportFragmentInjector backPressFragment = fragment } - protected fun event(@ActivityLifecycle.Event event: Long): Maybe<*> = + protected fun event(@ActivityLifecycle.Event event: Int): Maybe<*> = lifecycle.filter({ e -> e == event }).firstElement() private fun applyTheme() { diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt index 05454645..07df948d 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt @@ -15,7 +15,7 @@ import io.reactivex.Maybe abstract class BaseFragment : MvpAppCompatFragment() { - private val lifecycle: BehaviorRelay = BehaviorRelay.create() + private val lifecycle: BehaviorRelay = BehaviorRelay.create() private lateinit var backPressHandler: BackPressHandler open fun onBackPressed(): Boolean = false @@ -80,6 +80,6 @@ abstract class BaseFragment : MvpAppCompatFragment() { lifecycle.accept(FragmentLifecycle.DETACH) } - protected fun event(@FragmentLifecycle.Event event: Long): Maybe<*> = + protected fun event(@FragmentLifecycle.Event event: Int): Maybe<*> = lifecycle.filter({ e -> e == event }).firstElement() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt index dd3566bb..45bc7acb 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt @@ -21,7 +21,7 @@ abstract class BasePresenter : MvpPresenter() { @Inject lateinit var eventBus: BehaviorRelay - private val lifecycle: BehaviorRelay = BehaviorRelay.create() + private val lifecycle: BehaviorRelay = BehaviorRelay.create() init { lifecycle.accept(PresenterLifecycle.CREATE) @@ -67,7 +67,7 @@ abstract class BasePresenter : MvpPresenter() { .subscribe(eventBus) } - fun setConnectionState(@ConnectionState.Event state: Long) { + fun setConnectionState(@ConnectionState.Event state: Int) { Observable .just(ConnectionEvent(state)) .observeOn(AndroidSchedulers.mainThread()) @@ -75,7 +75,7 @@ abstract class BasePresenter : MvpPresenter() { .subscribe(eventBus) } - fun setNavDrawerItem(@NavigationSection.Section section: Long) { + fun setNavDrawerItem(@NavigationSection.Section section: Int) { Observable .just(NavDrawerEvent(section)) .observeOn(AndroidSchedulers.mainThread()) @@ -83,6 +83,6 @@ abstract class BasePresenter : MvpPresenter() { .subscribe(eventBus) } - protected fun event(@PresenterLifecycle.Event event: Long): Maybe<*> = + protected fun event(@PresenterLifecycle.Event event: Int): Maybe<*> = lifecycle.filter({ e -> e == event }).firstElement() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt index 53c0cca6..9dbdbf16 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt @@ -5,10 +5,10 @@ import android.support.annotation.IntDef class ConnectionState { companion object { - const val IDLE = 0L - const val LOADING = 1L - const val COMPLETED = 2L - const val ERROR = 3L + const val IDLE = 0 + const val LOADING = 1 + const val COMPLETED = 2 + const val ERROR = 3 } @Retention(AnnotationRetention.SOURCE) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt index c492bfa9..d8d534cb 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt @@ -5,12 +5,12 @@ import android.support.annotation.IntDef class ActivityLifecycle { companion object { - const val CREATE = 0L - const val START = 1L - const val RESUME = 2L - const val PAUSE = 3L - const val STOP = 4L - const val DESTROY = 5L + const val CREATE = 0 + const val START = 1 + const val RESUME = 2 + const val PAUSE = 3 + const val STOP = 4 + const val DESTROY = 5 } @Retention(AnnotationRetention.SOURCE) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt index 5e0b3b86..8beb8fcd 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt @@ -5,14 +5,14 @@ import android.support.annotation.IntDef class FragmentLifecycle { companion object { - const val ATTACH = 0L - const val CREATE = 1L - const val START = 2L - const val RESUME = 3L - const val PAUSE = 4L - const val STOP = 5L - const val DESTROY = 6L - const val DETACH = 7L + const val ATTACH = 0 + const val CREATE = 1 + const val START = 2 + const val RESUME = 3 + const val PAUSE = 4 + const val STOP = 5 + const val DESTROY = 6 + const val DETACH = 7 } @Retention(AnnotationRetention.SOURCE) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt index 93dbc757..2088c425 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt @@ -5,10 +5,10 @@ import android.support.annotation.IntDef class PresenterLifecycle { companion object { - const val CREATE = 0L - const val ATTACH_VIEW = 1L - const val DETACH_VIEW = 2L - const val DESTROY = 3L + const val CREATE = 0 + const val ATTACH_VIEW = 1 + const val DETACH_VIEW = 2 + const val DESTROY = 3 } @Retention(AnnotationRetention.SOURCE) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt index f9937ce6..a0ad5c92 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt @@ -4,15 +4,15 @@ import android.support.annotation.IntDef class NavigationSection { companion object { - const val MAIN_PAGE = 0L - const val FORUMS = 1L - const val ACTIVE_TOPICS = 2L - const val INCUBATOR = 3L - const val BOOKMARKS = 4L - const val SITE_SEARCH = 5L - const val SETTINGS = 6L - const val SIGN_IN = 7L - const val SIGN_OUT = 8L + const val MAIN_PAGE = 0 + const val FORUMS = 1 + const val ACTIVE_TOPICS = 2 + const val INCUBATOR = 3 + const val BOOKMARKS = 4 + const val SITE_SEARCH = 5 + const val SETTINGS = 6 + const val SIGN_IN = 7 + const val SIGN_OUT = 8 } @Retention(AnnotationRetention.SOURCE) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt index d242eac6..bda04422 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt @@ -4,7 +4,7 @@ sealed class AppEvent { class AppbarEvent(val title: String) : AppEvent() - class ConnectionEvent(val state: Long) : AppEvent() + class ConnectionEvent(val state: Int) : AppEvent() - class NavDrawerEvent(val itemId: Long) : AppEvent() + class NavDrawerEvent(val itemId: Int) : AppEvent() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt index e85cfb8b..48bf8820 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt @@ -43,7 +43,7 @@ class IncubatorAdapter @Inject constructor( } } - override fun onViewDetachedFromWindow(holder: ViewHolder?) { + override fun onViewDetachedFromWindow(holder: ViewHolder) { super.onViewDetachedFromWindow(holder) holder?.itemView?.clearAnimation() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt index 091005b1..eee74df7 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt @@ -127,8 +127,8 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { supportActionBar?.title = title } - override fun selectNavDrawerItem(item: Long) { - navDrawer.setSelection(item, false) + override fun selectNavDrawerItem(item: Int) { + navDrawer.setSelection(item.toLong(), false) } override fun updateNavDrawerProfile(userInfo: LoginSessionInfoModel) { @@ -150,9 +150,9 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { } override fun clearDynamicNavigationItems() { - navDrawer.removeItem(NavigationSection.SIGN_IN) - navDrawer.removeItem(NavigationSection.SIGN_OUT) - navDrawer.removeItem(NavigationSection.BOOKMARKS) + navDrawer.removeItem(NavigationSection.SIGN_IN.toLong()) + navDrawer.removeItem(NavigationSection.SIGN_OUT.toLong()) + navDrawer.removeItem(NavigationSection.BOOKMARKS.toLong()) } override fun displaySignedInNavigation() { @@ -176,7 +176,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { private fun initializeNavigationDrawer(savedInstanceState: Bundle?) { drawerItemMainPage = PrimaryDrawerItem() - .withIdentifier(NavigationSection.MAIN_PAGE) + .withIdentifier(NavigationSection.MAIN_PAGE.toLong()) .withName(R.string.nav_drawer_main_page) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_home) @@ -186,7 +186,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavMainPage) drawerItemForums = PrimaryDrawerItem() - .withIdentifier(NavigationSection.FORUMS) + .withIdentifier(NavigationSection.FORUMS.toLong()) .withName(R.string.nav_drawer_forums) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_forum) @@ -196,7 +196,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavForums) drawerItemActiveTopics = PrimaryDrawerItem() - .withIdentifier(NavigationSection.ACTIVE_TOPICS) + .withIdentifier(NavigationSection.ACTIVE_TOPICS.toLong()) .withName(R.string.nav_drawer_active_topics) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_bulletin_board) @@ -206,7 +206,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavActiveTopics) drawerItemIncubator = PrimaryDrawerItem() - .withIdentifier(NavigationSection.INCUBATOR) + .withIdentifier(NavigationSection.INCUBATOR.toLong()) .withName(R.string.nav_drawer_incubator) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_human_child) @@ -216,7 +216,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavIncubator) drawerItemBookmarks = PrimaryDrawerItem() - .withIdentifier(NavigationSection.BOOKMARKS) + .withIdentifier(NavigationSection.BOOKMARKS.toLong()) .withName(R.string.nav_drawer_bookmarks) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_bookmark_outline) @@ -226,7 +226,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavBookmarks) drawerItemSearch = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SITE_SEARCH) + .withIdentifier(NavigationSection.SITE_SEARCH.toLong()) .withName(R.string.nav_drawer_search) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_magnify) @@ -236,7 +236,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavSearch) drawerItemSettings = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SETTINGS) + .withIdentifier(NavigationSection.SETTINGS.toLong()) .withIcon(CommunityMaterial.Icon.cmd_settings) .withName(R.string.nav_drawer_settings) // .withSelectable(false) @@ -246,7 +246,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavSettings) drawerItemSignIn = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SIGN_IN) + .withIdentifier(NavigationSection.SIGN_IN.toLong()) .withName(R.string.nav_drawer_sign_in) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_login) @@ -256,7 +256,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavSignIn) drawerItemSignOut = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SIGN_OUT) + .withIdentifier(NavigationSection.SIGN_OUT.toLong()) .withName(R.string.nav_drawer_sign_out) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_logout) @@ -295,7 +295,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .addDrawerItems(drawerItemSettings) .withOnDrawerItemClickListener { _, _, drawerItem -> if (drawerItem is Nameable<*>) { - navigationPresenter.navigateToChosenSection(drawerItem.identifier) + navigationPresenter.navigateToChosenSection(drawerItem.identifier.toInt()) } false } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt index 427e56a3..9003e164 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt @@ -9,5 +9,5 @@ interface MainActivityView : BaseView { fun setAppbarTitle(title: String) - fun selectNavDrawerItem(item: Long) + fun selectNavDrawerItem(item: Int) } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt index 9c824712..860fb7b1 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt @@ -56,7 +56,7 @@ class NavigationPresenter @Inject constructor( router.removeResultListener(RequestCode.SIGN_IN) } - fun navigateToChosenSection(@NavigationSection.Section identifier: Long) { + fun navigateToChosenSection(@NavigationSection.Section identifier: Int) { when (identifier) { NavigationSection.MAIN_PAGE -> router.newRootScreen(NavigationScreen.NEWS_SCREEN) NavigationSection.ACTIVE_TOPICS -> router.newRootScreen(NavigationScreen.ACTIVE_TOPICS_SCREEN) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt index f3697327..3356c7ef 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt @@ -41,7 +41,7 @@ class NewsAdapter @Inject constructor( } } - override fun onViewDetachedFromWindow(holder: ViewHolder?) { + override fun onViewDetachedFromWindow(holder: ViewHolder) { super.onViewDetachedFromWindow(holder) holder?.itemView?.clearAnimation() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt index 32f82693..43e42908 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt @@ -48,7 +48,7 @@ class AddMessagePresenter @Inject constructor( super.detachView(view) } - fun insertChosenTag(selectionStart: Int, selectionEnd: Int, @Tag tag: Long) { + fun insertChosenTag(selectionStart: Int, selectionEnd: Int, @Tag tag: Int) { when { tag == MessageTagCodes.TAG_LINK -> onLinkTagClicked() tag == MessageTagCodes.TAG_VIDEO -> onVideoLinkTagClicked() @@ -88,7 +88,7 @@ class AddMessagePresenter @Inject constructor( viewState.showImagePickerDialog() } - private fun onTagClickedWithSelection(@Tag tag: Long) { + private fun onTagClickedWithSelection(@Tag tag: Int) { when (tag) { MessageTagCodes.TAG_B -> { viewState.insertTags(MessageTags.B_OPEN, MessageTags.B_CLOSE) @@ -102,7 +102,7 @@ class AddMessagePresenter @Inject constructor( } } - private fun onTagClickedWithNoSelection(@Tag tag: Long) { + private fun onTagClickedWithNoSelection(@Tag tag: Int) { when (tag) { MessageTagCodes.TAG_B -> { if (isBOpened) { diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt index 84db448f..0ac1f3e2 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt @@ -4,11 +4,11 @@ import android.support.annotation.IntDef class MessageTagCodes { companion object { - const val TAG_B = 0L - const val TAG_I = 1L - const val TAG_U = 2L - const val TAG_LINK = 3L - const val TAG_VIDEO = 4L + const val TAG_B = 0 + const val TAG_I = 1 + const val TAG_U = 2 + const val TAG_LINK = 3 + const val TAG_VIDEO = 4 } @Retention(AnnotationRetention.SOURCE) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt index 1c9d6144..8da5e594 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt @@ -15,5 +15,5 @@ data class SearchRequest( val searchIn: String, @SearchConditions.Value val searchHow: String, @SortingMode.Value val sortBy: String, - @TargetPeriod.Value val periodInDays: Long + @TargetPeriod.Value val periodInDays: Int ) : Parcelable diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt index 0a5ebd72..4fc41ec3 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt @@ -4,14 +4,14 @@ import android.support.annotation.IntDef class TargetPeriod { companion object { - const val ALL_TIME = 0L - const val TODAY = 1L - const val DAYS_7 = 7L - const val DAYS_30 = 30L - const val DAYS_60 = 60L - const val DAYS_90 = 90L - const val DAYS_180 = 180L - const val DAYS_365 = 365L + const val ALL_TIME = 0 + const val TODAY = 1 + const val DAYS_7 = 7 + const val DAYS_30 = 30 + const val DAYS_60 = 60 + const val DAYS_90 = 90 + const val DAYS_180 = 180 + const val DAYS_365 = 365 } @Retention(AnnotationRetention.SOURCE) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt index 3c5e3041..a3390ecf 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt @@ -4,7 +4,6 @@ import com.sedsoftware.yaptalker.domain.entity.BaseEntity import com.sedsoftware.yaptalker.domain.entity.base.NavigationPanel import com.sedsoftware.yaptalker.domain.entity.base.SinglePost import com.sedsoftware.yaptalker.domain.entity.base.TopicInfoBlock -import com.sedsoftware.yaptalker.presentation.extensions.validateUrl import com.sedsoftware.yaptalker.presentation.mappers.util.TextTransformer import com.sedsoftware.yaptalker.presentation.model.YapEntity import com.sedsoftware.yaptalker.presentation.model.base.NavigationPanelModel @@ -57,7 +56,7 @@ class TopicGalleryModelMapper @Inject constructor( ) } - is SinglePost -> imagesList.addAll(item.postContentParsed.images.map { url -> url.validateUrl() }) + is SinglePost -> imagesList.addAll(item.postContentParsed.images) } } From 678b7c7ddc2232e19150d0a7f2380edaebd0c9f8 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 20:23:19 +0300 Subject: [PATCH 10/29] Simple gallery displaying --- .../features/gallery/TopicGalleryActivity.kt | 37 +++++++- .../features/gallery/TopicGalleryPresenter.kt | 89 ++++++++++++++++++- .../features/gallery/TopicGalleryView.kt | 13 ++- .../gallery/adapter/TopicGalleryAdapter.kt | 36 ++++++-- .../TopicGalleryLoadMoreClickListener.kt | 5 ++ .../gallery/di/TopicGalleryActivityModule.kt | 17 +++- .../res/layout/activity_topic_gallery.xml | 3 +- .../activity_topic_gallery_item_load_more.xml | 1 + 8 files changed, 184 insertions(+), 17 deletions(-) create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryLoadMoreClickListener.kt diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt index 6a375f47..e3513ea2 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt @@ -3,17 +3,22 @@ package com.sedsoftware.yaptalker.presentation.features.gallery import android.content.Context import android.content.Intent import android.os.Bundle +import android.support.v7.widget.LinearLayoutManager +import android.support.v7.widget.PagerSnapHelper import com.arellomobile.mvp.presenter.InjectPresenter import com.arellomobile.mvp.presenter.ProvidePresenter import com.sedsoftware.yaptalker.R import com.sedsoftware.yaptalker.commons.annotation.LayoutResource import com.sedsoftware.yaptalker.presentation.base.BaseActivity import com.sedsoftware.yaptalker.presentation.extensions.toastError -import timber.log.Timber +import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryAdapter +import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener +import com.sedsoftware.yaptalker.presentation.model.YapEntity +import kotlinx.android.synthetic.main.activity_topic_gallery.* import javax.inject.Inject @LayoutResource(R.layout.activity_topic_gallery) -class TopicGalleryActivity : BaseActivity(), TopicGalleryView { +class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadMoreClickListener { companion object { fun getIntent(ctx: Context, triple: Triple): Intent { @@ -29,6 +34,9 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView { private const val CURRENT_PAGE_KEY = "CURRENT_PAGE_KEY" } + @Inject + lateinit var galleryAdapter: TopicGalleryAdapter + @Inject @InjectPresenter lateinit var presenter: TopicGalleryPresenter @@ -50,10 +58,33 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - Timber.d("forumId = $forumId, topicId = $topicId, currentPage = $currentPage") + + with(topic_gallery) { + val linearLayout = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) + layoutManager = linearLayout + adapter = galleryAdapter + setHasFixedSize(true) + } + + val snapHelper = PagerSnapHelper() + snapHelper.attachToRecyclerView(topic_gallery) + + presenter.loadTopicGallery(forumId, topicId, currentPage) } override fun showErrorMessage(message: String) { toastError(message) } + + override fun appendImages(images: List) { + galleryAdapter.addList(images) + } + + override fun updateCurrentUiState(title: String) { + supportActionBar?.title = title + } + + override fun onLoadMoreClicked() { + presenter.loadMoreImages() + } } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt index da89b82c..a4115dd1 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt @@ -1,6 +1,93 @@ package com.sedsoftware.yaptalker.presentation.features.gallery +import com.arellomobile.mvp.InjectViewState +import com.sedsoftware.yaptalker.domain.device.Settings +import com.sedsoftware.yaptalker.domain.interactor.topic.GetChosenTopic import com.sedsoftware.yaptalker.presentation.base.BasePresenter +import com.sedsoftware.yaptalker.presentation.base.enums.ConnectionState +import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.PresenterLifecycle +import com.sedsoftware.yaptalker.presentation.mappers.TopicGalleryModelMapper +import com.sedsoftware.yaptalker.presentation.model.YapEntity +import com.sedsoftware.yaptalker.presentation.model.base.NavigationPanelModel +import com.sedsoftware.yaptalker.presentation.model.base.SinglePostGalleryImageModel +import com.uber.autodispose.kotlin.autoDisposable +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.observers.DisposableSingleObserver +import io.reactivex.schedulers.Schedulers import javax.inject.Inject -class TopicGalleryPresenter @Inject constructor() : BasePresenter() +@InjectViewState +class TopicGalleryPresenter @Inject constructor( + settings: Settings, + private val getChosenTopicUseCase: GetChosenTopic, + private val galleryMapper: TopicGalleryModelMapper +) : BasePresenter() { + + companion object { + private const val OFFSET_FOR_PAGE_NUMBER = 1 + } + + private val postsPerPage = settings.getMessagesPerPage() + private var currentForumId = 0 + private var currentTopicId = 0 + private var currentPage = 1 + private var totalPages = 1 + private var currentTitleLabel = "" + + fun loadTopicGallery(forumId: Int, topicId: Int, startingPost: Int = 0) { + currentForumId = forumId + currentTopicId = topicId + + currentPage = when { + startingPost != 0 -> startingPost / postsPerPage + 1 + else -> 1 + } + + loadTopicCurrentPageGallery() + } + + fun loadMoreImages() { + currentPage++ + loadTopicCurrentPageGallery() + } + + private fun loadTopicCurrentPageGallery() { + + val startingPost = (currentPage - OFFSET_FOR_PAGE_NUMBER) * postsPerPage + + getChosenTopicUseCase + .execute(GetChosenTopic.Params(currentForumId, currentTopicId, startingPost)) + .subscribeOn(Schedulers.io()) + .map(galleryMapper) + .observeOn(AndroidSchedulers.mainThread()) + .doOnSubscribe { setConnectionState(ConnectionState.LOADING) } + .doOnError { setConnectionState(ConnectionState.ERROR) } + .doOnSuccess { setConnectionState(ConnectionState.COMPLETED) } + .autoDisposable(event(PresenterLifecycle.DESTROY)) + .subscribe(getTopicGalleryObserver()) + } + + private fun getTopicGalleryObserver() = + object : DisposableSingleObserver>() { + + override fun onSuccess(items: List) { + + items.forEach { item -> + when (item) { + is NavigationPanelModel -> { + currentPage = item.currentPage + totalPages = item.totalPages + currentTitleLabel = item.navigationLabel + } + } + } + + viewState.appendImages(items.filter { it is SinglePostGalleryImageModel }) + viewState.updateCurrentUiState(currentTitleLabel) + } + + override fun onError(error: Throwable) { + error.message?.let { viewState.showErrorMessage(it) } + } + } +} diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt index 43f8e8fd..b3163fe3 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt @@ -1,5 +1,16 @@ package com.sedsoftware.yaptalker.presentation.features.gallery +import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy +import com.arellomobile.mvp.viewstate.strategy.AddToEndStrategy +import com.arellomobile.mvp.viewstate.strategy.StateStrategyType import com.sedsoftware.yaptalker.presentation.base.BaseView +import com.sedsoftware.yaptalker.presentation.model.YapEntity -interface TopicGalleryView : BaseView +interface TopicGalleryView : BaseView { + + @StateStrategyType(AddToEndStrategy::class) + fun appendImages(images: List) + + @StateStrategyType(AddToEndSingleStrategy::class) + fun updateCurrentUiState(title: String) +} diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt index e9e2631b..5b85b560 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt @@ -4,15 +4,22 @@ import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView.ViewHolder import android.view.ViewGroup import com.sedsoftware.yaptalker.R +import com.sedsoftware.yaptalker.presentation.extensions.hideView import com.sedsoftware.yaptalker.presentation.extensions.inflate import com.sedsoftware.yaptalker.presentation.extensions.loadFromUrl -import kotlinx.android.synthetic.main.activity_topic_gallery_item.view.gallery_image +import com.sedsoftware.yaptalker.presentation.extensions.showView +import com.sedsoftware.yaptalker.presentation.model.YapEntity +import com.sedsoftware.yaptalker.presentation.model.base.SinglePostGalleryImageModel +import kotlinx.android.synthetic.main.activity_topic_gallery_item.view.* +import kotlinx.android.synthetic.main.activity_topic_gallery_item_load_more.view.* import java.util.ArrayList import javax.inject.Inject -class TopicGalleryAdapter @Inject constructor() : RecyclerView.Adapter() { +class TopicGalleryAdapter @Inject constructor( + private val loadMoreCallback: TopicGalleryLoadMoreClickListener +) : RecyclerView.Adapter() { - private var items: ArrayList = ArrayList() + private var items: ArrayList = ArrayList() init { setHasStableIds(true) @@ -22,24 +29,35 @@ class TopicGalleryAdapter @Inject constructor() : RecyclerView.Adapter) { - items.clear() + fun addList(images: List) { + val insertPosition = items.size items.addAll(images) - notifyDataSetChanged() + notifyItemRangeInserted(insertPosition, items.size) } inner class ImageViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(parent.inflate(R.layout.activity_topic_gallery_item)) { - fun bind(url: String) { - itemView.gallery_image.loadFromUrl(url) + fun bind(image: SinglePostGalleryImageModel) { + + itemView.load_more_button.hideView() + itemView.gallery_image.loadFromUrl(image.url) + + if (image.showLoadMore) { + itemView.load_more_button.showView() + itemView.load_more_button.setOnClickListener { + loadMoreCallback.onLoadMoreClicked() + itemView.load_more_label.hideView() + itemView.load_more_progress.showView() + } + } } } } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryLoadMoreClickListener.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryLoadMoreClickListener.kt new file mode 100644 index 00000000..0d662497 --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryLoadMoreClickListener.kt @@ -0,0 +1,5 @@ +package com.sedsoftware.yaptalker.presentation.features.gallery.adapter + +interface TopicGalleryLoadMoreClickListener { + fun onLoadMoreClicked() +} diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt index 2b6309c8..0aebdc6b 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt @@ -1,6 +1,21 @@ package com.sedsoftware.yaptalker.presentation.features.gallery.di +import com.sedsoftware.yaptalker.data.repository.YapChosenTopicRepository +import com.sedsoftware.yaptalker.di.scopes.ActivityScope +import com.sedsoftware.yaptalker.domain.repository.ChosenTopicRepository +import com.sedsoftware.yaptalker.presentation.features.gallery.TopicGalleryActivity +import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener +import dagger.Binds import dagger.Module @Module -abstract class TopicGalleryActivityModule +abstract class TopicGalleryActivityModule { + + @ActivityScope + @Binds + abstract fun chosenTopicGalleryRepository(repo: YapChosenTopicRepository): ChosenTopicRepository + + @ActivityScope + @Binds + abstract fun galleryClickListener(activity: TopicGalleryActivity): TopicGalleryLoadMoreClickListener +} diff --git a/app/src/main/res/layout/activity_topic_gallery.xml b/app/src/main/res/layout/activity_topic_gallery.xml index a6c7d461..77dbb898 100644 --- a/app/src/main/res/layout/activity_topic_gallery.xml +++ b/app/src/main/res/layout/activity_topic_gallery.xml @@ -3,7 +3,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" android:orientation="vertical" tools:context="com.sedsoftware.yaptalker.presentation.features.gallery.TopicGalleryActivity"> @@ -12,6 +11,6 @@ + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml b/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml index 8ace8143..85a4ab09 100644 --- a/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml +++ b/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml @@ -1,5 +1,6 @@ Date: Sat, 3 Mar 2018 20:25:05 +0300 Subject: [PATCH 11/29] Separate usecase for topic gallery --- .../features/gallery/TopicGalleryPresenter.kt | 8 ++++---- .../interactor/topic/GetChosenTopicGallery.kt | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 domain/src/main/java/com/sedsoftware/yaptalker/domain/interactor/topic/GetChosenTopicGallery.kt diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt index a4115dd1..7fee4df0 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt @@ -2,7 +2,7 @@ package com.sedsoftware.yaptalker.presentation.features.gallery import com.arellomobile.mvp.InjectViewState import com.sedsoftware.yaptalker.domain.device.Settings -import com.sedsoftware.yaptalker.domain.interactor.topic.GetChosenTopic +import com.sedsoftware.yaptalker.domain.interactor.topic.GetChosenTopicGallery import com.sedsoftware.yaptalker.presentation.base.BasePresenter import com.sedsoftware.yaptalker.presentation.base.enums.ConnectionState import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.PresenterLifecycle @@ -19,7 +19,7 @@ import javax.inject.Inject @InjectViewState class TopicGalleryPresenter @Inject constructor( settings: Settings, - private val getChosenTopicUseCase: GetChosenTopic, + private val getTopicGalleryUseCase: GetChosenTopicGallery, private val galleryMapper: TopicGalleryModelMapper ) : BasePresenter() { @@ -55,8 +55,8 @@ class TopicGalleryPresenter @Inject constructor( val startingPost = (currentPage - OFFSET_FOR_PAGE_NUMBER) * postsPerPage - getChosenTopicUseCase - .execute(GetChosenTopic.Params(currentForumId, currentTopicId, startingPost)) + getTopicGalleryUseCase + .execute(GetChosenTopicGallery.Params(currentForumId, currentTopicId, startingPost)) .subscribeOn(Schedulers.io()) .map(galleryMapper) .observeOn(AndroidSchedulers.mainThread()) diff --git a/domain/src/main/java/com/sedsoftware/yaptalker/domain/interactor/topic/GetChosenTopicGallery.kt b/domain/src/main/java/com/sedsoftware/yaptalker/domain/interactor/topic/GetChosenTopicGallery.kt new file mode 100644 index 00000000..c9e85331 --- /dev/null +++ b/domain/src/main/java/com/sedsoftware/yaptalker/domain/interactor/topic/GetChosenTopicGallery.kt @@ -0,0 +1,18 @@ +package com.sedsoftware.yaptalker.domain.interactor.topic + +import com.sedsoftware.yaptalker.domain.entity.BaseEntity +import com.sedsoftware.yaptalker.domain.interactor.SingleUseCaseWithParameter +import com.sedsoftware.yaptalker.domain.repository.ChosenTopicRepository +import io.reactivex.Single +import javax.inject.Inject + +class GetChosenTopicGallery @Inject constructor( + private val chosenTopicRepository: ChosenTopicRepository +) : SingleUseCaseWithParameter> { + + override fun execute(parameter: Params): Single> = + chosenTopicRepository + .getChosenTopic(parameter.forumId, parameter.topicId, parameter.startPage) + + class Params(val forumId: Int, val topicId: Int, val startPage: Int) +} From 3e9f5ff0de667dbb27fbebd6cd19e96a150cc081 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 20:40:45 +0300 Subject: [PATCH 12/29] Black background for gallery activity --- app/src/main/AndroidManifest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 338093d1..d950ac9e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -115,7 +115,8 @@ + android:parentActivityName=".presentation.features.navigation.MainActivity" + android:theme="@style/AppTheme.DarkBackground"> From c1fcf2afcff1b7bf7d0e989829fa2328320bcc31 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 20:41:05 +0300 Subject: [PATCH 13/29] More gallery behavior tweaks --- .../features/gallery/TopicGalleryActivity.kt | 15 +++++++++++++-- .../gallery/adapter/TopicGalleryAdapter.kt | 17 +++++++++++------ .../features/topic/ChosenTopicPresenter.kt | 1 + .../res/layout/activity_topic_gallery_item.xml | 5 +++++ .../activity_topic_gallery_item_load_more.xml | 6 +++--- app/src/main/res/values-ru/strings.xml | 3 ++- app/src/main/res/values/colors.xml | 2 +- app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 3 ++- 9 files changed, 39 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt index e3513ea2..48ad7e77 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt @@ -10,11 +10,15 @@ import com.arellomobile.mvp.presenter.ProvidePresenter import com.sedsoftware.yaptalker.R import com.sedsoftware.yaptalker.commons.annotation.LayoutResource import com.sedsoftware.yaptalker.presentation.base.BaseActivity +import com.sedsoftware.yaptalker.presentation.extensions.stringRes import com.sedsoftware.yaptalker.presentation.extensions.toastError import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryAdapter import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener import com.sedsoftware.yaptalker.presentation.model.YapEntity +import com.sedsoftware.yaptalker.presentation.model.base.SinglePostGalleryImageModel import kotlinx.android.synthetic.main.activity_topic_gallery.* +import kotlinx.android.synthetic.main.include_main_appbar.* +import java.util.Locale import javax.inject.Inject @LayoutResource(R.layout.activity_topic_gallery) @@ -34,6 +38,10 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM private const val CURRENT_PAGE_KEY = "CURRENT_PAGE_KEY" } + private val titleTemplate: String by lazy { + stringRes(R.string.navigation_gallery_page) + } + @Inject lateinit var galleryAdapter: TopicGalleryAdapter @@ -59,6 +67,9 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + setSupportActionBar(toolbar) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + with(topic_gallery) { val linearLayout = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) layoutManager = linearLayout @@ -77,11 +88,11 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM } override fun appendImages(images: List) { - galleryAdapter.addList(images) + galleryAdapter.addList(images.map { it as SinglePostGalleryImageModel }) } override fun updateCurrentUiState(title: String) { - supportActionBar?.title = title + supportActionBar?.title = String.format(Locale.getDefault(), titleTemplate, title) } override fun onLoadMoreClicked() { diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt index 5b85b560..19af53b9 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt @@ -8,7 +8,6 @@ import com.sedsoftware.yaptalker.presentation.extensions.hideView import com.sedsoftware.yaptalker.presentation.extensions.inflate import com.sedsoftware.yaptalker.presentation.extensions.loadFromUrl import com.sedsoftware.yaptalker.presentation.extensions.showView -import com.sedsoftware.yaptalker.presentation.model.YapEntity import com.sedsoftware.yaptalker.presentation.model.base.SinglePostGalleryImageModel import kotlinx.android.synthetic.main.activity_topic_gallery_item.view.* import kotlinx.android.synthetic.main.activity_topic_gallery_item_load_more.view.* @@ -19,7 +18,7 @@ class TopicGalleryAdapter @Inject constructor( private val loadMoreCallback: TopicGalleryLoadMoreClickListener ) : RecyclerView.Adapter() { - private var items: ArrayList = ArrayList() + private var items: MutableList = ArrayList() init { setHasStableIds(true) @@ -29,17 +28,23 @@ class TopicGalleryAdapter @Inject constructor( override fun onBindViewHolder(holder: ViewHolder, position: Int) { holder as ImageViewHolder - holder.bind(items[position] as SinglePostGalleryImageModel) + holder.bind(items[position]) } override fun getItemId(position: Int) = position.toLong() override fun getItemCount(): Int = items.size - fun addList(images: List) { - val insertPosition = items.size + fun addList(images: List) { + clearLoadingIndicators() items.addAll(images) - notifyItemRangeInserted(insertPosition, items.size) + notifyDataSetChanged() + } + + private fun clearLoadingIndicators() { + items = items + .map { item -> SinglePostGalleryImageModel(url = item.url, showLoadMore = false) } + .toMutableList() } inner class ImageViewHolder(parent: ViewGroup) : diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt index a9ded422..8cab7eb4 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/ChosenTopicPresenter.kt @@ -195,6 +195,7 @@ class ChosenTopicPresenter @Inject constructor( fun openTopicGallery() { router.navigateTo(NavigationScreen.TOPIC_GALLERY, Triple(currentForumId, currentTopicId, currentPage)) + viewState.hideLoadingIndicator() } fun showPostKarmaMenuIfAvailable(postId: Int) { diff --git a/app/src/main/res/layout/activity_topic_gallery_item.xml b/app/src/main/res/layout/activity_topic_gallery_item.xml index c5764d3a..e48bd12b 100644 --- a/app/src/main/res/layout/activity_topic_gallery_item.xml +++ b/app/src/main/res/layout/activity_topic_gallery_item.xml @@ -4,6 +4,11 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + android:layout_width="@dimen/load_more_progress_indicator_size" + android:layout_height="@dimen/load_more_progress_indicator_size" + android:visibility="invisible" /> \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ed8b0975..ec584031 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -31,7 +31,8 @@ Перейти на страницу Введите номер страницы… Страница %d недоступна - Загрузить\nеще… + Далее + Страница: %s Логин Пароль diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 11af4cd2..f08b4018 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -50,5 +50,5 @@ @color/material_color_green_500 @color/material_color_teal_500 - #64ffffff + #7dffffff diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 9117859d..83e0866a 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -18,6 +18,7 @@ 54dp 8dp 8dp + 24dp 4dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d691738e..64cf0568 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,7 +40,8 @@ > << >> - Load\nmore… + Next + Page: %s Login From 21ea8275a1f7e61d0fdbc4739ee871ef54e8e708 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 21:45:32 +0300 Subject: [PATCH 14/29] Add simple gallery page indicator --- .../features/gallery/TopicGalleryActivity.kt | 2 + .../adapter/LinePagerIndicatorDecoration.kt | 152 ++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/LinePagerIndicatorDecoration.kt diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt index 48ad7e77..e3eafd2d 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt @@ -12,6 +12,7 @@ import com.sedsoftware.yaptalker.commons.annotation.LayoutResource import com.sedsoftware.yaptalker.presentation.base.BaseActivity import com.sedsoftware.yaptalker.presentation.extensions.stringRes import com.sedsoftware.yaptalker.presentation.extensions.toastError +import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.LinePagerIndicatorDecoration import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryAdapter import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener import com.sedsoftware.yaptalker.presentation.model.YapEntity @@ -75,6 +76,7 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM layoutManager = linearLayout adapter = galleryAdapter setHasFixedSize(true) + addItemDecoration(LinePagerIndicatorDecoration()) } val snapHelper = PagerSnapHelper() diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/LinePagerIndicatorDecoration.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/LinePagerIndicatorDecoration.kt new file mode 100644 index 00000000..a8caf2f3 --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/LinePagerIndicatorDecoration.kt @@ -0,0 +1,152 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 David Medenjak + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.sedsoftware.yaptalker.presentation.features.gallery.adapter + +import android.content.res.Resources +import android.graphics.Canvas +import android.graphics.Paint +import android.graphics.Rect +import android.support.v7.widget.LinearLayoutManager +import android.support.v7.widget.RecyclerView +import android.view.View +import android.view.animation.AccelerateDecelerateInterpolator + +@Suppress("MagicNumber") +class LinePagerIndicatorDecoration : RecyclerView.ItemDecoration() { + + companion object { + private val DP = Resources.getSystem().displayMetrics.density + } + + private val colorActive = -0x1 + private val colorInactive = 0x66FFFFFF + private val indicatorHeight = (DP * 16).toInt() + private val indicatorStrokeWidth = DP * 2 + private val indicatorItemLength = DP * 16 + private val indicatorItemPadding = DP * 4 + private val interpolator = AccelerateDecelerateInterpolator() + + private val mPaint = Paint() + + init { + mPaint.strokeCap = Paint.Cap.ROUND + mPaint.strokeWidth = indicatorStrokeWidth + mPaint.style = Paint.Style.STROKE + mPaint.isAntiAlias = true + } + + override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State?) { + super.onDrawOver(c, parent, state) + + val itemCount = parent.adapter.itemCount + + // center horizontally, calculate width and subtract half from center + val totalLength = indicatorItemLength * itemCount + val paddingBetweenItems = Math.max(0, itemCount - 1) * indicatorItemPadding + val indicatorTotalWidth = totalLength + paddingBetweenItems + val indicatorStartX = (parent.width - indicatorTotalWidth) / 2f + + // center vertically in the allotted space + val indicatorPosY = parent.height - indicatorHeight / 2f + + drawInactiveIndicators(c, indicatorStartX, indicatorPosY, itemCount) + + + // find active page (which should be highlighted) + val layoutManager = parent.layoutManager as LinearLayoutManager + val activePosition = layoutManager.findFirstVisibleItemPosition() + if (activePosition == RecyclerView.NO_POSITION) { + return + } + + // find offset of active page (if the user is scrolling) + val activeChild = layoutManager.findViewByPosition(activePosition) + val left = activeChild.left + val width = activeChild.width + + // on swipe the active item will be positioned from [-width, 0] + // interpolate offset for smooth animation + val progress = interpolator.getInterpolation(left * -1 / width.toFloat()) + + drawHighlights(c, indicatorStartX, indicatorPosY, activePosition, progress, itemCount) + } + + private fun drawInactiveIndicators(c: Canvas, indicatorStartX: Float, indicatorPosY: Float, itemCount: Int) { + mPaint.color = colorInactive + + // width of item indicator including padding + val itemWidth = indicatorItemLength + indicatorItemPadding + + var start = indicatorStartX + for (i in 0 until itemCount) { + // draw the line for every item + c.drawLine(start, indicatorPosY, start + indicatorItemLength, indicatorPosY, mPaint) + start += itemWidth + } + } + + private fun drawHighlights( + c: Canvas, indicatorStartX: Float, indicatorPosY: Float, + highlightPosition: Int, progress: Float, itemCount: Int + ) { + mPaint.color = colorActive + + // width of item indicator including padding + val itemWidth = indicatorItemLength + indicatorItemPadding + + if (progress == 0f) { + // no swipe, draw a normal indicator + val highlightStart = indicatorStartX + itemWidth * highlightPosition + c.drawLine( + highlightStart, indicatorPosY, + highlightStart + indicatorItemLength, indicatorPosY, mPaint + ) + } else { + var highlightStart = indicatorStartX + itemWidth * highlightPosition + // calculate partial highlight + val partialLength = indicatorItemLength * progress + + // draw the cut off highlight + c.drawLine( + highlightStart + partialLength, indicatorPosY, + highlightStart + indicatorItemLength, indicatorPosY, mPaint + ) + + // draw the highlight overlapping to the next item as well + if (highlightPosition < itemCount - 1) { + highlightStart += itemWidth + c.drawLine( + highlightStart, indicatorPosY, + highlightStart + partialLength, indicatorPosY, mPaint + ) + } + } + } + + override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State?) { + super.getItemOffsets(outRect, view, parent, state) + outRect.bottom = indicatorHeight + } +} From d2a21165bec6d1094ec1530fc31892fb2f340e4d Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sat, 3 Mar 2018 22:27:10 +0300 Subject: [PATCH 15/29] Share/save image for gallery --- .../extensions/RecyclerViewExt.kt | 9 +++ .../features/gallery/TopicGalleryActivity.kt | 62 +++++++++++++++++++ .../features/gallery/TopicGalleryPresenter.kt | 32 +++++++++- .../features/gallery/TopicGalleryView.kt | 6 ++ .../gallery/adapter/TopicGalleryAdapter.kt | 2 +- .../gallery/di/TopicGalleryActivityModule.kt | 12 ++++ 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/extensions/RecyclerViewExt.kt diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/extensions/RecyclerViewExt.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/extensions/RecyclerViewExt.kt new file mode 100644 index 00000000..46e356d5 --- /dev/null +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/extensions/RecyclerViewExt.kt @@ -0,0 +1,9 @@ +package com.sedsoftware.yaptalker.presentation.extensions + +import android.support.v7.widget.LinearLayoutManager +import android.support.v7.widget.RecyclerView + +fun RecyclerView.visibleItemPosition(): Int { + val layoutManager = this.layoutManager as? LinearLayoutManager + return layoutManager?.findFirstVisibleItemPosition() ?: -1 +} diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt index e3eafd2d..df85c0c3 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt @@ -1,10 +1,16 @@ package com.sedsoftware.yaptalker.presentation.features.gallery +import android.Manifest import android.content.Context import android.content.Intent +import android.content.pm.PackageManager import android.os.Bundle +import android.support.v4.app.ActivityCompat +import android.support.v4.content.ContextCompat import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.PagerSnapHelper +import android.view.Menu +import android.view.MenuItem import com.arellomobile.mvp.presenter.InjectPresenter import com.arellomobile.mvp.presenter.ProvidePresenter import com.sedsoftware.yaptalker.R @@ -12,6 +18,8 @@ import com.sedsoftware.yaptalker.commons.annotation.LayoutResource import com.sedsoftware.yaptalker.presentation.base.BaseActivity import com.sedsoftware.yaptalker.presentation.extensions.stringRes import com.sedsoftware.yaptalker.presentation.extensions.toastError +import com.sedsoftware.yaptalker.presentation.extensions.toastSuccess +import com.sedsoftware.yaptalker.presentation.extensions.visibleItemPosition import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.LinePagerIndicatorDecoration import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryAdapter import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener @@ -37,6 +45,7 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM private const val FORUM_ID_KEY = "FORUM_ID_KEY" private const val TOPIC_ID_KEY = "TOPIC_ID_KEY" private const val CURRENT_PAGE_KEY = "CURRENT_PAGE_KEY" + private const val STORAGE_WRITE_PERMISSION = 0 } private val titleTemplate: String by lazy { @@ -85,6 +94,33 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM presenter.loadTopicGallery(forumId, topicId, currentPage) } + override fun onCreateOptionsMenu(menu: Menu?): Boolean { + menuInflater.inflate(R.menu.menu_image_display, menu) + return true + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + val itemPosition = topic_gallery.visibleItemPosition() + + if (itemPosition == -1) { + return false + } + + val imageUrl = galleryAdapter.items[itemPosition] + + return when (item.itemId) { + R.id.action_share -> { + presenter.shareImage(imageUrl.url) + true + } + R.id.action_save -> { + checkPermissionAndSaveImage(imageUrl.url) + true + } + else -> super.onOptionsItemSelected(item) + } + } + override fun showErrorMessage(message: String) { toastError(message) } @@ -97,7 +133,33 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM supportActionBar?.title = String.format(Locale.getDefault(), titleTemplate, title) } + override fun fileSavedMessage(filepath: String) { + String.format(Locale.getDefault(), stringRes(R.string.msg_file_saved), filepath).apply { + toastSuccess(this) + } + } + + override fun fileNotSavedMessage() { + toastError(stringRes(R.string.msg_file_not_saved)) + } + override fun onLoadMoreClicked() { presenter.loadMoreImages() } + + private fun checkPermissionAndSaveImage(imageUrl: String) { + if (ContextCompat.checkSelfPermission( + this, + Manifest.permission.WRITE_EXTERNAL_STORAGE + ) != PackageManager.PERMISSION_GRANTED) { + + ActivityCompat.requestPermissions( + this, + arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), + STORAGE_WRITE_PERMISSION + ) + } else { + presenter.saveImage(imageUrl) + } + } } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt index 7fee4df0..d5cdbc96 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt @@ -2,10 +2,13 @@ package com.sedsoftware.yaptalker.presentation.features.gallery import com.arellomobile.mvp.InjectViewState import com.sedsoftware.yaptalker.domain.device.Settings +import com.sedsoftware.yaptalker.domain.interactor.imagedisplay.SaveImage +import com.sedsoftware.yaptalker.domain.interactor.imagedisplay.ShareImage import com.sedsoftware.yaptalker.domain.interactor.topic.GetChosenTopicGallery import com.sedsoftware.yaptalker.presentation.base.BasePresenter import com.sedsoftware.yaptalker.presentation.base.enums.ConnectionState import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.PresenterLifecycle +import com.sedsoftware.yaptalker.presentation.extensions.validateUrl import com.sedsoftware.yaptalker.presentation.mappers.TopicGalleryModelMapper import com.sedsoftware.yaptalker.presentation.model.YapEntity import com.sedsoftware.yaptalker.presentation.model.base.NavigationPanelModel @@ -14,13 +17,16 @@ import com.uber.autodispose.kotlin.autoDisposable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.observers.DisposableSingleObserver import io.reactivex.schedulers.Schedulers +import timber.log.Timber import javax.inject.Inject @InjectViewState class TopicGalleryPresenter @Inject constructor( settings: Settings, private val getTopicGalleryUseCase: GetChosenTopicGallery, - private val galleryMapper: TopicGalleryModelMapper + private val galleryMapper: TopicGalleryModelMapper, + private val saveImageUseCase: SaveImage, + private val shareImageUseCase: ShareImage ) : BasePresenter() { companion object { @@ -90,4 +96,28 @@ class TopicGalleryPresenter @Inject constructor( error.message?.let { viewState.showErrorMessage(it) } } } + + fun saveImage(url: String) { + saveImageUseCase + .execute(SaveImage.Params(url.validateUrl())) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .autoDisposable(event(PresenterLifecycle.DESTROY)) + .subscribe({ fileName -> + viewState.fileSavedMessage(fileName) + }, { _ -> + viewState.fileNotSavedMessage() + }) + } + + fun shareImage(url: String) { + shareImageUseCase + .execute(ShareImage.Params(url.validateUrl())) + .autoDisposable(event(PresenterLifecycle.DETACH_VIEW)) + .subscribe({ + Timber.d("Image sharing request launched.") + }, { e -> + e.message?.let { viewState.showErrorMessage(it) } + }) + } } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt index b3163fe3..6249a3d6 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt @@ -2,10 +2,12 @@ package com.sedsoftware.yaptalker.presentation.features.gallery import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy import com.arellomobile.mvp.viewstate.strategy.AddToEndStrategy +import com.arellomobile.mvp.viewstate.strategy.SkipStrategy import com.arellomobile.mvp.viewstate.strategy.StateStrategyType import com.sedsoftware.yaptalker.presentation.base.BaseView import com.sedsoftware.yaptalker.presentation.model.YapEntity +@StateStrategyType(SkipStrategy::class) interface TopicGalleryView : BaseView { @StateStrategyType(AddToEndStrategy::class) @@ -13,4 +15,8 @@ interface TopicGalleryView : BaseView { @StateStrategyType(AddToEndSingleStrategy::class) fun updateCurrentUiState(title: String) + + fun fileSavedMessage(filepath: String) + + fun fileNotSavedMessage() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt index 19af53b9..b01893e4 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt @@ -18,7 +18,7 @@ class TopicGalleryAdapter @Inject constructor( private val loadMoreCallback: TopicGalleryLoadMoreClickListener ) : RecyclerView.Adapter() { - private var items: MutableList = ArrayList() + var items: MutableList = ArrayList() init { setHasStableIds(true) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt index 0aebdc6b..ae634270 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/di/TopicGalleryActivityModule.kt @@ -1,7 +1,11 @@ package com.sedsoftware.yaptalker.presentation.features.gallery.di import com.sedsoftware.yaptalker.data.repository.YapChosenTopicRepository +import com.sedsoftware.yaptalker.device.sharing.YapSharingHelper +import com.sedsoftware.yaptalker.device.storage.YapImageStorage import com.sedsoftware.yaptalker.di.scopes.ActivityScope +import com.sedsoftware.yaptalker.domain.device.ImageStorage +import com.sedsoftware.yaptalker.domain.device.SharingHelper import com.sedsoftware.yaptalker.domain.repository.ChosenTopicRepository import com.sedsoftware.yaptalker.presentation.features.gallery.TopicGalleryActivity import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener @@ -18,4 +22,12 @@ abstract class TopicGalleryActivityModule { @ActivityScope @Binds abstract fun galleryClickListener(activity: TopicGalleryActivity): TopicGalleryLoadMoreClickListener + + @ActivityScope + @Binds + abstract fun imageSharingHelper(helper: YapSharingHelper): SharingHelper + + @ActivityScope + @Binds + abstract fun imageStorage(storage: YapImageStorage): ImageStorage } From d8ec8f52a199c23f3a426a6d40268248253b1791 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 10:18:30 +0300 Subject: [PATCH 16/29] Transparent toolbar for image displaying --- app/src/main/AndroidManifest.xml | 1 - .../imagedisplay/ImageDisplayActivity.kt | 3 ++- .../res/drawable/bg_toolbar_translucent.xml | 8 ++++++++ .../res/layout/activity_image_display.xml | 9 ++++----- .../include_main_appbar_transparent.xml | 19 +++++++++++++++++++ 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/bg_toolbar_translucent.xml create mode 100644 app/src/main/res/layout/include_main_appbar_transparent.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d950ac9e..6db7b5dc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -83,7 +83,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_image_display.xml b/app/src/main/res/layout/activity_image_display.xml index 496ee387..2829d9d3 100644 --- a/app/src/main/res/layout/activity_image_display.xml +++ b/app/src/main/res/layout/activity_image_display.xml @@ -1,16 +1,15 @@ - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/layout/include_main_appbar_transparent.xml b/app/src/main/res/layout/include_main_appbar_transparent.xml new file mode 100644 index 00000000..0532c2ad --- /dev/null +++ b/app/src/main/res/layout/include_main_appbar_transparent.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file From 91d1b8649da4a9833818cdf2eb46013aed7b852a Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 10:51:46 +0300 Subject: [PATCH 17/29] Scroll to new image when loaded --- app/src/main/AndroidManifest.xml | 1 - .../features/gallery/TopicGalleryActivity.kt | 8 +- .../features/gallery/TopicGalleryPresenter.kt | 8 +- .../features/gallery/TopicGalleryView.kt | 2 + .../adapter/LinePagerIndicatorDecoration.kt | 152 ------------------ .../res/layout/activity_topic_gallery.xml | 9 +- 6 files changed, 18 insertions(+), 162 deletions(-) delete mode 100644 app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/LinePagerIndicatorDecoration.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6db7b5dc..2641da1b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -113,7 +113,6 @@ - - - - \ No newline at end of file + + + \ No newline at end of file From 0067bc6a47cd41469d70f155d5f03e0065552ad6 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 11:29:38 +0300 Subject: [PATCH 18/29] Gallery next button behavior tweak --- .../features/gallery/TopicGalleryActivity.kt | 4 +++ .../features/gallery/TopicGalleryPresenter.kt | 9 ++++-- .../features/gallery/TopicGalleryView.kt | 2 ++ .../gallery/adapter/TopicGalleryAdapter.kt | 29 +++++++++++++++---- .../mappers/TopicGalleryModelMapper.kt | 6 ++-- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt index 9e7655ac..f55644b3 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt @@ -135,6 +135,10 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM topic_gallery.smoothScrollToPosition( galleryAdapter.itemCount - newImagesOffset) } + override fun lastPageReached() { + galleryAdapter.isLastPageVisible = true + } + override fun fileSavedMessage(filepath: String) { String.format(Locale.getDefault(), stringRes(R.string.msg_file_saved), filepath).apply { toastSuccess(this) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt index 613dc2b5..600be9db 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt @@ -88,14 +88,17 @@ class TopicGalleryPresenter @Inject constructor( } } + if (currentPage == totalPages) { + viewState.lastPageReached() + } + val images = items.filter { it is SinglePostGalleryImageModel } + viewState.appendImages(images) + viewState.updateCurrentUiState(currentTitleLabel) if (images.isNotEmpty()) { - viewState.appendImages(images) viewState.scrollToFirstNewImage(images.size) } - - viewState.updateCurrentUiState(currentTitleLabel) } override fun onError(error: Throwable) { diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt index 49658c9e..2a3098a1 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryView.kt @@ -18,6 +18,8 @@ interface TopicGalleryView : BaseView { fun scrollToFirstNewImage(newImagesOffset: Int) + fun lastPageReached() + fun fileSavedMessage(filepath: String) fun fileNotSavedMessage() diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt index b01893e4..2bb4c9e9 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/adapter/TopicGalleryAdapter.kt @@ -4,7 +4,7 @@ import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView.ViewHolder import android.view.ViewGroup import com.sedsoftware.yaptalker.R -import com.sedsoftware.yaptalker.presentation.extensions.hideView +import com.sedsoftware.yaptalker.presentation.extensions.hideViewAsInvisible import com.sedsoftware.yaptalker.presentation.extensions.inflate import com.sedsoftware.yaptalker.presentation.extensions.loadFromUrl import com.sedsoftware.yaptalker.presentation.extensions.showView @@ -19,6 +19,7 @@ class TopicGalleryAdapter @Inject constructor( ) : RecyclerView.Adapter() { var items: MutableList = ArrayList() + var isLastPageVisible = false init { setHasStableIds(true) @@ -36,8 +37,14 @@ class TopicGalleryAdapter @Inject constructor( override fun getItemCount(): Int = items.size fun addList(images: List) { - clearLoadingIndicators() - items.addAll(images) + + if (images.isNotEmpty()) { + clearLoadingIndicators() + items.addAll(images) + } else { + showLastLoadingIndicator() + } + notifyDataSetChanged() } @@ -47,19 +54,29 @@ class TopicGalleryAdapter @Inject constructor( .toMutableList() } + private fun showLastLoadingIndicator() { + clearLoadingIndicators() + val newLast = SinglePostGalleryImageModel(url = items.last().url, showLoadMore = true) + items.removeAt(items.lastIndex) + items.add(newLast) + } + inner class ImageViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(parent.inflate(R.layout.activity_topic_gallery_item)) { fun bind(image: SinglePostGalleryImageModel) { - itemView.load_more_button.hideView() + itemView.load_more_button.hideViewAsInvisible() + itemView.load_more_label.hideViewAsInvisible() + itemView.load_more_progress.hideViewAsInvisible() itemView.gallery_image.loadFromUrl(image.url) - if (image.showLoadMore) { + if (image.showLoadMore && !isLastPageVisible) { itemView.load_more_button.showView() + itemView.load_more_label.showView() itemView.load_more_button.setOnClickListener { loadMoreCallback.onLoadMoreClicked() - itemView.load_more_label.hideView() + itemView.load_more_label.hideViewAsInvisible() itemView.load_more_progress.showView() } } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt index a3390ecf..7c0437c5 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt @@ -26,7 +26,7 @@ class TopicGalleryModelMapper @Inject constructor( val result: MutableList = ArrayList() val imagesList: MutableList = ArrayList() var currentPage = 0 - var totalPage = 0 + var totalPages = 0 items.forEach { item -> when (item) { @@ -46,7 +46,7 @@ class TopicGalleryModelMapper @Inject constructor( is NavigationPanel -> { currentPage = item.currentPage - totalPage = item.totalPages + totalPages = item.totalPages result.add( NavigationPanelModel( currentPage = item.currentPage, @@ -64,7 +64,7 @@ class TopicGalleryModelMapper @Inject constructor( result.add( SinglePostGalleryImageModel( url = imageUrl, - showLoadMore = index == imagesList.lastIndex && currentPage != totalPage + showLoadMore = index == imagesList.lastIndex ) ) } From 79f3fc27ce292aac7968dadb8bd049e1bc4a2adc Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 17:22:26 +0300 Subject: [PATCH 19/29] Another annotation tweaks --- .../presentation/base/BaseActivity.kt | 4 +-- .../presentation/base/BaseFragment.kt | 4 +-- .../presentation/base/BasePresenter.kt | 8 ++--- .../base/enums/ConnectionState.kt | 12 ++++---- .../base/enums/lifecycle/ActivityLifecycle.kt | 16 +++++----- .../base/enums/lifecycle/FragmentLifecycle.kt | 20 ++++++------- .../enums/lifecycle/PresenterLifecycle.kt | 12 ++++---- .../enums/navigation/NavigationSection.kt | 22 +++++++------- .../presentation/base/events/AppEvent.kt | 4 +-- .../features/navigation/MainActivity.kt | 30 +++++++++---------- .../features/navigation/MainActivityView.kt | 2 +- .../navigation/NavigationPresenter.kt | 2 +- .../features/posting/AddMessagePresenter.kt | 6 ++-- .../features/posting/tags/MessageTagCodes.kt | 14 ++++----- .../features/search/SearchRequest.kt | 2 +- .../features/search/options/TargetPeriod.kt | 20 ++++++------- 16 files changed, 89 insertions(+), 89 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt index 20abed7b..a1e9b504 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseActivity.kt @@ -32,7 +32,7 @@ abstract class BaseActivity : MvpAppCompatActivity(), HasSupportFragmentInjector protected lateinit var backPressFragment: BaseFragment - private val lifecycle: BehaviorRelay = BehaviorRelay.create() + private val lifecycle: BehaviorRelay = BehaviorRelay.create() override fun onCreate(savedInstanceState: Bundle?) { AndroidInjection.inject(this) @@ -92,7 +92,7 @@ abstract class BaseActivity : MvpAppCompatActivity(), HasSupportFragmentInjector backPressFragment = fragment } - protected fun event(@ActivityLifecycle.Event event: Int): Maybe<*> = + protected fun event(@ActivityLifecycle.Event event: Long): Maybe<*> = lifecycle.filter({ e -> e == event }).firstElement() private fun applyTheme() { diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt index 07df948d..05454645 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseFragment.kt @@ -15,7 +15,7 @@ import io.reactivex.Maybe abstract class BaseFragment : MvpAppCompatFragment() { - private val lifecycle: BehaviorRelay = BehaviorRelay.create() + private val lifecycle: BehaviorRelay = BehaviorRelay.create() private lateinit var backPressHandler: BackPressHandler open fun onBackPressed(): Boolean = false @@ -80,6 +80,6 @@ abstract class BaseFragment : MvpAppCompatFragment() { lifecycle.accept(FragmentLifecycle.DETACH) } - protected fun event(@FragmentLifecycle.Event event: Int): Maybe<*> = + protected fun event(@FragmentLifecycle.Event event: Long): Maybe<*> = lifecycle.filter({ e -> e == event }).firstElement() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt index 45bc7acb..dd3566bb 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BasePresenter.kt @@ -21,7 +21,7 @@ abstract class BasePresenter : MvpPresenter() { @Inject lateinit var eventBus: BehaviorRelay - private val lifecycle: BehaviorRelay = BehaviorRelay.create() + private val lifecycle: BehaviorRelay = BehaviorRelay.create() init { lifecycle.accept(PresenterLifecycle.CREATE) @@ -67,7 +67,7 @@ abstract class BasePresenter : MvpPresenter() { .subscribe(eventBus) } - fun setConnectionState(@ConnectionState.Event state: Int) { + fun setConnectionState(@ConnectionState.Event state: Long) { Observable .just(ConnectionEvent(state)) .observeOn(AndroidSchedulers.mainThread()) @@ -75,7 +75,7 @@ abstract class BasePresenter : MvpPresenter() { .subscribe(eventBus) } - fun setNavDrawerItem(@NavigationSection.Section section: Int) { + fun setNavDrawerItem(@NavigationSection.Section section: Long) { Observable .just(NavDrawerEvent(section)) .observeOn(AndroidSchedulers.mainThread()) @@ -83,6 +83,6 @@ abstract class BasePresenter : MvpPresenter() { .subscribe(eventBus) } - protected fun event(@PresenterLifecycle.Event event: Int): Maybe<*> = + protected fun event(@PresenterLifecycle.Event event: Long): Maybe<*> = lifecycle.filter({ e -> e == event }).firstElement() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt index 9dbdbf16..eca81b9c 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt @@ -1,17 +1,17 @@ package com.sedsoftware.yaptalker.presentation.base.enums -import android.support.annotation.IntDef +import android.support.annotation.LongDef class ConnectionState { companion object { - const val IDLE = 0 - const val LOADING = 1 - const val COMPLETED = 2 - const val ERROR = 3 + const val IDLE = 0L + const val LOADING = 1L + const val COMPLETED = 2L + const val ERROR = 3L } @Retention(AnnotationRetention.SOURCE) - @IntDef(IDLE, LOADING, COMPLETED, ERROR) + @LongDef(IDLE, LOADING, COMPLETED, ERROR) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt index d8d534cb..9097f5da 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt @@ -1,19 +1,19 @@ package com.sedsoftware.yaptalker.presentation.base.enums.lifecycle -import android.support.annotation.IntDef +import android.support.annotation.LongDef class ActivityLifecycle { companion object { - const val CREATE = 0 - const val START = 1 - const val RESUME = 2 - const val PAUSE = 3 - const val STOP = 4 - const val DESTROY = 5 + const val CREATE = 0L + const val START = 1L + const val RESUME = 2L + const val PAUSE = 3L + const val STOP = 4L + const val DESTROY = 5L } @Retention(AnnotationRetention.SOURCE) - @IntDef(CREATE, START, RESUME, PAUSE, STOP, DESTROY) + @LongDef(CREATE, START, RESUME, PAUSE, STOP, DESTROY) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt index 8beb8fcd..cbde885d 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt @@ -1,21 +1,21 @@ package com.sedsoftware.yaptalker.presentation.base.enums.lifecycle -import android.support.annotation.IntDef +import android.support.annotation.LongDef class FragmentLifecycle { companion object { - const val ATTACH = 0 - const val CREATE = 1 - const val START = 2 - const val RESUME = 3 - const val PAUSE = 4 - const val STOP = 5 - const val DESTROY = 6 - const val DETACH = 7 + const val ATTACH = 0L + const val CREATE = 1L + const val START = 2L + const val RESUME = 3L + const val PAUSE = 4L + const val STOP = 5L + const val DESTROY = 6L + const val DETACH = 7L } @Retention(AnnotationRetention.SOURCE) - @IntDef(ATTACH, CREATE, START, RESUME, PAUSE, STOP, DESTROY, DETACH) + @LongDef(ATTACH, CREATE, START, RESUME, PAUSE, STOP, DESTROY, DETACH) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt index 2088c425..195b7a2f 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt @@ -1,17 +1,17 @@ package com.sedsoftware.yaptalker.presentation.base.enums.lifecycle -import android.support.annotation.IntDef +import android.support.annotation.LongDef class PresenterLifecycle { companion object { - const val CREATE = 0 - const val ATTACH_VIEW = 1 - const val DETACH_VIEW = 2 - const val DESTROY = 3 + const val CREATE = 0L + const val ATTACH_VIEW = 1L + const val DETACH_VIEW = 2L + const val DESTROY = 3L } @Retention(AnnotationRetention.SOURCE) - @IntDef(CREATE, DESTROY) + @LongDef(CREATE, ATTACH_VIEW, DETACH_VIEW, DESTROY) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt index a0ad5c92..b668dbaf 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt @@ -1,21 +1,21 @@ package com.sedsoftware.yaptalker.presentation.base.enums.navigation -import android.support.annotation.IntDef +import android.support.annotation.LongDef class NavigationSection { companion object { - const val MAIN_PAGE = 0 - const val FORUMS = 1 - const val ACTIVE_TOPICS = 2 - const val INCUBATOR = 3 - const val BOOKMARKS = 4 - const val SITE_SEARCH = 5 - const val SETTINGS = 6 - const val SIGN_IN = 7 - const val SIGN_OUT = 8 + const val MAIN_PAGE = 0L + const val FORUMS = 1L + const val ACTIVE_TOPICS = 2L + const val INCUBATOR = 3L + const val BOOKMARKS = 4L + const val SITE_SEARCH = 5L + const val SETTINGS = 6L + const val SIGN_IN = 7L + const val SIGN_OUT = 8L } @Retention(AnnotationRetention.SOURCE) - @IntDef(MAIN_PAGE, FORUMS, ACTIVE_TOPICS, INCUBATOR, BOOKMARKS, SITE_SEARCH, SETTINGS, SIGN_IN, SIGN_OUT) + @LongDef(MAIN_PAGE, FORUMS, ACTIVE_TOPICS, INCUBATOR, BOOKMARKS, SITE_SEARCH, SETTINGS, SIGN_IN, SIGN_OUT) annotation class Section } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt index bda04422..d242eac6 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/events/AppEvent.kt @@ -4,7 +4,7 @@ sealed class AppEvent { class AppbarEvent(val title: String) : AppEvent() - class ConnectionEvent(val state: Int) : AppEvent() + class ConnectionEvent(val state: Long) : AppEvent() - class NavDrawerEvent(val itemId: Int) : AppEvent() + class NavDrawerEvent(val itemId: Long) : AppEvent() } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt index eee74df7..091005b1 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivity.kt @@ -127,8 +127,8 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { supportActionBar?.title = title } - override fun selectNavDrawerItem(item: Int) { - navDrawer.setSelection(item.toLong(), false) + override fun selectNavDrawerItem(item: Long) { + navDrawer.setSelection(item, false) } override fun updateNavDrawerProfile(userInfo: LoginSessionInfoModel) { @@ -150,9 +150,9 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { } override fun clearDynamicNavigationItems() { - navDrawer.removeItem(NavigationSection.SIGN_IN.toLong()) - navDrawer.removeItem(NavigationSection.SIGN_OUT.toLong()) - navDrawer.removeItem(NavigationSection.BOOKMARKS.toLong()) + navDrawer.removeItem(NavigationSection.SIGN_IN) + navDrawer.removeItem(NavigationSection.SIGN_OUT) + navDrawer.removeItem(NavigationSection.BOOKMARKS) } override fun displaySignedInNavigation() { @@ -176,7 +176,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { private fun initializeNavigationDrawer(savedInstanceState: Bundle?) { drawerItemMainPage = PrimaryDrawerItem() - .withIdentifier(NavigationSection.MAIN_PAGE.toLong()) + .withIdentifier(NavigationSection.MAIN_PAGE) .withName(R.string.nav_drawer_main_page) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_home) @@ -186,7 +186,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavMainPage) drawerItemForums = PrimaryDrawerItem() - .withIdentifier(NavigationSection.FORUMS.toLong()) + .withIdentifier(NavigationSection.FORUMS) .withName(R.string.nav_drawer_forums) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_forum) @@ -196,7 +196,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavForums) drawerItemActiveTopics = PrimaryDrawerItem() - .withIdentifier(NavigationSection.ACTIVE_TOPICS.toLong()) + .withIdentifier(NavigationSection.ACTIVE_TOPICS) .withName(R.string.nav_drawer_active_topics) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_bulletin_board) @@ -206,7 +206,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavActiveTopics) drawerItemIncubator = PrimaryDrawerItem() - .withIdentifier(NavigationSection.INCUBATOR.toLong()) + .withIdentifier(NavigationSection.INCUBATOR) .withName(R.string.nav_drawer_incubator) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_human_child) @@ -216,7 +216,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavIncubator) drawerItemBookmarks = PrimaryDrawerItem() - .withIdentifier(NavigationSection.BOOKMARKS.toLong()) + .withIdentifier(NavigationSection.BOOKMARKS) .withName(R.string.nav_drawer_bookmarks) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_bookmark_outline) @@ -226,7 +226,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavBookmarks) drawerItemSearch = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SITE_SEARCH.toLong()) + .withIdentifier(NavigationSection.SITE_SEARCH) .withName(R.string.nav_drawer_search) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_magnify) @@ -236,7 +236,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavSearch) drawerItemSettings = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SETTINGS.toLong()) + .withIdentifier(NavigationSection.SETTINGS) .withIcon(CommunityMaterial.Icon.cmd_settings) .withName(R.string.nav_drawer_settings) // .withSelectable(false) @@ -246,7 +246,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavSettings) drawerItemSignIn = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SIGN_IN.toLong()) + .withIdentifier(NavigationSection.SIGN_IN) .withName(R.string.nav_drawer_sign_in) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_login) @@ -256,7 +256,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .withSelectedIconColorRes(R.color.colorNavSignIn) drawerItemSignOut = PrimaryDrawerItem() - .withIdentifier(NavigationSection.SIGN_OUT.toLong()) + .withIdentifier(NavigationSection.SIGN_OUT) .withName(R.string.nav_drawer_sign_out) // .withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_logout) @@ -295,7 +295,7 @@ class MainActivity : BaseActivity(), MainActivityView, NavigationView { .addDrawerItems(drawerItemSettings) .withOnDrawerItemClickListener { _, _, drawerItem -> if (drawerItem is Nameable<*>) { - navigationPresenter.navigateToChosenSection(drawerItem.identifier.toInt()) + navigationPresenter.navigateToChosenSection(drawerItem.identifier) } false } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt index 9003e164..427e56a3 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/MainActivityView.kt @@ -9,5 +9,5 @@ interface MainActivityView : BaseView { fun setAppbarTitle(title: String) - fun selectNavDrawerItem(item: Int) + fun selectNavDrawerItem(item: Long) } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt index 860fb7b1..9c824712 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/navigation/NavigationPresenter.kt @@ -56,7 +56,7 @@ class NavigationPresenter @Inject constructor( router.removeResultListener(RequestCode.SIGN_IN) } - fun navigateToChosenSection(@NavigationSection.Section identifier: Int) { + fun navigateToChosenSection(@NavigationSection.Section identifier: Long) { when (identifier) { NavigationSection.MAIN_PAGE -> router.newRootScreen(NavigationScreen.NEWS_SCREEN) NavigationSection.ACTIVE_TOPICS -> router.newRootScreen(NavigationScreen.ACTIVE_TOPICS_SCREEN) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt index 43e42908..32f82693 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/AddMessagePresenter.kt @@ -48,7 +48,7 @@ class AddMessagePresenter @Inject constructor( super.detachView(view) } - fun insertChosenTag(selectionStart: Int, selectionEnd: Int, @Tag tag: Int) { + fun insertChosenTag(selectionStart: Int, selectionEnd: Int, @Tag tag: Long) { when { tag == MessageTagCodes.TAG_LINK -> onLinkTagClicked() tag == MessageTagCodes.TAG_VIDEO -> onVideoLinkTagClicked() @@ -88,7 +88,7 @@ class AddMessagePresenter @Inject constructor( viewState.showImagePickerDialog() } - private fun onTagClickedWithSelection(@Tag tag: Int) { + private fun onTagClickedWithSelection(@Tag tag: Long) { when (tag) { MessageTagCodes.TAG_B -> { viewState.insertTags(MessageTags.B_OPEN, MessageTags.B_CLOSE) @@ -102,7 +102,7 @@ class AddMessagePresenter @Inject constructor( } } - private fun onTagClickedWithNoSelection(@Tag tag: Int) { + private fun onTagClickedWithNoSelection(@Tag tag: Long) { when (tag) { MessageTagCodes.TAG_B -> { if (isBOpened) { diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt index 0ac1f3e2..0e84694c 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt @@ -1,18 +1,18 @@ package com.sedsoftware.yaptalker.presentation.features.posting.tags -import android.support.annotation.IntDef +import android.support.annotation.LongDef class MessageTagCodes { companion object { - const val TAG_B = 0 - const val TAG_I = 1 - const val TAG_U = 2 - const val TAG_LINK = 3 - const val TAG_VIDEO = 4 + const val TAG_B = 0L + const val TAG_I = 1L + const val TAG_U = 2L + const val TAG_LINK = 3L + const val TAG_VIDEO = 4L } @Retention(AnnotationRetention.SOURCE) - @IntDef( + @LongDef( TAG_B, TAG_I, TAG_U, diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt index 8da5e594..1c9d6144 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/SearchRequest.kt @@ -15,5 +15,5 @@ data class SearchRequest( val searchIn: String, @SearchConditions.Value val searchHow: String, @SortingMode.Value val sortBy: String, - @TargetPeriod.Value val periodInDays: Int + @TargetPeriod.Value val periodInDays: Long ) : Parcelable diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt index 4fc41ec3..872294be 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt @@ -1,20 +1,20 @@ package com.sedsoftware.yaptalker.presentation.features.search.options -import android.support.annotation.IntDef +import android.support.annotation.LongDef class TargetPeriod { companion object { - const val ALL_TIME = 0 - const val TODAY = 1 - const val DAYS_7 = 7 - const val DAYS_30 = 30 - const val DAYS_60 = 60 - const val DAYS_90 = 90 - const val DAYS_180 = 180 - const val DAYS_365 = 365 + const val ALL_TIME = 0L + const val TODAY = 1L + const val DAYS_7 = 7L + const val DAYS_30 = 30L + const val DAYS_60 = 60L + const val DAYS_90 = 90L + const val DAYS_180 = 180L + const val DAYS_365 = 365L } @Retention(AnnotationRetention.SOURCE) - @IntDef(ALL_TIME, TODAY, DAYS_7, DAYS_30, DAYS_60, DAYS_90, DAYS_180, DAYS_365) + @LongDef(ALL_TIME, TODAY, DAYS_7, DAYS_30, DAYS_60, DAYS_90, DAYS_180, DAYS_365) annotation class Value } From 291cbdb2d513ee2ba010931a0d820ca418a62d55 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 17:25:59 +0300 Subject: [PATCH 20/29] Code analysis tweaks --- .../presentation/features/incubator/adapter/IncubatorAdapter.kt | 2 +- .../yaptalker/presentation/features/news/adapter/NewsAdapter.kt | 2 +- build.gradle | 2 +- .../yaptalker/data/repository/YapLoginSessionRepository.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt index 48bf8820..f48ea5df 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/incubator/adapter/IncubatorAdapter.kt @@ -45,7 +45,7 @@ class IncubatorAdapter @Inject constructor( override fun onViewDetachedFromWindow(holder: ViewHolder) { super.onViewDetachedFromWindow(holder) - holder?.itemView?.clearAnimation() + holder.itemView?.clearAnimation() } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt index 3356c7ef..f2cb9f18 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/news/adapter/NewsAdapter.kt @@ -43,7 +43,7 @@ class NewsAdapter @Inject constructor( override fun onViewDetachedFromWindow(holder: ViewHolder) { super.onViewDetachedFromWindow(holder) - holder?.itemView?.clearAnimation() + holder.itemView?.clearAnimation() } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = diff --git a/build.gradle b/build.gradle index c0900912..569a6bf4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.2.21' + ext.kotlin_version = '1.2.30' ext.goole_play_services_version = '3.2.0' ext.fabric_version = '1.25.1' repositories { diff --git a/data/src/main/java/com/sedsoftware/yaptalker/data/repository/YapLoginSessionRepository.kt b/data/src/main/java/com/sedsoftware/yaptalker/data/repository/YapLoginSessionRepository.kt index 1d1544f2..6fa41f27 100644 --- a/data/src/main/java/com/sedsoftware/yaptalker/data/repository/YapLoginSessionRepository.kt +++ b/data/src/main/java/com/sedsoftware/yaptalker/data/repository/YapLoginSessionRepository.kt @@ -77,7 +77,7 @@ class YapLoginSessionRepository @Inject constructor( for (i in 0 until messageDigest.size) { var hex = Integer.toHexString(0xFF and messageDigest[i].toInt()) while (hex.length < 2) - hex = "0" + hex + hex = "0$hex" hexString.append(hex) } return hexString.toString() From 04ffb452f4139efbb5f0fb8e277d56f7989803f3 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 18:57:02 +0300 Subject: [PATCH 21/29] Revert support library update --- .../base/enums/ConnectionState.kt | 4 +- .../base/enums/lifecycle/ActivityLifecycle.kt | 4 +- .../base/enums/lifecycle/FragmentLifecycle.kt | 4 +- .../enums/lifecycle/PresenterLifecycle.kt | 4 +- .../enums/navigation/NavigationSection.kt | 4 +- .../features/posting/tags/MessageTagCodes.kt | 4 +- .../features/search/options/TargetPeriod.kt | 4 +- buildsystem/dependencies.gradle | 190 +++++++++--------- 8 files changed, 109 insertions(+), 109 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt index eca81b9c..53c0cca6 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/ConnectionState.kt @@ -1,6 +1,6 @@ package com.sedsoftware.yaptalker.presentation.base.enums -import android.support.annotation.LongDef +import android.support.annotation.IntDef class ConnectionState { @@ -12,6 +12,6 @@ class ConnectionState { } @Retention(AnnotationRetention.SOURCE) - @LongDef(IDLE, LOADING, COMPLETED, ERROR) + @IntDef(IDLE, LOADING, COMPLETED, ERROR) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt index 9097f5da..c492bfa9 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/ActivityLifecycle.kt @@ -1,6 +1,6 @@ package com.sedsoftware.yaptalker.presentation.base.enums.lifecycle -import android.support.annotation.LongDef +import android.support.annotation.IntDef class ActivityLifecycle { @@ -14,6 +14,6 @@ class ActivityLifecycle { } @Retention(AnnotationRetention.SOURCE) - @LongDef(CREATE, START, RESUME, PAUSE, STOP, DESTROY) + @IntDef(CREATE, START, RESUME, PAUSE, STOP, DESTROY) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt index cbde885d..5e0b3b86 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/FragmentLifecycle.kt @@ -1,6 +1,6 @@ package com.sedsoftware.yaptalker.presentation.base.enums.lifecycle -import android.support.annotation.LongDef +import android.support.annotation.IntDef class FragmentLifecycle { @@ -16,6 +16,6 @@ class FragmentLifecycle { } @Retention(AnnotationRetention.SOURCE) - @LongDef(ATTACH, CREATE, START, RESUME, PAUSE, STOP, DESTROY, DETACH) + @IntDef(ATTACH, CREATE, START, RESUME, PAUSE, STOP, DESTROY, DETACH) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt index 195b7a2f..db2e1a25 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/lifecycle/PresenterLifecycle.kt @@ -1,6 +1,6 @@ package com.sedsoftware.yaptalker.presentation.base.enums.lifecycle -import android.support.annotation.LongDef +import android.support.annotation.IntDef class PresenterLifecycle { @@ -12,6 +12,6 @@ class PresenterLifecycle { } @Retention(AnnotationRetention.SOURCE) - @LongDef(CREATE, ATTACH_VIEW, DETACH_VIEW, DESTROY) + @IntDef(CREATE, ATTACH_VIEW, DETACH_VIEW, DESTROY) annotation class Event } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt index b668dbaf..f9937ce6 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/enums/navigation/NavigationSection.kt @@ -1,6 +1,6 @@ package com.sedsoftware.yaptalker.presentation.base.enums.navigation -import android.support.annotation.LongDef +import android.support.annotation.IntDef class NavigationSection { companion object { @@ -16,6 +16,6 @@ class NavigationSection { } @Retention(AnnotationRetention.SOURCE) - @LongDef(MAIN_PAGE, FORUMS, ACTIVE_TOPICS, INCUBATOR, BOOKMARKS, SITE_SEARCH, SETTINGS, SIGN_IN, SIGN_OUT) + @IntDef(MAIN_PAGE, FORUMS, ACTIVE_TOPICS, INCUBATOR, BOOKMARKS, SITE_SEARCH, SETTINGS, SIGN_IN, SIGN_OUT) annotation class Section } diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt index 0e84694c..84db448f 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/posting/tags/MessageTagCodes.kt @@ -1,6 +1,6 @@ package com.sedsoftware.yaptalker.presentation.features.posting.tags -import android.support.annotation.LongDef +import android.support.annotation.IntDef class MessageTagCodes { companion object { @@ -12,7 +12,7 @@ class MessageTagCodes { } @Retention(AnnotationRetention.SOURCE) - @LongDef( + @IntDef( TAG_B, TAG_I, TAG_U, diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt index 872294be..0a5ebd72 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/search/options/TargetPeriod.kt @@ -1,6 +1,6 @@ package com.sedsoftware.yaptalker.presentation.features.search.options -import android.support.annotation.LongDef +import android.support.annotation.IntDef class TargetPeriod { companion object { @@ -15,6 +15,6 @@ class TargetPeriod { } @Retention(AnnotationRetention.SOURCE) - @LongDef(ALL_TIME, TODAY, DAYS_7, DAYS_30, DAYS_60, DAYS_90, DAYS_180, DAYS_365) + @IntDef(ALL_TIME, TODAY, DAYS_7, DAYS_30, DAYS_60, DAYS_90, DAYS_180, DAYS_365) annotation class Value } diff --git a/buildsystem/dependencies.gradle b/buildsystem/dependencies.gradle index 5a55e3fc..9a4a92ca 100644 --- a/buildsystem/dependencies.gradle +++ b/buildsystem/dependencies.gradle @@ -7,7 +7,7 @@ allprojects { ext { // Android final KOTLIN_VERSION = "1.2.30" - final SUPPORT_LIBRARY_VERSION = "27.1.0" + final SUPPORT_LIBRARY_VERSION = "27.0.2" final CONSTRAINT_LAYOUT_VERSION = "1.1.0-beta5" // Rx @@ -16,7 +16,7 @@ ext { final RX_KOTLIN_VERSION = "2.2.0" final RX_RELAY_VERSION = "2.0.0" final RX_LINT_VERSION = "1.6.1" - final RX_BINDING_VERSION = "2.1.0" + final RX_BINDING_VERSION = "2.1.1" final AUTO_DISPOSE_VERSION = "0.6.1" // Core @@ -56,125 +56,125 @@ ext { final LEAK_CANARY_VERSION = "1.5.4" domainDependencies = [ - kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", - javax : "javax.inject:javax.inject:$JAVAX_INJECT_VERSION", - rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", - rxKotlin: "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", + kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", + javax : "javax.inject:javax.inject:$JAVAX_INJECT_VERSION", + rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", + rxKotlin: "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", ] domainTestDependencies = [ - junit : "junit:junit:$JUNIT_VERSION", - expekt: "com.winterbe:expekt:$EXPEKT_VERSION", + junit : "junit:junit:$JUNIT_VERSION", + expekt: "com.winterbe:expekt:$EXPEKT_VERSION", ] dataDependencies = [ - kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", - javax : "javax.inject:javax.inject:$JAVAX_INJECT_VERSION", - rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", - rxKotlin: "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", - retrofit: "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION", - jspoon : "pl.droidsonroids:jspoon:$JSPOON_VERSION", + kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", + javax : "javax.inject:javax.inject:$JAVAX_INJECT_VERSION", + rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", + rxKotlin: "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", + retrofit: "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION", + jspoon : "pl.droidsonroids:jspoon:$JSPOON_VERSION", ] dataTestDependencies = [ - junit : "junit:junit:$JUNIT_VERSION", - mockito : "org.mockito:mockito-core:$MOCKITO_VERSION", - mockitoKotlin: "com.nhaarman:mockito-kotlin-kt1.1:$MOCKITO_KOTLIN_VERSION", - expekt : "com.winterbe:expekt:$EXPEKT_VERSION", + junit : "junit:junit:$JUNIT_VERSION", + mockito : "org.mockito:mockito-core:$MOCKITO_VERSION", + mockitoKotlin: "com.nhaarman:mockito-kotlin-kt1.1:$MOCKITO_KOTLIN_VERSION", + expekt : "com.winterbe:expekt:$EXPEKT_VERSION", ] deviceDependencies = [ - appCompat: "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION", - kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", - javax : "javax.inject:javax.inject:$JAVAX_INJECT_VERSION", - rxAndroid: "io.reactivex.rxjava2:rxandroid:$RX_ANDROID_VERSION", - rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", - rxKotlin : "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", - okhttp : "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION", - picasso : "com.squareup.picasso:picasso:$PICASSO_VERSION", + appCompat: "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION", + kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", + javax : "javax.inject:javax.inject:$JAVAX_INJECT_VERSION", + rxAndroid: "io.reactivex.rxjava2:rxandroid:$RX_ANDROID_VERSION", + rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", + rxKotlin : "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", + okhttp : "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION", + picasso : "com.squareup.picasso:picasso:$PICASSO_VERSION", ] deviceTestDependencies = [ - junit : "junit:junit:$JUNIT_VERSION", - mockito : "org.mockito:mockito-core:$MOCKITO_VERSION", - mockitoKotlin: "com.nhaarman:mockito-kotlin-kt1.1:$MOCKITO_KOTLIN_VERSION", - expekt : "com.winterbe:expekt:$EXPEKT_VERSION", + junit : "junit:junit:$JUNIT_VERSION", + mockito : "org.mockito:mockito-core:$MOCKITO_VERSION", + mockitoKotlin: "com.nhaarman:mockito-kotlin-kt1.1:$MOCKITO_KOTLIN_VERSION", + expekt : "com.winterbe:expekt:$EXPEKT_VERSION", ] presentationDependencies = [ - kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", - - appCompat : "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION", - preferenceV7 : "com.android.support:preference-v7:$SUPPORT_LIBRARY_VERSION", - preferenceV14 : "com.android.support:preference-v14:$SUPPORT_LIBRARY_VERSION", - cardView : "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION", - design : "com.android.support:design:$SUPPORT_LIBRARY_VERSION", - recyclerView : "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION", - constraintLayout : "com.android.support.constraint:constraint-layout:$CONSTRAINT_LAYOUT_VERSION", - - dagger : "com.google.dagger:dagger:$DAGGER_VERSION", - daggerCompiler : "com.google.dagger:dagger-compiler:$DAGGER_VERSION", - daggerAndroid : "com.google.dagger:dagger-android:$DAGGER_VERSION", - daggerAndroidCompiler : "com.google.dagger:dagger-android-processor:$DAGGER_VERSION", - daggerAndroidSupport : "com.google.dagger:dagger-android-support:$DAGGER_VERSION", - moxy : "com.arello-mobile:moxy:$MOXY_VERSION", - moxyCompiler : "com.arello-mobile:moxy-compiler:$MOXY_VERSION", - moxyAndroid : "com.arello-mobile:moxy-android:$MOXY_VERSION", - moxyAppCompat : "com.arello-mobile:moxy-app-compat:$MOXY_VERSION", - cicerone : "ru.terrakok.cicerone:cicerone:$CICERONE_VERSION", - anko : "org.jetbrains.anko:anko-commons:$ANKO_VERSION", - ankoDesign : "org.jetbrains.anko:anko-design:$ANKO_VERSION", - - rxAndroid : "io.reactivex.rxjava2:rxandroid:$RX_ANDROID_VERSION", - rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", - rxKotlin : "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", - rxRelay : "com.jakewharton.rxrelay2:rxrelay:$RX_RELAY_VERSION", - rxLint : "nl.littlerobots.rxlint:rxlint:$RX_LINT_VERSION", - rxBinding : "com.jakewharton.rxbinding2:rxbinding-kotlin:$RX_BINDING_VERSION", - rxBindingAppCompat : "com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:$RX_BINDING_VERSION", - rxBindingRecyclerView : "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7-kotlin:$RX_BINDING_VERSION", - rxBindingSupport : "com.jakewharton.rxbinding2:rxbinding-support-v4-kotlin:$RX_BINDING_VERSION", - autoDispose : "com.uber.autodispose:autodispose:$AUTO_DISPOSE_VERSION", - autoDisposeKotlin : "com.uber.autodispose:autodispose-kotlin:$AUTO_DISPOSE_VERSION", - - moshi : "com.squareup.moshi:moshi:$MOSHI_VERSION", - retrofit : "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION", - retrofitRxAdapter : "com.squareup.retrofit2:adapter-rxjava2:$RETROFIT_VERSION", - retrofitMoshiConverter : "com.squareup.retrofit2:converter-moshi:$RETROFIT_VERSION", - retrofitScalarsConverter: "com.squareup.retrofit2:converter-scalars:$RETROFIT_VERSION", - retrofitJspoonConverter : "pl.droidsonroids.retrofit2:converter-jspoon:$JSPOON_VERSION", - okhttp : "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION", - okhttpInterceptor : "com.squareup.okhttp3:logging-interceptor:$OKHTTP_VERSION", - picasso : "com.squareup.picasso:picasso:$PICASSO_VERSION", - - materialValues : "blue.aodev:material-values:$MATERIAL_VALUES_VERSION", - materialDrawer : "com.mikepenz:materialdrawer:$MATERIAL_DRAWER_VERSION", - iconicsCore : "com.mikepenz:iconics-core:$ICONICS_VERSION", - iconicsView : "com.mikepenz:iconics-views:$ICONICS_VERSION", - materialTypeface : "com.mikepenz:community-material-typeface:$COMMUNITY_MATERIAL_ICONS_VERSION", - materialDialogs : "com.afollestad.material-dialogs:core:$MATERIAL_DIALOGUES_VERSION", - materialDialogsCommons : "com.afollestad.material-dialogs:commons:$MATERIAL_DIALOGUES_VERSION", - toasty : "com.github.grenderg:toasty:$TOASTY_VERSION", - photoView : "com.github.chrisbanes:PhotoView:$PHOTOVIEW_VERSION", + kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION", + + appCompat : "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION", + preferenceV7 : "com.android.support:preference-v7:$SUPPORT_LIBRARY_VERSION", + preferenceV14 : "com.android.support:preference-v14:$SUPPORT_LIBRARY_VERSION", + cardView : "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION", + design : "com.android.support:design:$SUPPORT_LIBRARY_VERSION", + recyclerView : "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION", + constraintLayout : "com.android.support.constraint:constraint-layout:$CONSTRAINT_LAYOUT_VERSION", + + dagger : "com.google.dagger:dagger:$DAGGER_VERSION", + daggerCompiler : "com.google.dagger:dagger-compiler:$DAGGER_VERSION", + daggerAndroid : "com.google.dagger:dagger-android:$DAGGER_VERSION", + daggerAndroidCompiler : "com.google.dagger:dagger-android-processor:$DAGGER_VERSION", + daggerAndroidSupport : "com.google.dagger:dagger-android-support:$DAGGER_VERSION", + moxy : "com.arello-mobile:moxy:$MOXY_VERSION", + moxyCompiler : "com.arello-mobile:moxy-compiler:$MOXY_VERSION", + moxyAndroid : "com.arello-mobile:moxy-android:$MOXY_VERSION", + moxyAppCompat : "com.arello-mobile:moxy-app-compat:$MOXY_VERSION", + cicerone : "ru.terrakok.cicerone:cicerone:$CICERONE_VERSION", + anko : "org.jetbrains.anko:anko-commons:$ANKO_VERSION", + ankoDesign : "org.jetbrains.anko:anko-design:$ANKO_VERSION", + + rxAndroid : "io.reactivex.rxjava2:rxandroid:$RX_ANDROID_VERSION", + rxJava : "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION", + rxKotlin : "io.reactivex.rxjava2:rxkotlin:$RX_KOTLIN_VERSION", + rxRelay : "com.jakewharton.rxrelay2:rxrelay:$RX_RELAY_VERSION", + rxLint : "nl.littlerobots.rxlint:rxlint:$RX_LINT_VERSION", + rxBinding : "com.jakewharton.rxbinding2:rxbinding-kotlin:$RX_BINDING_VERSION", + rxBindingAppCompat : "com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:$RX_BINDING_VERSION", + rxBindingRecyclerView : "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7-kotlin:$RX_BINDING_VERSION", + rxBindingSupport : "com.jakewharton.rxbinding2:rxbinding-support-v4-kotlin:$RX_BINDING_VERSION", + autoDispose : "com.uber.autodispose:autodispose:$AUTO_DISPOSE_VERSION", + autoDisposeKotlin : "com.uber.autodispose:autodispose-kotlin:$AUTO_DISPOSE_VERSION", + + moshi : "com.squareup.moshi:moshi:$MOSHI_VERSION", + retrofit : "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION", + retrofitRxAdapter : "com.squareup.retrofit2:adapter-rxjava2:$RETROFIT_VERSION", + retrofitMoshiConverter : "com.squareup.retrofit2:converter-moshi:$RETROFIT_VERSION", + retrofitScalarsConverter: "com.squareup.retrofit2:converter-scalars:$RETROFIT_VERSION", + retrofitJspoonConverter : "pl.droidsonroids.retrofit2:converter-jspoon:$JSPOON_VERSION", + okhttp : "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION", + okhttpInterceptor : "com.squareup.okhttp3:logging-interceptor:$OKHTTP_VERSION", + picasso : "com.squareup.picasso:picasso:$PICASSO_VERSION", + + materialValues : "blue.aodev:material-values:$MATERIAL_VALUES_VERSION", + materialDrawer : "com.mikepenz:materialdrawer:$MATERIAL_DRAWER_VERSION", + iconicsCore : "com.mikepenz:iconics-core:$ICONICS_VERSION", + iconicsView : "com.mikepenz:iconics-views:$ICONICS_VERSION", + materialTypeface : "com.mikepenz:community-material-typeface:$COMMUNITY_MATERIAL_ICONS_VERSION", + materialDialogs : "com.afollestad.material-dialogs:core:$MATERIAL_DIALOGUES_VERSION", + materialDialogsCommons : "com.afollestad.material-dialogs:commons:$MATERIAL_DIALOGUES_VERSION", + toasty : "com.github.grenderg:toasty:$TOASTY_VERSION", + photoView : "com.github.chrisbanes:PhotoView:$PHOTOVIEW_VERSION", ] presentationTestDependencies = [ - junit : "junit:junit:$JUNIT_VERSION", - expekt : "com.winterbe:expekt:$EXPEKT_VERSION", - mockito : "org.mockito:mockito-core:$MOCKITO_VERSION", - mockitoKotlin : "com.nhaarman:mockito-kotlin-kt1.1:$MOCKITO_KOTLIN_VERSION", - mockitoAndroid: "org.mockito:mockito-android:$MOCKITO_VERSION", - espresso : "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION", + junit : "junit:junit:$JUNIT_VERSION", + expekt : "com.winterbe:expekt:$EXPEKT_VERSION", + mockito : "org.mockito:mockito-core:$MOCKITO_VERSION", + mockitoKotlin : "com.nhaarman:mockito-kotlin-kt1.1:$MOCKITO_KOTLIN_VERSION", + mockitoAndroid: "org.mockito:mockito-android:$MOCKITO_VERSION", + espresso : "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION", ] supportingToolsDependencies = [ - crashalytics: "com.crashlytics.sdk.android:crashlytics:$ANDROID_CRASHALYTICS_VERSION", - firebaseCore: "com.google.firebase:firebase-core:$FIREBASE_CORE_VERSION", + crashalytics: "com.crashlytics.sdk.android:crashlytics:$ANDROID_CRASHALYTICS_VERSION", + firebaseCore: "com.google.firebase:firebase-core:$FIREBASE_CORE_VERSION", ] developmentDependencies = [ - timber : "com.jakewharton.timber:timber:$TIMBER_VERSION", - leakCanary : "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY_VERSION", - leakCanaryNoOp: "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY_VERSION", + timber : "com.jakewharton.timber:timber:$TIMBER_VERSION", + leakCanary : "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY_VERSION", + leakCanaryNoOp: "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY_VERSION", ] } From 5e35fb76f78578eeed91732c34ff21bf502cc38e Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 19:17:28 +0300 Subject: [PATCH 22/29] Remove unused vars --- .../yaptalker/presentation/mappers/TopicGalleryModelMapper.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt index 7c0437c5..31a8a420 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/mappers/TopicGalleryModelMapper.kt @@ -25,8 +25,6 @@ class TopicGalleryModelMapper @Inject constructor( val result: MutableList = ArrayList() val imagesList: MutableList = ArrayList() - var currentPage = 0 - var totalPages = 0 items.forEach { item -> when (item) { @@ -45,8 +43,6 @@ class TopicGalleryModelMapper @Inject constructor( ) is NavigationPanel -> { - currentPage = item.currentPage - totalPages = item.totalPages result.add( NavigationPanelModel( currentPage = item.currentPage, From e706d5ffa5c338edc95a93f3039e8fe239a82e51 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 19:38:43 +0300 Subject: [PATCH 23/29] Test loading indicator strategy tweak --- .../com/sedsoftware/yaptalker/presentation/base/BaseView.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseView.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseView.kt index 07ffcb7e..8952fa9e 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseView.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/base/BaseView.kt @@ -5,16 +5,17 @@ import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy import com.arellomobile.mvp.viewstate.strategy.SkipStrategy import com.arellomobile.mvp.viewstate.strategy.StateStrategyType -@StateStrategyType(AddToEndSingleStrategy::class) +@StateStrategyType(SkipStrategy::class) interface BaseView : MvpView { - @StateStrategyType(SkipStrategy::class) fun showErrorMessage(message: String) + @StateStrategyType(value = AddToEndSingleStrategy::class, tag = "LoadingIndicator") fun showLoadingIndicator() { // Default empty implementation } + @StateStrategyType(value = AddToEndSingleStrategy::class, tag = "LoadingIndicator") fun hideLoadingIndicator() { // Default empty implementation } From 6b8d267b7e6d0e18363950be2449a169bfa265e7 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 19:43:19 +0300 Subject: [PATCH 24/29] Tweak image saving after permission request --- .../features/gallery/TopicGalleryActivity.kt | 16 +++++++++++++--- .../imagedisplay/ImageDisplayActivity.kt | 11 +++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt index f55644b3..dfe0aa60 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryActivity.kt @@ -24,8 +24,8 @@ import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGall import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener import com.sedsoftware.yaptalker.presentation.model.YapEntity import com.sedsoftware.yaptalker.presentation.model.base.SinglePostGalleryImageModel -import kotlinx.android.synthetic.main.activity_topic_gallery.* -import kotlinx.android.synthetic.main.include_main_appbar_transparent.* +import kotlinx.android.synthetic.main.activity_topic_gallery.topic_gallery +import kotlinx.android.synthetic.main.include_main_appbar_transparent.toolbar import java.util.Locale import javax.inject.Inject @@ -73,6 +73,8 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM intent.getIntExtra(CURRENT_PAGE_KEY, 0) } + private var savingImageUrl = "" + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -153,12 +155,20 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM presenter.loadMoreImages() } + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + when (requestCode) { + STORAGE_WRITE_PERMISSION -> { + presenter.saveImage(savingImageUrl) + } + } + } + private fun checkPermissionAndSaveImage(imageUrl: String) { if (ContextCompat.checkSelfPermission( this, Manifest.permission.WRITE_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED) { - + savingImageUrl = imageUrl ActivityCompat.requestPermissions( this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/imagedisplay/ImageDisplayActivity.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/imagedisplay/ImageDisplayActivity.kt index 63feeeca..10ebf695 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/imagedisplay/ImageDisplayActivity.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/imagedisplay/ImageDisplayActivity.kt @@ -18,8 +18,8 @@ import com.sedsoftware.yaptalker.presentation.extensions.loadFromUrl import com.sedsoftware.yaptalker.presentation.extensions.stringRes import com.sedsoftware.yaptalker.presentation.extensions.toastError import com.sedsoftware.yaptalker.presentation.extensions.toastSuccess -import kotlinx.android.synthetic.main.activity_image_display.* -import kotlinx.android.synthetic.main.include_main_appbar_transparent.* +import kotlinx.android.synthetic.main.activity_image_display.photo_view +import kotlinx.android.synthetic.main.include_main_appbar_transparent.toolbar import java.util.Locale import javax.inject.Inject @@ -92,12 +92,7 @@ class ImageDisplayActivity : BaseActivity(), ImageDisplayView { toastError(stringRes(R.string.msg_file_not_saved)) } - override fun onRequestPermissionsResult( - requestCode: Int, - permissions: Array, - grantResults: IntArray - ) { - + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { when (requestCode) { STORAGE_WRITE_PERMISSION -> { presenter.saveImage(imageUrl) From f7dde535e8e6b2532a6566bc5fa63147ea7ac7bf Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 20:16:49 +0300 Subject: [PATCH 25/29] Load more progress gravity tweak --- .../main/res/layout/activity_topic_gallery_item_load_more.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml b/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml index 9f0f03f2..383b99cf 100644 --- a/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml +++ b/app/src/main/res/layout/activity_topic_gallery_item_load_more.xml @@ -18,6 +18,7 @@ android:id="@+id/load_more_progress" android:layout_width="@dimen/load_more_progress_indicator_size" android:layout_height="@dimen/load_more_progress_indicator_size" + android:layout_gravity="center" android:visibility="invisible" /> \ No newline at end of file From 5a57040e3b02fbf0a45b8c9670b1bbae3f13a7f6 Mon Sep 17 00:00:00 2001 From: DJ_Kovrik Date: Sun, 4 Mar 2018 20:26:58 +0300 Subject: [PATCH 26/29] Make posts text selectable --- .../features/topic/adapter/ChosenTopicDelegateAdapter.kt | 6 ++++++ app/src/main/res/layout/fragment_incubator_item.xml | 1 + app/src/main/res/layout/fragment_news_item.xml | 1 + 3 files changed, 8 insertions(+) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/adapter/ChosenTopicDelegateAdapter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/adapter/ChosenTopicDelegateAdapter.kt index acdc4b29..2308bf17 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/adapter/ChosenTopicDelegateAdapter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/topic/adapter/ChosenTopicDelegateAdapter.kt @@ -103,6 +103,7 @@ class ChosenTopicDelegateAdapter( quoteAuthor.textSize = normalFontSize quoteAuthor.setTextColor(primaryTextColor) quoteAuthor.text = contentItem.text + quoteAuthor.setTextIsSelectable(true) if (currentNestingLevel > INITIAL_NESTING_LEVEL) { quoteAuthor.setPadding(textPadding * currentNestingLevel, 0, 0, 0) } @@ -116,6 +117,7 @@ class ChosenTopicDelegateAdapter( quoteText.textFromHtmlWithEmoji(contentItem.text) quoteText.setBackgroundColor(quoteBackgroundColor) quoteText.setPadding(textPadding * currentNestingLevel, 0, 0, 0) + quoteText.setTextIsSelectable(true) itemView.post_content_text_container.addView(quoteText) } is PostTextModel -> { @@ -125,6 +127,7 @@ class ChosenTopicDelegateAdapter( postText.textSize = normalFontSize postText.setTextColor(primaryTextColor) postText.textFromHtmlWithEmoji(contentItem.text) + postText.setTextIsSelectable(true) if (currentNestingLevel > INITIAL_NESTING_LEVEL) { postText.setBackgroundColor(quoteBackgroundColor) postText.setPadding(textPadding * currentNestingLevel, 0, 0, 0) @@ -136,6 +139,7 @@ class ChosenTopicDelegateAdapter( hiddenText.textSize = smallFontSize hiddenText.setTextColor(primaryTextColor) hiddenText.textFromHtmlWithEmoji(contentItem.text) + hiddenText.setTextIsSelectable(true) itemView.post_content_text_container.addView(hiddenText) } is PostScriptModel -> { @@ -144,6 +148,7 @@ class ChosenTopicDelegateAdapter( postScriptText.textSize = smallFontSize postScriptText.setTextColor(secondaryTextColor) postScriptText.text = contentItem.text + postScriptText.setTextIsSelectable(true) itemView.post_content_text_container.addView(postScriptText) } is PostWarningModel -> { @@ -158,6 +163,7 @@ class ChosenTopicDelegateAdapter( warningText.textSize = smallFontSize warningText.setTextColor(secondaryTextColor) warningText.text = warning.text + warningText.setTextIsSelectable(true) itemView.post_content_text_container.addView(warningText) } } diff --git a/app/src/main/res/layout/fragment_incubator_item.xml b/app/src/main/res/layout/fragment_incubator_item.xml index b9661233..56df367c 100644 --- a/app/src/main/res/layout/fragment_incubator_item.xml +++ b/app/src/main/res/layout/fragment_incubator_item.xml @@ -71,6 +71,7 @@ android:paddingBottom="@dimen/material_card_title_block_small_padding_vertical" android:paddingEnd="@dimen/material_card_title_block_padding_horizontal" android:paddingStart="@dimen/material_card_title_block_padding_horizontal" + android:textIsSelectable="true" tools:text="Here is a long news text, here is a long news text here" /> Date: Mon, 5 Mar 2018 14:48:25 +0300 Subject: [PATCH 27/29] Add resolutionStrategy for all configurations --- app/build.gradle | 4 ++++ data/build.gradle | 4 ++++ device/build.gradle | 4 ++++ domain/build.gradle | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index eb1c9121..2c9e62eb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -146,4 +146,8 @@ dependencies { testImplementation developmentDependencies.leakCanaryNoOp } +configurations.all() { + resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" +} + apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/data/build.gradle b/data/build.gradle index 8ff5a36e..143285fc 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -65,3 +65,7 @@ dependencies { testImplementation dataTestDependencies.mockitoKotlin testImplementation dataTestDependencies.expekt } + +configurations.all() { + resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" +} diff --git a/device/build.gradle b/device/build.gradle index 591c0dc0..ab3f3b93 100644 --- a/device/build.gradle +++ b/device/build.gradle @@ -66,3 +66,7 @@ dependencies { testImplementation deviceTestDependencies.mockitoKotlin testImplementation deviceTestDependencies.expekt } + +configurations.all() { + resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" +} diff --git a/domain/build.gradle b/domain/build.gradle index 1daecb6f..8893a92f 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -14,3 +14,7 @@ dependencies { testImplementation domainTestDependencies.junit testImplementation domainTestDependencies.expekt } + +configurations.all() { + resolutionStrategy.force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" +} From 655c15d2094aaec2455806ff773523c24d1b43fd Mon Sep 17 00:00:00 2001 From: Sergey Vasilchenko Date: Mon, 5 Mar 2018 15:06:49 +0300 Subject: [PATCH 28/29] Gallery page loading fix --- .../features/gallery/TopicGalleryPresenter.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt index 600be9db..d0442dd9 100644 --- a/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt +++ b/app/src/main/java/com/sedsoftware/yaptalker/presentation/features/gallery/TopicGalleryPresenter.kt @@ -40,14 +40,10 @@ class TopicGalleryPresenter @Inject constructor( private var totalPages = 1 private var currentTitleLabel = "" - fun loadTopicGallery(forumId: Int, topicId: Int, startingPost: Int = 0) { + fun loadTopicGallery(forumId: Int, topicId: Int, page: Int) { currentForumId = forumId currentTopicId = topicId - - currentPage = when { - startingPost != 0 -> startingPost / postsPerPage + 1 - else -> 1 - } + currentPage = page loadTopicCurrentPageGallery() } From 277de3ff79fc11260468d3fd66c907aaa47a7c81 Mon Sep 17 00:00:00 2001 From: Sergey Vasilchenko Date: Mon, 5 Mar 2018 15:09:50 +0300 Subject: [PATCH 29/29] Prepare version 0.9.1 --- build.gradle | 4 ++-- docs/CHANGELOG.md | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 569a6bf4..5f4865a3 100644 --- a/build.gradle +++ b/build.gradle @@ -24,10 +24,10 @@ apply from: 'buildsystem/dependencies.gradle' // Versioning convention from ribot: // Major -> Millions, Minor -> Thousands, Bugfix -> Hundreds. E.g 1.3.72 == 1,003,072 -// Current: 0.9.0 (000,009,000) +// Current: 0.9.1 (000,009,001) def versionMajor = 0 def versionMinor = 9 -def versionPatch = 0 +def versionPatch = 1 allprojects { ext { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 333d9341..a644a36f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,10 @@ -### Current version: 0.9.0 +### Current version: 0.9.1 # Changelog +## [0.9.1] - 2018-03-05 +## Added +- Selectable text for messages +- Gallery mode for topics + ## [0.9.0] - 2018-02-20 ## Added - Images posting