diff --git a/app/res/values-de/strings.xml b/app/res/values-de/strings.xml
index b12a249ad..c4b87fb12 100644
--- a/app/res/values-de/strings.xml
+++ b/app/res/values-de/strings.xml
@@ -381,8 +381,12 @@
Alle
Erstellt die häufig verwendete standard GnuCash Konten
Standard Konten erstellen
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Wiederkehrende Buchungen
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
\ No newline at end of file
diff --git a/app/res/values-el/strings.xml b/app/res/values-el/strings.xml
index 00ac5a362..365087934 100644
--- a/app/res/values-el/strings.xml
+++ b/app/res/values-el/strings.xml
@@ -397,8 +397,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-es-rMX/strings.xml b/app/res/values-es-rMX/strings.xml
index 5fffe80f0..f28f06abf 100644
--- a/app/res/values-es-rMX/strings.xml
+++ b/app/res/values-es-rMX/strings.xml
@@ -381,8 +381,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-es/strings.xml b/app/res/values-es/strings.xml
index b9e022aa2..2d48ed288 100644
--- a/app/res/values-es/strings.xml
+++ b/app/res/values-es/strings.xml
@@ -381,8 +381,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-fr/strings.xml b/app/res/values-fr/strings.xml
index fd6fffd9c..c1c4994b1 100644
--- a/app/res/values-fr/strings.xml
+++ b/app/res/values-fr/strings.xml
@@ -379,8 +379,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
\ No newline at end of file
diff --git a/app/res/values-hu/strings.xml b/app/res/values-hu/strings.xml
index 74110e4dc..d91d47281 100644
--- a/app/res/values-hu/strings.xml
+++ b/app/res/values-hu/strings.xml
@@ -382,8 +382,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
\ No newline at end of file
diff --git a/app/res/values-it/strings.xml b/app/res/values-it/strings.xml
index ebb2f657d..a79ca66d5 100644
--- a/app/res/values-it/strings.xml
+++ b/app/res/values-it/strings.xml
@@ -382,8 +382,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-nb/strings.xml b/app/res/values-nb/strings.xml
index c7bcb29d8..7afe47948 100644
--- a/app/res/values-nb/strings.xml
+++ b/app/res/values-nb/strings.xml
@@ -384,8 +384,12 @@ format og importeres i regnskapsprogrammet GnuCash for PC.
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-nl/strings.xml b/app/res/values-nl/strings.xml
index 9c1eec8cb..880dd4771 100644
--- a/app/res/values-nl/strings.xml
+++ b/app/res/values-nl/strings.xml
@@ -383,8 +383,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-pt-rBR/strings.xml b/app/res/values-pt-rBR/strings.xml
index 3230b66d1..d72f4c5e8 100644
--- a/app/res/values-pt-rBR/strings.xml
+++ b/app/res/values-pt-rBR/strings.xml
@@ -381,8 +381,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-ru/strings.xml b/app/res/values-ru/strings.xml
index d85fccdae..0e0de000a 100644
--- a/app/res/values-ru/strings.xml
+++ b/app/res/values-ru/strings.xml
@@ -379,8 +379,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values-zh/strings.xml b/app/res/values-zh/strings.xml
index aae41e9d4..3eb954068 100644
--- a/app/res/values-zh/strings.xml
+++ b/app/res/values-zh/strings.xml
@@ -379,8 +379,12 @@
All
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml
index c889147db..639485157 100644
--- a/app/res/values/strings.xml
+++ b/app/res/values/strings.xml
@@ -617,8 +617,12 @@
create_default_accounts
Creates default GnuCash commonly-used account structure
Create default accounts
- New accounts will be created in addition to the existing
+ New accounts will be created in addition to the existing
account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding!
Recurring Transactions
+ Welcome to GnuCash Android! \nYou can either create
+ a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also
+ available in app Settings so you can decide later.
+
diff --git a/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java b/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java
index 6c089bdc8..b72ca2363 100644
--- a/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java
+++ b/app/src/org/gnucash/android/ui/accounts/AccountsActivity.java
@@ -26,7 +26,6 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
-import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -47,10 +46,7 @@
import com.actionbarsherlock.view.MenuItem;
import com.viewpagerindicator.TitlePageIndicator;
import org.gnucash.android.R;
-import org.gnucash.android.data.Account;
-import org.gnucash.android.data.Account.AccountType;
import org.gnucash.android.data.Money;
-import org.gnucash.android.db.AccountsDbAdapter;
import org.gnucash.android.ui.Refreshable;
import org.gnucash.android.ui.transactions.RecurringTransactionsListFragment;
import org.gnucash.android.ui.transactions.TransactionsActivity;
@@ -60,7 +56,8 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
-import java.util.*;
+import java.util.Currency;
+import java.util.Locale;
/**
* Manages actions related to accounts, displaying, exporting and creating new accounts
@@ -74,8 +71,8 @@ public class AccountsActivity extends SherlockFragmentActivity implements OnAcco
* Tag used for identifying the account list fragment when it is added to this activity
*/
public static final String FRAGMENT_ACCOUNTS_LIST = "accounts_list";
-
- /**
+
+ /**
* Tag used for identifying the account export fragment
*/
protected static final String FRAGMENT_EXPORT_OFX = "export_ofx";
@@ -120,12 +117,6 @@ public class AccountsActivity extends SherlockFragmentActivity implements OnAcco
*/
private SparseArray mFragmentPageReferenceMap = new SparseArray();
- /**
- * Stores the indices of accounts which have been selected by the user for creation from the dialog.
- * The account names are stored as string resources and the selected indices are then used to choose which accounts to create
- * The dialog for creating default accounts is only shown when the app is started for the first time.
- */
- private ArrayList mSelectedDefaultAccounts = new ArrayList();
/**
* Dialog which is shown to the user on first start prompting the user to create some accounts
@@ -240,7 +231,7 @@ private void init() {
if (locale.getCountry().equals("UK")) {
locale = new Locale(locale.getLanguage(), "GB");
}
- String currencyCode = null;
+ String currencyCode;
try { //there are some strange locales out there
currencyCode = prefs.getString(getString(R.string.key_default_currency),
Currency.getInstance(locale).getCurrencyCode());
@@ -300,13 +291,13 @@ private boolean hasNewFeatures(){
public static void showWhatsNewDialog(Context context){
Resources resources = context.getResources();
StringBuilder releaseTitle = new StringBuilder(resources.getString(R.string.title_whats_new));
- PackageInfo packageInfo = null;
+ PackageInfo packageInfo;
try {
packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
+ releaseTitle.append(" - v").append(packageInfo.versionName);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
- releaseTitle.append(" - v").append(packageInfo.versionName);
new AlertDialog.Builder(context)
.setTitle(releaseTitle.toString())
@@ -421,80 +412,20 @@ public void onNewAccountClick(View v) {
}
/**
- * Creates the default accounts which have the selected by the user.
- * The indices of the default accounts is stored in {@link #mSelectedDefaultAccounts}
+ * Shows the user dialog to create default account structure or import existing account structure
*/
private void createDefaultAccounts(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- boolean[] checkedDefaults = new boolean[]{true, true, false, false, false};
- //add the checked defaults, the rest will be added by user action
- mSelectedDefaultAccounts.add(0);
- mSelectedDefaultAccounts.add(1);
- builder.setTitle(R.string.title_default_accounts);
- builder.setMultiChoiceItems(R.array.default_accounts, checkedDefaults, new DialogInterface.OnMultiChoiceClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which, boolean isChecked) {
- if (isChecked){
- mSelectedDefaultAccounts.add(which);
- } else {
- mSelectedDefaultAccounts.remove(Integer.valueOf(which));
- }
- }
- });
+ builder.setTitle(R.string.title_default_accounts);
+ builder.setMessage(R.string.message_confirm_create_default_accounts_first_run);
+
builder.setPositiveButton(R.string.btn_create_accounts, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- AccountsDbAdapter dbAdapter = new AccountsDbAdapter(getApplicationContext());
- String[] defaultAccounts = getResources().getStringArray(R.array.default_accounts);
- for (int index : mSelectedDefaultAccounts) {
- String name = defaultAccounts[index];
- Account account = new Account(name);
-
- //these indices are bound to the order in which the accounts occur in strings.xml
- switch (index) {
- case 0:
- account.setAccountType(AccountType.EXPENSE);
- account.setColorCode(getString(R.color.account_red));
- break;
-
- case 1:
- account.setAccountType(AccountType.INCOME);
- account.setColorCode(getString(R.color.account_green));
- break;
-
- case 2:
- account.setAccountType(AccountType.ASSET);
- account.setColorCode(getString(R.color.account_gold));
- break;
- case 3:
- account.setAccountType(AccountType.EQUITY);
- account.setColorCode(getString(R.color.account_blue));
- break;
- case 4:
- account.setAccountType(AccountType.LIABILITY);
- account.setColorCode(getString(R.color.account_purple));
- break;
-
- default:
- account.setAccountType(AccountType.CASH);
- account.setColorCode(getString(R.color.account_green));
- break;
- }
- dbAdapter.addAccount(account);
- }
-
- dbAdapter.close();
- removeFirstRunFlag();
- Fragment fragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_ACCOUNTS_LIST);
- if (fragment != null){
- try{
- ((AccountsListFragment) fragment).refresh();
- } catch (ClassCastException e) {
- Log.e(TAG, e.getMessage());
- }
- }
+ InputStream accountFileInputStream = getResources().openRawResource(R.raw.default_accounts);
+ new AccountsActivity.AccountImporterTask(AccountsActivity.this).execute(accountFileInputStream);
+ removeFirstRunFlag();
}
});
diff --git a/app/src/org/gnucash/android/ui/settings/AccountPreferencesFragment.java b/app/src/org/gnucash/android/ui/settings/AccountPreferencesFragment.java
index 44d318b83..e081cf0d8 100644
--- a/app/src/org/gnucash/android/ui/settings/AccountPreferencesFragment.java
+++ b/app/src/org/gnucash/android/ui/settings/AccountPreferencesFragment.java
@@ -23,7 +23,6 @@
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
-import android.view.ContextThemeWrapper;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
import org.gnucash.android.R;
@@ -76,7 +75,7 @@ public boolean onPreferenceClick(Preference preference) {
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(getActivity())
.setTitle(R.string.title_create_default_accounts)
- .setMessage(R.string.message_create_default_accounts_confirmation)
+ .setMessage(R.string.message_confirm_create_default_accounts_setting)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(R.string.btn_create_accounts, new DialogInterface.OnClickListener() {
@Override