Skip to content

Commit c25b7fa

Browse files
committed
Release Version 1.05
- Updated navigation drawer - Updated email and password validation
1 parent b5997b1 commit c25b7fa

File tree

12 files changed

+431
-404
lines changed

12 files changed

+431
-404
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Android drawing application for annotating the backbone of worms.
66

77
## Releases
88

9+
### 1.05 (2018-02-22)
10+
- More robust email validation
11+
- Improved password fields
12+
- Added basic navigation drawer to access user profile
13+
- Google Sign-in now fully supported
14+
- Added push notification support
15+
- Firebase analytics
16+
917
### 1.04 (2018-01-24)
1018
- Added quick options to marking bad images rather than just a general comment box
1119
- Resolved an issue where an empty email or password login would lead to a crash

app/.idea/workspace.xml

Lines changed: 281 additions & 359 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 8 additions & 6 deletions
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.04"
13+
versionName "1.05"
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
}
1616
buildTypes {
@@ -35,21 +35,23 @@ dependencies {
3535
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
3636
exclude group: 'com.android.support', module: 'support-annotations'
3737
})
38+
39+
compile 'com.android.support:appcompat-v7:26.1.0'
40+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
41+
compile 'com.android.support:cardview-v7:26.1.0'
42+
testCompile 'junit:junit:4.12'
43+
implementation 'com.android.support:design:26.1.0'
44+
3845
compile 'com.google.firebase:firebase-storage:11.8.0'
3946
compile 'com.google.firebase:firebase-auth:11.8.0'
4047
compile 'com.google.android.gms:play-services-auth:11.8.0'
4148
compile 'com.google.firebase:firebase-messaging:11.8.0'
4249
compile 'com.google.firebase:firebase-database:11.8.0'
4350
compile 'com.google.firebase:firebase-perf:11.8.0'
44-
compile 'com.android.support:appcompat-v7:26.1.0'
45-
compile 'com.android.support.constraint:constraint-layout:1.0.2'
46-
compile 'com.android.support:cardview-v7:26.1.0'
4751
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
4852
transitive = true
4953
}
5054
compile 'com.google.firebase:firebase-core:11.8.0'
51-
testCompile 'junit:junit:4.12'
52-
implementation 'com.android.support:design:26.1.0'
5355
}
5456

5557
apply plugin: 'com.google.gms.google-services'

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
</intent-filter>
3939
</service>
4040

41+
<!-- Activities -->
4142
<activity
4243
android:name=".LoginActivity"
4344
android:screenOrientation="portrait"
@@ -47,12 +48,10 @@
4748
<category android:name="android.intent.category.LAUNCHER" />
4849
</intent-filter>
4950
</activity>
50-
5151
<activity
5252
android:name=".RegistrationActivity"
5353
android:screenOrientation="portrait"
5454
android:theme="@style/AppTheme" />
55-
5655
<activity
5756
android:name=".DrawingActivity"
5857
android:screenOrientation="portrait"

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

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
import android.content.Intent;
55
import android.content.res.Resources;
66
import android.graphics.Bitmap;
7+
import android.graphics.BitmapFactory;
8+
import android.graphics.BitmapShader;
79
import android.graphics.PointF;
10+
import android.graphics.Shader;
11+
import android.net.Uri;
12+
import android.os.AsyncTask;
813
import android.os.Bundle;
14+
import android.provider.MediaStore;
915
import android.support.constraint.ConstraintLayout;
1016
import android.support.constraint.ConstraintSet;
1117
import android.support.design.widget.FloatingActionButton;
@@ -24,33 +30,39 @@
2430
import android.view.MotionEvent;
2531
import android.view.View;
2632
import android.widget.Button;
27-
import android.widget.LinearLayout;
33+
import android.widget.ImageView;
2834
import android.widget.ProgressBar;
2935
import android.widget.RadioButton;
3036
import android.widget.RadioGroup;
3137
import android.widget.RatingBar;
3238
import android.widget.TextView;
3339

40+
import com.google.firebase.analytics.FirebaseAnalytics;
3441
import com.google.firebase.auth.FirebaseAuth;
3542
import com.google.firebase.auth.FirebaseUser;
3643
import com.google.firebase.database.DataSnapshot;
3744
import com.google.firebase.database.DatabaseError;
3845
import com.google.firebase.database.DatabaseReference;
3946
import com.google.firebase.database.FirebaseDatabase;
4047
import com.google.firebase.database.ValueEventListener;
41-
import com.google.firebase.iid.FirebaseInstanceId;
4248
import com.google.firebase.storage.FirebaseStorage;
4349
import com.google.firebase.storage.StorageMetadata;
4450
import com.google.firebase.storage.StorageReference;
4551
import com.google.firebase.storage.UploadTask;
4652

