Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -11,22 +12,35 @@
import com.pedrocarrillo.expensetracker.R;
import com.pedrocarrillo.expensetracker.entities.Category;

import java.util.List;


/**
* Created by pcarrillo on 21/09/2015.
*/
public class CategoriesSpinnerAdapter extends ArrayAdapter<Category> {
public class CategoriesAutoCompleteAdapter extends ArrayAdapter<Category> {

List<Category> categoriesList = null;
//LayoutInflater inflater;

Category[] categoriesList = null;
LayoutInflater inflater;
public CategoriesAutoCompleteAdapter(Activity context) {
super(context, android.R.layout.simple_dropdown_item_1line);
this.categoriesList = Category.getCategoriesExpense();
//this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

public CategoriesSpinnerAdapter(Activity context, Category[] categoriesList) {
super(context, android.R.layout.simple_spinner_dropdown_item, categoriesList);
this.categoriesList = categoriesList;
this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@Override
public int getCount() {
return categoriesList.size();
}

@Nullable
@Override
public Category getItem(int position) {
return categoriesList.get(position);
}

/*@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
Expand All @@ -42,6 +56,6 @@ public View getCustomView(int position, View convertView, ViewGroup parent) {
TextView title = (TextView)row.findViewById(R.id.tv_title);
title.setText(category.getName());
return row;
}
}*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,27 @@ public static List<Category> getCategoriesExpense() {
return getCategoriesForType(IExpensesType.MODE_EXPENSES);
}

public static List<Category> getCategoriesForType(@IExpensesType int type){
public static List<Category> getCategoriesForType(@IExpensesType int type) {
return RealmManager.getInstance().getRealmInstance().where(Category.class)
.equalTo("type", type)
.findAll();
}

public static Category getCategoryByName(String name) {
Category result = RealmManager.getInstance().getRealmInstance().where(Category.class)
.equalTo("name", name)
.findFirst();

if(result == null){
result = new Category(name,IExpensesType.MODE_EXPENSES);
RealmManager.getInstance().save(result,Category.class);
}

Category c = RealmManager.getInstance().getRealmInstance().where(Category.class)
.equalTo("name", name)
.findFirst();

return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.pedrocarrillo.expensetracker.R;
import com.pedrocarrillo.expensetracker.adapters.CategoriesSpinnerAdapter;
import com.pedrocarrillo.expensetracker.adapters.CategoriesAutoCompleteAdapter;
import com.pedrocarrillo.expensetracker.entities.Category;
import com.pedrocarrillo.expensetracker.entities.Expense;
import com.pedrocarrillo.expensetracker.interfaces.IExpensesType;
Expand All @@ -33,23 +33,24 @@
import java.util.Date;
import java.util.List;

/**
* Created by pcarrillo on 21/09/2015.
*/
public class NewExpenseFragment extends DialogFragment implements View.OnClickListener{
public class NewExpenseFragment extends DialogFragment implements View.OnClickListener {

private TextView tvTitle;
private Button btnDate;
private Spinner spCategory;
private AutoCompleteTextView acCategory;
private EditText etDescription;
private EditText etTotal;

private CategoriesSpinnerAdapter mCategoriesSpinnerAdapter;
private CategoriesAutoCompleteAdapter mCategoriesAutoCompleteAdapter;
private Date selectedDate;
private Expense mExpense;

private @IUserActionsMode int mUserActionMode;
private @IExpensesType int mExpenseType;
private
@IUserActionsMode
int mUserActionMode;
private
@IExpensesType
int mExpenseType;

static NewExpenseFragment newInstance(@IUserActionsMode int mode, String expenseId) {
NewExpenseFragment newExpenseFragment = new NewExpenseFragment();
Expand All @@ -64,11 +65,11 @@ static NewExpenseFragment newInstance(@IUserActionsMode int mode, String expense
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_dialog_new_expense, container, false);
tvTitle = (TextView)rootView.findViewById(R.id.tv_title);
btnDate = (Button)rootView.findViewById(R.id.btn_date);
spCategory = (Spinner)rootView.findViewById(R.id.sp_categories);
etDescription = (EditText)rootView.findViewById(R.id.et_description);
etTotal = (EditText)rootView.findViewById(R.id.et_total);
tvTitle = (TextView) rootView.findViewById(R.id.tv_title);
btnDate = (Button) rootView.findViewById(R.id.btn_date);
acCategory = (AutoCompleteTextView) rootView.findViewById(R.id.actv_categories);
etDescription = (EditText) rootView.findViewById(R.id.et_description);
etTotal = (EditText) rootView.findViewById(R.id.et_total);
mExpenseType = IExpensesType.MODE_EXPENSES;
return rootView;
}
Expand Down Expand Up @@ -96,8 +97,8 @@ private void setModeViews() {
List<Category> categoriesList = Category.getCategoriesExpense();
Category[] categoriesArray = new Category[categoriesList.size()];
categoriesArray = categoriesList.toArray(categoriesArray);
mCategoriesSpinnerAdapter = new CategoriesSpinnerAdapter(getActivity(), categoriesArray);
spCategory.setAdapter(mCategoriesSpinnerAdapter);
mCategoriesAutoCompleteAdapter = new CategoriesAutoCompleteAdapter(getActivity());
acCategory.setAdapter(mCategoriesAutoCompleteAdapter);
switch (mUserActionMode) {
case IUserActionsMode.MODE_CREATE:
selectedDate = new Date();
Expand All @@ -111,13 +112,13 @@ private void setModeViews() {
etDescription.setText(mExpense.getDescription());
etTotal.setText(String.valueOf(mExpense.getTotal()));
int categoryPosition = 0;
for (int i=0; i<categoriesArray.length; i++) {
for (int i = 0; i < categoriesArray.length; i++) {
if (categoriesArray[i].getId().equalsIgnoreCase(mExpense.getCategory().getId())) {
categoryPosition = i;
break;
}
}
spCategory.setSelection(categoryPosition);
acCategory.setSelection(categoryPosition);
}
break;
}
Expand All @@ -135,7 +136,7 @@ public void onStart() {

@Override
public void onClick(View view) {
if(view.getId() == R.id.btn_date) {
if (view.getId() == R.id.btn_date) {
showDateDialog();
} else if (view.getId() == R.id.btn_cancel) {
dismiss();
Expand All @@ -145,9 +146,9 @@ public void onClick(View view) {
}

private void onSaveExpense() {
if (mCategoriesSpinnerAdapter.getCount() > 0 ) {
if (acCategory.getText().length() > 0) {
if (!Util.isEmptyField(etTotal)) {
Category currentCategory = (Category) spCategory.getSelectedItem();
Category currentCategory = Category.getCategoryByName(acCategory.getText().toString());
String total = etTotal.getText().toString();
String description = etDescription.getText().toString();
if (mUserActionMode == IUserActionsMode.MODE_CREATE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
style="?android:attr/borderlessButtonStyle"
android:elevation="@dimen/elevation_dp"/>

<Spinner
android:id="@+id/sp_categories"
<AutoCompleteTextView
android:id="@+id/actv_categories"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen_20dp"
android:layout_marginLeft="@dimen/dimen_20dp"
android:layout_marginRight="@dimen/dimen_20dp"
style="@style/ExpenseTrackerSpinner"/>
android:layout_marginRight="@dimen/dimen_20dp"/>

<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
Expand Down
76 changes: 76 additions & 0 deletions ExpenseTracker/app/src/main/res/values-iw/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Expense Tracker</string>
<string name="Save">שמור</string>
<string name="action_help">עזרה</string>
<string name="action_settings">הגדרות</string>
<string name="add_new_expense">הוסף הוצאה</string>
<string name="cancel">ביטול</string>
<string name="categories">קטגוריות</string>
<string name="categories_empty">אין עדיין קטגוריות. התחל ע\"י יצירת קטגוריה ותוכל להינות מהיתרונות של הסטטיסטיקה</string>
<string name="categories_percentage">אחוזי קטגוריות</string>
<string name="confirm">אשר</string>
<string name="confirm_delete">\"אתה בטוח שברצונך למחוק\"</string>
<string name="confirm_delete_expense">אתה בטוח שברצונך למחוק הוצאה זאת?</string>
<string name="confirm_delete_items">אתה בטוח שברצונך למחוק פריט(ים) אלה</string>
<string name="confirm_reminder_delete">אתה בטוח שברצונך לבטל את התזכורת?</string>
<string name="country_currency">מטבע</string>
<string name="create_a_reminder">צור תזכורת</string>
<string name="create_category">צור קטגוריה</string>
<string name="credit_card_content_desc">אייקון כרטיס אשראי</string>
<string name="date_format">פורמט תאריך</string>
<string name="date_from">תאריך מ</string>
<string name="date_placeholder">כתוב תאריך פה</string>
<string name="default_country">IL</string>
<string name="default_date_format">dd/MM/yyyy</string>
<string name="delete">מחק</string>
<string name="description">תיאור</string>
<string name="edit_a_reminder">ערוך תזכורת</string>
<string name="edit_category">ערך קטגוריה</string>
<string name="error_name">הכנס שם בבקשה</string>
<string name="error_total">הכנס סכום בבקשה</string>
<string name="expense_detail">פרטי הוצאה</string>
<string name="expenses">הוצאות</string>
<string name="expenses_mail_content">הקלטת הוצאות בעזרת Expense Tracker</string>
<string name="export">ייצא</string>
<string name="help_text">באפשרותך למחוק הוצאות, קטגוריות ותזכורות על ידי החזקת פריט, והתפריט שיפתח יאפשר לך לבחור פריט אחד או יותר למחיקה.\n\nבחר את התאריך שברצונך ליצור בו הוצאה בחלון \"הוצאה חדשה\" על ידי לחיצה על התאריך.\n\nצור תזכורת כדי לקבל התראה בתאריך או שעה ספציפית.\n\nערוך את שם הקטגוריה על ידי הקשה אחת על קגוריה. לכל שאלה או הערה לא להתלבט ולפנות אל carrillochero6@gmail.com</string>
<string name="hint_category">דוגמא: אוכל</string>
<string name="history">הסטוריה</string>
<string name="income">הכנסה</string>
<string name="month">חודש</string>
<string name="no_categories_error">עליך ליצור קטגוריה על מנת לרשום הוצאות</string>
<string name="no_chart_data">לא קיימים נתונים</string>
<string name="no_expenses_today">אין הוצאות ליום זה</string>
<string name="ok">אישור</string>
<string name="optional_description">תיאור (אופציונאלי)</string>
<string name="pick_dates">בחר טווח תאריכים</string>
<string name="pick_day_of_month">בחר יום בחודש</string>
<string name="reminder_help">צור תזכורת כדי לעזור לעצמך לקבל התראה באותו יום בחודש כדי לזכור מתי החשבון מתקבל. ההתראה תופיע בזמן המתאים. אתה יכול לכבות את התזכורת בכל זמן שתרצה.</string>
<string name="reminder_name_hint">לדוגמא: כרטיס אשראי של חברה</string>
<string name="reminder_name_validation">הכנס את שם התזכורת</string>
<string name="reminder_schedule_title">התזכורת מיועדת ל(יום בחודש):</string>
<string name="reminder_time_sent_title">היא תופיע בשעה:</string>
<string name="reminders">תזכורות</string>
<string name="reminders_empty">לא קיימות תזכורות. צור תזכורות כדי לקבל התראה בתאריכים מיוחדים.</string>
<string name="same_category_this_week">קטגוריה זאת בשבוע</string>
<string name="save">שמור</string>
<string name="second_page_desc">השתמש בנתונים הסטטיסטיים כדי לזהות היכן תוכל לחסוך כסף</string>
<string name="share_title">שלח את המאגר שלך אל תיבת המייל שלך</string>
<string name="start">התחל</string>
<string name="start_using_expense">התחל להשתמש בExpense Tracker</string>
<string name="statistics">סטטיסטיקות</string>
<string name="third_page_desc">הגדר תזכורות כדי להתריע כשר תאריכי הפרעון קרובים.</string>
<string name="this_week">השבוע הנוכחי</string>
<string name="title_activity_expense_detail">חלון פירוט הוצאות</string>
<string name="title_activity_help">חלון עזרה</string>
<string name="title_activity_login">חלון התחברות</string>
<string name="to_date">עד תאריך</string>
<string name="today">היום</string>
<string name="today_expenses_total">היום: %s</string>
<string name="total">סה\"כ</string>
<string name="total_expenses_per_category">סך הוצאות לפי קטגוריה</string>
<string name="week">שבוע</string>
<string name="welcome">ברוך הבא!</string>
<string name="welcome_first_page">תוכל לעקוב אחרי ההוצאות שלך בכל זמן! קבל מבט מהיר על ההוצאות שלך על פי יום, שבוע וחודש!</string>
<string name="write_external_message">Expense Tracker רוצה ליצור קבצים כדי לייצא את נתוני ההוצאות</string>
</resources>