8
8
import android .os .Bundle ;
9
9
import android .view .LayoutInflater ;
10
10
import android .view .View ;
11
- import android .widget .AdapterView ;
12
- import android .widget .ArrayAdapter ;
13
11
import android .widget .CheckBox ;
14
12
import android .widget .ImageView ;
15
- import android .widget .LinearLayout ;
16
- import android .widget .Spinner ;
17
13
import android .widget .TimePicker ;
18
14
import android .widget .Toast ;
19
15
24
20
import androidx .constraintlayout .widget .ConstraintSet ;
25
21
26
22
import com .google .android .material .textfield .TextInputEditText ;
27
- import com .google .android .material .textfield .TextInputLayout ;
28
23
import com .poupa .attestationdeplacement .generator .Attestation ;
29
24
import com .poupa .attestationdeplacement .generator .AttestationDeplacementDerogatoireGenerator ;
30
25
import com .poupa .attestationdeplacement .generator .AttestationGenerator ;
31
- import com .poupa .attestationdeplacement .generator .AutoAttestationTransportsGenerator ;
32
- import com .poupa .attestationdeplacement .generator .DeclarationDeplacementGenerator ;
33
26
import com .poupa .attestationdeplacement .ui .DateTextWatcher ;
34
27
35
28
import java .util .Calendar ;
@@ -43,16 +36,10 @@ public class CreateAttestationActivity extends AppCompatActivity {
43
36
private TextInputEditText birthPlaceInput ;
44
37
private TextInputEditText addressInput ;
45
38
private TextInputEditText cityInput ;
46
- private TextInputEditText destinationCityInput ;
47
- private TextInputEditText destinationDepartmentInput ;
48
39
private TextInputEditText postalCodeInput ;
49
40
private TextInputEditText travelDateInput ;
50
41
private TextInputEditText travelHourInput ;
51
- private TextInputLayout travelHourLayout ;
52
42
53
- private TextInputLayout destinationCityLayout ;
54
- private TextInputLayout destinationDepartmentLayout ;
55
- private LinearLayout recurringLayout ;
56
43
private ConstraintLayout constraintLayout ;
57
44
private ConstraintSet constraintSet ;
58
45
@@ -62,12 +49,6 @@ public class CreateAttestationActivity extends AppCompatActivity {
62
49
63
50
private Attestation attestation ;
64
51
65
- public enum AttestationType {
66
- DECLARATION_DEPLACEMENT ,
67
- AUTO_ATTESTATION_TRANSPORTS ,
68
- ATTESTATION_DEPLACEMENT_DEROGATOIRE
69
- }
70
-
71
52
@ Override
72
53
protected void onCreate (Bundle savedInstanceState ) {
73
54
super .onCreate (savedInstanceState );
@@ -86,7 +67,8 @@ protected void onCreate(Bundle savedInstanceState) {
86
67
*/
87
68
private void initFields () {
88
69
attestation = new Attestation ();
89
- attestation .setAttestationType (AttestationType .AUTO_ATTESTATION_TRANSPORTS );
70
+
71
+ attestationGenerator = new AttestationDeplacementDerogatoireGenerator (this , attestation );
90
72
91
73
SharedPreferences userDetails = getSharedPreferences ("userDetails" , MODE_PRIVATE );
92
74
@@ -120,14 +102,6 @@ private void initFields() {
120
102
121
103
postalCodeInput .setText (userDetails .getString ("postalCode" , "" ));
122
104
123
- destinationCityInput = findViewById (R .id .destination_city );
124
-
125
- destinationCityInput .setText (userDetails .getString ("destinationCity" , "" ));
126
-
127
- destinationDepartmentInput = findViewById (R .id .destination_department );
128
-
129
- destinationDepartmentInput .setText (userDetails .getString ("destinationDepartment" , "" ));
130
-
131
105
travelDateInput = findViewById (R .id .travel_date );
132
106
133
107
travelHourInput = findViewById (R .id .travel_hour );
@@ -168,22 +142,12 @@ public void onClick(View v) {
168
142
}
169
143
});
170
144
171
- travelHourLayout = findViewById (R .id .travel_hour_layout );
172
- destinationCityLayout = findViewById (R .id .destination_city_layout );
173
- destinationDepartmentLayout = findViewById (R .id .destination_department_layout );
174
- recurringLayout = findViewById (R .id .recurring_layout );
175
- constraintLayout = findViewById (R .id .constraint_layout );
176
-
177
145
constraintSet = new ConstraintSet ();
178
-
179
- Spinner spinner = findViewById (R .id .attestation_type );
180
-
181
- ArrayAdapter <CharSequence > adapter = ArrayAdapter .createFromResource (this ,
182
- R .array .attestation_type , android .R .layout .simple_spinner_item );
183
- adapter .setDropDownViewResource (android .R .layout .simple_spinner_dropdown_item );
184
- spinner .setAdapter (adapter );
185
-
186
- spinner .setOnItemSelectedListener (new SpinnerOnItemSelectedListener ());
146
+ constraintLayout = findViewById (R .id .constraint_layout );
147
+ constraintSet .clone (constraintLayout );
148
+ constraintSet .connect (R .id .reasonsTextView , ConstraintSet .TOP ,
149
+ R .id .travel_hour_layout , ConstraintSet .BOTTOM );
150
+ constraintSet .applyTo (constraintLayout );
187
151
}
188
152
189
153
/**
@@ -271,12 +235,6 @@ public void saveFields() {
271
235
attestation .setPostalCode (postalCodeInput .getText ().toString ());
272
236
edit .putString ("postalCode" , attestation .getPostalCode ());
273
237
274
- attestation .setDestinationCity (destinationCityInput .getText ().toString ());
275
- edit .putString ("destinationCity" , attestation .getDestinationCity ());
276
-
277
- attestation .setDestinationDepartment (destinationDepartmentInput .getText ().toString ());
278
- edit .putString ("destinationDepartment" , attestation .getDestinationDepartment ());
279
-
280
238
edit .apply ();
281
239
282
240
// Do not save this for further uses
@@ -298,9 +256,6 @@ public void saveFields() {
298
256
attestation .setReason6 (((CheckBox ) findViewById (R .id .reason6 )).isChecked ());
299
257
attestation .setReason7 (((CheckBox ) findViewById (R .id .reason7 )).isChecked ());
300
258
attestation .setReason8 (((CheckBox ) findViewById (R .id .reason8 )).isChecked ());
301
- attestation .setReason9 (((CheckBox ) findViewById (R .id .reason9 )).isChecked ());
302
-
303
- attestation .setRecurring (((CheckBox ) findViewById (R .id .recurring )).isChecked ());
304
259
}
305
260
306
261
/**
@@ -342,60 +297,4 @@ private void getReasonsDialog() {
342
297
builder .setPositiveButton (getString (android .R .string .ok ),null );
343
298
builder .show ();
344
299
}
345
-
346
- private class SpinnerOnItemSelectedListener implements AdapterView .OnItemSelectedListener {
347
- @ Override
348
- public void onItemSelected (AdapterView <?> parent , View view , int position , long id ) {
349
- if (position == 0 ) {
350
- attestation .setAttestationType (AttestationType .DECLARATION_DEPLACEMENT );
351
-
352
- attestationGenerator = new DeclarationDeplacementGenerator (parent .getContext (), attestation );
353
-
354
- travelHourLayout .setVisibility (View .INVISIBLE );
355
- destinationCityLayout .setVisibility (View .VISIBLE );
356
- destinationDepartmentLayout .setVisibility (View .VISIBLE );
357
- recurringLayout .setVisibility (View .VISIBLE );
358
-
359
- constraintSet .clone (constraintLayout );
360
- constraintSet .connect (R .id .reasonsTextView , ConstraintSet .TOP ,
361
- R .id .recurring_layout , ConstraintSet .BOTTOM );
362
- constraintSet .applyTo (constraintLayout );
363
-
364
- } else if (position == 1 ) {
365
- attestation .setAttestationType (AttestationType .AUTO_ATTESTATION_TRANSPORTS );
366
-
367
- attestationGenerator = new AutoAttestationTransportsGenerator (parent .getContext (), attestation );
368
-
369
- travelHourLayout .setVisibility (View .INVISIBLE );
370
- destinationCityLayout .setVisibility (View .INVISIBLE );
371
- destinationDepartmentLayout .setVisibility (View .INVISIBLE );
372
- recurringLayout .setVisibility (View .INVISIBLE );
373
-
374
- constraintSet .clone (constraintLayout );
375
- constraintSet .connect (R .id .reasonsTextView , ConstraintSet .TOP ,
376
- R .id .travel_date_layout , ConstraintSet .BOTTOM );
377
- constraintSet .applyTo (constraintLayout );
378
-
379
- } else {
380
- attestation .setAttestationType (AttestationType .ATTESTATION_DEPLACEMENT_DEROGATOIRE );
381
-
382
- attestationGenerator = new AttestationDeplacementDerogatoireGenerator (parent .getContext (), attestation );
383
-
384
- travelHourLayout .setVisibility (View .VISIBLE );
385
- destinationCityLayout .setVisibility (View .INVISIBLE );
386
- destinationDepartmentLayout .setVisibility (View .INVISIBLE );
387
- recurringLayout .setVisibility (View .INVISIBLE );
388
-
389
- constraintSet .clone (constraintLayout );
390
- constraintSet .connect (R .id .reasonsTextView , ConstraintSet .TOP ,
391
- R .id .travel_hour_layout , ConstraintSet .BOTTOM );
392
- constraintSet .applyTo (constraintLayout );
393
- }
394
- }
395
-
396
- @ Override
397
- public void onNothingSelected (AdapterView <?> parent ) {
398
-
399
- }
400
- }
401
300
}
0 commit comments