improved translation label

This commit is contained in:
Mariotaku Lee 2016-02-26 21:47:03 +08:00
parent 670d74132d
commit 1c3d9e803d
12 changed files with 132 additions and 18 deletions

View File

@ -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'])
}

View File

@ -44,6 +44,7 @@ public interface HelpResources {
* help/configuration | Twitter Developers</a>
* @since Twitter4J 2.2.3
*/
@GET("/help/configuration.json")
TwitterAPIConfiguration getAPIConfiguration() throws TwitterException;
/**

View File

@ -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 {
}

View File

@ -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<GNUSocialAccountExtra> CREATOR = new Creator<GNUSocialAccountExtra>() {
public GNUSocialAccountExtra createFromParcel(Parcel source) {
GNUSocialAccountExtra target = new GNUSocialAccountExtra();
GNUSocialAccountExtraParcelablePlease.readFromParcel(target, source);
return target;
}
public GNUSocialAccountExtra[] newArray(int size) {
return new GNUSocialAccountExtra[size];
}
};
}

View File

@ -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<ParcelableAccount> CREATOR = new Creator<ParcelableAccount>() {
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 +
'}';
}

View File

@ -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();
}

View File

@ -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<TwitterAccountExtra> CREATOR = new Creator<TwitterAccountExtra>() {
public TwitterAccountExtra createFromParcel(Parcel source) {
TwitterAccountExtra target = new TwitterAccountExtra();
TwitterAccountExtraParcelablePlease.readFromParcel(target, source);
return target;
}
public TwitterAccountExtra[] newArray(int size) {
return new TwitterAccountExtra[size];
}
};
}

View File

@ -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};
}

View File

@ -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')

View File

@ -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;

View File

@ -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);
}
}

View File

@ -748,4 +748,6 @@
<string name="quote_name_text">Quote <xliff:g id="name">%1$s</xliff:g>: <xliff:g id="text">%2$s</xliff:g></string>
<string name="unsupported_login_verification_type_name">Unsupported login verification type <xliff:g id="name">%1$s</xliff:g>, please report to support account.</string>
<string name="status_menu_title_format"><xliff:g id="name">%1$s</xliff:g>: <xliff:g id="text">%2$s</xliff:g></string>
<string name="translate_from_language">Translate from <xliff:g id="language">%s</xliff:g></string>
<string name="translation">Translation</string>
</resources>