Skip to content

Commit aca9acd

Browse files
author
Anirudh S
committed
Clear button will light up only when changes are made
1 parent ef5cc1f commit aca9acd

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

helpstack/res/layout/hs_activity_edit_attachment.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
android:layout_marginBottom="4dp">
2323

2424
<TextView
25-
android:id="@+id/clear_TextView"
25+
android:id="@+id/clear_change_text"
2626
android:layout_width="wrap_content"
2727
android:layout_height="match_parent"
2828
android:layout_marginLeft="8dp"
29-
android:textColor="@android:color/white"
29+
android:textColor="@color/hs_darkerGreycolor"
3030
android:text="@string/hs_clear"
3131
android:layout_gravity="center_horizontal"
3232
android:textSize="@dimen/hs_default_text_size" />

helpstack/res/values/hs_colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<color name="hs_transparent_color">#0000</color>
1010
<color name="hs_lightGreycolor">#ECECEC</color>
1111
<color name="hs_darkGreycolor">#B5B5B5</color>
12+
<color name="hs_darkerGreycolor">#ff555555</color>
1213

1314
<color name="hs_rightchat_bubblecolor">#228CD1</color>
1415
<color name="hs_leftchat_bubblecolor">#FFFFFF</color>

helpstack/src/com/tenmiles/helpstack/activities/DrawingView.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class DrawingView extends View {
3131
private int resizedHeight;
3232
private boolean isEdited;
3333

34+
private ObserverInterface mObserver;
35+
3436
public DrawingView(Context context, AttributeSet attrs) {
3537
super(context, attrs);
3638

@@ -92,6 +94,7 @@ public boolean onTouchEvent(MotionEvent event) {
9294
drawCanvas.drawPath(drawPath, drawPaint);
9395
setIsEdited(true);
9496
drawPath.reset();
97+
activateClearOptionInActivity(true);
9598
break;
9699
default:
97100
return false;
@@ -112,6 +115,7 @@ public void clearChanges() {
112115
drawPath.reset();
113116
setCanvasBitmap(cachedBitmap);
114117
setIsEdited(false);
118+
activateClearOptionInActivity(false);
115119
invalidate();
116120
}
117121

@@ -138,4 +142,18 @@ private int getLeftStart(int resizedWidth) {
138142
int leftStart = (this.getLeft() + this.getRight() - resizedWidth) >> 1;
139143
return leftStart;
140144
}
145+
146+
public void setObserver(ObserverInterface observer){
147+
mObserver = observer;
148+
}
149+
150+
private void activateClearOptionInActivity(boolean isEdited){
151+
if( mObserver != null ){
152+
mObserver.activateClearOption(isEdited);
153+
}
154+
}
155+
156+
public interface ObserverInterface {
157+
void activateClearOption(boolean isEdited);
158+
}
141159
}

helpstack/src/com/tenmiles/helpstack/activities/EditAttachmentActivity.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public class EditAttachmentActivity extends Activity {
5555
private HSAttachment selectedAttachment;
5656
private Bitmap originalBitmap;
5757

58+
private TextView clearChangesTextView;
59+
5860
@Override
5961
protected void onCreate(Bundle savedInstanceState) {
6062
super.onCreate(savedInstanceState);
@@ -64,7 +66,14 @@ protected void onCreate(Bundle savedInstanceState) {
6466
getActionBar().setTitle(R.string.hs_attachment_edit);
6567

6668
drawView = (DrawingView)findViewById(R.id.drawing);
67-
TextView clearChanges = (TextView) findViewById(R.id.clear_TextView);
69+
drawView.setObserver(new DrawingView.ObserverInterface() {
70+
@Override
71+
public void activateClearOption(boolean isEnabled) {
72+
activityClearTextView(isEnabled);
73+
}
74+
});
75+
76+
TextView clearChanges = (TextView) findViewById(R.id.clear_change_text);
6877
clearChanges.setOnClickListener(new View.OnClickListener() {
6978
@Override
7079
public void onClick(View view) {
@@ -74,6 +83,7 @@ public void onClick(View view) {
7483

7584
currentPaint = (ImageButton) findViewById(R.id.hs_red_brush);
7685
currentPaint.setBackground(getResources().getDrawable(R.drawable.paint_pressed));
86+
clearChangesTextView = (TextView)findViewById(R.id.clear_change_text);
7787

7888
Intent intent = new Intent();
7989
intent.setType("image/*");
@@ -214,5 +224,12 @@ public void onClick(DialogInterface arg0, int arg1) {
214224
}
215225

216226

217-
227+
public void activityClearTextView(boolean isEnabled) {
228+
if (isEnabled) {
229+
clearChangesTextView.setTextColor(getResources().getColor(android.R.color.white));
230+
}
231+
else {
232+
clearChangesTextView.setTextColor(getResources().getColor(R.color.hs_darkerGreycolor));
233+
}
234+
}
218235
}

0 commit comments

Comments
 (0)