Skip to content

Commit 4ae32b0

Browse files
author
rifqi.fardi
committed
- fix minimum selection and enhance counter limitation
1 parent 096a94d commit 4ae32b0

15 files changed

+118
-24
lines changed

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "io.github.jboxx.catering_subscribe"
77
minSdkVersion 19
88
targetSdkVersion 27
9-
versionCode 2
10-
versionName "1.1"
9+
versionCode 3
10+
versionName "1.2"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {

app/release/output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":2,"versionName":"1.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
1+
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":3,"versionName":"1.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

app/src/main/java/io/github/jboxx/catering_subscribe/customviews/AbstractBaseView.java

-9
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
3131

3232
private void logSpec(int specMode) {
3333
if (specMode == MeasureSpec.UNSPECIFIED) {
34-
Log.d(TAG, "mode: unspecified");
3534
return;
3635
}
3736
if (specMode == MeasureSpec.AT_MOST) {
38-
Log.d(TAG, "mode: at most");
3937
return;
4038
}
4139
if (specMode == MeasureSpec.EXACTLY) {
42-
Log.d(TAG, "mode: exact");
4340
return;
4441
}
4542
}
@@ -51,31 +48,26 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
5148

5249
@Override
5350
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
54-
Log.d(TAG, "onLayout");
5551
super.onLayout(changed, left, top, right, bottom);
5652
}
5753

5854
@Override
5955
public void onDraw(Canvas canvas) {
6056
super.onDraw(canvas);
61-
Log.d(TAG, "onDraw called");
6257
}
6358

6459
@Override
6560
protected void onRestoreInstanceState(Parcelable p) {
66-
Log.d(TAG, "onRestoreInstanceState");
6761
super.onRestoreInstanceState(p);
6862
}
6963

7064
@Override
7165
protected Parcelable onSaveInstanceState() {
72-
Log.d(TAG, "onSaveInstanceState");
7366
Parcelable p = super.onSaveInstanceState();
7467
return p;
7568
}
7669

