Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 55de54d

Browse files
author
Evgeniy Kanivets
committed
Added colors to dialogs
1 parent dee7bdb commit 55de54d

File tree

6 files changed

+144
-29
lines changed

6 files changed

+144
-29
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.blogspot.e_kanivets.moneytracker;
2+
3+
/**
4+
* Created by eugene on 29/08/14.
5+
*/
6+
public class Constants {
7+
8+
public static final String TAG = "Unique";
9+
10+
public static final String DB_NAME = "database";
11+
public static final int DB_VERSION = 1;
12+
public static final String TABLE_RECORDS = "records";
13+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.blogspot.e_kanivets.moneytracker;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.database.sqlite.SQLiteDatabase;
6+
import android.database.sqlite.SQLiteOpenHelper;
7+
8+
/**
9+
* Created by eugene on 29/08/14.
10+
*/
11+
public class DBHelper extends SQLiteOpenHelper {
12+
13+
public DBHelper(Context context) {
14+
super(context, Constants.DB_NAME, null, Constants.DB_VERSION);
15+
}
16+
17+
@Override
18+
public void onCreate(SQLiteDatabase db) {
19+
db.execSQL("create table " + Constants.TABLE_RECORDS + "("
20+
+ "id integer primary key autoincrement,"
21+
+ "time integer,"
22+
+ "title text,"
23+
+ "category_id integer,"
24+
+ "price integer" + ");");
25+
}
26+
27+
@Override
28+
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
29+
30+
}
31+
}

app/src/main/java/com/blogspot/e_kanivets/moneytracker/MainActivity.java

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.view.MenuItem;
99
import android.view.View;
1010
import android.widget.Button;
11+
import android.widget.TextView;
1112

1213

1314
public class MainActivity extends ActionBarActivity {
@@ -69,14 +70,58 @@ private void showAddExpenseDialog() {
6970

7071
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
7172
builder.setView(layout);
72-
builder.show();
73+
74+
final AlertDialog dialog = builder.show();
75+
76+
TextView tvTitle = (TextView) layout.findViewById(R.id.tv_title);
77+
tvTitle.setText(R.string.expense);
78+
tvTitle.setBackgroundColor(getResources().getColor(R.color.red_light));
79+
80+
Button buttonAdd = (Button) layout.findViewById(R.id.b_add);
81+
buttonAdd.setText(getResources().getString(R.string.add_expense));
82+
buttonAdd.setOnClickListener(new View.OnClickListener() {
83+
@Override
84+
public void onClick(View v) {
85+
dialog.dismiss();
86+
}
87+
});
88+
89+
Button buttonCancel = (Button) layout.findViewById(R.id.b_cancel);
90+
buttonCancel.setOnClickListener(new View.OnClickListener() {
91+
@Override
92+
public void onClick(View v) {
93+
dialog.dismiss();
94+
}
95+
});
7396
}
7497

7598
private void showAddIncomeDialog() {
7699
View layout = getLayoutInflater().inflate(R.layout.dialog_add_record, null);
77100

78101
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
79102
builder.setView(layout);
80-
builder.show();
103+
104+
final AlertDialog dialog = builder.show();
105+
106+
TextView tvTitle = (TextView) layout.findViewById(R.id.tv_title);
107+
tvTitle.setText(R.string.income);
108+
tvTitle.setBackgroundColor(getResources().getColor(R.color.green_light));
109+
110+
Button buttonAdd = (Button) layout.findViewById(R.id.b_add);
111+
buttonAdd.setText(getResources().getString(R.string.add_income));
112+
buttonAdd.setOnClickListener(new View.OnClickListener() {
113+
@Override
114+
public void onClick(View v) {
115+
dialog.dismiss();
116+
}
117+
});
118+
119+
Button buttonCancel = (Button) layout.findViewById(R.id.b_cancel);
120+
buttonCancel.setOnClickListener(new View.OnClickListener() {
121+
@Override
122+
public void onClick(View v) {
123+
dialog.dismiss();
124+
}
125+
});
81126
}
82127
}

