updated lib version
This commit is contained in:
parent
b22d9dea7c
commit
19c180e586
|
@ -63,7 +63,7 @@ subprojects {
|
|||
TwitterText : '1.14.7',
|
||||
MediaViewerLibrary : '0.9.23',
|
||||
MultiValueSwitch : '0.9.8',
|
||||
PickNCrop : '0.9.27',
|
||||
PickNCrop : '0.9.28',
|
||||
AndroidGIFDrawable : '1.2.6',
|
||||
KPreferences : '0.9.8',
|
||||
Kovenant : '3.3.0',
|
||||
|
@ -73,7 +73,7 @@ subprojects {
|
|||
SQLiteQB : '0.9.18',
|
||||
Glide : '4.6.1',
|
||||
GlideOkHttp3 : '4.6.1',
|
||||
AndroidImageCropper : '2.4.6',
|
||||
AndroidImageCropper : '2.7.0',
|
||||
ExportablePreferences : '0.9.7',
|
||||
ACRA : '4.9.2',
|
||||
AbstractTask : '0.9.8',
|
||||
|
|
|
@ -563,16 +563,6 @@
|
|||
<activity
|
||||
android:name=".activity.content.FavoriteConfirmDialogActivity"
|
||||
android:theme="@style/Theme.Twidere.NoDisplay"/>
|
||||
<activity
|
||||
android:name=".activity.presentation.ToggleRefreshActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/action_refresh_launch_presentations"
|
||||
android:theme="@style/Theme.Twidere.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="org.mariotaku.twidere.HIDDEN_SETTINGS_ENTRY"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.feedback.FeedbackActivity"
|
||||
android:exported="false"
|
||||
|
|
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.model.presentation;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
|
||||
import org.mariotaku.commons.logansquare.StringBasedListTypeConverter;
|
||||
import org.mariotaku.twidere.model.CronExpression;
|
||||
import org.mariotaku.twidere.model.util.CronExpressionConverter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/8/16.
|
||||
*/
|
||||
@JsonObject
|
||||
public class LaunchPresentation {
|
||||
|
||||
@JsonField(name = "images")
|
||||
List<Image> images;
|
||||
|
||||
@JsonField(name = "locales", typeConverter = Locale.ListConverter.class)
|
||||
List<Locale> locales;
|
||||
|
||||
@JsonField(name = "url")
|
||||
String url;
|
||||
|
||||
@JsonField(name = "schedule")
|
||||
Schedule schedule;
|
||||
|
||||
@JsonField(name = "is_promotion")
|
||||
boolean isPromotion;
|
||||
|
||||
public List<Image> getImages() {
|
||||
return images;
|
||||
}
|
||||
|
||||
public List<Locale> getLocales() {
|
||||
return locales;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public Schedule getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public boolean isPromotion() {
|
||||
return isPromotion;
|
||||
}
|
||||
|
||||
@JsonObject
|
||||
public static class Schedule {
|
||||
@JsonField(name = "cron", typeConverter = CronExpressionConverter.class)
|
||||
CronExpression cron;
|
||||
@JsonField(name = "local")
|
||||
boolean local;
|
||||
|
||||
public CronExpression getCron() {
|
||||
return cron;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Locale {
|
||||
@NonNull
|
||||
final String language;
|
||||
@Nullable
|
||||
final String country;
|
||||
|
||||
public Locale(@NonNull String language, @Nullable String country) {
|
||||
this.language = language;
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (country == null) return language;
|
||||
return language + "-" + country;
|
||||
}
|
||||
|
||||
public static Locale valueOf(@NonNull String str) {
|
||||
int dashIndex = str.indexOf('-');
|
||||
if (dashIndex == -1) return new Locale(str, null);
|
||||
return new Locale(str.substring(0, dashIndex),
|
||||
str.substring(dashIndex + 1, str.length()));
|
||||
}
|
||||
|
||||
static class ListConverter extends StringBasedListTypeConverter<Locale> {
|
||||
|
||||
@Override
|
||||
public Locale getItemFromString(String str) {
|
||||
if (str == null) return null;
|
||||
return Locale.valueOf(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertItemToString(Locale item) {
|
||||
if (item == null) return null;
|
||||
return item.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsonObject
|
||||
public static class Image {
|
||||
@JsonField(name = "url")
|
||||
String url;
|
||||
|
||||
@JsonField(name = "density")
|
||||
float density;
|
||||
|
||||
@JsonField(name = "width")
|
||||
int width;
|
||||
|
||||
@JsonField(name = "height")
|
||||
int height;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public float getDensity() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -171,7 +171,7 @@ class ImageCropperActivity : BaseActivity(), CropImageView.OnSetImageUriComplete
|
|||
private fun getResultIntent(uri: Uri?, error: Exception?, sampleSize: Int): Intent {
|
||||
val result = CropImage.ActivityResult(cropImageView.imageUri, uri, error,
|
||||
cropImageView.cropPoints, cropImageView.cropRect, cropImageView.rotatedDegrees,
|
||||
sampleSize)
|
||||
cropImageView.wholeImageRect, sampleSize)
|
||||
val intent = Intent()
|
||||
intent.putExtra(CropImage.CROP_IMAGE_EXTRA_RESULT, result)
|
||||
return intent
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.activity.presentation
|
||||
|
||||
import android.os.Bundle
|
||||
import org.mariotaku.twidere.activity.BaseActivity
|
||||
import org.mariotaku.twidere.util.TaskServiceRunner
|
||||
|
||||
class ToggleRefreshActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
taskServiceRunner.promise(TaskServiceRunner.ACTION_REFRESH_LAUNCH_PRESENTATIONS)
|
||||
finish()
|
||||
}
|
||||
}
|
|
@ -39,7 +39,6 @@ import org.mariotaku.twidere.fragment.media.VideoPageFragment
|
|||
import org.mariotaku.twidere.fragment.preference.ThemedPreferenceDialogFragmentCompat
|
||||
import org.mariotaku.twidere.loader.CacheUserSearchLoader
|
||||
import org.mariotaku.twidere.loader.DefaultAPIConfigLoader
|
||||
import org.mariotaku.twidere.loader.ParcelableStatusLoader
|
||||
import org.mariotaku.twidere.loader.statuses.AbsRequestStatusesLoader
|
||||
import org.mariotaku.twidere.loader.userlists.BaseUserListsLoader
|
||||
import org.mariotaku.twidere.preference.AccountsListPreference
|
||||
|
@ -105,8 +104,6 @@ interface GeneralComponent {
|
|||
|
||||
fun inject(preference: KeyboardShortcutPreference)
|
||||
|
||||
fun inject(loader: ParcelableStatusLoader)
|
||||
|
||||
fun inject(loader: DefaultAPIConfigLoader)
|
||||
|
||||
fun inject(service: BaseIntentService)
|
||||
|
@ -135,8 +132,6 @@ interface GeneralComponent {
|
|||
|
||||
fun inject(promises: DefaultFeaturesPromises)
|
||||
|
||||
fun inject(promises: LaunchPresentationsPromises)
|
||||
|
||||
fun inject(promise: UpdateStatusPromise)
|
||||
|
||||
fun inject(promise: GetTrendsPromise)
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension.model
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v4.os.LocaleListCompat
|
||||
import org.mariotaku.ktextension.localesCompat
|
||||
import org.mariotaku.twidere.model.presentation.LaunchPresentation
|
||||
import java.util.*
|
||||
|
||||
fun LaunchPresentation.shouldShow(context: Context): Boolean {
|
||||
// Check language
|
||||
val userLocales = context.resources.configuration.localesCompat
|
||||
if (locales != null && locales.none { it.matchesAny(userLocales) }) {
|
||||
return false
|
||||
}
|
||||
// Check date/time
|
||||
val date = Date()
|
||||
if (schedule != null && !schedule.matches(date)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun LaunchPresentation.Schedule.matches(date: Date): Boolean {
|
||||
val cal = Calendar.getInstance()
|
||||
cal.time = date
|
||||
return cron.matches(cal)
|
||||
}
|
||||
|
||||
|
||||
fun LaunchPresentation.Locale.matches(locale: Locale): Boolean {
|
||||
if (language != locale.language) return false
|
||||
if (country == null) {
|
||||
return locale.country.isNullOrEmpty()
|
||||
}
|
||||
return country == locale.country
|
||||
}
|
||||
|
||||
fun LaunchPresentation.Locale.matchesAny(locales: LocaleListCompat): Boolean {
|
||||
return (0 until locales.size()).any { matches(locales[it]) }
|
||||
}
|
||||
|
||||
fun LaunchPresentation.Image.displayingScore(viewDensity: Float, viewWidth: Int,
|
||||
viewHeight: Int): Int {
|
||||
if (viewWidth == 0 || viewHeight == 0) return 0
|
||||
var score = 0
|
||||
// Compute size scores
|
||||
score += when {
|
||||
viewWidth == width && viewHeight <= height -> 100
|
||||
viewHeight == height && viewWidth <= width -> 100
|
||||
viewWidth < width && viewHeight < height -> {
|
||||
val diffW = (width / viewWidth.toFloat() - 1).coerceAtMost(0.5f)
|
||||
val diffH = (height / viewHeight.toFloat() - 1).coerceAtMost(0.5f)
|
||||
100 - Math.round(diffH * 100) - Math.round(diffW * 100)
|
||||
}
|
||||
else -> {
|
||||
val diffW = (width / viewWidth.toFloat() - 1).coerceAtMost(0.5f)
|
||||
val diffH = (height / viewHeight.toFloat() - 1).coerceAtMost(0.5f)
|
||||
100 - Math.round(diffH * 50) - Math.round(diffW * 50)
|
||||
}
|
||||
}
|
||||
if (this.density != 0f) {
|
||||
score += 100 - Math.round(Math.abs(this.density / viewDensity - 1).coerceAtMost(1f))
|
||||
}
|
||||
return score
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2014 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/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.loader
|
||||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.support.v4.content.FixedAsyncTaskLoader
|
||||
import org.mariotaku.ktextension.set
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.model.microblog.ErrorInfo
|
||||
import org.mariotaku.restfu.http.RestHttpClient
|
||||
import org.mariotaku.twidere.constant.IntentConstants
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT
|
||||
import org.mariotaku.twidere.dagger.component.GeneralComponent
|
||||
import org.mariotaku.twidere.exception.AccountNotFoundException
|
||||
import org.mariotaku.twidere.extension.getDetails
|
||||
import org.mariotaku.twidere.extension.model.updateExtraInformation
|
||||
import org.mariotaku.twidere.model.ParcelableStatus
|
||||
import org.mariotaku.twidere.model.SingleResponse
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.util.DataStoreUtils
|
||||
import org.mariotaku.twidere.util.deleteActivityStatus
|
||||
import org.mariotaku.twidere.util.deleteStatus
|
||||
import javax.inject.Inject
|
||||
|
||||
class ParcelableStatusLoader(
|
||||
context: Context,
|
||||
private val omitIntentExtra: Boolean,
|
||||
private val extras: Bundle?,
|
||||
private val accountKey: UserKey?,
|
||||
private val statusId: String?
|
||||
) : FixedAsyncTaskLoader<SingleResponse<ParcelableStatus>>(context) {
|
||||
|
||||
@Inject
|
||||
internal lateinit var restHttpClient: RestHttpClient
|
||||
|
||||
init {
|
||||
GeneralComponent.get(context).inject(this)
|
||||
}
|
||||
|
||||
override fun loadInBackground(): SingleResponse<ParcelableStatus> {
|
||||
if (accountKey == null || statusId == null) {
|
||||
return SingleResponse(IllegalArgumentException())
|
||||
}
|
||||
val details = AccountManager.get(context).getDetails(accountKey, true)
|
||||
if (!omitIntentExtra && extras != null) {
|
||||
val cache: ParcelableStatus? = extras.getParcelable(IntentConstants.EXTRA_STATUS)
|
||||
if (cache != null) {
|
||||
val response = SingleResponse(cache)
|
||||
response.extras[EXTRA_ACCOUNT] = details
|
||||
return response
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (details == null) throw AccountNotFoundException()
|
||||
val status = DataStoreUtils.findStatus(context, accountKey, statusId)
|
||||
status.updateExtraInformation(details)
|
||||
val response = SingleResponse(status)
|
||||
response.extras[EXTRA_ACCOUNT] = details
|
||||
return response
|
||||
} catch (e: MicroBlogException) {
|
||||
if (e.errorCode == ErrorInfo.STATUS_NOT_FOUND) {
|
||||
// Delete all deleted status
|
||||
val cr = context.contentResolver
|
||||
cr.deleteStatus(accountKey, statusId, null)
|
||||
cr.deleteActivityStatus(accountKey, statusId, null)
|
||||
}
|
||||
return SingleResponse(e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onStartLoading() {
|
||||
forceLoad()
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.promise
|
||||
|
||||
import android.content.Context
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.task
|
||||
import org.mariotaku.restfu.annotation.method.GET
|
||||
import org.mariotaku.restfu.http.HttpRequest
|
||||
import org.mariotaku.restfu.http.RestHttpClient
|
||||
import org.mariotaku.twidere.BuildConfig
|
||||
import org.mariotaku.twidere.dagger.component.GeneralComponent
|
||||
import org.mariotaku.twidere.extension.get
|
||||
import org.mariotaku.twidere.model.presentation.LaunchPresentation
|
||||
import org.mariotaku.twidere.util.JsonSerializer
|
||||
import org.mariotaku.twidere.util.cache.JsonCache
|
||||
import org.mariotaku.twidere.util.lang.ApplicationContextSingletonHolder
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
class LaunchPresentationsPromises private constructor(context: Context) {
|
||||
|
||||
@Inject
|
||||
lateinit var restHttpClient: RestHttpClient
|
||||
@Inject
|
||||
lateinit var jsonCache: JsonCache
|
||||
|
||||
init {
|
||||
GeneralComponent.get(context).inject(this)
|
||||
}
|
||||
|
||||
fun promise(): Promise<Boolean, Exception> = task {
|
||||
val builder = HttpRequest.Builder()
|
||||
builder.method(GET.METHOD)
|
||||
if (BuildConfig.DEBUG) {
|
||||
builder.url("https://twidere.mariotaku.org/assets/data/launch_presentations_debug.json")
|
||||
} else {
|
||||
builder.url("https://twidere.mariotaku.org/assets/data/launch_presentations.json")
|
||||
}
|
||||
val request = builder.build()
|
||||
val presentations = restHttpClient.newCall(request).execute().use {
|
||||
if (!it.isSuccessful) return@use null
|
||||
return@use JsonSerializer.parseList(it.body.stream(), LaunchPresentation::class.java)
|
||||
}
|
||||
jsonCache.saveList(JSON_CACHE_KEY, presentations, LaunchPresentation::class.java)
|
||||
return@task true
|
||||
}
|
||||
|
||||
companion object : ApplicationContextSingletonHolder<LaunchPresentationsPromises>(::LaunchPresentationsPromises) {
|
||||
const val JSON_CACHE_KEY = "launch_presentations"
|
||||
}
|
||||
}
|
||||
|
|
@ -78,6 +78,7 @@ class JobTaskService : JobService() {
|
|||
const val JOB_ID_REFRESH_NOTIFICATIONS = 2
|
||||
const val JOB_ID_REFRESH_DIRECT_MESSAGES = 3
|
||||
const val JOB_ID_REFRESH_FILTERS_SUBSCRIPTIONS = 19
|
||||
@Deprecated("Removed")
|
||||
const val JOB_ID_REFRESH_LAUNCH_PRESENTATIONS = 18
|
||||
const val JOB_ID_SYNC_DRAFTS = 21
|
||||
const val JOB_ID_SYNC_FILTERS = 22
|
||||
|
@ -102,7 +103,6 @@ class JobTaskService : JobService() {
|
|||
JOB_ID_REFRESH_NOTIFICATIONS -> TaskServiceRunner.ACTION_REFRESH_NOTIFICATIONS
|
||||
JOB_ID_REFRESH_DIRECT_MESSAGES -> TaskServiceRunner.ACTION_REFRESH_DIRECT_MESSAGES
|
||||
JOB_ID_REFRESH_FILTERS_SUBSCRIPTIONS -> TaskServiceRunner.ACTION_REFRESH_FILTERS_SUBSCRIPTIONS
|
||||
JOB_ID_REFRESH_LAUNCH_PRESENTATIONS -> TaskServiceRunner.ACTION_REFRESH_LAUNCH_PRESENTATIONS
|
||||
JOB_ID_SYNC_DRAFTS -> TaskServiceRunner.ACTION_SYNC_DRAFTS
|
||||
JOB_ID_SYNC_FILTERS -> TaskServiceRunner.ACTION_SYNC_FILTERS
|
||||
JOB_ID_SYNC_USER_NICKNAMES -> TaskServiceRunner.ACTION_SYNC_USER_NICKNAMES
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.mariotaku.twidere.annotation.AutoRefreshType
|
|||
import org.mariotaku.twidere.constant.refreshIntervalKey
|
||||
import org.mariotaku.twidere.service.JobTaskService
|
||||
import org.mariotaku.twidere.service.JobTaskService.Companion.JOB_ID_REFRESH_FILTERS_SUBSCRIPTIONS
|
||||
import org.mariotaku.twidere.service.JobTaskService.Companion.JOB_ID_REFRESH_LAUNCH_PRESENTATIONS
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
|
@ -53,9 +52,6 @@ class JobSchedulerRefreshTaskController(
|
|||
if (allJobs.none { job -> job.id == JOB_ID_REFRESH_FILTERS_SUBSCRIPTIONS }) {
|
||||
scheduleJob(JOB_ID_REFRESH_FILTERS_SUBSCRIPTIONS, TimeUnit.HOURS.toMillis(4))
|
||||
}
|
||||
if (allJobs.none { job -> job.id == JOB_ID_REFRESH_LAUNCH_PRESENTATIONS }) {
|
||||
scheduleJob(JOB_ID_REFRESH_LAUNCH_PRESENTATIONS, TimeUnit.HOURS.toMillis(6))
|
||||
}
|
||||
}
|
||||
|
||||
override fun schedule(@AutoRefreshType type: String) {
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.mariotaku.twidere.constant.refreshIntervalKey
|
|||
import org.mariotaku.twidere.service.JobTaskService.Companion.JOB_IDS_REFRESH
|
||||
import org.mariotaku.twidere.service.LegacyTaskService
|
||||
import org.mariotaku.twidere.util.TaskServiceRunner.Companion.ACTION_REFRESH_FILTERS_SUBSCRIPTIONS
|
||||
import org.mariotaku.twidere.util.TaskServiceRunner.Companion.ACTION_REFRESH_LAUNCH_PRESENTATIONS
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class LegacyRefreshTaskController(
|
||||
|
@ -58,7 +57,6 @@ class LegacyRefreshTaskController(
|
|||
override fun appStarted() {
|
||||
rescheduleAll()
|
||||
rescheduleFiltersSubscriptionsRefresh()
|
||||
rescheduleLaunchPresentationsRefresh()
|
||||
}
|
||||
|
||||
override fun rescheduleAll() {
|
||||
|
@ -91,15 +89,6 @@ class LegacyRefreshTaskController(
|
|||
PendingIntent.getService(context, 0, intent, 0))
|
||||
}
|
||||
|
||||
private fun rescheduleLaunchPresentationsRefresh() {
|
||||
val interval = TimeUnit.HOURS.toMillis(6)
|
||||
val triggerAt = SystemClock.elapsedRealtime() + interval
|
||||
val intent = Intent(context, LegacyTaskService::class.java)
|
||||
intent.action = ACTION_REFRESH_LAUNCH_PRESENTATIONS
|
||||
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAt, interval,
|
||||
PendingIntent.getService(context, 0, intent, 0))
|
||||
}
|
||||
|
||||
companion object {
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
fun removeAllJobs(context: Context, jobIds: IntArray) {
|
||||
|
|
|
@ -11,14 +11,12 @@ import org.mariotaku.ktextension.mapToArray
|
|||
import org.mariotaku.ktextension.toNulls
|
||||
import org.mariotaku.twidere.constant.IntentConstants.INTENT_PACKAGE_PREFIX
|
||||
import org.mariotaku.twidere.constant.stopAutoRefreshWhenBatteryLowKey
|
||||
import org.mariotaku.twidere.extension.get
|
||||
import org.mariotaku.twidere.extension.promise
|
||||
import org.mariotaku.twidere.model.AccountPreferences
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.pagination.Pagination
|
||||
import org.mariotaku.twidere.model.pagination.SinceMaxPagination
|
||||
import org.mariotaku.twidere.model.refresh.ContentRefreshParam
|
||||
import org.mariotaku.twidere.promise.LaunchPresentationsPromises
|
||||
import org.mariotaku.twidere.promise.RefreshFiltersSubscriptionsPromise
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Activities
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses
|
||||
|
@ -41,9 +39,6 @@ class TaskServiceRunner(
|
|||
ACTION_REFRESH_DIRECT_MESSAGES -> {
|
||||
return createRefreshTask(action)?.promise()
|
||||
}
|
||||
ACTION_REFRESH_LAUNCH_PRESENTATIONS -> {
|
||||
LaunchPresentationsPromises.get(context).promise()
|
||||
}
|
||||
ACTION_REFRESH_FILTERS_SUBSCRIPTIONS -> {
|
||||
RefreshFiltersSubscriptionsPromise.get(context).promise()
|
||||
}
|
||||
|
@ -99,8 +94,8 @@ class TaskServiceRunner(
|
|||
}
|
||||
|
||||
@StringDef(ACTION_REFRESH_HOME_TIMELINE, ACTION_REFRESH_NOTIFICATIONS, ACTION_REFRESH_DIRECT_MESSAGES,
|
||||
ACTION_REFRESH_FILTERS_SUBSCRIPTIONS, ACTION_REFRESH_LAUNCH_PRESENTATIONS,
|
||||
ACTION_SYNC_DRAFTS, ACTION_SYNC_FILTERS, ACTION_SYNC_USER_NICKNAMES, ACTION_SYNC_USER_COLORS)
|
||||
ACTION_REFRESH_FILTERS_SUBSCRIPTIONS, ACTION_SYNC_DRAFTS, ACTION_SYNC_FILTERS,
|
||||
ACTION_SYNC_USER_NICKNAMES, ACTION_SYNC_USER_COLORS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class Action
|
||||
|
||||
|
@ -136,8 +131,6 @@ class TaskServiceRunner(
|
|||
@Action
|
||||
const val ACTION_REFRESH_FILTERS_SUBSCRIPTIONS = INTENT_PACKAGE_PREFIX + "REFRESH_FILTERS_SUBSCRIPTIONS"
|
||||
@Action
|
||||
const val ACTION_REFRESH_LAUNCH_PRESENTATIONS = INTENT_PACKAGE_PREFIX + "REFRESH_LAUNCH_PRESENTATIONS"
|
||||
@Action
|
||||
const val ACTION_SYNC_DRAFTS = INTENT_PACKAGE_PREFIX + "SYNC_DRAFTS"
|
||||
@Action
|
||||
const val ACTION_SYNC_FILTERS = INTENT_PACKAGE_PREFIX + "SYNC_FILTERS"
|
||||
|
|
Loading…
Reference in New Issue