From 7f063531b6ab9087be13f170e5861d3427e245c9 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Wed, 29 Apr 2015 00:54:42 +0800 Subject: [PATCH] updated library version --- build.gradle | 7 +--- gradle/wrapper/gradle-wrapper.properties | 2 +- twidere.component.common/build.gradle | 2 +- twidere/build.gradle | 7 ++-- .../support/CreateUserListDialogFragment.java | 2 +- .../fragment/support/UserListFragment.java | 2 +- .../support/UserProfileEditorFragment.java | 21 ++++++---- .../mariotaku/twidere/util/ThemeUtils.java | 13 ++---- .../TwitterValidatorMETLengthChecker.java | 42 +++++++++++++++++++ .../org/mariotaku/twidere/util/Utils.java | 16 ++++--- ...xml => dialog_user_list_detail_editor.xml} | 0 11 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 twidere/src/main/java/org/mariotaku/twidere/util/TwitterValidatorMETLengthChecker.java rename twidere/src/main/res/layout/{edit_user_list_detail.xml => dialog_user_list_detail_editor.xml} (100%) diff --git a/build.gradle b/build.gradle index c7fa1f2dd..fec61cb03 100644 --- a/build.gradle +++ b/build.gradle @@ -4,12 +4,10 @@ apply plugin: 'com.github.ben-manes.versions' buildscript { repositories { jcenter() - mavenCentral() - maven { url 'https://raw.github.com/xujiaao/mvn-repository/master/releases' } } dependencies { - classpath 'com.github.ben-manes:gradle-versions-plugin:0.8' - classpath 'com.android.tools.build:gradle:1.1.3' + classpath 'com.github.ben-manes:gradle-versions-plugin:0.9' + classpath 'com.android.tools.build:gradle:1.2.1' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -19,7 +17,6 @@ buildscript { allprojects { repositories { jcenter() - mavenCentral() } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 819314ff3..efe477082 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip diff --git a/twidere.component.common/build.gradle b/twidere.component.common/build.gradle index a2144a178..c942d2a26 100644 --- a/twidere.component.common/build.gradle +++ b/twidere.component.common/build.gradle @@ -39,7 +39,7 @@ android { dependencies { apt 'com.bluelinelabs:logansquare-compiler:1.0.6' compile 'com.bluelinelabs:logansquare:1.0.6' - compile 'com.android.support:support-annotations:22.1.0' + compile 'com.android.support:support-annotations:22.1.1' compile 'org.apache.commons:commons-lang3:3.4' compile project(':twidere.component.querybuilder') compile project(':twidere.component.twitter4j') diff --git a/twidere/build.gradle b/twidere/build.gradle index 00e09a98f..ca3145d5c 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -54,7 +54,6 @@ android { repositories { jcenter() - mavenCentral() maven { url 'https://repo.commonsware.com.s3.amazonaws.com' } maven { url 'https://github.com/suckgamony/RapidDecoder/raw/master/repository' } maven { url "https://jitpack.io" } @@ -79,11 +78,11 @@ dependencies { compile 'dnsjava:dnsjava:2.1.7' compile 'com.commonsware.cwac:merge:1.1.1' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.1.3' - compile 'com.rengwuxian.materialedittext:library:2.0.3' + compile 'com.rengwuxian.materialedittext:library:2.1.3' compile 'com.pnikosis:materialish-progress:1.5' compile 'com.squareup.okhttp:okhttp:2.3.0' - compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.5' - compile 'com.github.johnpersano:supertoasts:1.3.4@aar' + compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.6' + compile 'com.github.johnpersano:supertoasts:1.3.4.1@aar' compile 'com.github.mariotaku:MessageBubbleView:1.0' compile 'com.github.mariotaku:DragSortListView:0.6.1' compile 'com.github.mariotaku:SlidingMenu:1.3' diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CreateUserListDialogFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CreateUserListDialogFragment.java index d53a02da7..33524a17a 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CreateUserListDialogFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/CreateUserListDialogFragment.java @@ -69,7 +69,7 @@ public class CreateUserListDialogFragment extends BaseSupportDialogFragment impl mAccountId = bundle != null ? bundle.getLong(EXTRA_ACCOUNT_ID, -1) : -1; final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); - final View view = LayoutInflater.from(wrapped).inflate(R.layout.edit_user_list_detail, null); + final View view = LayoutInflater.from(wrapped).inflate(R.layout.dialog_user_list_detail_editor, null); builder.setView(view); mEditName = (EditText) view.findViewById(R.id.name); mEditDescription = (EditText) view.findViewById(R.id.description); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java index bf7db53f7..b4a2c86b0 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserListFragment.java @@ -486,7 +486,7 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList mIsPublic = bundle == null || bundle.getBoolean(EXTRA_IS_PUBLIC, true); final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); - final View view = LayoutInflater.from(wrapped).inflate(R.layout.edit_user_list_detail, null); + final View view = LayoutInflater.from(wrapped).inflate(R.layout.dialog_user_list_detail_editor, null); builder.setView(view); mEditName = (EditText) view.findViewById(R.id.name); mEditDescription = (EditText) view.findViewById(R.id.description); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserProfileEditorFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserProfileEditorFragment.java index d374ec6fc..b2a4f2c68 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserProfileEditorFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserProfileEditorFragment.java @@ -42,10 +42,12 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; +import com.rengwuxian.materialedittext.MaterialEditText; +import com.twitter.Validator; + import org.mariotaku.twidere.R; import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity; import org.mariotaku.twidere.activity.support.ImagePickerActivity; @@ -60,6 +62,7 @@ import org.mariotaku.twidere.util.AsyncTwitterWrapper.UpdateProfileImageTask; import org.mariotaku.twidere.util.KeyboardShortcutsHandler; import org.mariotaku.twidere.util.MediaLoaderWrapper; import org.mariotaku.twidere.util.ParseUtils; +import org.mariotaku.twidere.util.TwitterValidatorMETLengthChecker; import org.mariotaku.twidere.util.TwitterWrapper; import org.mariotaku.twidere.util.Utils; import org.mariotaku.twidere.view.ForegroundColorView; @@ -82,12 +85,13 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On private static final int REQUEST_UPLOAD_PROFILE_BANNER_IMAGE = 2; private static final int REQUEST_PICK_LINK_COLOR = 3; private static final int REQUEST_PICK_BACKGROUND_COLOR = 4; + private MediaLoaderWrapper mLazyImageLoader; private AsyncTaskManager mAsyncTaskManager; private AsyncTask mTask; private ImageView mProfileImageView; private ImageView mProfileBannerView; - private EditText mEditName, mEditDescription, mEditLocation, mEditUrl; + private MaterialEditText mEditName, mEditDescription, mEditLocation, mEditUrl; private View mProgressContainer, mEditProfileContent; private View mProfileImageCamera, mProfileImageGallery; private View mProfileBannerGallery, mProfileBannerRemove; @@ -223,11 +227,14 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On return; } - // setOverrideExitAniamtion(false); + final TwitterValidatorMETLengthChecker lengthChecker = new TwitterValidatorMETLengthChecker(new Validator()); mEditName.addTextChangedListener(this); mEditDescription.addTextChangedListener(this); mEditLocation.addTextChangedListener(this); mEditUrl.addTextChangedListener(this); + + mEditDescription.setLengthChecker(lengthChecker); + mProfileImageView.setOnClickListener(this); mProfileBannerView.setOnClickListener(this); mProfileImageCamera.setOnClickListener(this); @@ -276,10 +283,10 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On mEditProfileContent = view.findViewById(R.id.edit_profile_content); mProfileBannerView = (ImageView) view.findViewById(R.id.profile_banner); mProfileImageView = (ImageView) view.findViewById(R.id.profile_image); - mEditName = (EditText) view.findViewById(R.id.name); - mEditDescription = (EditText) view.findViewById(R.id.description); - mEditLocation = (EditText) view.findViewById(R.id.location); - mEditUrl = (EditText) view.findViewById(R.id.url); + mEditName = (MaterialEditText) view.findViewById(R.id.name); + mEditDescription = (MaterialEditText) view.findViewById(R.id.description); + mEditLocation = (MaterialEditText) view.findViewById(R.id.location); + mEditUrl = (MaterialEditText) view.findViewById(R.id.url); mProfileImageCamera = view.findViewById(R.id.profile_image_camera); mProfileImageGallery = view.findViewById(R.id.profile_image_gallery); mProfileBannerGallery = view.findViewById(R.id.profile_banner_gallery); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java index 71961abee..e5af7a8d9 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java @@ -1070,15 +1070,10 @@ public class ThemeUtils implements Constants { public static void setActionBarOverflowColor(ActionMenuPresenter presenter, int itemColor) { if (presenter == null) return; - View overflowView = null; - View view = (View) Utils.findFieldOfTypes(presenter, ActionMenuPresenter.class, ActionMenuView.ActionMenuChildView.class, View.class); - if (view == null) return; - final ActionMenuView.LayoutParams lp = (ActionMenuView.LayoutParams) view.getLayoutParams(); - if (lp.isOverflowButton) { - overflowView = view; - } - if (!(overflowView instanceof ImageView)) return; - ((ImageView) overflowView).setColorFilter(itemColor, Mode.SRC_ATOP); + final View view = (View) Utils.findFieldOfTypes(presenter, ActionMenuPresenter.class, + ActionMenuView.ActionMenuChildView.class, View.class); + if (!(view instanceof ImageView)) return; + ((ImageView) view).setColorFilter(itemColor, Mode.SRC_ATOP); } public static void setActionBarOverflowColor(ActionMenuView actionMenuView, int itemColor) { diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/TwitterValidatorMETLengthChecker.java b/twidere/src/main/java/org/mariotaku/twidere/util/TwitterValidatorMETLengthChecker.java new file mode 100644 index 000000000..1a08dab5a --- /dev/null +++ b/twidere/src/main/java/org/mariotaku/twidere/util/TwitterValidatorMETLengthChecker.java @@ -0,0 +1,42 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 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; + +import android.support.annotation.NonNull; + +import com.rengwuxian.materialedittext.validation.METLengthChecker; +import com.twitter.Validator; + +/** + * Created by mariotaku on 15/4/29. + */ +public class TwitterValidatorMETLengthChecker extends METLengthChecker { + private Validator mValidator; + + public TwitterValidatorMETLengthChecker(@NonNull Validator validator) { + mValidator = validator; + } + + @Override + public int getLength(CharSequence charSequence) { + return mValidator.getTweetLength(String.valueOf(charSequence)); + } + +} diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java index 190459fad..919087d50 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java @@ -4235,15 +4235,19 @@ public final class Utils implements Constants, TwitterConstants { public static Object findFieldOfTypes(T obj, Class cls, Class... checkTypes) { labelField: for (Field field : cls.getDeclaredFields()) { - final Class type = field.getType(); - View view = null; - for (Class checkType : checkTypes) { - if (!checkType.isAssignableFrom(type)) continue labelField; - } field.setAccessible(true); + final Object fieldObj; try { - return field.get(obj); + fieldObj = field.get(obj); } catch (Exception ignore) { + continue; + } + if (fieldObj != null) { + final Class type = fieldObj.getClass(); + for (Class checkType : checkTypes) { + if (!checkType.isAssignableFrom(type)) continue labelField; + } + return fieldObj; } } return null; diff --git a/twidere/src/main/res/layout/edit_user_list_detail.xml b/twidere/src/main/res/layout/dialog_user_list_detail_editor.xml similarity index 100% rename from twidere/src/main/res/layout/edit_user_list_detail.xml rename to twidere/src/main/res/layout/dialog_user_list_detail_editor.xml