Skip to content

Commit

Permalink
Release Version 1.05
Browse files Browse the repository at this point in the history
- Updated navigation drawer
- Updated email and password validation
  • Loading branch information
jiangshen committed Feb 22, 2018
1 parent b5997b1 commit c25b7fa
Show file tree
Hide file tree
Showing 12 changed files with 431 additions and 404 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Android drawing application for annotating the backbone of worms.

## Releases

### 1.05 (2018-02-22)
- More robust email validation
- Improved password fields
- Added basic navigation drawer to access user profile
- Google Sign-in now fully supported
- Added push notification support
- Firebase analytics

### 1.04 (2018-01-24)
- Added quick options to marking bad images rather than just a general comment box
- Resolved an issue where an empty email or password login would lead to a crash
Expand Down
640 changes: 281 additions & 359 deletions app/.idea/workspace.xml

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.04"
versionName "1.05"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -35,21 +35,23 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:26.1.0'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'

compile 'com.google.firebase:firebase-storage:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-perf:11.8.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:26.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}
compile 'com.google.firebase:firebase-core:11.8.0'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'
}

apply plugin: 'com.google.gms.google-services'
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</intent-filter>
</service>

<!-- Activities -->
<activity
android:name=".LoginActivity"
android:screenOrientation="portrait"
Expand All @@ -47,12 +48,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".RegistrationActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

<activity
android:name=".DrawingActivity"
android:screenOrientation="portrait"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.PointF;
import android.graphics.Shader;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.ConstraintSet;
import android.support.design.widget.FloatingActionButton;
Expand All @@ -24,33 +30,39 @@
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RatingBar;
import android.widget.TextView;

import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageMetadata;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -80,6 +92,8 @@ public class DrawingActivity extends AppCompatActivity implements View.OnTouchLi
/* FireBase */
private FirebaseStorage mStorage;
private DatabaseReference mDatabase;
private FirebaseAnalytics mFirebaseAnalytics;
private FirebaseUser mUser;

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

String userUID;
String userEmail;
byte[] imgData;

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

Log.d("TAG", FirebaseInstanceId.getInstance().getToken());

/* Setting up toolbar */
toolbar = findViewById(R.id.drawing_toolbar);
setSupportActionBar(toolbar);
Expand All @@ -118,30 +129,54 @@ protected void onCreate(Bundle savedInstanceState) {
drawer.addDrawerListener(toggle);
toggle.syncState();

mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
mStorage = FirebaseStorage.getInstance();
mDatabase = FirebaseDatabase.getInstance().getReference();
mUser = FirebaseAuth.getInstance().getCurrentUser();
userUID = mUser.getUid();
userEmail = mUser.getEmail();

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
userUID = user.getUid();
userEmail = user.getEmail();
// FIXME
TextView tvUserEmail = findViewById(R.id.tv_user_email);
tvUserEmail.setText(mUser.isEmailVerified() ? "User is verified" : "User is not verified");

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

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

//get the model object
/* Get the Draw Model Object */
drawModel = new DrawModel(PIXEL_WIDTH, PIXEL_HEIGHT);
btnMarkBad = findViewById(R.id.btn_mark_bad);
// brushColor = btnMarkBad.getBackgroundTintList();
clDrawMain = findViewById(R.id.cl_draw_main);
navView = findViewById(R.id.nav_view);
navHeaderLayout = navView.getHeaderView(0);
navUserEmail = navHeaderLayout.findViewById(R.id.nav_drawer_email);
navUserEmail.setText(userEmail);
tvImageName = findViewById(R.id.tv_img_name);

TextView navUserName = navHeaderLayout.findViewById(R.id.nav_drawer_name);
String userName = mUser.getDisplayName();
if (!(userName == null || userName.equals(""))) {
navUserName.setText(userName);
}

// FIXME get user profile photo
ImageView navUserImgView = navHeaderLayout.findViewById(R.id.nav_imgview);
// navUserImgView.setImageBitmap(getImageBitmap(mUser.getPhotoUrl().toString()));
//
// Uri userPhotoUrl = mUser.getPhotoUrl();
// if (userPhotoUrl != null){
// try {
// Bitmap userBMP = MediaStore.Images.Media.
// getBitmap(this.getContentResolver(), userPhotoUrl);
// navUserImgView.setImageBitmap(userBMP);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }

constraintSet.clone(clDrawMain);
dp56 = dpToPx(56);
fabSend = findViewById(R.id.fab_send);
Expand Down Expand Up @@ -350,6 +385,7 @@ public void sendImage(View v) {
String path = "uploaded/" + currBatchName + "/" + currImgNo + "/" + uuid + ".jpg";
StorageReference mStorageRef = mStorage.getReference(path);

// FIXME change setCustomMetadata or delete it?
StorageMetadata metadata = new StorageMetadata.Builder()
.setCustomMetadata("text", "my first upload")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* Created by Caden on 10/13/17.
*/

public class ImageManager {
class ImageManager {

static byte[] imgData;

public static void setImage(byte[] data) {
static void setImage(byte[] data) {
imgData = data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,19 @@ public void login(View v) {
emailField.setError(null);
passwordField.setError(null);

/* Null field check */
if (email.equals("") && password.equals("")) {
emailField.setError("Email cannot be empty");
passwordField.setError("Password cannot be empty");
emailField.requestFocus();
} else if (email.equals("")) {
/* Email & Password Validation */
if (email.equals("")) {
emailField.setError("Email cannot be empty");
emailField.requestFocus();
} else if (password.equals("")) {
passwordField.requestFocus();
passwordField.setError("Password cannot be empty");
passwordField.requestFocus();
} else if (!Util.isPasswordValid(password)) {
passwordField.setError("Password cannot be less than 8 characters");
passwordField.requestFocus();
} else if (!Util.isEmailValid(email)) {
emailField.setError("Email format is not valid");
emailField.requestFocus();
} else {
progressbar.setVisibility(View.VISIBLE);
mAuth.signInWithEmailAndPassword(email, password)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,34 @@ public void registerUser(View v) {
String email = txt_email.getText().toString();
String password = txt_psw.getText().toString();

mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
transition();
} else {
// If sign in fails, display a message to the user.
Snackbar sd = Snackbar.make(v,
String.format("\uD83D\uDE21\uD83D\uDE21\uD83D\uDE21 %s",
task.getException().getMessage()), Snackbar.LENGTH_LONG);
sd.show();
}
});

/* Email & Password Validation */
if (email.equals("")) {
txt_email.setError("Email cannot be empty");
txt_email.requestFocus();
} else if (password.equals("")) {
txt_psw.setError("Password cannot be empty");
txt_psw.requestFocus();
} else if (!Util.isPasswordValid(password)) {
txt_psw.setError("Password cannot be less than 8 characters");
txt_psw.requestFocus();
} else if (!Util.isEmailValid(email)) {
txt_email.setError("Email format is not valid");
txt_email.requestFocus();
} else {
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
transition();
} else {
// If sign in fails, display a message to the user.
Snackbar sd = Snackbar.make(v,
String.format("\uD83D\uDE21\uD83D\uDE21\uD83D\uDE21 %s",
task.getException().getMessage()), Snackbar.LENGTH_LONG);
sd.show();
}
});
}
}

private void transition() {
Expand Down
Loading

0 comments on commit c25b7fa

Please sign in to comment.