Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#110 searchable spinner arrayadapter #895

Open
wants to merge 147 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
5357d0e
Merge remote-tracking branch 'codinguser/master' into develop
pnemonic78 Jun 22, 2017
c234c0d
Merge remote-tracking branch 'codinguser/develop' into develop
pnemonic78 Jun 22, 2017
60d31e3
Merge remote-tracking branch 'codinguser/master' into hotfix/patches
pnemonic78 Oct 2, 2017
dfe8c99
Merge remote-tracking branch 'codinguser/develop' into develop
pnemonic78 Oct 2, 2017
ad9877d
IRR defined double currency.
pnemonic78 Oct 2, 2017
c375478
copy currencies from GnuCash desktop.
pnemonic78 Oct 2, 2017
3dac05d
Currencies XML was modified, so re-populate the commodities database …
pnemonic78 Oct 3, 2017
7a6ff6a
Merge remote-tracking branch 'codinguser/develop' into develop
pnemonic78 May 29, 2018
5f620e3
Merge branch 'develop' into bug-731
pnemonic78 May 29, 2018
9f293d7
Fix issue #790 - text margins for RTL text in transaction details scr…
pnemonic78 Jun 11, 2018
a35d233
Merge pull request #791 from pnemonic78/bug_790a
codinguser Jun 12, 2018
7301bd3
Merge branch 'master' into develop
codinguser Jun 15, 2018
8bc6468
Update gradle wrapper to 4.4 and plugin to 3.1.4
Sep 13, 2018
c546904
Add privacy policy
codinguser Sep 20, 2018
21fc3cf
fixed add button disappearing after rotaion
Feb 14, 2019
08a56cd
Merge pull request #812 from RajatChandel/develop
codinguser Mar 1, 2019
f69a609
Fixes crash when exporting CSV to 3rd party applications
codinguser Mar 1, 2019
15af632
Initial release of croatian accounts
milotype Mar 1, 2019
ef99555
Fixes slow CSV exports
Pikrass Oct 5, 2019
a037f43
Cache account names when exporting transactions to CSV
Pikrass Oct 5, 2019
bbabd3b
Merge pull request #739 from pnemonic78/bug-731
codinguser Nov 9, 2019
9eac7f2
Merge pull request #799 from GianpaMX/develop
codinguser Nov 9, 2019
0d7b396
Merge pull request #826 from milotype/milotype-patch-1
codinguser Nov 9, 2019
9b1851a
Merge pull request #845 from Pikrass/fix-csv-export
codinguser Nov 9, 2019
2a62ab8
Upgrades compileSdk, targetSdk, buildTools and gradle versions
codinguser Nov 9, 2019
448caae
Fixes UI (integration) tests
codinguser Nov 9, 2019
87e2b1d
Upgrade version of robolectric to fix execution of unit tests
codinguser Nov 9, 2019
d2cfae3
Add Book name as subtitle in Accounts Activity
AnilPraharaj Feb 14, 2019
0c7e4e3
Update Java source compatibility to Java 8
codinguser Nov 9, 2019
9fa40d4
Update version for 2.4.1 release
codinguser Nov 9, 2019
b401372
Update translations from CrowdIn
codinguser Nov 10, 2019
4fac627
Update CHANGELOG for v2.4.1 release
codinguser Nov 10, 2019
a9fcb9f
Update version and CHANGELOG for v2.4.1-beta2 release
codinguser Nov 21, 2019
8631c7f
Fixes crash when exporting after upgrading to v2.4.1-beta1 from v2.4.0
codinguser Nov 27, 2019
32ee927
Upgrade version for v2.4.1-beta3 release
codinguser Nov 28, 2019
85704b4
Upgrade version for v2.4.1 final release
codinguser Nov 30, 2019
5670ac8
#110 - Create SearchableSpinner
JeanGarf Jan 17, 2020
7fa63f4
#110 - Use SearchableSpinner in Transactions
JeanGarf Jan 17, 2020
4bb7a0a
#110 - WithContainsFilterArrayAdapter based on ArrayTextFilter
JeanGarf Jan 18, 2020
564a0f0
#110 - Add empty lines to be more readable
JeanGarf Jan 18, 2020
7048863
#110 - Renaming and comments
JeanGarf Jan 18, 2020
697ed1d
#110 - Change PositiveButton label to "Cancel"
JeanGarf Jan 18, 2020
84891c7
#110 - Reformat code to be more readable
JeanGarf Jan 18, 2020
a0fb401
#110 - Replace maxLines by singleLine
JeanGarf Jan 19, 2020
d7052ac
#110 - Add comments
JeanGarf Jan 19, 2020
6cf5542
#110 - Customize item appearance for searchableListView
JeanGarf Jan 19, 2020
a2dd297
#110 - After test, it's better to allow multi-line
JeanGarf Jan 19, 2020
cf3b090
#110 - use singleLine instead of maxLines=1
JeanGarf Jan 22, 2020
7768eb9
#110 - Rename account_spinner_item into transaction_account_spinner_item
JeanGarf Jan 22, 2020
0351d7b
#110 - Improve code quality
JeanGarf Jan 25, 2020
f226bbc
#110 - Rename SearchableSpinner into SearchableSpinnerView
JeanGarf Jan 25, 2020
e1625da
#110 - Use Parent Adapter
JeanGarf Jan 25, 2020
73c2c65
#110 - Use QualifiedAccountNameCursorAdapter and a FilterQueryProvide…
JeanGarf Jan 29, 2020
dbe91e0
#110 - Renamings
JeanGarf Jan 29, 2020
48d738d
#110 - Do not hide keyboard
JeanGarf Jan 29, 2020
f7c517e
#110 - Use account_spinner_dropdown_item for DropDown items
JeanGarf Jan 30, 2020
a49b55f
#110 - Handle keyboard hiding and add colors to debug
JeanGarf Feb 1, 2020
1bf4837
#110 - Comment unused code
JeanGarf Feb 1, 2020
86a2720
#110 - Commit WithContainingTextArrayFilterArrayAdapter before deletion
JeanGarf Feb 1, 2020
ecc99b6
#110 - Delete WithContainingTextArrayFilterArrayAdapter
JeanGarf Feb 1, 2020
2491a60
#110 - Cleaning code
JeanGarf Feb 1, 2020
2c7bfee
#110 - Set Focus onto Amount at first
JeanGarf Feb 1, 2020
2e9bbcd
#110 - Restore black color
JeanGarf Feb 1, 2020
d7740d3
#110 - Use Theme to configure spinners
JeanGarf Feb 2, 2020
1fe5b8c
#110 - SearchableSpinnerView for TransactionActivity ToolBar
JeanGarf Feb 2, 2020
83bd981
#110 - Create displayFavoriteAccountStarIcon() and removeFavoriteIcon…
JeanGarf Feb 2, 2020
38fda80
#110 - Use removeFavoriteIconFromSelectedView()
JeanGarf Feb 2, 2020
0ab14bd
#110 - Add a OnCancelListener and call it on Cancel
JeanGarf Feb 2, 2020
16db0d4
#110 - Rename removeFavoriteIconFromSelectedView() into hideFavoriteA…
JeanGarf Feb 2, 2020
bd6d8ce
#110 - Fetch Accounts except Root and Hidden
JeanGarf Feb 2, 2020
2cce9c2
#110 - Correct query
JeanGarf Feb 2, 2020
c990de6
#110 - Error in selectCurrentAccountInToolbarSpinner() : Shall use a …
JeanGarf Feb 8, 2020
e66301e
#110 - Define Filter only once
JeanGarf Feb 8, 2020
6a2822b
#110 - Reformat code
JeanGarf Feb 8, 2020
8154f12
#110 - Error in selectCurrentAccountInToolbarSpinner() : Shall use a …
JeanGarf Feb 8, 2020
ba5c91c
#110 - OK, but ToolbarSpinner can not select Placeholder
JeanGarf Feb 8, 2020
b465876
#110 - SearchableSpinner for parent and defaultTransfertAccount (but …
JeanGarf Feb 8, 2020
a76418b
#110 - Add setAllowPlaceHolderAccounts() in SearchableSpinnerView
JeanGarf Feb 8, 2020
eaba866
#110 - Use a inner CursorAdapter not the SearchableSpinnerView one's
JeanGarf Feb 11, 2020
a22c18b
#110 - Remove position in onSearchableItemClicked(...)
JeanGarf Feb 11, 2020
952209d
#110 - Add TODO
JeanGarf Feb 11, 2020
6090403
#110 - AllowPlaceHolderAccounts for Parent Account List
JeanGarf Feb 11, 2020
c66a7a0
#110 - Filtering using parentCursorAdapter
JeanGarf Feb 13, 2020
c8a1ee3
#110 - QualifiedAccountNameCursorAdapter with null Cursor => OK
JeanGarf Feb 13, 2020
51c337e
#110 - Cleaning
JeanGarf Feb 13, 2020
cbba374
#110 - Add CursorWhere and CursorWhereArgs in setAdapter(...) in orde…
JeanGarf Feb 13, 2020
9d972fe
#110 - Use new setAdapter(..., where, whereArgs)
JeanGarf Feb 13, 2020
fdc5312
#110 - Filter using CursorWhere an CursorWhereArgs + LIKE %searchView…
JeanGarf Feb 13, 2020
523cc3a
Merge branch '#110_searchable_spinner_v3' into #110_searchable_spinne…
JeanGarf Feb 13, 2020
a19520c
#110 - Do not use _listView.setFilterText(s) because it makes a big b…
JeanGarf Feb 14, 2020
07d767f
#110 - Spinner DropDown with 2 lines (partial)
JeanGarf Feb 14, 2020
00113b5
#110 - Spinner DropDown with 2 lines (partial)
JeanGarf Feb 14, 2020
2eacfbf
#110 - Update styles
JeanGarf Feb 14, 2020
9dbec73
#110 - Transfert selectSpinnerAccount()
JeanGarf Feb 14, 2020
e7a0019
#110 - Impact of renaming select_account
JeanGarf Feb 14, 2020
ee77367
#110 - Add mIsDismissing
JeanGarf Feb 14, 2020
b87cde5
#110 - Display Parent Account Full Name on line 2 and use Account Col…
JeanGarf Feb 15, 2020
8c5b58c
#110 - Renaming
JeanGarf Feb 15, 2020
8cbe17f
#110 - Create setAccountTextColor() to colorize Account Name accordin…
JeanGarf Feb 15, 2020
caa2a10
#110 - Use setAccountTextColor() to colorize Account Name according t…
JeanGarf Feb 15, 2020
6a1e935
#110 - Renamings
JeanGarf Feb 16, 2020
1f69edc
#110 - Change hideFavoriteAccountStarIcon() signature
JeanGarf Feb 16, 2020
6a9728e
#110 - Dismiss on Positive Button
JeanGarf Feb 16, 2020
aa179f0
#110 - Trying to restore color when Positive button, but does not work
JeanGarf Feb 16, 2020
807137a
#110 - Add TODO
JeanGarf Feb 16, 2020
4459fe5
#110 - Use black color for Accounts which have no customized color
JeanGarf Feb 18, 2020
6071994
#110 - Add preferences to open/close keyboard and to allow/deny use o…
JeanGarf Feb 18, 2020
9d5512d
#110 - Renamings
JeanGarf Feb 18, 2020
9406957
#110 - Start to retry with ArrayAdapter instead of CursorAdapter
JeanGarf Feb 19, 2020
7651173
#110 - Differentiate CursorAdapter and ArrayAdapter treatment
JeanGarf Feb 23, 2020
639da09
#110 - Default selected spinner item is black
JeanGarf Feb 25, 2020
cc9d106
#110 - Excepted for Toolbar spinner which is white
JeanGarf Feb 25, 2020
1019d25
#110 - Use pop-up with search text only for QualifiedAccountNameCurso…
JeanGarf Feb 25, 2020
9a723ed
#110 - Code quality
JeanGarf Feb 25, 2020
de6b29e
#110 - Restore compare with uid
JeanGarf Feb 25, 2020
32c2c86
#110 - Create items filter that retain items whose toString() contain…
JeanGarf Feb 25, 2020
82b78fd
#110 - Use SimpleAdapter and ItemToStringContainsTextFilter
JeanGarf Feb 25, 2020
2d031b0
#110 - Override getView() in SimpleAdapter to colorize according to UID
JeanGarf Feb 25, 2020
d96cbd1
#110 - Factorize methods
JeanGarf Feb 25, 2020
efce61e
#110 - Code quality
JeanGarf Feb 26, 2020
731b2de
#110 - Rename ItemToStringContainsTextFilter to ItemContainingTextFil…
JeanGarf Feb 26, 2020
8fde3f8
#110 - Override isFoundInItem() in order to search on the Account Ful…
JeanGarf Feb 26, 2020
107f8d0
#110 - Add Getter
JeanGarf Feb 26, 2020
749f9e9
#110 - Add T_ITEM generic type
JeanGarf Feb 26, 2020
710ac8b
#110 - SearchableSpinnerView compatible with CursorAdapter and ArrayA…
JeanGarf Feb 27, 2020
1871671
#110 - Preference to open keyboard, default to false
JeanGarf Feb 27, 2020
9630f96
#110 - Add TODO
JeanGarf Feb 27, 2020
496f50b
Correct title in StackedBarChartFragment
JeanGarf Feb 27, 2020
ad1c0b9
Use title_cash_flow_report and title_balance_sheet_report instead of …
JeanGarf Feb 27, 2020
578022e
Fill Map in order to get ReportToolbarSpinner containing the 4 charts
JeanGarf Feb 27, 2020
c8d295f
Merge branch 'reports_errors' into #110_searchable_spinner_arayadapter
JeanGarf Feb 27, 2020
7a4e4e5
Fixes #872 Add a final commit
JeanGarf Feb 27, 2020
edefd3d
Merge branch '#872_reports_errors' into #110_searchable_spinner_araya…
JeanGarf Feb 27, 2020
273813a
#110 - Use listPreferredItemHeight height and center vertically in Re…
JeanGarf Feb 27, 2020
2729652
#110 - Revert to use theme_primary color for Accounts which have no c…
JeanGarf Feb 27, 2020
7022ac4
#110 - Cleaning code
JeanGarf Feb 29, 2020
cf19704
#110 Accounts sorted by Favorites first in Splits
JeanGarf Feb 29, 2020
c3e71ca
#110 Use SearchableSpinnerView in Splits
JeanGarf Feb 29, 2020
07a4c03
#110 Avoid "attempt to re-open an already-closed object" Exception in…
JeanGarf Feb 29, 2020
a394590
#110 Do not show root account, itself and placeholder account in tran…
JeanGarf Feb 29, 2020
dd4ffe0
#110 Factorize in AccountUtils.getTransfertAccountWhereClause() the c…
JeanGarf Feb 29, 2020
a4b29da
#110 Enhance Split display
JeanGarf Feb 29, 2020
897c297
#110 Set color on selected (= closed) spinner item
JeanGarf Feb 29, 2020
88f5eb2
#110 Colorize selected (= closed) spinner item, except in toolbar_spi…
JeanGarf Feb 29, 2020
2426942
#110 - Cleaning code
JeanGarf Feb 29, 2020
f1df16e
#110 - Respect Splits sort list order
JeanGarf Feb 29, 2020
2acaa93
#110 - Don't close SearchableSpinner automatically
JeanGarf Mar 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#110 - Rename SearchableSpinner into SearchableSpinnerView
JeanGarf committed Jan 25, 2020
commit f226bbc6e2eb1bdd0ac7269b6a4ffc020e27f331
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@
import org.gnucash.android.ui.util.RecurrenceViewClickListener;
import org.gnucash.android.ui.util.widget.CalculatorEditText;
import org.gnucash.android.ui.util.widget.TransactionTypeSwitch;
import org.gnucash.android.ui.util.widget.searchablespinner.SearchableSpinner;
import org.gnucash.android.ui.util.widget.searchablespinner.SearchableSpinnerView;
import org.gnucash.android.util.QualifiedAccountNameCursorAdapter;