app/src/main/res/drawable/drawable.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/src/main/res/layout/dialog_add_record.xml

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,82 @@
2020
android:background="@color/blue"
2121
android:textColor="@color/white"
2222
android:gravity="center"
23-
android:textAllCaps="true"/>
23+
android:textAllCaps="true"
24+
android:id="@+id/tv_title" />
2425

2526
<LinearLayout
26-
android:orientation="horizontal"
27+
android:orientation="vertical"
2728
android:layout_width="match_parent"
2829
android:layout_height="wrap_content">
2930

3031
<LinearLayout
31-
android:orientation="vertical"
32-
android:layout_width="wrap_content"
33-
android:layout_height="match_parent"
34-
android:layout_margin="10dp">
32+
android:orientation="horizontal"
33+
android:layout_width="fill_parent"
34+
android:layout_height="wrap_content"
35+
android:layout_margin="2dp">
3536

3637
<TextView
37-
android:layout_width="wrap_content"
38+
android:layout_width="match_parent"
3839
android:layout_height="match_parent"
39-
android:text="@string/category"
40-
android:gravity="center"
41-
android:layout_weight="1" />
40+
android:text="@string/title"
41+
android:layout_weight="3"
42+
android:gravity="center_vertical|left"
43+
android:paddingLeft="10dp" />
44+
45+
<EditText
46+
android:layout_width="match_parent"
47+
android:layout_height="match_parent"
48+
android:id="@+id/et_title"
49+
android:layout_weight="1"
50+
android:layout_marginRight="10dp" />
51+
</LinearLayout>
52+
53+
<LinearLayout
54+
android:orientation="horizontal"
55+
android:layout_width="match_parent"
56+
android:layout_height="wrap_content"
57+
android:layout_weight="1"
58+
android:layout_margin="2dp">
4259

4360
<TextView
44-
android:layout_width="wrap_content"
61+
android:layout_width="match_parent"
4562
android:layout_height="match_parent"
46-
android:text="@string/amount"
47-
android:gravity="center_vertical"
48-
android:layout_weight="1" />
63+
android:text="@string/category"
64+
android:layout_weight="3"
65+
android:gravity="center_vertical|left"
66+
android:paddingLeft="10dp" />
67+
68+
<EditText
69+
android:layout_width="match_parent"
70+
android:layout_height="match_parent"
71+
android:id="@+id/et_expense_category"
72+
android:layout_weight="1"
73+
android:layout_marginRight="10dp" />
4974

5075
</LinearLayout>
5176

5277
<LinearLayout
53-
android:orientation="vertical"
78+
android:orientation="horizontal"
5479
android:layout_width="match_parent"
5580
android:layout_height="wrap_content"
5681
android:layout_gravity="center_horizontal"
57-
android:layout_margin="10dp">
82+
android:layout_weight="1"
83+
android:layout_margin="2dp">
5884

59-
<EditText
85+
<TextView
6086
android:layout_width="match_parent"
6187
android:layout_height="match_parent"
62-
android:id="@+id/et_expense_category" />
88+
android:text="@string/price"
89+
android:layout_weight="3"
90+
android:gravity="center_vertical|left"
91+
android:paddingLeft="10dp" />
6392

6493
<EditText
6594
android:layout_width="match_parent"
6695
android:layout_height="wrap_content"
67-
android:id="@+id/et_expense_amount" />
96+
android:id="@+id/et_expense_amount"
97+
android:layout_weight="1"
98+
android:layout_marginRight="10dp" />
6899

69100
</LinearLayout>
70101
</LinearLayout>
@@ -74,8 +105,7 @@
74105
android:layout_width="match_parent"
75106
android:layout_height="wrap_content"
76107
android:layout_gravity="center_horizontal"
77-
android:layout_margin="10dp"
78-
android:id="@+id/linearLayout">
108+
android:layout_margin="10dp">
79109

80110
<Button
81111
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
<string name="hello_world">Hello world!</string>
66
<string name="action_settings">Settings</string>
77

8+
<string name="title">Title</string>
89
<string name="category">Category</string>
9-
<string name="amount">Amount</string>
10+
<string name="price">Price</string>
1011
<string name="add_income">Add income</string>
1112
<string name="add_expense">Add expense</string>
1213
<string name="income">INCOME</string>

0 commit comments

Comments
 (0)