From 17418bebf893b266e52ea515d9c7ce4855875cda Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sun, 26 Mar 2017 13:32:30 +0800 Subject: [PATCH] fixed profile image background shape in lollipop added unsupported message for send image to buffer --- .../microblog/library/twitter/Twitter.java | 3 +- .../library/twitter/api/MutesResources.java | 59 +++++++++++++++++++ .../twitter/api/PrivateMutesResources.java | 45 ++++++++++++++ .../library/twitter/api/UsersResources.java | 15 ----- .../library/twitter/model/MutedKeyword.java | 31 ++++++++++ .../twidere/view/ShapedImageView.java | 22 ++++--- .../twidere/task/twitter/UpdateStatusTask.kt | 6 +- .../util/schedule/StatusScheduleController.kt | 3 +- twidere/src/main/res/menu/menu_compose.xml | 4 +- twidere/src/main/res/values/strings.xml | 2 + 10 files changed, 156 insertions(+), 34 deletions(-) create mode 100644 twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/MutesResources.java create mode 100644 twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/PrivateMutesResources.java create mode 100644 twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/MutedKeyword.java diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/Twitter.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/Twitter.java index cf29e6803..6aad881cd 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/Twitter.java +++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/Twitter.java @@ -26,6 +26,7 @@ import org.mariotaku.microblog.library.twitter.api.FavoritesResources; import org.mariotaku.microblog.library.twitter.api.FriendsFollowersResources; import org.mariotaku.microblog.library.twitter.api.HelpResources; import org.mariotaku.microblog.library.twitter.api.ListResources; +import org.mariotaku.microblog.library.twitter.api.MutesResources; import org.mariotaku.microblog.library.twitter.api.PlacesGeoResources; import org.mariotaku.microblog.library.twitter.api.SavedSearchesResources; import org.mariotaku.microblog.library.twitter.api.SearchResources; @@ -41,5 +42,5 @@ import org.mariotaku.microblog.library.twitter.api.UsersResources; public interface Twitter extends SearchResources, TimelineResources, TweetResources, UsersResources, ListResources, DirectMessagesResources, FriendsFollowersResources, FavoritesResources, SpamReportingResources, SavedSearchesResources, TrendsResources, PlacesGeoResources, - HelpResources, TwitterPrivate { + HelpResources, MutesResources, TwitterPrivate { } diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/MutesResources.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/MutesResources.java new file mode 100644 index 000000000..7ff27e691 --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/MutesResources.java @@ -0,0 +1,59 @@ +/* + * Twidere - Twitter client for Android + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.mariotaku.microblog.library.twitter.api; + +import org.mariotaku.microblog.library.MicroBlogException; +import org.mariotaku.microblog.library.twitter.model.IDs; +import org.mariotaku.microblog.library.twitter.model.PageableResponseList; +import org.mariotaku.microblog.library.twitter.model.Paging; +import org.mariotaku.microblog.library.twitter.model.User; +import org.mariotaku.microblog.library.twitter.template.UserAnnotationTemplate; +import org.mariotaku.restfu.annotation.method.GET; +import org.mariotaku.restfu.annotation.method.POST; +import org.mariotaku.restfu.annotation.param.Param; +import org.mariotaku.restfu.annotation.param.Queries; +import org.mariotaku.restfu.annotation.param.Query; + +/** + * Created by mariotaku on 2017/3/26. + */ +@Queries(template = UserAnnotationTemplate.class) +public interface MutesResources { + + @POST("/mutes/users/create.json") + User createMute(@Param("user_id") String userId) throws MicroBlogException; + + @POST("/mutes/users/create.json") + User createMuteByScreenName(@Query("screen_name") String screenName) throws MicroBlogException; + + @POST("/mutes/users/destroy.json") + User destroyMute(@Param("user_id") String userId) throws MicroBlogException; + + @POST("/mutes/users/destroy.json") + User destroyMuteByScreenName(@Query("screen_name") String screenName) throws MicroBlogException; + + @GET("/mutes/users/ids.json") + IDs getMutesUsersIDs(Paging paging) throws MicroBlogException; + + @GET("/mutes/users/list.json") + PageableResponseList getMutesUsersList(@Query Paging paging) throws MicroBlogException; +} diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/PrivateMutesResources.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/PrivateMutesResources.java new file mode 100644 index 000000000..dfdaa3820 --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/PrivateMutesResources.java @@ -0,0 +1,45 @@ +/* + * Twidere - Twitter client for Android + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.mariotaku.microblog.library.twitter.api; + +import org.mariotaku.microblog.library.MicroBlogException; +import org.mariotaku.microblog.library.twitter.model.IDs; +import org.mariotaku.microblog.library.twitter.model.MutedKeyword; +import org.mariotaku.microblog.library.twitter.model.PageableResponseList; +import org.mariotaku.microblog.library.twitter.model.Paging; +import org.mariotaku.microblog.library.twitter.template.UserAnnotationTemplate; +import org.mariotaku.restfu.annotation.method.GET; +import org.mariotaku.restfu.annotation.param.Queries; +import org.mariotaku.restfu.annotation.param.Query; + +/** + * Created by mariotaku on 2017/3/26. + */ +@Queries(template = UserAnnotationTemplate.class) +public interface PrivateMutesResources { + + @GET("/mutes/keywords/ids.json") + IDs getMutesKeywordsIDs(Paging paging) throws MicroBlogException; + + @GET("/mutes/keywords/list.json") + PageableResponseList getMutesKeywordsList(@Query Paging paging) throws MicroBlogException; +} diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/UsersResources.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/UsersResources.java index c776a1800..72bd04e68 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/UsersResources.java +++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/api/UsersResources.java @@ -51,11 +51,6 @@ public interface UsersResources { @POST("/blocks/create.json") User createBlockByScreenName(@Query("screen_name") String screenName) throws MicroBlogException; - @POST("/mutes/users/create.json") - User createMute(@Param("user_id") String userId) throws MicroBlogException; - - @POST("/mutes/users/create.json") - User createMuteByScreenName(@Query("screen_name") String screenName) throws MicroBlogException; @POST("/blocks/destroy.json") User destroyBlock(@Param("user_id") String userId) throws MicroBlogException; @@ -63,11 +58,6 @@ public interface UsersResources { @POST("/blocks/destroy.json") User destroyBlockByScreenName(@Query("screen_name") String screenName) throws MicroBlogException; - @POST("/mutes/users/destroy.json") - User destroyMute(@Param("user_id") String userId) throws MicroBlogException; - - @POST("/mutes/users/destroy.json") - User destroyMuteByScreenName(@Query("screen_name") String screenName) throws MicroBlogException; @GET("/account/settings.json") AccountSettings getAccountSettings() throws MicroBlogException; @@ -80,11 +70,6 @@ public interface UsersResources { ResponseList getMemberSuggestions(String categorySlug) throws MicroBlogException; - @GET("/mutes/users/ids.json") - IDs getMutesUsersIDs(Paging paging) throws MicroBlogException; - - @GET("/mutes/users/list.json") - PageableResponseList getMutesUsersList(@Query Paging paging) throws MicroBlogException; ResponseList getSuggestedUserCategories() throws MicroBlogException; diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/MutedKeyword.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/MutedKeyword.java new file mode 100644 index 000000000..b92c76a0f --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/MutedKeyword.java @@ -0,0 +1,31 @@ +/* + * Twidere - Twitter client for Android + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.mariotaku.microblog.library.twitter.model; + +import com.bluelinelabs.logansquare.annotation.JsonObject; + +/** + * Created by mariotaku on 2017/3/26. + */ +@JsonObject +public class MutedKeyword { +} diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java b/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java index ccdde5b8c..e4fe6c377 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/ShapedImageView.java @@ -119,12 +119,8 @@ public class ShapedImageView extends AppCompatImageView { } public void setShapeBackground(final int color) { - if (OUTLINE_DRAW) { - setBackgroundColor(color); - } else { - mBackgroundPaint.setColor(color); - invalidate(); - } + mBackgroundPaint.setColor(color); + invalidate(); } public int[] getBorderColors() { @@ -193,15 +189,17 @@ public class ShapedImageView extends AppCompatImageView { mDestination.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); + final int contentLeft = getPaddingLeft(), contentTop = getPaddingTop(), + contentRight = getWidth() - getPaddingRight(), + contentBottom = getHeight() - getPaddingBottom(); + final int contentWidth = contentRight - contentLeft, + contentHeight = contentBottom - contentTop; + final int size = Math.min(contentWidth, contentHeight); + if (OUTLINE_DRAW) { + drawShape(canvas, mDestination, 0, mBackgroundPaint); super.onDraw(canvas); } else { - final int contentLeft = getPaddingLeft(), contentTop = getPaddingTop(), - contentRight = getWidth() - getPaddingRight(), - contentBottom = getHeight() - getPaddingBottom(); - final int contentWidth = contentRight - contentLeft, - contentHeight = contentBottom - contentTop; - final int size = Math.min(contentWidth, contentHeight); if (mShadowBitmap != null && mDrawShadow) { canvas.drawBitmap(mShadowBitmap, contentLeft + (contentWidth - size) / 2 - mShadowRadius, contentTop + (contentHeight - size) / 2 - mShadowRadius, null); 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 b869cdc7a..c4ffd3050 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("No scheduler found") } - controller.scheduleStatus(statusUpdate, pendingUpdate.overrideTexts, scheduleInfo) + controller.scheduleStatus(statusUpdate, pendingUpdate, scheduleInfo) return UpdateStatusResult(pendingUpdate.length, draftId) } @@ -499,9 +499,9 @@ class UpdateStatusTask( } } - internal class PendingStatusUpdate(val length: Int, defaultText: String) { + class PendingStatusUpdate internal constructor(val length: Int, defaultText: String) { - constructor(statusUpdate: ParcelableStatusUpdate) : this(statusUpdate.accounts.size, + internal constructor(statusUpdate: ParcelableStatusUpdate) : this(statusUpdate.accounts.size, statusUpdate.text) var sharedMediaIds: Array? = 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/StatusScheduleController.kt index 11a2aac7f..9e51648f7 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleController.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/schedule/StatusScheduleController.kt @@ -25,6 +25,7 @@ import android.support.annotation.WorkerThread import org.mariotaku.twidere.model.ParcelableStatusUpdate import org.mariotaku.twidere.model.schedule.ScheduleInfo import org.mariotaku.twidere.task.twitter.UpdateStatusTask +import org.mariotaku.twidere.task.twitter.UpdateStatusTask.PendingStatusUpdate import java.util.* /** @@ -35,7 +36,7 @@ interface StatusScheduleController { @WorkerThread @Throws(UpdateStatusTask.ScheduleException::class) - fun scheduleStatus(statusUpdate: ParcelableStatusUpdate, overrideTexts: Array, + fun scheduleStatus(statusUpdate: ParcelableStatusUpdate, pendingUpdate: PendingStatusUpdate, scheduleInfo: ScheduleInfo) fun createSetScheduleIntent(): Intent diff --git a/twidere/src/main/res/menu/menu_compose.xml b/twidere/src/main/res/menu/menu_compose.xml index f97438f3d..eb2c1e20a 100644 --- a/twidere/src/main/res/menu/menu_compose.xml +++ b/twidere/src/main/res/menu/menu_compose.xml @@ -7,13 +7,13 @@ diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml index 63130ba15..2022d4e29 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -1258,4 +1258,6 @@ User\'s tweets Vibration + Schedule media with Buffer is not yet supported + Schedule with Buffer