Allows to force translation button to be displayed

This commit is contained in:
tom79 2017-09-23 08:16:32 +02:00
parent 85b64fbcbd
commit ed179d54e7
5 changed files with 28 additions and 1 deletions

View File

@ -287,6 +287,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.new_element.setVisibility(View.INVISIBLE);
int iconSizePercent = sharedpreferences.getInt(Helper.SET_ICON_SIZE, 130);
int textSizePercent = sharedpreferences.getInt(Helper.SET_TEXT_SIZE, 110);
boolean trans_forced = sharedpreferences.getBoolean(Helper.SET_TRANS_FORCED, false);
holder.status_more.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_more.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_privacy.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
@ -486,7 +487,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_action_container.setVisibility(View.GONE);
}else {
holder.status_action_container.setVisibility(View.VISIBLE);
if( translator != Helper.TRANS_NONE && currentLocale != null && status.getLanguage() != null && !status.getLanguage().trim().equals(currentLocale)){
if( trans_forced || (translator != Helper.TRANS_NONE && currentLocale != null && status.getLanguage() != null && !status.getLanguage().trim().equals(currentLocale))){
holder.status_translate.setVisibility(View.VISIBLE);
}else {
holder.status_translate.setVisibility(View.GONE);

View File

@ -472,6 +472,18 @@ public class SettingsFragment extends Fragment {
}
});
boolean trans_forced = sharedpreferences.getBoolean(Helper.SET_TRANS_FORCED, false);
final CheckBox set_trans_forced = (CheckBox) rootView.findViewById(R.id.set_trans_forced);
set_trans_forced.setChecked(trans_forced);
set_trans_forced.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_TRANS_FORCED, set_trans_forced.isChecked());
editor.apply();
}
});
return rootView;
}

View File

@ -229,6 +229,7 @@ public class Helper {
public static final int TRANS_GOOGLE = 1;
public static final int TRANS_NONE = 2;
public static final String SET_TRANS_FORCED = "set_trans_forced";
public static final String SET_NOTIF_FOLLOW = "set_notif_follow";
public static final String SET_NOTIF_ADD = "set_notif_follow_add";
public static final String SET_NOTIF_ASK = "set_notif_follow_ask";

View File

@ -123,6 +123,13 @@
android:id="@+id/translation_layout_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:id="@+id/set_trans_forced"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout

View File

@ -123,6 +123,12 @@
android:id="@+id/translation_layout_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:id="@+id/set_trans_forced"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout