diff --git a/app/res/values-de/strings.xml b/app/res/values-de/strings.xml index ea9336642..813c2325b 100644 --- a/app/res/values-de/strings.xml +++ b/app/res/values-de/strings.xml @@ -337,6 +337,7 @@ All transactions in all accounts will be deleted! Delete all transactions All transactions successfully deleted! + Importing accounts %d Unterkonto %d Unterkonten diff --git a/app/res/values-el/strings.xml b/app/res/values-el/strings.xml index c6145ec53..44b1c03f0 100644 --- a/app/res/values-el/strings.xml +++ b/app/res/values-el/strings.xml @@ -351,6 +351,7 @@ Διαγραφή όλων των κινήσεων Όλες οι κινήσεις διαγράφηκαν με επιτυχία! + Importing accounts %d υπο-λογαριασμός %d υπο-λογαριασμοί diff --git a/app/res/values-es-rMX/strings.xml b/app/res/values-es-rMX/strings.xml index dfdedd04c..b12b7cf9a 100644 --- a/app/res/values-es-rMX/strings.xml +++ b/app/res/values-es-rMX/strings.xml @@ -334,6 +334,7 @@ ¡Todas las transaccipnes en todas las cuentas serán borradas! Borrar todas las transacciones ¡Todas las transacciones han sido borradas con exitósamente! + Importing accounts %d subcuenta %d subcuentas diff --git a/app/res/values-es/strings.xml b/app/res/values-es/strings.xml index 4922ac255..25041a20a 100644 --- a/app/res/values-es/strings.xml +++ b/app/res/values-es/strings.xml @@ -335,6 +335,7 @@ Todas las transaccipnes en todas las cuentas serán borradas Borrar todas las transacciones Todas las transacciones han sido borradas con éxito + Importing accounts %d sub-cuenta %d sub-cuentas diff --git a/app/res/values-fr/strings.xml b/app/res/values-fr/strings.xml index e724905ac..b40d4f212 100644 --- a/app/res/values-fr/strings.xml +++ b/app/res/values-fr/strings.xml @@ -333,6 +333,7 @@ Toutes les transactions sur tous les comptes seront supprimés! Supprimer toutes les transactions Toutes les transactions ont été supprimées avec succès! + Importing accounts %d sous-compte %d sous-comptes diff --git a/app/res/values-hu/strings.xml b/app/res/values-hu/strings.xml index 977a66505..8a8880be1 100644 --- a/app/res/values-hu/strings.xml +++ b/app/res/values-hu/strings.xml @@ -336,6 +336,7 @@ All transactions in all accounts will be deleted! Delete all transactions All transactions successfully deleted! + Importing accounts %d sub-account %d sub-accounts diff --git a/app/res/values-it/strings.xml b/app/res/values-it/strings.xml index c3e51fc24..d5a3160e2 100644 --- a/app/res/values-it/strings.xml +++ b/app/res/values-it/strings.xml @@ -336,6 +336,7 @@ Verranno eliminate tutte le transazioni in tutti i conti Elimina tutte le transazioni Tutte le transazioni sono state eliminate! + Importing accounts %d sotto-conto %d sotto-conti diff --git a/app/res/values-nb/strings.xml b/app/res/values-nb/strings.xml index 5f2daac31..f63670229 100644 --- a/app/res/values-nb/strings.xml +++ b/app/res/values-nb/strings.xml @@ -338,6 +338,7 @@ format og importeres i regnskapsprogrammet GnuCash for PC. Alle transaksjoner i alle kontoer vil bli slettet! Slette alle transaksjoner Alle transaksjoner slettet! + Importing accounts %d under-konto %d under-kontoer diff --git a/app/res/values-nl/strings.xml b/app/res/values-nl/strings.xml index 516f94110..7714d35b0 100644 --- a/app/res/values-nl/strings.xml +++ b/app/res/values-nl/strings.xml @@ -337,6 +337,7 @@ All transactions in all accounts will be deleted! Delete all transactions All transactions successfully deleted! + Importing accounts %d sub-account %d sub-accounts diff --git a/app/res/values-pt-rBR/strings.xml b/app/res/values-pt-rBR/strings.xml index e6a31d417..3ce7d40fd 100644 --- a/app/res/values-pt-rBR/strings.xml +++ b/app/res/values-pt-rBR/strings.xml @@ -336,6 +336,7 @@ All transactions in all accounts will be deleted! Delete all transactions All transactions successfully deleted! + Importing accounts %d sub-account %d sub-accounts diff --git a/app/res/values-ru/strings.xml b/app/res/values-ru/strings.xml index 959f62059..0ef42c1ef 100644 --- a/app/res/values-ru/strings.xml +++ b/app/res/values-ru/strings.xml @@ -333,6 +333,7 @@ Все проводки во всех счетах будут удалены! Удалить все проводки Все проводки удалены! + Importing accounts %d дочерний счёт %d шт. дочерних счетов diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index 5f921a8db..4680075a1 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -533,6 +533,7 @@ All transactions in all accounts will be deleted! Delete all transactions All transactions successfully deleted! + Importing accounts %d sub-account %d sub-accounts diff --git a/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java b/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java index ab178a4e0..3384e281a 100644 --- a/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java +++ b/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java @@ -17,12 +17,16 @@ package org.gnucash.android.ui.accounts; import android.app.AlertDialog; +import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; @@ -46,6 +50,7 @@ import org.gnucash.android.util.OnAccountClickedListener; import java.io.FileNotFoundException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Currency; import java.util.Locale; @@ -384,17 +389,22 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode){ case AccountsListFragment.REQUEST_PICK_ACCOUNTS_FILE: - try { - GnucashAccountXmlHandler.parse(this, getContentResolver().openInputStream(data.getData())); - Toast.makeText(this, R.string.toast_success_importing_accounts, Toast.LENGTH_LONG).show(); - } catch (FileNotFoundException e) { - Toast.makeText(this, R.string.toast_error_importing_accounts, Toast.LENGTH_LONG).show(); - e.printStackTrace(); - } + new AccountImporterTask(this).execute(data.getData()); break; } } + /** + * Starts the AccountsActivity and clears the activity stack + * @param context Application context + */ + public static void start(Context context){ + Intent accountsActivityIntent = new Intent(context, AccountsActivity.class); + accountsActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + accountsActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(accountsActivityIntent); + } + @Override public void accountSelected(long accountRowId) { Intent intent = new Intent(this, TransactionsActivity.class); @@ -414,4 +424,47 @@ private void removeFirstRunFlag(){ editor.commit(); } + /** + * Imports a GnuCash (desktop) account file and displays a progress dialog. + * The AccountsActivity is opened when importing is done. + */ + public static class AccountImporterTask extends AsyncTask{ + private final Context context; + private ProgressDialog progressDialog; + + public AccountImporterTask(Context context){ + this.context = context; + } + + @Override + protected void onPreExecute() { + super.onPreExecute(); + progressDialog = new ProgressDialog(context); + progressDialog.setTitle(R.string.title_progress_importing_accounts); + progressDialog.setIndeterminate(true); + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.show(); + } + + @Override + protected Boolean doInBackground(Uri... uris) { + try { + GnucashAccountXmlHandler.parse(context, context.getContentResolver().openInputStream(uris[0])); + } catch (Exception exception){ + exception.printStackTrace(); + return false; + } + return true; + } + + @Override + protected void onPostExecute(Boolean importSuccess) { + progressDialog.dismiss(); + + int message = importSuccess ? R.string.toast_success_importing_accounts : R.string.toast_error_importing_accounts; + Toast.makeText(context, message, Toast.LENGTH_LONG).show(); + + AccountsActivity.start(context); + } + } } \ No newline at end of file diff --git a/app/src/org/gnucash/android/ui/settings/SettingsActivity.java b/app/src/org/gnucash/android/ui/settings/SettingsActivity.java index d35be2ffd..f276cfe81 100644 --- a/app/src/org/gnucash/android/ui/settings/SettingsActivity.java +++ b/app/src/org/gnucash/android/ui/settings/SettingsActivity.java @@ -33,6 +33,7 @@ import com.actionbarsherlock.view.MenuItem; import org.gnucash.android.R; import org.gnucash.android.data.Money; +import org.gnucash.android.ui.accounts.AccountsActivity; import org.gnucash.android.ui.accounts.AccountsListFragment; import org.gnucash.android.util.GnucashAccountXmlHandler; @@ -167,14 +168,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode){ case AccountsListFragment.REQUEST_PICK_ACCOUNTS_FILE: - try { - GnucashAccountXmlHandler.parse(this, getContentResolver().openInputStream(data.getData())); - - Toast.makeText(this, R.string.toast_success_importing_accounts, Toast.LENGTH_LONG).show(); - } catch (FileNotFoundException e) { - Toast.makeText(this, R.string.toast_error_importing_accounts, Toast.LENGTH_LONG).show(); - e.printStackTrace(); - } + new AccountsActivity.AccountImporterTask(this).execute(data.getData()); break; } } diff --git a/app/src/org/gnucash/android/ui/transactions/TransactionsActivity.java b/app/src/org/gnucash/android/ui/transactions/TransactionsActivity.java index b4e9d7a73..9a751ca24 100644 --- a/app/src/org/gnucash/android/ui/transactions/TransactionsActivity.java +++ b/app/src/org/gnucash/android/ui/transactions/TransactionsActivity.java @@ -248,10 +248,7 @@ public boolean onOptionsItemSelected(MenuItem item) { if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); } else { - Intent accountsActivityIntent = new Intent(this, AccountsActivity.class); - accountsActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - accountsActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(accountsActivityIntent); + AccountsActivity.start(this); finish(); } return true;