Changes delay between translations
This commit is contained in:
parent
575a0d79fc
commit
8d2e4ced34
|
@ -776,11 +776,12 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
||||||
return true;
|
return true;
|
||||||
String dateString = sharedpreferences.getString(Helper.LAST_TRANSLATION_TIME, null);
|
String dateString = sharedpreferences.getString(Helper.LAST_TRANSLATION_TIME, null);
|
||||||
if( dateString != null){
|
if( dateString != null){
|
||||||
Date date = Helper.stringToDate(getApplicationContext(), dateString);
|
Date dateCompare = Helper.stringToDate(getApplicationContext(), dateString);
|
||||||
Date dateCompare = new Date( System.currentTimeMillis() + (TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE)));
|
Date date = new Date();
|
||||||
if( date.before(dateCompare))
|
if( date.before(dateCompare)) {
|
||||||
Toast.makeText(getApplicationContext(),R.string.please_wait,Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), R.string.please_wait, Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
picker.setListener(new CountryPickerListener() {
|
picker.setListener(new CountryPickerListener() {
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
|
@ -793,8 +794,16 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
||||||
popup_trans = getLayoutInflater().inflate( R.layout.popup_translate, null );
|
popup_trans = getLayoutInflater().inflate( R.layout.popup_translate, null );
|
||||||
transAlert.setView(popup_trans);
|
transAlert.setView(popup_trans);
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(getApplicationContext(), new Date()));
|
editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(getApplicationContext(), new Date( System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE))));
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
TextView yandex_translate = popup_trans.findViewById(R.id.yandex_translate);
|
||||||
|
yandex_translate.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://translate.yandex.com/"));
|
||||||
|
startActivity(browserIntent);
|
||||||
|
}
|
||||||
|
});
|
||||||
new Translate(getApplicationContext(), Helper.targetField.CW, locale, TootActivity.this).privacy(toot_cw_content.getText().toString());
|
new Translate(getApplicationContext(), Helper.targetField.CW, locale, TootActivity.this).privacy(toot_cw_content.getText().toString());
|
||||||
new Translate(getApplicationContext(), Helper.targetField.STATUS, locale, TootActivity.this).privacy(toot_content.getText().toString());
|
new Translate(getApplicationContext(), Helper.targetField.STATUS, locale, TootActivity.this).privacy(toot_content.getText().toString());
|
||||||
transAlert.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
|
transAlert.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
|
||||||
|
|
|
@ -256,7 +256,7 @@ public class Helper {
|
||||||
|
|
||||||
//Translate wait time
|
//Translate wait time
|
||||||
public static final String LAST_TRANSLATION_TIME = "last_translation_time";
|
public static final String LAST_TRANSLATION_TIME = "last_translation_time";
|
||||||
public static final int SECONDES_BETWEEN_TRANSLATE = 60;
|
public static final int SECONDES_BETWEEN_TRANSLATE = 30;
|
||||||
//Intent
|
//Intent
|
||||||
public static final String INTENT_ACTION = "intent_action";
|
public static final String INTENT_ACTION = "intent_action";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue