forked from codinguser/gnucash-android
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
90 changed files
with
2,865 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
|
||
package org.gnucash.android.ui.account; | ||
|
||
import static org.gnucash.android.ui.colorpicker.ColorPickerDialog.COLOR_PICKER_DIALOG_TAG; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
@@ -46,12 +48,14 @@ | |
import android.widget.EditText; | ||
import android.widget.Spinner; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.core.content.res.ResourcesCompat; | ||
import androidx.cursoradapter.widget.SimpleCursorAdapter; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentResultListener; | ||
|
||
import com.google.android.material.textfield.TextInputLayout; | ||
|
||
|
@@ -65,7 +69,6 @@ | |
import org.gnucash.android.model.Commodity; | ||
import org.gnucash.android.model.Money; | ||
import org.gnucash.android.ui.colorpicker.ColorPickerDialog; | ||
import org.gnucash.android.ui.colorpicker.ColorPickerSwatch; | ||
import org.gnucash.android.ui.colorpicker.ColorSquare; | ||
import org.gnucash.android.ui.common.UxArgument; | ||
import org.gnucash.android.ui.settings.PreferenceActivity; | ||
|
@@ -87,12 +90,7 @@ | |
* @author Ngewi Fet <[email protected]> | ||
* @author Yongxin Wang <[email protected]> | ||
*/ | ||
public class AccountFormFragment extends Fragment { | ||
|
||
/** | ||
* Tag for the color picker dialog fragment | ||
*/ | ||
private static final String COLOR_PICKER_DIALOG_TAG = "color_picker_dialog"; | ||
public class AccountFormFragment extends Fragment implements FragmentResultListener { | ||
|
||
/** | ||
* EditText for the name of the account to be created/edited | ||
|
@@ -223,16 +221,6 @@ public class AccountFormFragment extends Fragment { | |
@BindView(R.id.input_color_picker) | ||
ColorSquare mColorSquare; | ||
|
||
private final ColorPickerSwatch.OnColorSelectedListener mColorSelectedListener = | ||
new ColorPickerSwatch.OnColorSelectedListener() { | ||
@Override | ||
public void onColorSelected(int color) { | ||
mColorSquare.setBackgroundColor(color); | ||
mSelectedColor = color; | ||
} | ||
}; | ||
|
||
|
||
/** | ||
* Default constructor | ||
* Required, else the app crashes on screen rotation | ||
|
@@ -565,10 +553,19 @@ private void showColorPickerDialog() { | |
R.string.color_picker_default_title, | ||
getAccountColorOptions(), | ||
currentColor, 4, 12); | ||
colorPickerDialogFragment.setOnColorSelectedListener(mColorSelectedListener); | ||
fragmentManager.setFragmentResultListener(COLOR_PICKER_DIALOG_TAG, this, this); | ||
colorPickerDialogFragment.show(fragmentManager, COLOR_PICKER_DIALOG_TAG); | ||
} | ||
|
||
@Override | ||
public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result) { | ||
if (COLOR_PICKER_DIALOG_TAG.equals(requestKey)) { | ||
int color = result.getInt(ColorPickerDialog.EXTRA_COLOR); | ||
mColorSquare.setBackgroundColor(color); | ||
mSelectedColor = color; | ||
} | ||
} | ||
|
||
@Override | ||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | ||
super.onCreateOptionsMenu(menu, inflater); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,12 +38,15 @@ | |
import android.widget.ProgressBar; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.appcompat.widget.PopupMenu; | ||
import androidx.appcompat.widget.SearchView; | ||
import androidx.core.view.MenuItemCompat; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
import androidx.fragment.app.FragmentResultListener; | ||
import androidx.loader.app.LoaderManager; | ||
import androidx.loader.content.Loader; | ||
import androidx.recyclerview.widget.GridLayoutManager; | ||
|
@@ -78,10 +81,11 @@ | |
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
public class AccountsListFragment extends Fragment implements | ||
Refreshable, | ||
LoaderManager.LoaderCallbacks<Cursor>, | ||
SearchView.OnQueryTextListener, | ||
SearchView.OnCloseListener { | ||
Refreshable, | ||
LoaderManager.LoaderCallbacks<Cursor>, | ||
SearchView.OnQueryTextListener, | ||
SearchView.OnCloseListener, | ||
FragmentResultListener { | ||
|
||
AccountRecyclerAdapter mAccountRecyclerAdapter; | ||
@BindView(R.id.account_recycler_view) | ||
|
@@ -263,9 +267,11 @@ private void tryDeleteAccount(String accountUID) { | |
* @param accountUID Unique ID of account to be deleted after confirmation | ||
*/ | ||
private void showConfirmationDialog(String accountUID) { | ||
FragmentManager fm = getChildFragmentManager(); | ||
DeleteAccountDialogFragment alertFragment = | ||
DeleteAccountDialogFragment.newInstance(accountUID); | ||
alertFragment.show(getChildFragmentManager(), "delete_confirmation_dialog"); | ||
fm.setFragmentResultListener(DeleteAccountDialogFragment.TAG, this, this); | ||
alertFragment.show(fm, DeleteAccountDialogFragment.TAG); | ||
} | ||
|
||
@Override | ||
|
@@ -471,6 +477,13 @@ public Cursor loadInBackground() { | |
} | ||
} | ||
|
||
@Override | ||
public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result) { | ||
if (DeleteAccountDialogFragment.TAG.equals(requestKey)) { | ||
boolean refresh = result.getBoolean(Refreshable.EXTRA_REFRESH); | ||
if (refresh) refresh(); | ||
} | ||
} | ||
|
||
class AccountRecyclerAdapter extends CursorRecyclerAdapter<AccountRecyclerAdapter.AccountViewHolder> { | ||
|
||
|
@@ -532,7 +545,7 @@ public void onClick(View v) { | |
if (budgets.size() == 1) { | ||
Budget budget = budgets.get(0); | ||
Money balance = mAccountsDbAdapter.getAccountBalance(accountUID, budget.getStartofCurrentPeriod(), budget.getEndOfCurrentPeriod()); | ||
double budgetProgress = balance.divide(budget.getAmount(accountUID)).asBigDecimal().doubleValue() * 100; | ||
double budgetProgress = balance.div(budget.getAmount(accountUID)).asBigDecimal().doubleValue() * 100; | ||
|
||
holder.budgetIndicator.setVisibility(View.VISIBLE); | ||
holder.budgetIndicator.setProgress((int) budgetProgress); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.