diff --git a/twidere/proguard-rules.pro b/twidere/proguard-rules.pro index 27b291580..17729ccf0 100644 --- a/twidere/proguard-rules.pro +++ b/twidere/proguard-rules.pro @@ -65,11 +65,13 @@ (android.content.Context); } --keep class * extends org.mariotaku.twidere.util.MapFragmentFactory --keep class * extends org.mariotaku.twidere.util.TwitterCardFragmentFactory -keep class * extends org.mariotaku.twidere.util.Analyzer +-keep class * extends org.mariotaku.twidere.util.MapFragmentFactory +-keep class * extends org.mariotaku.twidere.util.gifshare.GifShareProvider.Factory -keep class * extends org.mariotaku.twidere.util.premium.ExtraFeaturesService --keep class * extends org.mariotaku.twidere.util.schedule.StatusScheduleController.Factory +-keep class * extends org.mariotaku.twidere.util.schedule.StatusScheduleProvider.Factory +-keep class * extends org.mariotaku.twidere.util.sync.SyncProviderInfoFactory +-keep class * extends org.mariotaku.twidere.util.twitter.card.TwitterCardViewFactory -keep class * extends org.mariotaku.twidere.util.view.AppBarChildBehavior.ChildTransformation -keepclassmembers class * { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt index 354a5434e..17ba405e6 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt @@ -64,8 +64,9 @@ import org.mariotaku.twidere.preference.iface.IDialogPreference import org.mariotaku.twidere.util.* import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback import org.mariotaku.twidere.util.dagger.GeneralComponentHelper +import org.mariotaku.twidere.util.gifshare.GifShareProvider import org.mariotaku.twidere.util.premium.ExtraFeaturesService -import org.mariotaku.twidere.util.schedule.StatusScheduleController +import org.mariotaku.twidere.util.schedule.StatusScheduleProvider import org.mariotaku.twidere.util.support.ActivitySupport import org.mariotaku.twidere.util.support.ActivitySupport.TaskDescriptionCompat import org.mariotaku.twidere.util.theme.TwidereAppearanceCreator @@ -101,14 +102,19 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity, IThe @Inject lateinit var extraFeaturesService: ExtraFeaturesService @Inject - lateinit var statusScheduleControllerFactory: StatusScheduleController.Factory + lateinit var statusScheduleProviderFactory: StatusScheduleProvider.Factory + @Inject + lateinit var gifShareProviderFactory: GifShareProvider.Factory @Inject lateinit var defaultFeatures: DefaultFeatures @Inject lateinit var restHttpClient: RestHttpClient - protected val statusScheduleController: StatusScheduleController? - get() = statusScheduleControllerFactory.newInstance(this) + protected val statusScheduleProvider: StatusScheduleProvider? + get() = statusScheduleProviderFactory.newInstance(this) + + protected val gifShareProvider: GifShareProvider? + get() = gifShareProviderFactory.newInstance(this) private val actionHelper = IBaseActivity.ActionHelper(this) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt index 519a1db8f..8794512bd 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt @@ -561,7 +561,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener updateTextCount() } R.id.schedule -> { - val controller = statusScheduleController ?: return true + val controller = statusScheduleProvider ?: return true startActivityForResult(controller.createSetScheduleIntent(), REQUEST_SET_SCHEDULE) } else -> { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/PremiumDashboardActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/PremiumDashboardActivity.kt index a72321b1c..39601c4fa 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/PremiumDashboardActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/PremiumDashboardActivity.kt @@ -31,7 +31,7 @@ import org.mariotaku.twidere.util.Analyzer import org.mariotaku.twidere.util.SharedPreferencesWrapper import org.mariotaku.twidere.util.dagger.GeneralComponentHelper import org.mariotaku.twidere.util.premium.ExtraFeaturesService -import org.mariotaku.twidere.util.schedule.StatusScheduleController +import org.mariotaku.twidere.util.schedule.StatusScheduleProvider import org.mariotaku.twidere.view.ContainerView import java.lang.ref.WeakReference import java.util.concurrent.atomic.AtomicBoolean @@ -169,7 +169,7 @@ class PremiumDashboardActivity : BaseActivity() { protected lateinit var preferences: SharedPreferencesWrapper @Inject - protected lateinit var scheduleControllerFactory: StatusScheduleController.Factory + protected lateinit var mScheduleProviderFactory: StatusScheduleProvider.Factory var position: Int = RecyclerView.NO_POSITION internal set diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt index 3dff70061..e013ab235 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt @@ -32,7 +32,7 @@ import org.mariotaku.twidere.model.DefaultFeatures import org.mariotaku.twidere.util.* import org.mariotaku.twidere.util.dagger.GeneralComponentHelper import org.mariotaku.twidere.util.premium.ExtraFeaturesService -import org.mariotaku.twidere.util.schedule.StatusScheduleController +import org.mariotaku.twidere.util.schedule.StatusScheduleProvider import javax.inject.Inject open class BaseFragment : Fragment(), IBaseFragment { @@ -67,12 +67,12 @@ open class BaseFragment : Fragment(), IBaseFragment { @Inject lateinit var defaultFeatures: DefaultFeatures @Inject - lateinit var statusScheduleControllerFactory: StatusScheduleController.Factory + lateinit var statusScheduleProviderFactory: StatusScheduleProvider.Factory @Inject lateinit var restHttpClient: RestHttpClient - protected val statusScheduleController: StatusScheduleController? - get() = statusScheduleControllerFactory.newInstance(context) + protected val statusScheduleProvider: StatusScheduleProvider? + get() = statusScheduleProviderFactory.newInstance(context) private val actionHelper = IBaseFragment.ActionHelper(this) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DraftsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DraftsFragment.kt index 0e6abb349..079f961e4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DraftsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DraftsFragment.kt @@ -135,7 +135,7 @@ class DraftsFragment : BaseFragment(), LoaderCallbacks, OnItemClickList override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.scheduled_statuses -> { - val scheduleManageIntent = statusScheduleController?.createManageIntent() ?: return true + val scheduleManageIntent = statusScheduleProvider?.createManageIntent() ?: return true startActivity(scheduleManageIntent) return true } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/BaseAbstractTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/BaseAbstractTask.kt index 6d0d034e5..bd74923d5 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/BaseAbstractTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/BaseAbstractTask.kt @@ -8,7 +8,7 @@ import org.mariotaku.twidere.util.* import org.mariotaku.twidere.util.dagger.GeneralComponentHelper import org.mariotaku.twidere.util.media.MediaPreloader import org.mariotaku.twidere.util.premium.ExtraFeaturesService -import org.mariotaku.twidere.util.schedule.StatusScheduleController +import org.mariotaku.twidere.util.schedule.StatusScheduleProvider import javax.inject.Inject /** @@ -38,10 +38,10 @@ abstract class BaseAbstractTask(val context: Context) @Inject lateinit var extraFeaturesService: ExtraFeaturesService @Inject - lateinit var scheduleControllerFactory: StatusScheduleController.Factory + lateinit var scheduleProviderFactory: StatusScheduleProvider.Factory - val scheduleController: StatusScheduleController? - get() = scheduleControllerFactory.newInstance(context) + val scheduleProvider: StatusScheduleProvider? + get() = scheduleProviderFactory.newInstance(context) init { injectMembers() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt index 8971eefc5..4f0617f7c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt @@ -262,7 +262,7 @@ class UpdateStatusTask( throw SchedulerNotFoundException(context.getString(R.string.error_message_scheduler_not_available)) } - val controller = scheduleController ?: run { + val controller = scheduleProvider ?: run { throw SchedulerNotFoundException(context.getString(R.string.error_message_scheduler_not_available)) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/dagger/ApplicationModule.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/dagger/ApplicationModule.kt index 61d289d47..436c9a26b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/dagger/ApplicationModule.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/dagger/ApplicationModule.kt @@ -62,7 +62,7 @@ import org.mariotaku.twidere.util.premium.ExtraFeaturesService import org.mariotaku.twidere.util.refresh.AutoRefreshController import org.mariotaku.twidere.util.refresh.JobSchedulerAutoRefreshController import org.mariotaku.twidere.util.refresh.LegacyAutoRefreshController -import org.mariotaku.twidere.util.schedule.StatusScheduleController +import org.mariotaku.twidere.util.schedule.StatusScheduleProvider import org.mariotaku.twidere.util.sync.JobSchedulerSyncController import org.mariotaku.twidere.util.sync.LegacySyncController import org.mariotaku.twidere.util.sync.SyncController @@ -257,8 +257,8 @@ class ApplicationModule(private val application: Application) { @Provides @Singleton - fun statusScheduleControllerFactory(): StatusScheduleController.Factory { - return StatusScheduleController.Factory.instance + fun statusScheduleProviderFactory(): StatusScheduleProvider.Factory { + return StatusScheduleProvider.Factory.instance } @Provides diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/gifshare/GifShareProvider.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/gifshare/GifShareProvider.kt new file mode 100644 index 000000000..8313454b8 --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/gifshare/GifShareProvider.kt @@ -0,0 +1,48 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2017 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.util.gifshare + +import android.content.Context +import android.content.Intent +import java.util.* + +/** + * Created by mariotaku on 2017/3/24. + */ + +interface GifShareProvider { + + fun createGifSelectorIntent(): Intent + + fun createSettingsIntent(): Intent? + + interface Factory { + fun newInstance(context: Context): GifShareProvider? + + companion object { + val instance: Factory get() = ServiceLoader.load(Factory::class.java)?.firstOrNull() ?: NullFactory + + private object NullFactory : Factory { + override fun newInstance(context: Context) = null + + } + } + } +} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleController.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleProvider.kt similarity index 95% rename from twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleController.kt rename to twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleProvider.kt index ecd1be0a5..883272da3 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleController.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleProvider.kt @@ -32,7 +32,7 @@ import java.util.* * Created by mariotaku on 2017/3/24. */ -interface StatusScheduleController { +interface StatusScheduleProvider { @WorkerThread @Throws(ScheduleException::class) @@ -57,7 +57,7 @@ interface StatusScheduleController { } interface Factory { - fun newInstance(context: Context): StatusScheduleController? + fun newInstance(context: Context): StatusScheduleProvider? fun parseInfo(json: String): ScheduleInfo?