Update placeholders and translations

This commit is contained in:
Tanguy Herbron 2018-07-19 23:59:29 +02:00
parent 47c4fb0daf
commit b53d52daeb
9 changed files with 68 additions and 19 deletions

View File

@ -46,7 +46,7 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
currencyDetailsList = CurrencyDetailsList.getInstance(this);
setTitle("Select a coin");
setTitle(getString(R.string.select_coin));
Intent intent = getIntent();
isWatchList = intent.getBooleanExtra("isWatchList", false);
@ -103,7 +103,7 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
}
else
{
Toast.makeText(getApplicationContext(), "Currency already in watchlist.", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), getString(R.string.already_watchlisr), Toast.LENGTH_SHORT).show();
}
}
else

View File

@ -120,7 +120,7 @@ public class Informations extends Fragment {
((TextView) view.findViewById(R.id.txtViewDescription))
.setMovementMethod(LinkMovementMethod.getInstance());
((TextView) view.findViewById(R.id.txtViewPercentageCoinEmited))
.setText("Percentage of coin emited : " + numberConformer(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100) + "%");
.setText(PlaceholderManager.getEmitedPercentageString(numberConformer(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100), getContext()));
if(currency.getMarketCapitalization() != 0)
{

View File

@ -341,8 +341,8 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
private void showErrorSnackbar()
{
Snackbar.make(getActivity().findViewById(R.id.content_frame), "Error while updating data", Snackbar.LENGTH_LONG)
.setAction("Update", new View.OnClickListener() {
Snackbar.make(getActivity().findViewById(R.id.content_frame), getString(R.string.error_update_data), Snackbar.LENGTH_LONG)
.setAction(getString(R.string.update), new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -584,7 +584,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
{
case "com.android.volley.AuthFailureError":
preferencesManager.disableHitBTC();
Snackbar.make(view, "HitBTC synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
Snackbar.make(view, getString(R.string.invalid_keys_hitbtc), Snackbar.LENGTH_LONG)
.show();
refreshLayout.setRefreshing(false);
@ -593,19 +593,19 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
break;
case "API-key format invalid.":
preferencesManager.disableBinance();
Snackbar.make(view, "Binance synchronization error : Invalid keys", Snackbar.LENGTH_LONG)
Snackbar.make(view, getString(R.string.invalid_keys_binance), Snackbar.LENGTH_LONG)
.show();
updateAll(true);
break;
case "com.android.volley.NoConnectionError: java.net.UnknownHostException: Unable to resolve host \"api.hitbtc.com\": No address associated with hostname":
Snackbar.make(view, "Can't resolve host", Snackbar.LENGTH_LONG)
Snackbar.make(view, getString(R.string.cannot_resole_host), Snackbar.LENGTH_LONG)
.show();
break;
case "com.android.volley.TimeoutError":
break;
default:
Snackbar.make(view, "Unexpected error", Snackbar.LENGTH_LONG)
Snackbar.make(view, R.string.unexpected, Snackbar.LENGTH_LONG)
.show();
Log.d("moodl", error);

View File

@ -19,6 +19,7 @@ import com.herbron.moodl.DataManagers.CurrencyData.Currency;
import com.herbron.moodl.DataManagers.CurrencyData.Transaction;
import com.herbron.moodl.DataManagers.DatabaseManager;
import com.herbron.moodl.DataManagers.PreferencesManager;
import com.herbron.moodl.PlaceholderManager;
import com.herbron.moodl.R;
import java.text.ParseException;
@ -168,7 +169,7 @@ public class RecordTransactionActivity extends AppCompatActivity {
if(transactionId != -1)
{
setTitle("Edit " + coin + " transaction");
setTitle(PlaceholderManager.getEditTransactionString(coin, getBaseContext()));
DatabaseManager databaseManager = new DatabaseManager(this);
Transaction transaction = databaseManager.getCurrencyTransactionById(transactionId);
@ -180,7 +181,7 @@ public class RecordTransactionActivity extends AppCompatActivity {
}
else
{
setTitle("Add " + coin + " transaction");
setTitle(PlaceholderManager.getAddCoinTransactionString(coin, getBaseContext()));
purchaseDate.setText(sdf.format(calendar.getTime()));
symbolTxtView.setText(symbol);
@ -300,7 +301,6 @@ public class RecordTransactionActivity extends AppCompatActivity {
purchasedPriceEditText.setText(price);
}
}, calendar.getTimeInMillis() / 1000);
Log.d("moodl", "Time : " + calendar.getTimeInMillis());
}
},
calendar.get(Calendar.HOUR_OF_DAY),

View File

@ -465,8 +465,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
});
dialogBuilder.setTitle("Create backup");
dialogBuilder.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
dialogBuilder.setTitle(getString(R.string.create_backup));
dialogBuilder.setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
checkPermissions();
@ -510,7 +510,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
dialog.dismiss();
}
});
dialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
dialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
@ -621,7 +621,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
else
{
textInputLayoutPassword.setError("Wrong password");
textInputLayoutPassword.setError(getString(R.string.wrong_password));
}
} catch (JSONException e) {

View File

@ -8,6 +8,8 @@ import android.os.CancellationSignal;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
import com.herbron.moodl.R;
/**
* Created by Guitoune on 28/02/2018.
*/
@ -39,7 +41,7 @@ public class FingerprintHandler extends FingerprintManager.AuthenticationCallbac
{
if(dialogFragment.isVisible())
{
dialogFragment.wrongFingerprint("Error");
dialogFragment.wrongFingerprint(context.getString(R.string.error));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
@ -57,7 +59,7 @@ public class FingerprintHandler extends FingerprintManager.AuthenticationCallbac
{
if(dialogFragment.isVisible())
{
dialogFragment.wrongFingerprint("Wrong fingerprint");
dialogFragment.wrongFingerprint(context.getString(R.string.wrong_fingerprint));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {

View File

@ -1,5 +1,7 @@
package com.herbron.moodl;
import android.content.Context;
import com.herbron.moodl.DataManagers.PreferencesManager;
/**
@ -32,7 +34,21 @@ public class PlaceholderManager {
return formattedString;
}
public static String getValuePercentageString(String value, String percentage, android.content.Context context)
public static String getAddCoinTransactionString(String coinName, Context context) {
return context.getResources().getString(R.string.add_coin_transaction, coinName);
}
public static String getEditTransactionString(String coinName, Context context)
{
return context.getResources().getString(R.string.edit_transaction, coinName);
}
public static String getEmitedPercentageString(String percentage, Context context)
{
return context.getResources().getString(R.string.emitedPlaceholder, percentage);
}
public static String getValuePercentageString(String value, String percentage, Context context)
{
PreferencesManager preferencesManager = new PreferencesManager(context);
String formattedString = null;

View File

@ -116,4 +116,19 @@
<item>6 mois</item>
<item>1 année</item>
</string-array>
<string name="emitedPlaceholder">Pourcentage de coin émis : %1$s%%</string>
<string name="edit_transaction">Edition d\'une transaction de %1$s</string>
<string name="add_coin_transaction">Ajouter d\'une transaction de %1$s</string>
<string name="error_update_data">Erreur lors de l\'actualisation des données</string>
<string name="update">Rafraichir</string>
<string name="invalid_keys_hitbtc">Erreur de synchronisation avec HitBTC : Clefs invalides</string>
<string name="invalid_keys_binance">Erreur de synchronisation avec Binance : Clefs invalides</string>
<string name="cannot_resole_host">Impossible de résoudre l\'hôte</string>
<string name="unexpected">Erreur inconnue</string>
<string name="select_coin">Selectionner une monnaie</string>
<string name="already_watchlisr">Monnaie déjà présente dans la liste suivie</string>
<string name="create_backup">Créer une sauvegarde</string>
<string name="wrong_password">Mauvais mot de passe</string>
<string name="error">Erreur</string>
<string name="wrong_fingerprint">Mauvaise empreinte digitale</string>
</resources>

View File

@ -174,6 +174,7 @@
<!--DetailsActivity placeholders-->
<string name="timestampPlaceholder">Date\n%1$s</string>
<string name="emitedPlaceholder">Percentage of coin emitted : %1$s%%</string>
<!--Dollar-->
<string name="volumeDollarPlaceholder">Volume\nUS$%1$s</string>
<string name="priceDollarPlaceholder">Price\nUS$%1$s</string>
@ -190,6 +191,9 @@
<string name="fingerprint_dialog_cancel">Cancel</string>
<string name="fingerprint_dialog_title">Verify your fingerprint to continue</string>
<string name="edit_transaction">Edit %1$s transaction</string>
<string name="add_coin_transaction">Add %1$s transaction</string>
<!--Marketcap placeholders-->
<!--Dollar-->
@ -219,5 +223,17 @@
<string name="market_dominance">Market Cap Dominance</string>
<string name="global">Global</string>
<string name="other_coins">Other coins</string>
<string name="error_update_data">Error while updating data</string>
<string name="update">Update</string>
<string name="invalid_keys_hitbtc">HitBTC synchronization error : Invalid keys</string>
<string name="invalid_keys_binance">Binance synchronization error : Invalid keys</string>
<string name="cannot_resole_host">Can\'t resolve host</string>
<string name="unexpected">Unexpected error</string>
<string name="select_coin">Select a coin</string>
<string name="already_watchlisr">Currency already in watchlist</string>
<string name="create_backup">Create backup</string>
<string name="wrong_password">Wrong password</string>
<string name="error">Error</string>
<string name="wrong_fingerprint">Wrong fingerprint</string>
</resources>