From 75da1ee9e8c86b5321a0e25427b5f66f5a9b3f01 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Tue, 5 Jun 2018 20:05:48 +0200 Subject: [PATCH] Translation & fix - Add complete french translation - Fix app crash when adding a transaction with empty field(s) --- .../HomeActivityFragments/Summary.java | 42 +++++------- .../Activities/RecordTransactionActivity.java | 66 +++++++++++++------ .../moodl/Activities/SettingsActivity.java | 21 ------ app/src/main/res/values-fr/strings.xml | 62 +++++++++++++++++ app/src/main/res/values/strings.xml | 54 ++++++++------- 5 files changed, 153 insertions(+), 92 deletions(-) diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java index 816602d..f97e596 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java +++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java @@ -288,7 +288,6 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface { lastTimestamp = System.currentTimeMillis() / 1000; balanceManager.updateExchangeKeys(); - refreshLayout.setRefreshing(true); resetCounters(); DataUpdater updater = new DataUpdater(); @@ -319,8 +318,6 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface { { coinCounter = 0; iconCounter = 0; - detailsChecker = false; - tickersChecker = false; totalValue = 0; totalFluctuation = 0; @@ -350,17 +347,18 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface { if(balanceManager.getTotalBalance() != null) { - if(coinCounter == balanceManager.getTotalBalance().size() && detailsChecker && tickersChecker) + if(balanceManager.getTotalBalance().size() == 0) { - IconDownloader iconDownloader = new IconDownloader(); - iconDownloader.execute(); + countIcons(); } else { - if(balanceManager.getTotalBalance().size() == 0) + if(coinCounter >= balanceManager.getTotalBalance().size() && detailsChecker && tickersChecker) { - countIcons(); + IconDownloader iconDownloader = new IconDownloader(); + iconDownloader.execute(); } + } } } @@ -398,25 +396,21 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface { private void updateNoBalance() { - refreshLayout.setRefreshing(false); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + refreshLayout.setRefreshing(false); - currencyLayout.removeAllViews(); + currencyLayout.removeAllViews(); - if(loadingDialog.isShowing()) - { - loadingDialog.dismiss(); - } - - try { - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - updateTitle(); + if(loadingDialog.isShowing()) + { + loadingDialog.dismiss(); } - }); - } catch (NullPointerException e) { - e.printStackTrace(); - } + + updateTitle(); + } + }); } protected void updateTitle() diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java index 596f692..88a3727 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java @@ -56,29 +56,33 @@ public class RecordTransactionActivity extends AppCompatActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_record: - double amount = Double.parseDouble(amountTxtView.getText().toString()); - double purchasedPrice = Double.parseDouble(purchasedPriceEditText.getText().toString()); - double fees = Double.parseDouble(feesTxtView.getText().toString()); - if(!sellButton.isEnabled()) + if(checkAmountText() && checkPriceText()) { - amount *= -1; - } + double amount = Double.parseDouble(amountTxtView.getText().toString()); + double purchasedPrice = Double.parseDouble(purchasedPriceEditText.getText().toString()); + double fees = Double.parseDouble(feesTxtView.getText().toString()); - if(transactionId != -1) - { - databaseManager.updateTransactionWithId(transactionId, amount, calendar.getTime(), purchasedPrice, fees); - } - else - { - databaseManager.addCurrencyToManualCurrency(symbol, amount, calendar.getTime(), purchasedPrice, fees); - } + if(!sellButton.isEnabled()) + { + amount *= -1; + } - preferenceManager.setMustUpdateSummary(true); - Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - startActivity(intent); - finish(); + if(transactionId != -1) + { + databaseManager.updateTransactionWithId(transactionId, amount, calendar.getTime(), purchasedPrice, fees); + } + else + { + databaseManager.addCurrencyToManualCurrency(symbol, amount, calendar.getTime(), purchasedPrice, fees); + } + + preferenceManager.setMustUpdateSummary(true); + Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + startActivity(intent); + finish(); + } break; case android.R.id.home: //NavUtils.navigateUpFromSameTask(this); @@ -90,6 +94,30 @@ public class RecordTransactionActivity extends AppCompatActivity { return true; } + private boolean checkPriceText() + { + if(purchasedPriceEditText.getText().toString().equals("")) + { + purchasedPriceEditText.setError(getResources().getString(R.string.field_empty)); + + return false; + } + + return true; + } + + private boolean checkAmountText() + { + if(amountTxtView.getText().toString().equals("")) + { + amountTxtView.setError(getResources().getString(R.string.field_empty)); + + return false; + } + + return true; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java index c8ede87..1b1d874 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java @@ -85,27 +85,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity { ? listPreference.getEntries()[index] : null); - } else if (preference instanceof RingtonePreference) { - // For ringtone preferences, look up the correct display value - // using RingtoneManager. - if (TextUtils.isEmpty(stringValue)) { - // Empty values correspond to 'silent' (no ringtone). - preference.setSummary(R.string.pref_ringtone_silent); - - } else { - Ringtone ringtone = RingtoneManager.getRingtone( - preference.getContext(), Uri.parse(stringValue)); - - if (ringtone == null) { - // Clear the summary if there was a lookup error. - preference.setSummary(null); - } else { - // Set the summary to reflect the new ringtone display - // name. - String name = ringtone.getTitle(preference.getContext()); - preference.setSummary(name); - } - } } else { // For all other preferences, set the summary to the value's // simple string representation. diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 1cedddb..50318d1 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -24,4 +24,66 @@ Transactions Possessions Capitalisation du marché + Montant minimum affiché + Historique du jour + Graphique linéaire + Graphique bougie + Prix de départ + Prix actuel + Delta + Volume total + Plus haut prix + Plus bas prix + Rang + Algorithme + Type de preuve + Date de début + Description + Historique de transaction + Historique d\'échange + Recherche d\'échange… + Volet + Dominance en pourcentage + Cryptomonnaies actives + Volume sur 24h + Marchés actifs + Ajouter une transaction + Ajouter à la liste suivie + Mode édition + Activer la synchronisation + Clé public + Clé privée + Activer la synchronisation + Clé public + Clé privée + Activer la synchronisation + Clé public + Clé privée + Liste suivie + Liste des monnaies + 1h + 3h + 1j + 3j + 1S + 1M + 3M + 6M + 1A + Date\n%1$s + Volume\nUS$%1$s + Prix\nUS$%1$s + Volume\n%1$s€ + Prix\n%1$s€ + Volume\n%1$s£ + Prix\n%1$s£ + Volume\n%1$s¥ + Prix\n%1$s¥ + Liquidité totale + Liquiditée en circulation + Capitalisation du marché + Annuler + Vérifier votre empreinte digitale pour continuer + Paramètres + Edition \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c157b62..4ac31f0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,7 +4,7 @@ Moodl_debugVolley Settings - currency + currency General @@ -39,10 +39,6 @@ Save - - - Silent - @@ -51,7 +47,7 @@ Line chart Candle stick chart - \n + \n Beginning price Current price Delta @@ -69,7 +65,7 @@ Transaction history Trade history Looking for trades… - -- + -- Drawer @@ -80,7 +76,7 @@ Add transaction Add to watchlist Edit mode - Hodl… + Hodl… Exchanges settings @@ -102,28 +98,28 @@ Enable synchronization Public key Private key - Binance + Binance Enable synchronization Public key Private key - Poloniex + Poloniex Enable synchronization Public key Private key - Kraken + Kraken Amount Purchased price Purchased date Fees - CurrencyDetailsActivity + CurrencyDetailsActivity History charts - Watchlist + Watchlist Infos Transactions Holdings @@ -142,25 +138,25 @@ 1y - (%1$s) - %1$s%2$s - %1$s%% + (%1$s) + %1$s%2$s + %1$s%% - (US$%1$s) - US$%1$s - US$%1$s (%2$s%%) + (US$%1$s) + US$%1$s + US$%1$s (%2$s%%) - (%1$s€) - %1$s€ - %1$s€ (%2$s%%) + (%1$s€) + %1$s€ + %1$s€ (%2$s%%) - (%1$s£) - %1$s£ - %1$s£ (%2$s%%) + (%1$s£) + %1$s£ + %1$s£ (%2$s%%) - (%1$s¥) - %1$s¥ - %1$s¥ (%2$s%%) + (%1$s¥) + %1$s¥ + %1$s¥ (%2$s%%) Date\n%1$s @@ -190,4 +186,6 @@ Settings Edition + This field cannot be blank +