Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Barashkov committed Sep 8, 2021
2 parents cb91d14 + 52c0929 commit 1b9a484
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 82 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ android {
applicationId "com.handydev.financier"
minSdkVersion 21
targetSdkVersion 29
versionCode 219
versionName "2.0.19"
versionCode 220
versionName "2.0.20"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private void addSpinnerItems(Spinner spinner, LocalizableEnum[] a) {
String value = x.name();
items[i] = new SpinnerItem(title, value);
}
ArrayAdapter<SpinnerItem> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, items);
ArrayAdapter<SpinnerItem> adapter = new ArrayAdapter<>(this, R.layout.spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

public class CategoryListAdapter2 extends BaseAdapter {

private final LayoutInflater inflater;
Expand All @@ -49,8 +52,8 @@ public CategoryListAdapter2(Context context, CategoryTree<Category> categories)
this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.categories = categories;
Resources resources = context.getResources();
this.expandedDrawable = resources.getDrawable(R.drawable.expander_ic_maximized);
this.collapsedDrawable = resources.getDrawable(R.drawable.expander_ic_minimized);
this.expandedDrawable = ContextCompat.getDrawable(context, R.drawable.expander_ic_maximized);
this.collapsedDrawable = ContextCompat.getDrawable(context, R.drawable.expander_ic_minimized);
this.incomeColor = resources.getColor(R.color.category_type_income);
this.expenseColor = resources.getColor(R.color.category_type_expense);
this.levelPadding = resources.getDimensionPixelSize(R.dimen.category_padding);
Expand Down Expand Up @@ -108,21 +111,14 @@ public View getView(final int position, View convertView, ViewGroup parent) {
if (c.hasChildren()) {
span.setImageDrawable(state.contains(c.id) ? expandedDrawable : collapsedDrawable);
span.setClickable(true);
span.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
onListItemClick(c.id);
}
});
span.setPadding(padding, 0, 0, 0);
span.setOnClickListener(v -> onListItemClick(c.id));
span.setVisibility(View.VISIBLE);
padding += collapsedDrawable.getMinimumWidth();
} else {
padding += levelPadding/2;
span.setVisibility(View.GONE);
}
title.setPadding(padding, 0, 0, 0);
label.setPadding(padding, 0, 0, 0);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) indicator.getLayoutParams();
layoutParams.leftMargin = padding + 8;
indicator.requestLayout();
long id = c.id;
if (attributes != null && attributes.containsKey(id)) {
label.setText(attributes.get(id));
Expand Down Expand Up @@ -193,10 +189,10 @@ private static class Holder {

public static Holder create(View convertView) {
Holder h = new Holder();
h.indicator = (TextView)convertView.findViewById(R.id.indicator);
h.span = (ImageView)convertView.findViewById(R.id.span);
h.title = (TextView)convertView.findViewById(R.id.line1);
h.label = (TextView)convertView.findViewById(R.id.label);
h.indicator = convertView.findViewById(R.id.indicator);
h.span = convertView.findViewById(R.id.span);
h.title = convertView.findViewById(R.id.line1);
h.label = convertView.findViewById(R.id.label);
convertView.setTag(h);
return h;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ open class DatabaseAdapter(context: Context?) : MyEntityManager(context) {
{
val category = categories.firstOrNull { it.id == excludingTreeId }
if(category != null) {
categories = categories.filter { it.id < category.left || it.id > category.right }
categories = categories.filter { !((it.id == category.id && it.level == category.level) || (it.id >= category.left && it.id <= category.right && it.level > category.level)) }
}
}
return CategoryTree.createFromCache(categories)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private Category insertChildCategory(String name, boolean income) {
Category child = categoryNameToCategory.get(name);
if (child == null) {
child = createCategoryInCache(name, childCategoryName, income);
parent.addChild(child);
parent.addChild(child, true);
}
return child;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class BudgetListFragment: AbstractListFragment(R.layout.budget_list) {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
val unmaskedRequestCode = requestCode and 0x0000ffff
if (unmaskedRequestCode == FILTER_BUDGET_REQUEST) {
if (unmaskedRequestCode == Activity.RESULT_FIRST_USER) {
if (resultCode == Activity.RESULT_FIRST_USER) {
filter.clear()
} else if (unmaskedRequestCode == Activity.RESULT_OK) {
} else if (resultCode == Activity.RESULT_OK) {
val periodType = data?.getStringExtra(DateFilterActivity.EXTRA_FILTER_PERIOD_TYPE)
if(periodType != null) {
val p = PeriodType.valueOf(periodType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ open class CategoryEntity<T : CategoryEntity<T>> : MyEntity() {
val parentId: Long
get() = if (parent != null) parent!!.id else 0

fun addChild(category: T) {
fun addChild(category: T, uniqueOnly: Boolean = true) {
if (children == null) {
children = CategoryTree()
}
if(children?.any { it.id == category.id } == true) {
if(uniqueOnly && children?.any { it.id == category.id } == true) {
return
}
category.parent = this as T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class CategoryTree<T : CategoryEntity<T>> : Iterable<T> {
val category = creator.createNode(c)
while (parent != null) {
parent = if (category.left > parent.left && category.right < parent.right) {
parent.addChild(category)
parent.addChild(category, false)
break
} else {
parent.parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public void separateIncomeAndExpense() {
newCategories.add(category);
} else {
if (category.isIncome()) {
income.addChild(category);
income.addChild(category, true);
} else {
expense.addChild(category);
expense.addChild(category, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

import static com.handydev.financier.activity.UiUtils.applyTheme;

import androidx.core.content.ContextCompat;

public class RecurrenceViewFactory {

private final RecurrenceActivity activity;
Expand Down Expand Up @@ -722,6 +724,7 @@ private class StopsOnDateView extends AbstractView {
public void createNodes(LinearLayout layout) {
onDateText = x.addInfoNode(layout, R.id.date, R.string.recur_repeat_stops_on,
DateUtils.getMediumDateFormat(activity).format(c.getTime()));
//onDateText.setTextColor(ContextCompat.getColor());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public CategoryAmount createNode(Cursor c) {
});

ArrayList<GraphUnitTree> roots = createTree(amounts, 0);
ArrayList<GraphUnit> units = new ArrayList<GraphUnit>();
ArrayList<GraphUnit> units = new ArrayList<>();
flattenTree(roots, units);
Total total = calculateTotal(roots);
return new ReportData(units, total);
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/category_list_item2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_alignParentLeft="true"
android:layout_height="fill_parent"
android:layout_width="3dp"
android:layout_marginLeft="5dp"
android:layout_marginLeft="50dp"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"/>
<ImageView android:id="@+id/span"
Expand All @@ -31,9 +31,10 @@
<TextView android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/indicator"
android:layout_toRightOf="@id/span"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dip"
android:layout_marginLeft="8dip"
android:layout_alignWithParentIfMissing="true"
android:layout_marginTop="-10dip"
android:singleLine="true"
Expand All @@ -44,7 +45,8 @@
<TextView android:id="@+id/line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/indicator"
android:layout_toRightOf="@id/span"
android:layout_marginLeft="8dip"
android:layout_alignParentTop="true"
android:layout_above="@id/label"
android:layout_alignWithParentIfMissing="true"
Expand Down
24 changes: 12 additions & 12 deletions app/src/main/res/layout/category_selector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:background="@color/brown_background"
android:paddingTop="2dp">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/button_background"
android:text="@string/back"
android:id="@+id/bBack"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/button_background"
android:text="@string/select"
android:id="@+id/bSelect"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/button_background"
android:text="@string/select"
android:id="@+id/bSelect"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/button_background"
android:text="@string/back"
android:id="@+id/bBack"/>
</LinearLayout>
</LinearLayout>
40 changes: 17 additions & 23 deletions app/src/main/res/layout/filter_period_select.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<!--
Copyright (c) 2010 Denis Solonenko.
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Public License v2.0
which accompanies this distribution, and is available at
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Contributors:
Denis Solonenko - initial API and implementation
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<DatePicker android:layout_width="wrap_content"
android:datePickerMode="spinner"
android:spinnersShown="false"
android:layout_height="wrap_content" android:id="@+id/date"/>
<TimePicker android:layout_width="wrap_content"
android:timePickerMode="spinner"
android:layout_height="wrap_content" android:layout_gravity="center"
android:id="@+id/time" />
<include layout="@layout/ok_cancel_buttons" />
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<DatePicker android:layout_width="wrap_content"
android:datePickerMode="spinner"
android:spinnersShown="false"
android:layout_height="wrap_content" android:id="@+id/date"/>
<TimePicker android:layout_width="wrap_content"
android:timePickerMode="spinner"
android:layout_height="wrap_content" android:layout_gravity="center"
android:id="@+id/time" />
<include layout="@layout/ok_cancel_buttons" />
</LinearLayout>
</ScrollView>
29 changes: 22 additions & 7 deletions app/src/main/res/layout/recur.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@color/brown_background_light"
android:orientation="vertical">
<View android:layout_height="1dp" android:background="@drawable/divider_horizontal_dark"
android:layout_width="fill_parent" android:layout_marginLeft="10dp"
Expand All @@ -21,22 +22,36 @@
<LinearLayout android:layout_height="wrap_content"
android:orientation="vertical" android:layout_width="fill_parent">
<TextView android:layout_width="wrap_content"
android:textColor="@color/main_text_color"
android:layout_height="wrap_content" android:text="@string/start_date" />
<Button android:layout_height="wrap_content" android:id="@+id/bStartDate"
android:layout_width="fill_parent"></Button>

<Button
android:layout_height="wrap_content"
android:id="@+id/bStartDate"
android:layout_width="fill_parent" />
<TextView android:layout_width="wrap_content"
android:textColor="@color/main_text_color"
android:layout_height="wrap_content" android:text="@string/interval" />
<Spinner android:layout_height="wrap_content"
android:layout_width="fill_parent" android:prompt="@string/recur_interval"
android:id="@+id/intervalSpinner" />
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/layoutInterval" android:layout_width="fill_parent"></LinearLayout>

<LinearLayout
android:layout_height="wrap_content"
android:id="@+id/layoutInterval"
android:layout_width="fill_parent" />
<TextView android:layout_width="wrap_content"
android:textColor="@color/main_text_color"
android:layout_height="wrap_content" android:text="@string/recur" />
<Spinner android:layout_height="wrap_content" android:id="@+id/recurSpinner"
<Spinner android:layout_height="wrap_content"
android:id="@+id/recurSpinner"
android:layout_width="fill_parent" android:prompt="@string/recur" />
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/recurInterval"></LinearLayout>

<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/recurInterval"
android:orientation="horizontal" />

</LinearLayout>
</ScrollView>
Expand Down
21 changes: 14 additions & 7 deletions app/src/main/res/layout/recur_stops_on_date.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
Denis Solonenko - initial API and implementation
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:paddingRight="2dp" android:text="@string/recur_repeat_stops_on"></TextView>



<Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bStopsOnDate"></Button>
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:textColor="@color/main_text_color"
android:layout_height="wrap_content"
android:paddingRight="2dp"
android:text="@string/recur_repeat_stops_on" />

<Button
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/bStopsOnDate" />
</LinearLayout>
9 changes: 9 additions & 0 deletions app/src/main/res/layout/spinner_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:textColor="@color/main_text_color"
android:singleLine="true"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="inherit"/>

0 comments on commit 1b9a484

Please sign in to comment.