From 1c3d9e803d13f27ab3c8441c335cf3dda18c78f7 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Fri, 26 Feb 2016 21:47:03 +0800 Subject: [PATCH] improved translation label --- twidere.component.common/build.gradle | 4 +- .../api/twitter/api/HelpResources.java | 1 + .../twidere/model/AccountExtras.java | 9 ++++ .../twidere/model/GNUSocialAccountExtra.java | 51 +++++++++++++++++++ .../twidere/model/ParcelableAccount.java | 16 +++--- .../twidere/model/ParcelableCredentials.java | 7 ++- .../twidere/model/TwitterAccountExtra.java | 34 +++++++++++++ .../twidere/provider/TwidereDataStore.java | 15 ++++-- twidere/build.gradle | 4 +- .../java/org/mariotaku/twidere/Constants.java | 2 +- .../fragment/support/StatusFragment.java | 5 +- twidere/src/main/res/values/strings.xml | 2 + 12 files changed, 132 insertions(+), 18 deletions(-) create mode 100644 twidere.component.common/src/main/java/org/mariotaku/twidere/model/AccountExtras.java create mode 100644 twidere.component.common/src/main/java/org/mariotaku/twidere/model/GNUSocialAccountExtra.java create mode 100644 twidere.component.common/src/main/java/org/mariotaku/twidere/model/TwitterAccountExtra.java diff --git a/twidere.component.common/build.gradle b/twidere.component.common/build.gradle index 01e2b3976..3126c626d 100644 --- a/twidere.component.common/build.gradle +++ b/twidere.component.common/build.gradle @@ -38,11 +38,11 @@ android { dependencies { apt 'com.bluelinelabs:logansquare-compiler:1.3.4' apt 'com.hannesdorfmann.parcelableplease:processor:1.0.2' - apt 'com.github.mariotaku.ObjectCursor:processor:0.9.4' + apt 'com.github.mariotaku.ObjectCursor:processor:0.9.5' compile 'com.android.support:support-annotations:23.2.0' compile 'com.bluelinelabs:logansquare:1.3.4' compile 'com.github.mariotaku.RestFu:library:0.9.21' compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.2' - compile 'com.github.mariotaku.ObjectCursor:core:0.9.4' + compile 'com.github.mariotaku.ObjectCursor:core:0.9.5' compile fileTree(dir: 'libs', include: ['*.jar']) } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/HelpResources.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/HelpResources.java index b6ed0d129..544551f8a 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/HelpResources.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/HelpResources.java @@ -44,6 +44,7 @@ public interface HelpResources { * help/configuration | Twitter Developers * @since Twitter4J 2.2.3 */ + @GET("/help/configuration.json") TwitterAPIConfiguration getAPIConfiguration() throws TwitterException; /** diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/AccountExtras.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/AccountExtras.java new file mode 100644 index 000000000..9021e757c --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/AccountExtras.java @@ -0,0 +1,9 @@ +package org.mariotaku.twidere.model; + +import android.os.Parcelable; + +/** + * Created by mariotaku on 16/2/26. + */ +public interface AccountExtras extends Parcelable { +} diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/GNUSocialAccountExtra.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/GNUSocialAccountExtra.java new file mode 100644 index 000000000..28d5af70b --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/GNUSocialAccountExtra.java @@ -0,0 +1,51 @@ +package org.mariotaku.twidere.model; + +import android.os.Parcel; +import android.os.Parcelable; + +import com.bluelinelabs.logansquare.annotation.JsonField; +import com.bluelinelabs.logansquare.annotation.JsonObject; +import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; +import com.hannesdorfmann.parcelableplease.annotation.ParcelableThisPlease; + +/** + * Created by mariotaku on 16/2/26. + */ +@ParcelablePlease +@JsonObject +public class GNUSocialAccountExtra implements Parcelable, AccountExtras { + + @ParcelableThisPlease + @JsonField(name = "character_limit") + int characterLimit; + + public int getCharacterLimit() { + return characterLimit; + } + + public void setCharacterLimit(int characterLimit) { + this.characterLimit = characterLimit; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + GNUSocialAccountExtraParcelablePlease.writeToParcel(this, dest, flags); + } + + public static final Creator CREATOR = new Creator() { + public GNUSocialAccountExtra createFromParcel(Parcel source) { + GNUSocialAccountExtra target = new GNUSocialAccountExtra(); + GNUSocialAccountExtraParcelablePlease.readFromParcel(target, source); + return target; + } + + public GNUSocialAccountExtra[] newArray(int size) { + return new GNUSocialAccountExtra[size]; + } + }; +} diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableAccount.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableAccount.java index a33d08e30..f638c15a8 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableAccount.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableAccount.java @@ -21,6 +21,7 @@ package org.mariotaku.twidere.model; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.Nullable; import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonObject; @@ -70,6 +71,14 @@ public class ParcelableAccount implements Parcelable { @JsonField(name = "is_activated") @CursorField(Accounts.IS_ACTIVATED) public boolean is_activated; + + @Nullable + @ParcelableThisPlease + @JsonField(name = "account_type") + @CursorField(Accounts.ACCOUNT_TYPE) + public String account_type; + + public static final Creator CREATOR = new Creator() { public ParcelableAccount createFromParcel(Parcel source) { ParcelableAccount target = new ParcelableAccount(); @@ -86,12 +95,6 @@ public class ParcelableAccount implements Parcelable { ParcelableAccount() { } - public static ParcelableAccount dummyAccount() { - final ParcelableAccount account = new ParcelableAccount(); - account.is_dummy = true; - return account; - } - public static ParcelableCredentials dummyCredentials() { final ParcelableCredentials credentials = new ParcelableCredentials(); credentials.is_dummy = true; @@ -108,6 +111,7 @@ public class ParcelableAccount implements Parcelable { ", account_id=" + account_id + ", color=" + color + ", is_activated=" + is_activated + + ", account_type='" + account_type + '\'' + ", is_dummy=" + is_dummy + '}'; } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableCredentials.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableCredentials.java index fedfa21d7..bbd8074ae 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableCredentials.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableCredentials.java @@ -35,7 +35,7 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Accounts; * Created by mariotaku on 15/5/26. */ @JsonObject -@CursorObject +@CursorObject(valuesCreator = true) @ParcelablePlease public class ParcelableCredentials extends ParcelableAccount implements Parcelable { @@ -97,6 +97,10 @@ public class ParcelableCredentials extends ParcelableAccount implements Parcelab @CursorField(Accounts.NO_VERSION_SUFFIX) public boolean no_version_suffix; + @ParcelableThisPlease + @JsonField(name = "account_extras") + @CursorField(Accounts.ACCOUNT_EXTRAS) + public String account_extras; ParcelableCredentials() { } @@ -114,6 +118,7 @@ public class ParcelableCredentials extends ParcelableAccount implements Parcelab ", api_url_format='" + api_url_format + '\'' + ", same_oauth_signing_url=" + same_oauth_signing_url + ", no_version_suffix=" + no_version_suffix + + ", account_extras='" + account_extras + '\'' + "} " + super.toString(); } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/TwitterAccountExtra.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/TwitterAccountExtra.java new file mode 100644 index 000000000..72d57aa5b --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/TwitterAccountExtra.java @@ -0,0 +1,34 @@ +package org.mariotaku.twidere.model; + +import android.os.Parcel; +import android.os.Parcelable; + +import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease; + +/** + * Created by mariotaku on 16/2/26. + */ +@ParcelablePlease +public class TwitterAccountExtra implements Parcelable, AccountExtras { + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + TwitterAccountExtraParcelablePlease.writeToParcel(this, dest, flags); + } + + public static final Creator CREATOR = new Creator() { + public TwitterAccountExtra createFromParcel(Parcel source) { + TwitterAccountExtra target = new TwitterAccountExtra(); + TwitterAccountExtraParcelablePlease.readFromParcel(target, source); + return target; + } + + public TwitterAccountExtra[] newArray(int size) { + return new TwitterAccountExtra[size]; + } + }; +} diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java index b63022a45..74c7ea4da 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java @@ -147,18 +147,23 @@ public interface TwidereDataStore { String SAME_OAUTH_SIGNING_URL = "same_oauth_signing_url"; String NO_VERSION_SUFFIX = "no_version_suffix"; + String ACCOUNT_TYPE = "account_type"; + + String ACCOUNT_EXTRAS = "account_extras"; + String[] COLUMNS_NO_CREDENTIALS = {_ID, NAME, SCREEN_NAME, ACCOUNT_ID, PROFILE_IMAGE_URL, PROFILE_BANNER_URL, COLOR, IS_ACTIVATED, - SORT_POSITION}; + SORT_POSITION, ACCOUNT_TYPE}; String[] COLUMNS = {_ID, NAME, SCREEN_NAME, ACCOUNT_ID, AUTH_TYPE, BASIC_AUTH_USERNAME, BASIC_AUTH_PASSWORD, OAUTH_TOKEN, OAUTH_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET, API_URL_FORMAT, SAME_OAUTH_SIGNING_URL, NO_VERSION_SUFFIX, PROFILE_IMAGE_URL, PROFILE_BANNER_URL, COLOR, - IS_ACTIVATED, SORT_POSITION}; + IS_ACTIVATED, SORT_POSITION, ACCOUNT_TYPE, ACCOUNT_EXTRAS}; - String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, - TYPE_INT_UNIQUE, TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, - TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_BOOLEAN, TYPE_INT}; + String[] TYPES = {TYPE_PRIMARY_KEY, TYPE_TEXT_NOT_NULL, TYPE_TEXT_NOT_NULL, TYPE_INT_UNIQUE, + TYPE_INT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, TYPE_TEXT, + TYPE_BOOLEAN, TYPE_BOOLEAN, TYPE_TEXT, TYPE_TEXT, TYPE_INT, TYPE_BOOLEAN, TYPE_INT, + TYPE_TEXT, TYPE_TEXT}; } diff --git a/twidere/build.gradle b/twidere/build.gradle index a8d33b097..0ae2defcd 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -71,7 +71,7 @@ dependencies { androidTestApt 'com.bluelinelabs:logansquare-compiler:1.3.4' apt 'com.hannesdorfmann.parcelableplease:processor:1.0.2' apt 'com.google.dagger:dagger-compiler:2.0.2' - apt "com.github.mariotaku.ObjectCursor:processor:0.9.4" + apt "com.github.mariotaku.ObjectCursor:processor:0.9.5" compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:support-v13:23.2.0' @@ -111,7 +111,7 @@ dependencies { compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.10' compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.10' compile 'com.github.mariotaku.SQLiteQB:library:0.9.5' - compile 'com.github.mariotaku.ObjectCursor:core:0.9.4' + compile 'com.github.mariotaku.ObjectCursor:core:0.9.5' compile project(':twidere.component.common') compile project(':twidere.component.nyan') diff --git a/twidere/src/main/java/org/mariotaku/twidere/Constants.java b/twidere/src/main/java/org/mariotaku/twidere/Constants.java index c79c66b62..5e6b2fe1a 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/Constants.java +++ b/twidere/src/main/java/org/mariotaku/twidere/Constants.java @@ -33,7 +33,7 @@ import static org.mariotaku.twidere.annotation.PreferenceType.STRING; public interface Constants extends TwidereConstants { String DATABASES_NAME = "twidere.sqlite"; - int DATABASES_VERSION = 122; + int DATABASES_VERSION = 123; int MENU_GROUP_STATUS_EXTENSION = 10; int MENU_GROUP_COMPOSE_EXTENSION = 11; diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java index 3fe41a299..b1f2ae7ca 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java @@ -1148,12 +1148,15 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac translateLabelView.setText(R.string.unknown_language); translateContainer.setVisibility(View.GONE); } else { - translateLabelView.setText(new Locale(lang).getDisplayLanguage()); + final Locale locale = new Locale(lang); translateContainer.setVisibility(View.VISIBLE); if (translation != null) { + translateLabelView.setText(context.getString(R.string.translation)); translateResultView.setVisibility(View.VISIBLE); translateResultView.setText(translation.getText()); } else { + translateLabelView.setText(context.getString(R.string.translate_from_language, + locale.getDisplayLanguage())); translateResultView.setVisibility(View.GONE); } } diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml index e26d4c6db..eff291e56 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -748,4 +748,6 @@ Quote %1$s: %2$s Unsupported login verification type %1$s, please report to support account. %1$s: %2$s + Translate from %s + Translation \ No newline at end of file