7770
private int getImprovedDefaultHeight(int measureSpec) {
78-
// int result = size;
7971
int specMode = MeasureSpec.getMode(measureSpec);
8072
int specSize = MeasureSpec.getSize(measureSpec);
8173
switch (specMode) {
@@ -90,7 +82,6 @@ private int getImprovedDefaultHeight(int measureSpec) {
9082
}
9183

9284
private int getImprovedDefaultWidth(int measureSpec) {
93-
// int result = size;
9485
int specMode = MeasureSpec.getMode(measureSpec);
9586
int specSize = MeasureSpec.getSize(measureSpec);
9687
switch (specMode) {

app/src/main/java/io/github/jboxx/catering_subscribe/customviews/CircleView.java

+35-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,30 @@
44
import android.content.res.TypedArray;
55
import android.graphics.Canvas;
66
import android.graphics.Paint;
7-
import android.support.annotation.ColorRes;
87
import android.support.annotation.Nullable;
8+
import android.support.annotation.StringDef;
99
import android.util.AttributeSet;
1010

11+
import java.lang.annotation.Retention;
12+
import java.lang.annotation.RetentionPolicy;
13+
1114
import io.github.jboxx.catering_subscribe.R;
1215

1316
public class CircleView extends AbstractBaseView {
1417

18+
@Retention(RetentionPolicy.SOURCE)
19+
@StringDef({
20+
ACTIVE,
21+
UNACTIVE,
22+
FILLED,
23+
})
24+
25+
public @interface CircleViewConstant {}
26+
27+
public static final String ACTIVE = "ACTIVE";
28+
public static final String UNACTIVE = "UNACTIVE";
29+
public static final String FILLED = "FILLED";
30+
1531
private int circleRadius = 18;
1632
private int strokeColor = 0xFFFD9714;
1733
private int strokeWidth = 8;
@@ -99,6 +115,24 @@ private Paint getFill() {
99115
return p;
100116
}
101117

118+
public void setCircleStatus(@CircleViewConstant String status) {
119+
switch (status) {
120+
case ACTIVE:
121+
this.strokeColor = 0xFFFD9714;
122+
this.fillColor = 0X00FFFFFF;
123+
break;
124+
case UNACTIVE:
125+
this.strokeColor = 0xFFE0E0E0;
126+
this.fillColor = 0X00FFFFFF;
127+
break;
128+
case FILLED:
129+
this.strokeColor = 0xFFFD9714;
130+
this.fillColor = 0xFFFD9714;
131+
break;
132+
}
133+
invalidate();
134+
}
135+
102136
public void setCircleActive(boolean isActive) {
103137
this.strokeColor = isActive ? 0xFFFD9714 : 0xFFE0E0E0;
104138
invalidate();

app/src/main/java/io/github/jboxx/catering_subscribe/customviews/CounterView.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class CounterView extends LinearLayout {
2525
private String prefix = "";
2626

2727
private TextView txtCounter;
28+
private Button btnMinus;
29+
private Button btnPlus;
2830
private boolean isPlusEnabled;
2931
private boolean isMinusEnabled;
3032
private OnCountChangedListener listener;
@@ -81,7 +83,7 @@ void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
8183
ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
8284
addView(txtCounter);
8385

84-
Button btnMinus = new Button(context);
86+
btnMinus = new Button(context);
8587
btnMinus.setText("-");
8688
btnMinus.setTextSize(18f);
8789
LayoutParams layoutParams = new LinearLayout.LayoutParams(
@@ -91,7 +93,7 @@ void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
9193
0, context.getResources().getDimensionPixelSize(R.dimen.margin_2dp), 0);
9294
btnMinus.setLayoutParams(layoutParams);
9395
btnMinus.setTextColor(ContextCompat.getColor(context, android.R.color.white));
94-
btnMinus.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_counter_left));
96+
btnMinus.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_counter_left_state));
9597
btnMinus.setOnClickListener(v -> {
9698
if (isMinusEnabled){
9799
--count;
@@ -104,14 +106,14 @@ void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
104106
});
105107
addView(btnMinus);
106108

107-
Button btnPlus = new Button(context);
109+
btnPlus = new Button(context);
108110
btnPlus.setText("+");
109111
btnPlus.setTextSize(18f);
110112
btnPlus.setLayoutParams(new LinearLayout.LayoutParams(
111113
context.getResources().getDimensionPixelSize(R.dimen.btn_counter_width),
112114
ViewGroup.LayoutParams.MATCH_PARENT));
113115
btnPlus.setTextColor(ContextCompat.getColor(context, android.R.color.white));
114-
btnPlus.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_counter_right));
116+
btnPlus.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_counter_right_state));
115117
btnPlus.setOnClickListener(v -> {
116118
if(isPlusEnabled){
117119
++count;
@@ -141,6 +143,16 @@ private void disableButtonsIfNeeded() {
141143
} else {
142144
isMinusEnabled = false;
143145
}
146+
setDisabilityLeftCounterButton();
147+
setDisabilityRightCounterButton();
148+
}
149+
150+
private void setDisabilityLeftCounterButton() {
151+
btnMinus.setEnabled(isMinusEnabled);
152+
}
153+
154+
private void setDisabilityRightCounterButton() {
155+
btnPlus.setEnabled(isPlusEnabled);
144156
}
145157

146158
private void redrawCounter(int count) {

app/src/main/java/io/github/jboxx/catering_subscribe/customviews/calendardecorator/DisableSaturdayAndMonday.java

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import org.threeten.bp.DayOfWeek;
88

9-
import java.util.Calendar;
109
import java.util.Collection;
1110
import java.util.HashSet;
1211

app/src/main/java/io/github/jboxx/catering_subscribe/subcripstions/SubcriptionsActivity.java

+24-5
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ public static void launch(Context context) {
8383
CircleView rvOne;
8484
@BindView(R.id.txtStep1Label)
8585
TextView txtStep1Label;
86+
@BindView(R.id.lineDivider1)
87+
View lineDivider1;
8688
@BindView(R.id.rvTwo)
8789
CircleView rvTwo;
8890
@BindView(R.id.txtStep2Label)
8991
TextView txtStep2Label;
92+
@BindView(R.id.lineDivider2)
93+
View lineDivider2;
9094
@BindView(R.id.rvThree)
9195
CircleView rvThree;
9296
@BindView(R.id.txtStep3Label)
@@ -220,19 +224,34 @@ public void showStep(int step, boolean isAnimForwards) {
220224

221225
switch (step){
222226
case SubcriptionsContract.STEP_START_SUBCRIPTION:
223-
rvTwo.setCircleActive(false);
227+
rvOne.setCircleStatus(CircleView.ACTIVE);
228+
rvTwo.setCircleStatus(CircleView.UNACTIVE);
229+
rvThree.setCircleStatus(CircleView.UNACTIVE);
230+
231+
lineDivider1.setBackgroundColor(ContextCompat.getColor(this, R.color.list_divider));
232+
lineDivider2.setBackgroundColor(ContextCompat.getColor(this, R.color.list_divider));
224233
txtStep2Label.setTextColor(ResourcesCompat.getColor(resources, R.color.grey_300, getTheme()));
225234
break;
226235
case SubcriptionsContract.STEP_DELIVERY_SUBCRIPTION:
227-
rvTwo.setCircleActive(true);
228-
rvThree.setCircleActive(false);
236+
rvOne.setCircleStatus(CircleView.FILLED);
237+
rvTwo.setCircleStatus(CircleView.ACTIVE);
238+
rvThree.setCircleStatus(CircleView.UNACTIVE);
239+
240+
lineDivider1.setBackgroundColor(ContextCompat.getColor(this, R.color.list_divider_active));
241+
lineDivider2.setBackgroundColor(ContextCompat.getColor(this, R.color.list_divider));
242+
229243
txtStep2Label.setTextColor(ResourcesCompat.getColor(resources, R.color.default_text_color, getTheme()));
230244
txtStep3Label.setTextColor(ResourcesCompat.getColor(resources, R.color.grey_300, getTheme()));
231245
break;
232246
case SubcriptionsContract.STEP_PAYMENT_SUBCRIPTION:
233-
rvThree.setCircleActive(true);
234-
txtStep3Label.setTextColor(ResourcesCompat.getColor(resources, R.color.default_text_color, getTheme()));
247+
rvOne.setCircleStatus(CircleView.FILLED);
248+
rvTwo.setCircleStatus(CircleView.FILLED);
249+
rvThree.setCircleStatus(CircleView.ACTIVE);
250+
251+
lineDivider1.setBackgroundColor(ContextCompat.getColor(this, R.color.list_divider_active));
252+
lineDivider2.setBackgroundColor(ContextCompat.getColor(this, R.color.list_divider_active));
235253

254+
txtStep3Label.setTextColor(ResourcesCompat.getColor(resources, R.color.default_text_color, getTheme()));
236255
break;
237256
}
238257
}

app/src/main/java/io/github/jboxx/catering_subscribe/subcripstions/SubcriptionsPresenter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ private void selectDateWithoutHoliday(int numberOfDays, LocalDate tomorrow) {
284284

285285
private void selectDay(CalendarDay deletedCalendar) {
286286
if (!subcriptionTime.getParam().equals(SubcriptionTime.CUSTOM)
287-
|| numberOfDays <= customSubcriptionTime.getShouldSelectedDays()) {
287+
|| numberOfDays < customSubcriptionTime.getShouldSelectedDays()) {
288288

289289
LocalDate localDate = sortedCalendarList().get(sortedCalendarList().size()-1);
290290

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:shape="rectangle" >
5+
<corners
6+
android:topLeftRadius="4dp"
7+
android:bottomLeftRadius="4dp"
8+
android:bottomRightRadius="0dp"
9+
android:topRightRadius="0dp"/>
10+
<solid
11+
android:color="@color/grey_300" />
12+
</shape>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:drawable="@drawable/bg_counter_left_enabled" android:state_enabled="true" />
4+
<item android:drawable="@drawable/bg_counter_left_disabled" android:state_enabled="false" />
5+
<!-- default state-->
6+
<item android:drawable="@drawable/bg_counter_left_enabled" />
7+
</selector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:shape="rectangle" >
5+
<corners
6+
android:topLeftRadius="0dp"
7+
android:bottomLeftRadius="0dp"
8+
android:bottomRightRadius="4dp"
9+
android:topRightRadius="4dp"/>
10+
<solid
11+
android:color="@color/grey_300" />
12+
</shape>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:drawable="@drawable/bg_counter_right_enabled" android:state_enabled="true" />
4+
<item android:drawable="@drawable/bg_counter_right_disabled" android:state_enabled="false" />
5+
<!-- default state-->
6+
<item android:drawable="@drawable/bg_counter_right_enabled" />
7+
</selector>

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

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<color name="default_text_color">#373D3F</color>
99
<color name="list_divider">#D8D8D8</color>
10+
<color name="list_divider_active">#FD9714</color>
1011

1112
<color name="gradient_start">@color/red_500</color>
1213
<color name="gradient_end">@color/orange_700</color>

0 commit comments

Comments
 (0)