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

#872 Reports errors #874

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 71 additions & 17 deletions app/src/main/java/org/gnucash/android/ui/report/ReportType.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,36 @@
public enum ReportType {
PIE_CHART(0), BAR_CHART(1), LINE_CHART(2), TEXT(3), NONE(4);

// #872 Use a list to be sure of the sort order which is not guaranted with a hashmap keys
List<String> mReportNames = null;

Map<String, Class> mReportTypeMap = new HashMap<>();

int mValue = 4;

/**
* Constructor
*
* @param index
*/
ReportType(int index){

mValue = index;

Context context = GnuCashApplication.getAppContext();
switch (index){
case 0:
mReportTypeMap.put(context.getString(R.string.title_pie_chart), PieChartFragment.class);
break;
case 1:
mReportTypeMap.put(context.getString(R.string.title_bar_chart), StackedBarChartFragment.class);
break;
case 2:
mReportTypeMap.put(context.getString(R.string.title_cash_flow_report), CashFlowLineChartFragment.class);
break;
case 3:
mReportTypeMap.put(context.getString(R.string.title_balance_sheet_report), BalanceSheetFragment.class);
break;
case 4:
break;
}

// #872 Fill the map with all the items, in order to fill the Report Toolbar Spinner
mReportTypeMap.put(context.getString(R.string.title_pie_chart),
PieChartFragment.class);

mReportTypeMap.put(context.getString(R.string.title_bar_chart),
StackedBarChartFragment.class);

mReportTypeMap.put(context.getString(R.string.title_cash_flow_report),
CashFlowLineChartFragment.class);

mReportTypeMap.put(context.getString(R.string.title_balance_sheet_report),
BalanceSheetFragment.class);
}

/**
Expand All @@ -83,8 +91,54 @@ public enum ReportType {
}
}

public static ReportType getReportType(final String name) {

Context context = GnuCashApplication.getAppContext();

if (name.equals(context.getString(R.string.title_pie_chart))) {

return PIE_CHART;

} else if (name.equals(context.getString(R.string.title_bar_chart))) {

return BAR_CHART;

} else if (name.equals(context.getString(R.string.title_cash_flow_report))) {

return LINE_CHART;

} else if (name.equals(context.getString(R.string.title_balance_sheet_report))) {

return TEXT;

} else {

return NONE;
}
}

public List<String> getReportNames(){
return new ArrayList<>(mReportTypeMap.keySet());

Context context = GnuCashApplication.getAppContext();

if (mReportNames == null) {
//

//
mReportNames = new ArrayList<String>();

mReportNames.add(context.getString(R.string.title_pie_chart));
mReportNames.add(context.getString(R.string.title_bar_chart));
mReportNames.add(context.getString(R.string.title_cash_flow_report));
mReportNames.add(context.getString(R.string.title_balance_sheet_report));

} else {
// n' pas

// RAF
}

return mReportNames;
}

public BaseReportFragment getFragment(String name){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class StackedBarChartFragment extends BaseReportFragment {

@Override
public int getTitle() {
return R.string.title_cash_flow_report;
return R.string.title_bar_chart;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_report_summary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ limitations under the License.
android:layout_weight="1"
android:drawableLeft="@drawable/ic_trending_up_white_24dp"
android:drawableStart="@drawable/ic_trending_up_white_24dp"
android:text="@string/title_line_chart"/>
android:text="@string/title_cash_flow_report"/>

<Button android:id="@+id/btn_balance_sheet"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_subject_white_24dp"
android:drawableStart="@drawable/ic_subject_white_24dp"
android:text="@string/title_report_sheet"/>
android:text="@string/title_balance_sheet_report"/>

</TableRow>
</TableLayout>
Expand Down