53+
import java.io.BufferedInputStream;
4754
import java.io.ByteArrayOutputStream;
55+
import java.io.IOException;
56+
import java.io.InputStream;
57+
import java.net.URL;
58+
import java.net.URLConnection;
4859
import java.text.DateFormat;
4960
import java.text.SimpleDateFormat;
5061
import java.util.Date;
5162
import java.util.HashMap;
5263
import java.util.Locale;
5364
import java.util.Map;
65+
import java.util.Objects;
5466
import java.util.Random;
5567
import java.util.Set;
5668
import java.util.UUID;
@@ -80,6 +92,8 @@ public class DrawingActivity extends AppCompatActivity implements View.OnTouchLi
8092
/* FireBase */
8193
private FirebaseStorage mStorage;
8294
private DatabaseReference mDatabase;
95+
private FirebaseAnalytics mFirebaseAnalytics;
96+
private FirebaseUser mUser;
8397

8498
Toolbar toolbar;
8599
ProgressBar barSend;
@@ -89,7 +103,6 @@ public class DrawingActivity extends AppCompatActivity implements View.OnTouchLi
89103

90104
String userUID;
91105
String userEmail;
92-
byte[] imgData;
93106

94107
ConstraintLayout clDrawMain;
95108
ConstraintSet constraintSet = new ConstraintSet();
@@ -105,8 +118,6 @@ protected void onCreate(Bundle savedInstanceState) {
105118
super.onCreate(savedInstanceState);
106119
setContentView(R.layout.activity_drawing);
107120

108-
Log.d("TAG", FirebaseInstanceId.getInstance().getToken());
109-
110121
/* Setting up toolbar */
111122
toolbar = findViewById(R.id.drawing_toolbar);
112123
setSupportActionBar(toolbar);
@@ -118,30 +129,54 @@ protected void onCreate(Bundle savedInstanceState) {
118129
drawer.addDrawerListener(toggle);
119130
toggle.syncState();
120131

132+
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
121133
mStorage = FirebaseStorage.getInstance();
122134
mDatabase = FirebaseDatabase.getInstance().getReference();
135+
mUser = FirebaseAuth.getInstance().getCurrentUser();
136+
userUID = mUser.getUid();
137+
userEmail = mUser.getEmail();
123138

124-
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
125-
userUID = user.getUid();
126-
userEmail = user.getEmail();
139+
// FIXME
140+
TextView tvUserEmail = findViewById(R.id.tv_user_email);
141+
tvUserEmail.setText(mUser.isEmailVerified() ? "User is verified" : "User is not verified");
127142

128143
// get drawing view from XML (where the finger writes the number)
129144
drawView = findViewById(R.id.draw);
130145

131-
// TODO where i put this function is very important due to FireBase async!!
146+
/* Get Wurm image from FireBase */
132147
fireBaseRetrieveImage();
133148

134-
//get the model object
149+
/* Get the Draw Model Object */
135150
drawModel = new DrawModel(PIXEL_WIDTH, PIXEL_HEIGHT);
136151
btnMarkBad = findViewById(R.id.btn_mark_bad);
137-
// brushColor = btnMarkBad.getBackgroundTintList();
138152
clDrawMain = findViewById(R.id.cl_draw_main);
139153
navView = findViewById(R.id.nav_view);
140154
navHeaderLayout = navView.getHeaderView(0);
141155
navUserEmail = navHeaderLayout.findViewById(R.id.nav_drawer_email);
142156
navUserEmail.setText(userEmail);
143157
tvImageName = findViewById(R.id.tv_img_name);
144158

159+
TextView navUserName = navHeaderLayout.findViewById(R.id.nav_drawer_name);
160+
String userName = mUser.getDisplayName();
161+
if (!(userName == null || userName.equals(""))) {
162+
navUserName.setText(userName);
163+
}
164+
165+
// FIXME get user profile photo
166+
ImageView navUserImgView = navHeaderLayout.findViewById(R.id.nav_imgview);
167+
// navUserImgView.setImageBitmap(getImageBitmap(mUser.getPhotoUrl().toString()));
168+
//
169+
// Uri userPhotoUrl = mUser.getPhotoUrl();
170+
// if (userPhotoUrl != null){
171+
// try {
172+
// Bitmap userBMP = MediaStore.Images.Media.
173+
// getBitmap(this.getContentResolver(), userPhotoUrl);
174+
// navUserImgView.setImageBitmap(userBMP);
175+
// } catch (IOException e) {
176+
// e.printStackTrace();
177+
// }
178+
// }
179+
145180
constraintSet.clone(clDrawMain);
146181
dp56 = dpToPx(56);
147182
fabSend = findViewById(R.id.fab_send);
@@ -350,6 +385,7 @@ public void sendImage(View v) {
350385
String path = "uploaded/" + currBatchName + "/" + currImgNo + "/" + uuid + ".jpg";
351386
StorageReference mStorageRef = mStorage.getReference(path);
352387

388+
// FIXME change setCustomMetadata or delete it?
353389
StorageMetadata metadata = new StorageMetadata.Builder()
354390
.setCustomMetadata("text", "my first upload")
355391
.build();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* Created by Caden on 10/13/17.
55
*/
66

7-
public class ImageManager {
7+
class ImageManager {
88

99
static byte[] imgData;
1010

11-
public static void setImage(byte[] data) {
11+
static void setImage(byte[] data) {
1212
imgData = data;
1313
}
1414
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,19 @@ public void login(View v) {
153153
emailField.setError(null);
154154
passwordField.setError(null);
155155

156-
/* Null field check */
157-
if (email.equals("") && password.equals("")) {
158-
emailField.setError("Email cannot be empty");
159-
passwordField.setError("Password cannot be empty");
160-
emailField.requestFocus();
161-
} else if (email.equals("")) {
156+
/* Email & Password Validation */
157+
if (email.equals("")) {
162158
emailField.setError("Email cannot be empty");
163159
emailField.requestFocus();
164160
} else if (password.equals("")) {
165-
passwordField.requestFocus();
166161
passwordField.setError("Password cannot be empty");
162+
passwordField.requestFocus();
163+
} else if (!Util.isPasswordValid(password)) {
164+
passwordField.setError("Password cannot be less than 8 characters");
165+
passwordField.requestFocus();
166+
} else if (!Util.isEmailValid(email)) {
167+
emailField.setError("Email format is not valid");
168+
emailField.requestFocus();
167169
} else {
168170
progressbar.setVisibility(View.VISIBLE);
169171
mAuth.signInWithEmailAndPassword(email, password)

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,34 @@ public void registerUser(View v) {
7171
String email = txt_email.getText().toString();
7272
String password = txt_psw.getText().toString();
7373

74-
mAuth.createUserWithEmailAndPassword(email, password)
75-
.addOnCompleteListener(this, task -> {
76-
if (task.isSuccessful()) {
77-
// Sign in success, update UI with the signed-in user's information
78-
transition();
79-
} else {
80-
// If sign in fails, display a message to the user.
81-
Snackbar sd = Snackbar.make(v,
82-
String.format("\uD83D\uDE21\uD83D\uDE21\uD83D\uDE21 %s",
83-
task.getException().getMessage()), Snackbar.LENGTH_LONG);
84-
sd.show();
85-
}
86-
});
87-
74+
/* Email & Password Validation */
75+
if (email.equals("")) {
76+
txt_email.setError("Email cannot be empty");
77+
txt_email.requestFocus();
78+
} else if (password.equals("")) {
79+
txt_psw.setError("Password cannot be empty");
80+
txt_psw.requestFocus();
81+
} else if (!Util.isPasswordValid(password)) {
82+
txt_psw.setError("Password cannot be less than 8 characters");
83+
txt_psw.requestFocus();
84+
} else if (!Util.isEmailValid(email)) {
85+
txt_email.setError("Email format is not valid");
86+
txt_email.requestFocus();
87+
} else {
88+
mAuth.createUserWithEmailAndPassword(email, password)
89+
.addOnCompleteListener(this, task -> {
90+
if (task.isSuccessful()) {
91+
// Sign in success, update UI with the signed-in user's information
92+
transition();
93+
} else {
94+
// If sign in fails, display a message to the user.
95+
Snackbar sd = Snackbar.make(v,
96+
String.format("\uD83D\uDE21\uD83D\uDE21\uD83D\uDE21 %s",
97+
task.getException().getMessage()), Snackbar.LENGTH_LONG);
98+
sd.show();
99+
}
100+
});
101+
}
88102
}
89103

90104
private void transition() {

0 commit comments

Comments
 (0)