Skip to content

Commit 96ada11

Browse files
committed
v1.02 Release
1 parent 65b6189 commit 96ada11

File tree

10 files changed

+85
-57
lines changed

10 files changed

+85
-57
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
minSdkVersion 21
1111
targetSdkVersion 26
1212
versionCode 1
13-
versionName "1.01"
13+
versionName "1.02"
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
}
1616
buildTypes {

app/src/main/java/com/example/caden/drawingtest/DrawActivity.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,7 @@ protected void onCreate(Bundle savedInstanceState) {
6262
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
6363
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
6464
mShakeDetector = new ShakeDetector();
65-
mShakeDetector.setOnShakeListener(new ShakeDetector.OnShakeListener() {
66-
@Override
67-
public void onShake(int count) {
68-
handleShakeEvent(count);
69-
}
70-
});
65+
mShakeDetector.setOnShakeListener(this::handleShakeEvent);
7166

7267
}
7368

app/src/main/java/com/example/caden/drawingtest/DrawingActivity.java

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.annotation.SuppressLint;
44
import android.content.Intent;
5-
import android.content.res.ColorStateList;
65
import android.content.res.Resources;
76
import android.graphics.Bitmap;
87
import android.graphics.Color;
@@ -26,8 +25,6 @@
2625
import android.widget.RatingBar;
2726
import android.widget.TextView;
2827

29-
import com.flask.colorpicker.ColorPickerView;
30-
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
3128
import com.google.firebase.auth.FirebaseAuth;
3229
import com.google.firebase.auth.FirebaseUser;
3330
import com.google.firebase.database.DataSnapshot;
@@ -92,7 +89,6 @@ public class DrawingActivity extends AppCompatActivity implements View.OnTouchLi
9289
private static final int PIXEL_WIDTH = 280;
9390
private static final int PIXEL_HEIGHT = 280;
9491

95-
@SuppressLint("ClickableViewAccessibility")
9692
@Override
9793
protected void onCreate(Bundle savedInstanceState) {
9894
super.onCreate(savedInstanceState);
@@ -118,7 +114,7 @@ protected void onCreate(Bundle savedInstanceState) {
118114

119115
//get the model object
120116
drawModel = new DrawModel(PIXEL_WIDTH, PIXEL_HEIGHT);
121-
btnBrushColor = findViewById(R.id.btn_brush_color);
117+
btnBrushColor = findViewById(R.id.btn_mark_bad);
122118
// brushColor = btnBrushColor.getBackgroundTintList();
123119
clDrawMain = findViewById(R.id.cl_draw_main);
124120
tvUserEmail = findViewById(R.id.tv_user_email);
@@ -138,7 +134,7 @@ protected void onCreate(Bundle savedInstanceState) {
138134
/* Readjust the height to be almost the same as screen width */
139135
int scrWidth = Resources.getSystem().getDisplayMetrics().widthPixels;
140136
int scrHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
141-
Log.d("ratio", scrHeight/(float)scrWidth + "");
137+
// Log.d("ratio", scrHeight/(float)scrWidth + "");
142138
drawView.getLayoutParams().height =
143139
(int)(Resources.getSystem().getDisplayMetrics().widthPixels * 0.85);
144140
drawView.requestLayout();
@@ -301,8 +297,8 @@ public void sendImage(View v) {
301297
constraintSet.applyTo(clDrawMain);
302298

303299
Bitmap bmp = drawView.getBitmapData();
304-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
305-
bmp.compress(Bitmap.CompressFormat.JPEG, 80, baos);
300+
ByteArrayOutputStream baOS = new ByteArrayOutputStream();
301+
bmp.compress(Bitmap.CompressFormat.JPEG, 80, baOS);
306302

307303
UUID uuid = UUID.randomUUID();
308304
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd EEE", Locale.US);
@@ -317,7 +313,7 @@ public void sendImage(View v) {
317313
StorageMetadata metadata = new StorageMetadata.Builder()
318314
.setCustomMetadata("text", "my first upload")
319315
.build();
320-
UploadTask upTask = mStorageRef.putBytes(baos.toByteArray(), metadata);
316+
UploadTask upTask = mStorageRef.putBytes(baOS.toByteArray(), metadata);
321317
upTask.addOnSuccessListener(this, taskSnapshot -> {
322318
TransitionManager.beginDelayedTransition(clDrawMain);
323319
constraintSet.constrainWidth(R.id.pbar_send, 0);
@@ -340,22 +336,45 @@ public void sendImage(View v) {
340336
.child(timeFormat.format(date)).child("user_uid").setValue(u.getUid());
341337
}
342338

343-
public void changeColor(View v) {
344-
ColorPickerDialogBuilder
345-
.with(this)
346-
.setTitle("Pick Color")
347-
.initialColor(Color.parseColor("#FFFFFF"))
348-
.wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
349-
.lightnessSliderOnly()
350-
.density(16)
351-
.setOnColorSelectedListener(selectedColor -> {})
352-
.setPositiveButton("ok", (dialog, selectedColor, allColors) -> {
353-
btnBrushColor.setBackgroundTintList(ColorStateList.valueOf(selectedColor));
354-
brushColor = selectedColor;
355-
ImageManager.setBrushColor(selectedColor);
339+
// public void changeColor(View v) {
340+
// ColorPickerDialogBuilder
341+
// .with(this)
342+
// .setTitle("Pick Color")
343+
// .initialColor(Color.parseColor("#FFFFFF"))
344+
// .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
345+
// .lightnessSliderOnly()
346+
// .density(16)
347+
// .setOnColorSelectedListener(selectedColor -> {})
348+
// .setPositiveButton("ok", (dialog, selectedColor, allColors) -> {
349+
// btnBrushColor.setBackgroundTintList(ColorStateList.valueOf(selectedColor));
350+
// brushColor = selectedColor;
351+
// ImageManager.setBrushColor(selectedColor);
352+
// })
353+
// .setNegativeButton("cancel", (dialog, which) -> {})
354+
// .build()
355+
// .show();
356+
// }
357+
358+
public void markAsBad(View v) {
359+
/* Update Database Reference */
360+
View aboutDialogView =
361+
getLayoutInflater().inflate(R.layout.image_comments_dialog,
362+
new ConstraintLayout(this), false);
363+
364+
TextView reasonText = aboutDialogView.findViewById(R.id.tv_mark_reason);
365+
366+
String userUID = mAuth.getCurrentUser().getUid();
367+
368+
new AlertDialog.Builder(this)
369+
.setView(aboutDialogView)
370+
.setMessage(R.string.reason_marking_image)
371+
.setTitle(R.string.app_name)
372+
.setPositiveButton("OK", (dialog, id) -> {
373+
mDatabase.child("bad_images").child(currBatchName).child(String.valueOf(currImgNo))
374+
.child(userUID).setValue(reasonText.getText().toString());
375+
nextImage(v);
376+
dialog.dismiss();
356377
})
357-
.setNegativeButton("cancel", (dialog, which) -> {})
358-
.build()
359378
.show();
360379
}
361380

@@ -380,20 +399,14 @@ private void initWithImage(HashMap dict) {
380399
int keyLen = keys.size();
381400
String[] keyArray = (String[]) keys.toArray(new String[keyLen]);
382401
Random rand = new Random();
383-
// TODO set is 0 based need to go from 0 to len - 1
402+
// 0 based need to go from 0 to len - 1
384403
int randKey = rand.nextInt(keyLen);
385404

386405
currBatchName = keyArray[randKey];
387-
388-
// FIXME HARDCODED CHANGE, use currBATCHNAME INSTEAD
389-
// currBatchName = "2017-09-23";
390406
currBatchSize = longToInt((Long) dict.get(currBatchName));
391-
392407
currImgNo = rand.nextInt(currBatchSize) + 1;
393-
394408
tvImageName.setText(String.format("%s / %d.png", currBatchName, currImgNo));
395409

396-
// FIXME load the image, check this code for errors!
397410
/* Load Drawing */
398411
String path = String.format("img/%s/%d.png", currBatchName, currImgNo);
399412
StorageReference mStorageRef = mStorage.getReference(path);
@@ -416,10 +429,10 @@ public void nextImage(View v) {
416429
currBatchName = keyArray[randKey];
417430
currBatchSize = longToInt((Long) uploadsDict.get(currBatchName));
418431
currImgNo = rand.nextInt(currBatchSize) + 1;
419-
tvImageName.setText(String.format("%s / %d.png", currBatchName, currImgNo));
432+
tvImageName.setText(String.format(Locale.US,"%s / %d.png", currBatchName, currImgNo));
420433

421434
/* Load Drawing */
422-
String path = String.format("img/%s/%d.png", currBatchName, currImgNo);
435+
String path = String.format(Locale.US,"img/%s/%d.png", currBatchName, currImgNo);
423436
StorageReference mStorageRef = mStorage.getReference(path);
424437

425438
final long ONE_KILOBYTE = 1024;

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

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FFffffff"
8+
android:pathData="M15,3L6,3c-0.83,0 -1.54,0.5 -1.84,1.22l-3.02,7.05c-0.09,0.23 -0.14,0.47 -0.14,0.73v1.91l0.01,0.01L1,14c0,1.1 0.9,2 2,2h6.31l-0.95,4.57 -0.03,0.32c0,0.41 0.17,0.79 0.44,1.06L9.83,23l6.59,-6.59c0.36,-0.36 0.58,-0.86 0.58,-1.41L17,5c0,-1.1 -0.9,-2 -2,-2zM19,3v12h4L23,3h-4z"/>
9+
</vector>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
android:layout_width="match_parent"
66
android:layout_height="match_parent">
77

8-
98
<RatingBar
109
android:id="@+id/ratingBar"
1110
android:layout_width="wrap_content"

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,15 @@
9797
app:layout_constraintTop_toBottomOf="@+id/tv_user_email">
9898

9999
<Button
100-
android:id="@+id/btn_brush_color"
100+
android:id="@+id/btn_mark_bad"
101101
style="@style/Widget.AppCompat.Button.Colored"
102102
android:layout_width="0dp"
103103
android:layout_height="52dp"
104104
android:layout_marginEnd="8dp"
105105
android:layout_marginStart="8dp"
106-
android:drawableStart="@drawable/ic_color_lens"
107-
android:drawableTint="#ffffff"
108-
android:onClick="changeColor"
109-
android:text="@string/color_text"
106+
android:drawableStart="@drawable/ic_thumb_down"
107+
android:text="@string/mark_as_bad"
108+
android:onClick="markAsBad"
110109
app:layout_constraintEnd_toStartOf="@+id/guideline"
111110
app:layout_constraintStart_toStartOf="parent"
112111
app:layout_constraintTop_toTopOf="parent" />
@@ -126,7 +125,7 @@
126125
app:layout_constraintBottom_toBottomOf="parent"
127126
app:layout_constraintEnd_toStartOf="@+id/guideline"
128127
app:layout_constraintStart_toStartOf="parent"
129-
app:layout_constraintTop_toBottomOf="@+id/btn_brush_color" />
128+
app:layout_constraintTop_toBottomOf="@+id/btn_mark_bad" />
130129

131130
<android.support.v7.widget.CardView
132131
android:id="@+id/cv_controls"
@@ -135,6 +134,7 @@
135134
android:layout_marginEnd="8dp"
136135
android:layout_marginTop="6dp"
137136
android:padding="0dp"
137+
android:visibility="gone"
138138
app:cardBackgroundColor="#607D8B"
139139
app:layout_constraintEnd_toEndOf="parent"
140140
app:layout_constraintStart_toStartOf="@+id/guideline"
@@ -190,7 +190,6 @@
190190
android:layout_height="52dp"
191191
android:layout_marginEnd="4dp"
192192
android:layout_marginStart="4dp"
193-
android:layout_marginTop="6dp"
194193
android:backgroundTint="#009688"
195194
android:drawableStart="@drawable/ic_casino"
196195
android:onClick="nextImage"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<MultiAutoCompleteTextView
9+
android:id="@+id/tv_mark_reason"
10+
android:layout_width="0dp"
11+
android:layout_height="wrap_content"
12+
android:layout_marginEnd="24dp"
13+
android:layout_marginStart="24dp"
14+
app:layout_constraintEnd_toEndOf="parent"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="parent" />
17+
18+
</android.support.constraint.ConstraintLayout>

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
<string name="placeholder_email">[email protected]</string>
1313
<string name="sign_out_text">Sign Out</string>
1414
<string name="next_random_text">Next Random</string>
15+
<string name="mark_as_bad">Mark as bad</string>
16+
<string name="reason_marking_image">Any reasons for marking this image?</string>
1517
</resources>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717
<string name="placeholder_email">[email protected]</string>
1818
<string name="sign_out_text">Sign Out</string>
1919
<string name="next_random_text">Next Random</string>
20+
<string name="mark_as_bad">Mark as bad</string>
21+
<string name="reason_marking_image">Any reasons for marking this image?</string>
2022
</resources>

0 commit comments

Comments
 (0)