import java.math.BigDecimal;
@@ -181,7 +181,7 @@ public class TransactionFormFragment extends Fragment implements
* Spinner for selecting the transfer account
*/
@BindView(R.id.input_transfer_account_spinner)
SearchableSpinner mTransferAccountSpinner;
SearchableSpinnerView mTransferAccountSpinnerView;

/**
* Checkbox indicating if this transaction should be saved as a template or not
@@ -271,7 +271,7 @@ public void onClick(View v) {
*/
private void startTransferFunds() {
Commodity fromCommodity = Commodity.getInstance((mTransactionsDbAdapter.getAccountCurrencyCode(mAccountUID)));
long id = mTransferAccountSpinner.getSelectedItemId();
long id = mTransferAccountSpinnerView.getSelectedItemId();
String targetCurrencyCode = mAccountsDbAdapter.getCurrencyCode(mAccountsDbAdapter.getUID(id));

if (fromCommodity.equals(Commodity.getInstance(targetCurrencyCode))
@@ -323,7 +323,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
//updateTransferAccountsList must only be called after initializing mAccountsDbAdapter
updateTransferAccountsList();

mTransferAccountSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
mTransferAccountSpinnerView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
/**
* Flag for ignoring first call to this listener.
* The first call is during layout, but we want it called only in response to user interaction
@@ -367,8 +367,8 @@ public void onNothingSelected(AdapterView<?> adapterView) {
}
});

mTransferAccountSpinner.setTitle(getString(R.string.select_transfer_account));
mTransferAccountSpinner.setPositiveButton(getString(R.string.alert_dialog_cancel));
mTransferAccountSpinnerView.setTitle(getString(R.string.select_transfer_account));
mTransferAccountSpinnerView.setPositiveButton(getString(R.string.alert_dialog_cancel));

ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
assert actionBar != null;
@@ -604,11 +604,14 @@ private void updateTransferAccountsList(){
if (mCursor != null) {
mCursor.close();
}
mCursor = mAccountsDbAdapter.fetchAccountsOrderedByFavoriteAndFullName(conditions, new String[]{mAccountUID, AccountType.ROOT.name()});
mCursor = mAccountsDbAdapter.fetchAccountsOrderedByFavoriteAndFullName(conditions,
new String[]{mAccountUID,
AccountType.ROOT.name()});

mAccountCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(), mCursor);
mAccountCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(),
mCursor);

mTransferAccountSpinner.setAdapter(mAccountCursorAdapter);
mTransferAccountSpinnerView.setAdapter(mAccountCursorAdapter);
}

/**
@@ -706,7 +709,7 @@ public void onClick(View v) {
private void setSelectedTransferAccount(long accountId){
int position = mAccountCursorAdapter.getPosition(mAccountsDbAdapter.getUID(accountId));
if (position >= 0)
mTransferAccountSpinner.setSelection(position);
mTransferAccountSpinnerView.setSelection(position);
}

/**
@@ -778,7 +781,7 @@ private List<Split> extractSplitsFromView(){
private @NonNull String getTransferAccountUID() {
String transferAcctUID;
if (mUseDoubleEntry) {
long transferAcctId = mTransferAccountSpinner.getSelectedItemId();
long transferAcctId = mTransferAccountSpinnerView.getSelectedItemId();
transferAcctUID = mAccountsDbAdapter.getUID(transferAcctId);
} else {
Commodity baseCommodity = mAccountsDbAdapter.getRecord(mAccountUID).getCommodity();
@@ -835,7 +838,7 @@ private boolean isMultiCurrencyTransaction(){
if (!mUseDoubleEntry)
return false;

String transferAcctUID = mAccountsDbAdapter.getUID(mTransferAccountSpinner.getSelectedItemId());
String transferAcctUID = mAccountsDbAdapter.getUID(mTransferAccountSpinnerView.getSelectedItemId());
String currencyCode = mAccountsDbAdapter.getAccountCurrencyCode(mAccountUID);
String transferCurrencyCode = mAccountsDbAdapter.getCurrencyCode(transferAcctUID);

@@ -961,7 +964,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (mAmountEditText.getValue() == null) {
Toast.makeText(getActivity(), R.string.toast_transanction_amount_required, Toast.LENGTH_SHORT).show();
}
if (mUseDoubleEntry && mTransferAccountSpinner.getCount() == 0){
if (mUseDoubleEntry && mTransferAccountSpinnerView.getCount() == 0){
Toast.makeText(getActivity(),
R.string.toast_disable_double_entry_to_save_transaction,
Toast.LENGTH_LONG).show();
@@ -981,7 +984,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
*/
private boolean canSave(){
return (mUseDoubleEntry && mAmountEditText.isInputValid()
&& mTransferAccountSpinner.getCount() > 0)
&& mTransferAccountSpinnerView.getCount() > 0)
|| (!mUseDoubleEntry && mAmountEditText.isInputValid());
}

Original file line number Diff line number Diff line change
@@ -5,27 +5,24 @@
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.SpinnerAdapter;

import org.gnucash.android.R;
import org.gnucash.android.db.DatabaseSchema;

import java.util.ArrayList;
import java.util.List;

public class SearchableSpinner
public class SearchableSpinnerView
extends android.support.v7.widget.AppCompatSpinner
implements View.OnTouchListener,
SearchableListDialog.OnSearchableItemClickedListener {
SearchableListDialogFragment.OnSearchableItemClickedListener {

public static final int NO_ITEM_SELECTED = -1;

@@ -35,47 +32,47 @@ public class SearchableSpinner
private List _items;
private List _allItems;

private SearchableListDialog _searchableListDialog;
private SearchableListDialogFragment _searchableListDialogFragment;

private boolean _isDirty;

// Adpater for Spinner based on data in a DB Cursor
private CursorAdapter _cursorAdapter;
// // Adpater for Spinner based on data in a DB Cursor
// private CursorAdapter _cursorAdapter;

private String _strHintText;
private boolean _isFromInit;

public SearchableSpinner(Context context) {
public SearchableSpinnerView(Context context) {

super(context);
this._context = context;
init();
}

public SearchableSpinner(Context context,
AttributeSet attrs) {
public SearchableSpinnerView(Context context,
AttributeSet attrs) {

super(context,
attrs);

this._context = context;

TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.SearchableSpinner);
R.styleable.SearchableSpinnerView);
final int N = a.getIndexCount();
for (int i = 0; i < N; ++i) {
int attr = a.getIndex(i);
if (attr == R.styleable.SearchableSpinner_hintText) {
if (attr == R.styleable.SearchableSpinnerView_hintText) {
_strHintText = a.getString(attr);
}
}
a.recycle();
init();
}

public SearchableSpinner(Context context,
AttributeSet attrs,
int defStyleAttr) {
public SearchableSpinnerView(Context context,
AttributeSet attrs,
int defStyleAttr) {

super(context,
attrs,
@@ -92,10 +89,11 @@ private void init() {
_items = new ArrayList();

// Create Dialog instance
_searchableListDialog = SearchableListDialog.newInstance(_items);
// TODO TW C 2020-01-25 : Supprimer _items
_searchableListDialogFragment = SearchableListDialogFragment.makeInstance(this, _items);

// S'abonner aux clicks sur un item
_searchableListDialog.setOnSearchableItemClickListener(this);
_searchableListDialogFragment.setOnSearchableItemClickListener(this);

// S'abonner aux évènements onTouch
setOnTouchListener(this);
@@ -116,47 +114,50 @@ private void init() {
public boolean onTouch(View v,
MotionEvent event) {

if (_searchableListDialog.isAdded()) {
if (_searchableListDialogFragment.isAdded()) {
// dialog is already visible

// NTD

} else {
// dialog is not visible

if (event.getAction() == MotionEvent.ACTION_UP) {

if (null != _cursorAdapter) {

// Refresh content #6
// Change Start
// Description: The items were only set initially, not reloading the data in the
// spinner every time it is loaded with items in the adapter.
_items.clear();
_allItems.clear();

//
// Add items from DB Cursor
//

for (int i = 0; i < _cursorAdapter.getCount(); i++) {

Cursor cursorOnRow = (Cursor) _cursorAdapter.getItem(i);

final String accountFullName = cursorOnRow.getString(cursorOnRow.getColumnIndexOrThrow(DatabaseSchema.AccountEntry.COLUMN_FULL_NAME));

// TODO TW C 2020-01-17 : Ajouter l'étoile pour les Favoris

_items.add(accountFullName);

} // for

// Create a copy of the items
_allItems.addAll(_items);

// Display SearchableListDialog
_searchableListDialog.show(scanForActivity(_context).getFragmentManager(),
"TAG");
}
// User has just clicked on the spinner

// if (null != _cursorAdapter) {
//
// //
// // Open Search & List Dialog
// //
//
// // Refresh content #6
// // Change Start
// // Description: The items were only set initially, not reloading the data in the
// // spinner every time it is loaded with items in the adapter.
// _items.clear();
// _allItems.clear();
//
// // Create items from DB Cursor
// for (int i = 0; i < _cursorAdapter.getCount(); i++) {
//
// Cursor cursorOnRow = (Cursor) _cursorAdapter.getItem(i);
//
// final String accountFullName = cursorOnRow.getString(cursorOnRow.getColumnIndexOrThrow(DatabaseSchema.AccountEntry.COLUMN_FULL_NAME));
//
// // TODO TW C 2020-01-17 : Ajouter l'étoile pour les Favoris
//
// _items.add(accountFullName);
//
// } // for
//
// // Create a copy of the items
// _allItems.addAll(_items);

// Display SearchableListDialogFragment
_searchableListDialogFragment.show(scanForActivity(_context).getFragmentManager(),
"TAG");
// }
}
}

@@ -170,64 +171,68 @@ public void onSearchableItemClicked(Object item,
// String accountFullName = (String) item;

// setSelection(_items.indexOf(item));
setSelection(_allItems.indexOf(item));

if (!_isDirty) {
_isDirty = true;
setAdapter(_cursorAdapter);
// setSelection(_items.indexOf(item));
setSelection(_allItems.indexOf(item));
}
// setSelection(_allItems.indexOf(item));
setSelection(position);

// if (!_isDirty) {
// _isDirty = true;
// setAdapter(_cursorAdapter);
//// setSelection(_items.indexOf(item));
// setSelection(_allItems.indexOf(item));
// }
}


@Override
public void setAdapter(SpinnerAdapter adapter) {

_cursorAdapter = (CursorAdapter) adapter;

if (!_isFromInit) {

// TODO TW C 2020-01-17 : Supprimer la partie ArrayAdapter
if (!TextUtils.isEmpty(_strHintText) && !_isDirty) {
//

//
ArrayAdapter arrayAdapter = new ArrayAdapter(_context,
android.R.layout.simple_list_item_1,
new String[]{_strHintText});
super.setAdapter(arrayAdapter);

} else {
super.setAdapter(adapter);
}

} else {
_isFromInit = false;
super.setAdapter(adapter);
}
super.setAdapter(adapter);

// _cursorAdapter = (CursorAdapter) adapter;
// _searchableListDialogFragment.setCursorAdapter((CursorAdapter) adapter);

// if (!_isFromInit) {
//
// // TODO TW C 2020-01-17 : Supprimer la partie ArrayAdapter
// if (!TextUtils.isEmpty(_strHintText) && !_isDirty) {
// //
//
// //
// ArrayAdapter arrayAdapter = new ArrayAdapter(_context,
// android.R.layout.simple_list_item_1,
// new String[]{_strHintText});
// super.setAdapter(arrayAdapter);
//
// } else {
// super.setAdapter(adapter);
// }
//
// } else {
// _isFromInit = false;
// super.setAdapter(adapter);
// }
}

public void setTitle(String strTitle) {

_searchableListDialog.setTitle(strTitle);
_searchableListDialogFragment.setTitle(strTitle);
}

public void setPositiveButton(String strPositiveButtonText) {

_searchableListDialog.setPositiveButton(strPositiveButtonText);
_searchableListDialogFragment.setPositiveButton(strPositiveButtonText);
}

public void setPositiveButton(String strPositiveButtonText,
DialogInterface.OnClickListener onPositiveBtnClickListener) {

_searchableListDialog.setPositiveButton(strPositiveButtonText,
onPositiveBtnClickListener);
_searchableListDialogFragment.setPositiveButton(strPositiveButtonText,
onPositiveBtnClickListener);
}

public void setOnSearchTextChangedListener(SearchableListDialog.OnSearchTextChangedListener onSearchTextChangedListener) {
public void setOnSearchTextChangedListener(SearchableListDialogFragment.OnSearchTextChangedListener onSearchTextChangedListener) {

_searchableListDialog.setOnSearchTextChangedListener(onSearchTextChangedListener);
_searchableListDialogFragment.setOnSearchTextChangedListener(onSearchTextChangedListener);
}

private Activity scanForActivity(Context cont) {
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_transaction_form.xml
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@
<ImageView style="@style/FormIcon"
android:src="@drawable/ic_action_forward"/>

<org.gnucash.android.ui.util.widget.searchablespinner.SearchableSpinner
<org.gnucash.android.ui.util.widget.searchablespinner.SearchableSpinnerView
android:id="@+id/input_transfer_account_spinner"
android:layout_width="0dp"
android:layout_weight="5"
2 changes: 1 addition & 1 deletion app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
<attr name="keyboardKeysLayout" format="reference" />
</declare-styleable>

<declare-styleable name="SearchableSpinner">
<declare-styleable name="SearchableSpinnerView">
<attr name="hintText" format="string"/>
</declare-styleable>