1 |
|
package com.loopback.androidapps.saveapp; |
2 |
|
|
3 |
|
import android.app.Activity; |
4 |
|
import android.app.AlertDialog; |
5 |
|
import android.content.DialogInterface; |
6 |
|
import android.content.Intent; |
7 |
|
import android.os.Bundle; |
8 |
|
import android.util.Log; |
9 |
|
import android.view.Menu; |
10 |
|
import android.view.MenuInflater; |
11 |
|
import android.view.MenuItem; |
12 |
|
import android.view.View; |
13 |
|
import android.widget.ImageButton; |
14 |
|
import android.widget.TextView; |
15 |
|
import android.widget.Toast; |
16 |
|
|
|
|
| 80,5% |
Uncovered Elements: 22 (113) |
Complexity: 21 |
Complexity Density: 0,24 |
|
17 |
|
public class OutlayDetailActivity extends Activity implements |
18 |
|
View.OnClickListener { |
19 |
|
|
20 |
|
private ImageButton btnPhoto, btnNotes, btnFile; |
21 |
|
TextView txtAccount, txtChargeValue, txtItemValue, txtPlaceValue, |
22 |
|
txtAddressValue, txtDateValue; |
23 |
|
private Outlay outlay; |
24 |
|
private String note; |
25 |
|
public boolean isEuropeanCalendar = true; |
26 |
|
private int outlayId; |
27 |
|
public SaveApp saveApp; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
32 |
9
|
public void onCreate(Bundle savedInstanceState) {... |
33 |
9
|
Log.i("OEA", "Init"); |
34 |
9
|
super.onCreate(savedInstanceState); |
35 |
9
|
setContentView(R.layout.outlaydetail); |
36 |
|
|
37 |
9
|
loadActivity(); |
38 |
|
} |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
|
|
| 96,4% |
Uncovered Elements: 1 (28) |
Complexity: 2 |
Complexity Density: 0,08 |
|
43 |
9
|
public void loadActivity() {... |
44 |
9
|
Log.i("ODA", "Loading..."); |
45 |
9
|
saveApp = ((SaveApp) getApplicationContext()); |
46 |
|
|
47 |
9
|
Bundle bundle = this.getIntent().getExtras(); |
48 |
9
|
outlayId = bundle.getInt("Id"); |
49 |
|
|
50 |
9
|
outlay = new Outlay(outlayId); |
51 |
|
|
52 |
9
|
note = null; |
53 |
9
|
btnPhoto = (ImageButton) findViewById(R.id.btnPhoto); |
54 |
9
|
btnNotes = (ImageButton) findViewById(R.id.btnNotes); |
55 |
9
|
btnFile = (ImageButton) findViewById(R.id.btnFile); |
56 |
9
|
txtChargeValue = (TextView) findViewById(R.id.txtChargeValue); |
57 |
9
|
txtItemValue = (TextView) findViewById(R.id.txtItemValue); |
58 |
9
|
txtPlaceValue = (TextView) findViewById(R.id.txtPlaceValue); |
59 |
9
|
txtAddressValue = (TextView) findViewById(R.id.txtAddress); |
60 |
9
|
txtDateValue = (TextView) findViewById(R.id.txtDate); |
61 |
9
|
txtAccount = (TextView) findViewById(R.id.txtAccount); |
62 |
|
|
63 |
9
|
btnNotes.setOnClickListener(this); |
64 |
9
|
btnFile.setOnClickListener(this); |
65 |
9
|
btnPhoto.setOnClickListener(this); |
66 |
|
|
67 |
9
|
Log.i("ODA", "Loading..."); |
68 |
9
|
txtChargeValue.setText(String.valueOf((outlay.getCharge()) |
69 |
|
+ saveApp.getCurrencySymbol())); |
70 |
9
|
txtItemValue.setText(outlay.getItemDesc()); |
71 |
9
|
txtPlaceValue.setText(outlay.getPlaceDesc()); |
72 |
9
|
txtAddressValue.setText((outlay.getAddressDesc() == null) ? "No data" |
73 |
|
: outlay.getAddressDesc()); |
74 |
9
|
txtDateValue.setText(Utilities.printDate(outlay.getDate())); |
75 |
|
|
76 |
9
|
txtAccount.setText(getString(R.string.strAccount) + ": " |
77 |
|
+ saveApp.getAccountDesc()); |
78 |
|
|
79 |
9
|
Log.i("ODA", "Loaded"); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
82 |
1
|
public void delete(){... |
83 |
1
|
Outlay outlayToDelete = new Outlay(outlayId); |
84 |
1
|
outlayToDelete.delete(); |
85 |
1
|
Intent intent = new Intent(this.getApplicationContext(), |
86 |
|
OutlaysListActivity.class); |
87 |
1
|
Log.i("ODA", "Starting Activity Outlay List"); |
88 |
1
|
startActivity(intent); |
89 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
90 |
4
|
public void onBackPressed() {... |
91 |
4
|
Log.i("ODA", "Back Pressed..."); |
92 |
4
|
Intent intent = new Intent(this.getApplicationContext(), |
93 |
|
OutlaysListActivity.class); |
94 |
4
|
Log.i("ODA", "Starting Activity Outlay List"); |
95 |
4
|
startActivity(intent); |
96 |
|
} |
97 |
|
|
|
|
| 47,6% |
Uncovered Elements: 11 (21) |
Complexity: 6 |
Complexity Density: 0,46 |
|
98 |
1
|
public void onClick(View v) {... |
99 |
1
|
if (v == btnNotes) { |
100 |
1
|
if (outlay.getNote().equals("") || outlay.getNote() == null) |
101 |
0
|
Toast.makeText(this, "No notes for this movement", |
102 |
|
Toast.LENGTH_SHORT).show(); |
103 |
|
else { |
104 |
1
|
Bundle bundle = new Bundle(); |
105 |
1
|
bundle.putString("Note", (outlay.getNote())); |
106 |
1
|
bundle.putInt("Id", outlayId); |
107 |
1
|
Intent intent = new Intent(this.getApplicationContext(), |
108 |
|
NoteViewActivity.class); |
109 |
1
|
intent.putExtras(bundle); |
110 |
1
|
startActivity(intent); |
111 |
|
} |
112 |
0
|
} else if (v == btnFile) { |
113 |
0
|
Toast.makeText(this, getString(R.string.strNotSupported), |
114 |
|
Toast.LENGTH_SHORT).show(); |
115 |
0
|
} else if (v == btnPhoto) { |
116 |
0
|
Toast.makeText(this, getString(R.string.strNotSupported), |
117 |
|
Toast.LENGTH_SHORT).show(); |
118 |
|
} |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
121 |
0
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {... |
122 |
0
|
note = data.getStringExtra("Note"); |
123 |
0
|
if (note != null) |
124 |
0
|
Toast.makeText(this, getString(R.string.strNoteAdded), |
125 |
|
Toast.LENGTH_SHORT).show(); |
126 |
|
|
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0
|
public void text() {... |
130 |
0
|
Toast.makeText(this, "Deleting", Toast.LENGTH_SHORT).show(); |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
137 |
6
|
public boolean onCreateOptionsMenu(Menu menu) {... |
138 |
6
|
Log.i("ODA", "Menu Inflating..."); |
139 |
6
|
MenuInflater inflater = getMenuInflater(); |
140 |
6
|
inflater.inflate(R.menu.menu, menu); |
141 |
6
|
Log.i("ODA", "Menu Inflated"); |
142 |
6
|
return true; |
143 |
|
} |
144 |
|
|
|
|
| 89,5% |
Uncovered Elements: 2 (19) |
Complexity: 3 |
Complexity Density: 0,16 |
|
145 |
5
|
@Override... |
146 |
|
public boolean onOptionsItemSelected(MenuItem item) { |
147 |
5
|
Log.i("ODA", "Menu..."); |
148 |
5
|
switch (item.getItemId()) { |
149 |
3
|
case R.id.mnuEdit: |
150 |
3
|
Log.i("ODA", "Menu Edit"); |
151 |
3
|
saveApp.outlay.inflate(outlayId); |
152 |
3
|
Bundle bundle = new Bundle(); |
153 |
3
|
bundle.putBoolean("HasChanges", false); |
154 |
3
|
bundle.putInt("Id", outlayId); |
155 |
3
|
Intent intentEdit = new Intent(this.getApplicationContext(), |
156 |
|
OutlayEditActivity.class); |
157 |
3
|
intentEdit.putExtras(bundle); |
158 |
3
|
Log.i("ODA", "Start Activity For Editint"); |
159 |
3
|
startActivity(intentEdit); |
160 |
3
|
return true; |
161 |
2
|
case R.id.mnuDelete: |
162 |
2
|
Log.i("ODA", "Menu Delete"); |
163 |
2
|
deleteOutlay(); |
164 |
2
|
return true; |
165 |
0
|
default: |
166 |
0
|
return super.onOptionsItemSelected(item); |
167 |
|
} |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
|
174 |
2
|
public void deleteOutlay() {... |
175 |
2
|
Log.i("ODA", "Delete Alert"); |
176 |
2
|
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); |
177 |
2
|
alt_bld.setMessage(getString(R.string.strDialogDelete)) |
178 |
|
.setCancelable(true) |
179 |
|
.setPositiveButton(getString(R.string.strYes), |
180 |
|
new DialogInterface.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
181 |
1
|
public void onClick(DialogInterface dialog, int id) {... |
182 |
1
|
delete(); |
183 |
|
} |
184 |
|
}) |
185 |
|
.setNegativeButton(getString(R.string.strNo), |
186 |
|
new DialogInterface.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
187 |
1
|
public void onClick(DialogInterface dialog, int id) {... |
188 |
|
|
189 |
1
|
dialog.cancel(); |
190 |
|
} |
191 |
|
}); |
192 |
2
|
AlertDialog alert = alt_bld.create(); |
193 |
2
|
alert.setTitle(getString(R.string.strAlert)); |
194 |
2
|
alert.setIcon(R.drawable.alert); |
195 |
2
|
alert.show(); |
196 |
|
} |
197 |
|
} |