Fix issue for translating own toots
This commit is contained in:
parent
4dbb024069
commit
4d7d365b9f
|
@ -71,8 +71,6 @@ dependencies {
|
||||||
implementation 'com.github.stom79:country-picker-android:1.2.0'
|
implementation 'com.github.stom79:country-picker-android:1.2.0'
|
||||||
implementation 'com.github.stom79:mytransl:1.5'
|
implementation 'com.github.stom79:mytransl:1.5'
|
||||||
|
|
||||||
implementation "net.gotev:uploadservice:$uploadServiceVersion"
|
|
||||||
implementation "net.gotev:uploadservice-okhttp:$uploadServiceVersion"
|
|
||||||
playstoreImplementation "io.github.kobakei:ratethisapp:$ratethisappLibraryVersion"
|
playstoreImplementation "io.github.kobakei:ratethisapp:$ratethisappLibraryVersion"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ import android.text.Html;
|
||||||
import android.text.InputFilter;
|
import android.text.InputFilter;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -853,7 +854,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
||||||
alert.show();
|
alert.show();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_translate:
|
case R.id.action_translate:
|
||||||
final CountryPicker picker = CountryPicker.newInstance("Select Country"); // dialog title
|
final CountryPicker picker = CountryPicker.newInstance(getString(R.string.which_language)); // dialog title
|
||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||||
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
if( theme == Helper.THEME_LIGHT){
|
if( theme == Helper.THEME_LIGHT){
|
||||||
|
@ -897,77 +898,84 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
||||||
myTransL.setYandexAPIKey(Helper.YANDEX_KEY);
|
myTransL.setYandexAPIKey(Helper.YANDEX_KEY);
|
||||||
myTransL.setObfuscation(true);
|
myTransL.setObfuscation(true);
|
||||||
myTransL.setTimeout(60);
|
myTransL.setTimeout(60);
|
||||||
myTransL.translate(toot_cw_content.getText().toString(), myTransL.getLocale(), new com.github.stom79.mytransl.client.Results() {
|
if( toot_cw_content.getText().toString().length() > 0)
|
||||||
@Override
|
myTransL.translate(toot_cw_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
|
||||||
public void onSuccess(Translate translate) {
|
@Override
|
||||||
try {
|
public void onSuccess(Translate translate) {
|
||||||
if( translate.getTranslatedContent() == null)
|
try {
|
||||||
return;
|
if( translate.getTranslatedContent() == null)
|
||||||
if( popup_trans != null ) {
|
return;
|
||||||
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
|
if( popup_trans != null ) {
|
||||||
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
|
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
|
||||||
if( trans_progress_cw != null)
|
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
|
||||||
trans_progress_cw.setVisibility(View.GONE);
|
if( trans_progress_cw != null)
|
||||||
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
|
trans_progress_cw.setVisibility(View.GONE);
|
||||||
if( trans_container != null ){
|
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
|
||||||
TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
|
if( trans_container != null ){
|
||||||
if( cw_trans != null) {
|
TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
|
||||||
cw_trans.setVisibility(View.VISIBLE);
|
if( cw_trans != null) {
|
||||||
cw_trans.setText(translate.getTranslatedContent());
|
cw_trans.setVisibility(View.VISIBLE);
|
||||||
|
cw_trans.setText(translate.getTranslatedContent());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}else {
|
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
|
||||||
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
|
||||||
|
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
|
||||||
}
|
}
|
||||||
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
|
} catch (IllegalArgumentException e) {
|
||||||
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
|
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
||||||
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
|
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onFail(HttpsConnectionException e) {
|
||||||
@Override
|
e.printStackTrace();
|
||||||
public void onFail(HttpsConnectionException e) {
|
}
|
||||||
|
});
|
||||||
}
|
else {
|
||||||
});
|
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
|
||||||
myTransL.translate(toot_content.getText().toString(), myTransL.getLocale(), new com.github.stom79.mytransl.client.Results() {
|
trans_progress_cw.setVisibility(View.GONE);
|
||||||
@Override
|
}
|
||||||
public void onSuccess(Translate translate) {
|
if( toot_content.getText().toString().length() > 0)
|
||||||
try {
|
myTransL.translate(toot_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
|
||||||
if( translate.getTranslatedContent() == null)
|
@Override
|
||||||
return;
|
public void onSuccess(Translate translate) {
|
||||||
if( popup_trans != null ) {
|
try {
|
||||||
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
|
if( translate.getTranslatedContent() == null)
|
||||||
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
|
return;
|
||||||
if( trans_progress_toot != null)
|
if( popup_trans != null ) {
|
||||||
trans_progress_toot.setVisibility(View.GONE);
|
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
|
||||||
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
|
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
|
||||||
if( trans_container != null ){
|
if( trans_progress_toot != null)
|
||||||
TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
|
trans_progress_toot.setVisibility(View.GONE);
|
||||||
if(toot_trans != null){
|
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
|
||||||
toot_trans.setVisibility(View.VISIBLE);
|
if( trans_container != null ){
|
||||||
toot_trans.setText(translate.getTranslatedContent());
|
TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
|
||||||
}
|
if(toot_trans != null){
|
||||||
}else {
|
toot_trans.setVisibility(View.VISIBLE);
|
||||||
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
toot_trans.setText(translate.getTranslatedContent());
|
||||||
}
|
}
|
||||||
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
|
}else {
|
||||||
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
|
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
||||||
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
|
}
|
||||||
}
|
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
|
||||||
} catch (IllegalArgumentException e) {
|
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
|
||||||
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFail(HttpsConnectionException e) {
|
public void onFail(HttpsConnectionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
transAlert.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
|
transAlert.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
|
@ -547,6 +547,7 @@
|
||||||
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
|
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
|
||||||
<string name="delete_instance">Delete this instance?</string>
|
<string name="delete_instance">Delete this instance?</string>
|
||||||
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
|
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
|
||||||
|
<string name="which_language">Translate in</string>
|
||||||
<string-array translatable="false" name="proxy_type_choice">
|
<string-array translatable="false" name="proxy_type_choice">
|
||||||
<item>HTTP</item>
|
<item>HTTP</item>
|
||||||
<item>SOCKS</item>
|
<item>SOCKS</item>
|
||||||
|
|
Loading…
Reference in New Issue