Merge branch 'feature/translate-button'
This commit is contained in:
commit
ac5d11159f
|
@ -84,7 +84,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
||||||
private final LinkedTextView text;
|
private final LinkedTextView text;
|
||||||
private final LinearLayout spoilerHeader;
|
private final LinearLayout spoilerHeader;
|
||||||
private final TextView spoilerTitle, spoilerTitleInline, translateInfo;
|
private final TextView spoilerTitle, spoilerTitleInline, translateInfo;
|
||||||
private final View spoilerOverlay, borderTop, borderBottom, textWrap, translateWrap;
|
private final View spoilerOverlay, borderTop, borderBottom, textWrap, translateWrap, translateProgress;
|
||||||
private final Drawable backgroundColor, borderColor;
|
private final Drawable backgroundColor, borderColor;
|
||||||
private final Button translateButton;
|
private final Button translateButton;
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
||||||
translateWrap=findViewById(R.id.translate_wrap);
|
translateWrap=findViewById(R.id.translate_wrap);
|
||||||
translateButton=findViewById(R.id.translate_btn);
|
translateButton=findViewById(R.id.translate_btn);
|
||||||
translateInfo=findViewById(R.id.translate_info);
|
translateInfo=findViewById(R.id.translate_info);
|
||||||
|
translateProgress=findViewById(R.id.translate_progress);
|
||||||
itemView.setOnClickListener(v->item.parentFragment.onRevealSpoilerClick(this));
|
itemView.setOnClickListener(v->item.parentFragment.onRevealSpoilerClick(this));
|
||||||
|
|
||||||
TypedValue outValue=new TypedValue();
|
TypedValue outValue=new TypedValue();
|
||||||
|
@ -153,16 +154,22 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
||||||
translateInfo.setText(item.translated ? itemView.getResources().getString(R.string.sk_translated_using, item.translation.provider) : "");
|
translateInfo.setText(item.translated ? itemView.getResources().getString(R.string.sk_translated_using, item.translation.provider) : "");
|
||||||
translateButton.setOnClickListener(v->{
|
translateButton.setOnClickListener(v->{
|
||||||
if (item.translation == null) {
|
if (item.translation == null) {
|
||||||
|
translateProgress.setVisibility(View.VISIBLE);
|
||||||
|
translateButton.setClickable(false);
|
||||||
new TranslateStatus(item.status.id).setCallback(new Callback<>() {
|
new TranslateStatus(item.status.id).setCallback(new Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(TranslatedStatus translatedStatus) {
|
public void onSuccess(TranslatedStatus translatedStatus) {
|
||||||
item.translation = translatedStatus;
|
item.translation = translatedStatus;
|
||||||
item.translated = true;
|
item.translated = true;
|
||||||
|
translateProgress.setVisibility(View.GONE);
|
||||||
|
translateButton.setClickable(true);
|
||||||
rebind();
|
rebind();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(ErrorResponse error) {
|
public void onError(ErrorResponse error) {
|
||||||
|
translateProgress.setVisibility(View.GONE);
|
||||||
|
translateButton.setClickable(true);
|
||||||
error.showToast(itemView.getContext());
|
error.showToast(itemView.getContext());
|
||||||
}
|
}
|
||||||
}).exec(item.parentFragment.getAccountID());
|
}).exec(item.parentFragment.getAccountID());
|
||||||
|
|
|
@ -57,16 +57,33 @@
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<Button
|
<FrameLayout
|
||||||
style="?secondaryButtonStyle"
|
android:id="@+id/action_btn_wrap"
|
||||||
android:background="?android:selectableItemBackground"
|
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:id="@+id/translate_btn"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="8dp"
|
android:layout_marginHorizontal="8dp"
|
||||||
android:paddingHorizontal="8dp"
|
android:clipToPadding="false">
|
||||||
android:text="Translate"/>
|
<org.joinmastodon.android.ui.views.ProgressBarButton
|
||||||
|
android:id="@+id/translate_btn"
|
||||||
|
style="?secondaryButtonStyle"
|
||||||
|
android:background="?android:selectableItemBackground"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="8dp"
|
||||||
|
tools:text="@string/translate_post"/>
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/translate_progress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:indeterminate="true"
|
||||||
|
style="?android:progressBarStyleSmall"
|
||||||
|
android:elevation="10dp"
|
||||||
|
android:outlineProvider="none"
|
||||||
|
android:indeterminateTint="?android:textColorPrimary"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/translate_info"
|
android:id="@+id/translate_info"
|
||||||
|
|
Loading…
Reference in New Issue