added scheduled status entry in drafts
This commit is contained in:
parent
069a1f2a93
commit
5d91cd05b3
|
@ -31,6 +31,7 @@ import org.mariotaku.twidere.util.Analyzer
|
||||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||||
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
||||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||||
|
import org.mariotaku.twidere.util.schedule.StatusScheduleController
|
||||||
import org.mariotaku.twidere.view.ContainerView
|
import org.mariotaku.twidere.view.ContainerView
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
@ -167,6 +168,9 @@ class PremiumDashboardActivity : BaseActivity() {
|
||||||
@Inject
|
@Inject
|
||||||
protected lateinit var preferences: SharedPreferencesWrapper
|
protected lateinit var preferences: SharedPreferencesWrapper
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected lateinit var scheduleControllerFactory: StatusScheduleController.Factory
|
||||||
|
|
||||||
var position: Int = RecyclerView.NO_POSITION
|
var position: Int = RecyclerView.NO_POSITION
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,13 @@ import android.support.v4.text.BidiFormatter
|
||||||
import com.squareup.otto.Bus
|
import com.squareup.otto.Bus
|
||||||
import com.twitter.Validator
|
import com.twitter.Validator
|
||||||
import nl.komponents.kovenant.Promise
|
import nl.komponents.kovenant.Promise
|
||||||
|
import org.mariotaku.restfu.http.RestHttpClient
|
||||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment
|
import org.mariotaku.twidere.fragment.iface.IBaseFragment
|
||||||
import org.mariotaku.twidere.model.DefaultFeatures
|
import org.mariotaku.twidere.model.DefaultFeatures
|
||||||
import org.mariotaku.twidere.util.*
|
import org.mariotaku.twidere.util.*
|
||||||
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
||||||
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||||
|
import org.mariotaku.twidere.util.schedule.StatusScheduleController
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
||||||
|
@ -64,6 +66,13 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
||||||
lateinit var permissionsManager: PermissionsManager
|
lateinit var permissionsManager: PermissionsManager
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var defaultFeatures: DefaultFeatures
|
lateinit var defaultFeatures: DefaultFeatures
|
||||||
|
@Inject
|
||||||
|
lateinit var statusScheduleControllerFactory: StatusScheduleController.Factory
|
||||||
|
@Inject
|
||||||
|
lateinit var restHttpClient: RestHttpClient
|
||||||
|
|
||||||
|
protected val statusScheduleController: StatusScheduleController?
|
||||||
|
get() = statusScheduleControllerFactory.newInstance(context)
|
||||||
|
|
||||||
private val actionHelper = IBaseFragment.ActionHelper(this)
|
private val actionHelper = IBaseFragment.ActionHelper(this)
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.mariotaku.twidere.fragment
|
package org.mariotaku.twidere.fragment
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -44,6 +45,7 @@ import android.widget.ListView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import kotlinx.android.synthetic.main.fragment_drafts.*
|
import kotlinx.android.synthetic.main.fragment_drafts.*
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
|
import org.mariotaku.ktextension.setItemAvailability
|
||||||
import org.mariotaku.sqliteqb.library.Expression
|
import org.mariotaku.sqliteqb.library.Expression
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.TwidereConstants.*
|
import org.mariotaku.twidere.TwidereConstants.*
|
||||||
|
@ -53,10 +55,13 @@ import org.mariotaku.twidere.constant.IntentConstants
|
||||||
import org.mariotaku.twidere.constant.textSizeKey
|
import org.mariotaku.twidere.constant.textSizeKey
|
||||||
import org.mariotaku.twidere.extension.*
|
import org.mariotaku.twidere.extension.*
|
||||||
import org.mariotaku.twidere.model.Draft
|
import org.mariotaku.twidere.model.Draft
|
||||||
|
import org.mariotaku.twidere.model.analyzer.PurchaseFinished
|
||||||
import org.mariotaku.twidere.provider.TwidereDataStore.Drafts
|
import org.mariotaku.twidere.provider.TwidereDataStore.Drafts
|
||||||
import org.mariotaku.twidere.service.LengthyOperationsService
|
import org.mariotaku.twidere.service.LengthyOperationsService
|
||||||
|
import org.mariotaku.twidere.util.Analyzer
|
||||||
import org.mariotaku.twidere.util.AsyncTaskUtils
|
import org.mariotaku.twidere.util.AsyncTaskUtils
|
||||||
import org.mariotaku.twidere.util.deleteDrafts
|
import org.mariotaku.twidere.util.deleteDrafts
|
||||||
|
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
class DraftsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, OnItemClickListener, MultiChoiceModeListener {
|
class DraftsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, OnItemClickListener, MultiChoiceModeListener {
|
||||||
|
@ -65,6 +70,7 @@ class DraftsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, OnItemClickList
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
setHasOptionsMenu(true)
|
||||||
adapter = DraftsAdapter(activity, Glide.with(this)).apply {
|
adapter = DraftsAdapter(activity, Glide.with(this)).apply {
|
||||||
textSize = preferences[textSizeKey].toFloat()
|
textSize = preferences[textSizeKey].toFloat()
|
||||||
}
|
}
|
||||||
|
@ -85,6 +91,16 @@ class DraftsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, OnItemClickList
|
||||||
super.onStart()
|
super.onStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
when (requestCode) {
|
||||||
|
REQUEST_PURCHASE_EXTRA_FEATURES -> {
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
Analyzer.log(PurchaseFinished.create(data!!))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
return inflater.inflate(R.layout.fragment_drafts, container, false)
|
return inflater.inflate(R.layout.fragment_drafts, container, false)
|
||||||
}
|
}
|
||||||
|
@ -106,6 +122,32 @@ class DraftsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, OnItemClickList
|
||||||
adapter.swapCursor(null)
|
adapter.swapCursor(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
inflater.inflate(R.menu.menu_drafts, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||||
|
val scheduleSupported = extraFeaturesService.isSupported(ExtraFeaturesService.FEATURE_SCHEDULE_STATUS)
|
||||||
|
menu.setItemAvailability(R.id.scheduled_statuses, scheduleSupported)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.scheduled_statuses -> {
|
||||||
|
if (extraFeaturesService.isEnabled(ExtraFeaturesService.FEATURE_SCHEDULE_STATUS)) {
|
||||||
|
val scheduleManageIntent = statusScheduleController?.createManageIntent()
|
||||||
|
startActivity(scheduleManageIntent)
|
||||||
|
} else {
|
||||||
|
ExtraFeaturesIntroductionDialogFragment.show(childFragmentManager,
|
||||||
|
ExtraFeaturesService.FEATURE_SCHEDULE_STATUS,
|
||||||
|
requestCode = REQUEST_PURCHASE_EXTRA_FEATURES)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
mode.menuInflater.inflate(R.menu.action_multi_select_drafts, menu)
|
mode.menuInflater.inflate(R.menu.action_multi_select_drafts, menu)
|
||||||
listView.updateSelectionItems(menu)
|
listView.updateSelectionItems(menu)
|
||||||
|
|
|
@ -41,6 +41,10 @@ interface StatusScheduleController {
|
||||||
|
|
||||||
fun createSetScheduleIntent(): Intent
|
fun createSetScheduleIntent(): Intent
|
||||||
|
|
||||||
|
fun createSettingsIntent(): Intent?
|
||||||
|
|
||||||
|
fun createManageIntent(): Intent?
|
||||||
|
|
||||||
class ScheduleException : UpdateStatusTask.UpdateStatusException {
|
class ScheduleException : UpdateStatusTask.UpdateStatusException {
|
||||||
|
|
||||||
constructor() : super()
|
constructor() : super()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Twidere - Twitter client for Android
|
* Twidere - Twitter client for Android
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
|
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -30,14 +30,14 @@ import org.mariotaku.twidere.util.Utils.showErrorMessage
|
||||||
|
|
||||||
open class DefaultWebViewClient<out A : Activity>(val activity: A) : WebViewClient() {
|
open class DefaultWebViewClient<out A : Activity>(val activity: A) : WebViewClient() {
|
||||||
|
|
||||||
@Deprecated("")
|
@Suppress("OverridingDeprecatedMember")
|
||||||
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
|
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
|
||||||
|
val uri = Uri.parse(url)
|
||||||
try {
|
try {
|
||||||
activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
|
activity.startActivity(Intent(Intent.ACTION_VIEW, uri))
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
showErrorMessage(activity, null, e, false)
|
showErrorMessage(activity, null, e, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Twidere - Twitter client for Android
|
||||||
|
~
|
||||||
|
~ Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||||
|
~
|
||||||
|
~ 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 <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/scheduled_statuses"
|
||||||
|
android:icon="@drawable/ic_action_time"
|
||||||
|
android:title="@string/title_scheduled_statuses"
|
||||||
|
app:showAsAction="always"/>
|
||||||
|
</menu>
|
|
@ -1123,7 +1123,9 @@
|
||||||
<string name="title_block_user">Block <xliff:g id="name">%s</xliff:g></string>
|
<string name="title_block_user">Block <xliff:g id="name">%s</xliff:g></string>
|
||||||
<string name="title_blocked_users">Blocked users</string>
|
<string name="title_blocked_users">Blocked users</string>
|
||||||
<string name="title_browser_sign_in">Browser sign in</string>
|
<string name="title_browser_sign_in">Browser sign in</string>
|
||||||
|
<string name="title_buffer_queue_manager">Buffer queue</string>
|
||||||
<string name="title_buffer_set_schedule">Schedule with Buffer</string>
|
<string name="title_buffer_set_schedule">Schedule with Buffer</string>
|
||||||
|
<string name="title_buffer_settings">Buffer settings</string>
|
||||||
<string name="title_compose">Compose</string>
|
<string name="title_compose">Compose</string>
|
||||||
<string name="title_conversation">Conversation</string>
|
<string name="title_conversation">Conversation</string>
|
||||||
<string name="title_dialog_sync_connect_to">Connect to…</string>
|
<string name="title_dialog_sync_connect_to">Connect to…</string>
|
||||||
|
@ -1261,4 +1263,5 @@
|
||||||
<string name="users_statuses">User\'s tweets</string>
|
<string name="users_statuses">User\'s tweets</string>
|
||||||
|
|
||||||
<string name="vibration">Vibration</string>
|
<string name="vibration">Vibration</string>
|
||||||
|
<string name="title_scheduled_statuses">Scheduled tweets</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue