diff --git a/README.md b/README.md
index c501f56..a8aad4b 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,14 @@ Android drawing application for annotating the backbone of worms.
## Releases
+### 1.09 (2018-4-28)
+- Updated Achievements scoring
+- Updated LeaderBoard submissions
+- User can now draw in different colors
+- Added color wheel type in settings
+- Added Wurm-o-Meter screen with user scores
+- Added Colorful Wurms achievement that unlocks color annotation
+
### 1.08 (2018-04-23)
- Added about screen
- Redesigned navigation drawer layout
diff --git a/app/.idea/assetWizardSettings.xml b/app/.idea/assetWizardSettings.xml
index b126989..e3965c9 100644
--- a/app/.idea/assetWizardSettings.xml
+++ b/app/.idea/assetWizardSettings.xml
@@ -18,7 +18,7 @@
@@ -29,7 +29,7 @@
diff --git a/app/.idea/caches/build_file_checksums.ser b/app/.idea/caches/build_file_checksums.ser
index 6816980..27752f9 100644
Binary files a/app/.idea/caches/build_file_checksums.ser and b/app/.idea/caches/build_file_checksums.ser differ
diff --git a/app/.idea/workspace.xml b/app/.idea/workspace.xml
index cec141d..c571b9b 100644
--- a/app/.idea/workspace.xml
+++ b/app/.idea/workspace.xml
@@ -10,24 +10,37 @@
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -62,68 +75,51 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
@@ -135,13 +131,39 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -154,36 +176,36 @@
- log.d
- done
- boolean
- user is veri
- submi
- ontouch
- GoogleSignInOptions
- cl_draw_main
- root
- closeDrawer
- example_text
- pref_general
- pref_title
- R.id.home
- addOnSuccessListener
- acct
- account
- navgacctonresumpopupopupgoogle planewbie
- userScorebadproleaderboardoncreonre
+ tvuser
+ sign out
+ sign_out
+ score
+ userscore
+ is
+ isGoogleSignIn
+ userScore
+ \u
+ color
+ whee
+ leaderbo
+ appapp_id
+ app_id
+ achieve
+ unlock
+ onres
+ draw_color
+ draw_in_color
@@ -2205,7 +2227,6 @@
@@ -2334,6 +2360,9 @@
+
+
+
@@ -2341,6 +2370,11 @@
+
+
+
+
+
@@ -2357,12 +2391,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2377,9 +2424,6 @@
-
-
-
@@ -2394,9 +2438,10 @@
-
-
+
+
+
@@ -2754,17 +2799,17 @@
-
-
+
+
-
+
-
+
+
-
@@ -2851,326 +2896,340 @@
-
-
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
+
-
-
+
+
+
-
+
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
+
-
+
-
+
-
-
+
+
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
-
-
+
+
+
+
+
+
-
+
-
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
-
+
-
-
-
+
+
-
-
-
-
+
-
-
+
+
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -3180,75 +3239,67 @@
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
+
-
+
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 9508d49..88ea9d0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -43,6 +43,8 @@ dependencies {
testCompile 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'
+ compile 'com.github.QuadFlask:colorpicker:0.0.13'
+
compile 'com.google.firebase:firebase-storage:15.0.0'
compile 'com.google.firebase:firebase-auth:15.0.0'
compile 'com.google.android.gms:play-services-auth:15.0.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c3ab94b..24827c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -56,6 +56,7 @@
android:theme="@style/AppTheme">
+
@@ -73,11 +74,11 @@
android:theme="@style/AppTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme.Settings">
@@ -86,7 +87,11 @@
android:name=".AboutActivity"
android:label="@string/title_activity_about"
android:screenOrientation="portrait"
- android:theme="@style/AppTheme.Settings"/>
+ android:theme="@style/AppTheme.Settings" />
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/caden/drawingtest/AppCompatPreferenceActivity.java b/app/src/main/java/com/example/caden/drawingtest/AppCompatPreferenceActivity.java
index 8d9a7dc..b41137d 100644
--- a/app/src/main/java/com/example/caden/drawingtest/AppCompatPreferenceActivity.java
+++ b/app/src/main/java/com/example/caden/drawingtest/AppCompatPreferenceActivity.java
@@ -4,6 +4,7 @@
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatDelegate;
@@ -12,10 +13,6 @@
import android.view.View;
import android.view.ViewGroup;
-/**
- * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
- * to be used with AppCompat.
- */
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
private AppCompatDelegate mDelegate;
@@ -41,6 +38,7 @@ public void setSupportActionBar(@Nullable Toolbar toolbar) {
getDelegate().setSupportActionBar(toolbar);
}
+ @NonNull
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
diff --git a/app/src/main/java/com/example/caden/drawingtest/DrawRenderer.java b/app/src/main/java/com/example/caden/drawingtest/DrawRenderer.java
index 8360462..b10418b 100644
--- a/app/src/main/java/com/example/caden/drawingtest/DrawRenderer.java
+++ b/app/src/main/java/com/example/caden/drawingtest/DrawRenderer.java
@@ -25,7 +25,7 @@ public static void renderModel(Canvas canvas, DrawModel model, Paint paint, int
//get the whole line from the model object
DrawModel.Line line = model.getLine(i);
//set its color
- paint.setColor(Color.parseColor("#FF2646"));
+ paint.setColor(SharedData.lineColor);
//get the first of many lines that make up the overall line
int elemSize = line.getElemSize();
//if its empty, skip
diff --git a/app/src/main/java/com/example/caden/drawingtest/DrawingActivity.java b/app/src/main/java/com/example/caden/drawingtest/DrawingActivity.java
index 095c676..9a5ed67 100644
--- a/app/src/main/java/com/example/caden/drawingtest/DrawingActivity.java
+++ b/app/src/main/java/com/example/caden/drawingtest/DrawingActivity.java
@@ -1,10 +1,14 @@
package com.example.caden.drawingtest;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.PointF;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.ConstraintSet;
@@ -18,7 +22,6 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.TransitionManager;
-import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -30,6 +33,8 @@
import android.widget.RatingBar;
import android.widget.TextView;
+import com.flask.colorpicker.ColorPickerView;
+import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.games.AchievementsClient;
@@ -71,7 +76,6 @@ public class DrawingActivity extends AppCompatActivity
private static final int RC_ACHIEVEMENT_UI = 9003;
private static final int RC_LEADERBOARD_UI = 9004;
private static final int RC_SETTING_UI = 9005;
- private static final int RC_LEADERBOARD_SCORE = 1337;
/* Variables */
String currBatchName;
@@ -83,12 +87,13 @@ public class DrawingActivity extends AppCompatActivity
/* Views */
private DrawModel drawModel;
private DrawView drawView;
- private PointF mTmpPoint = new PointF();
+ private PointF mTmpPt = new PointF();
private float mLastX;
private float mLastY;
Button btnMarkBad;
+ Button btnColor;
/* FireBase */
private FirebaseStorage mStorage;
@@ -101,13 +106,15 @@ public class DrawingActivity extends AppCompatActivity
AchievementsClient mAchClient;
LeaderboardsClient mLeadClient;
+ /* Settings */
+ SharedPreferences sharedPref;
+
Toolbar toolbar;
ProgressBar barSend;
FloatingActionButton fabSend;
TextView navUserEmail;
TextView navUserName;
TextView tvImageName;
- TextView tvUserScore;
String userUID;
String userEmail;
@@ -121,7 +128,6 @@ public class DrawingActivity extends AppCompatActivity
boolean isGoogleSignIn = false;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -150,8 +156,8 @@ protected void onCreate(Bundle savedInstanceState) {
isGoogleSignIn = true;
}
}
+ SharedData.isGoogleSignIn = isGoogleSignIn;
- // get drawing view from XML (where the finger writes the number)
drawView = findViewById(R.id.draw);
/* Get Wurm image from FireBase */
@@ -159,13 +165,10 @@ protected void onCreate(Bundle savedInstanceState) {
fireBaseRetrieveUserScore();
updateLeaderBoard();
- tvUserScore = findViewById(R.id.tv_user_score);
- tvUserScore.setText(String.valueOf(userScore));
-
-
/* Get the Draw Model Object */
drawModel = new DrawModel(PIXEL_WIDTH, PIXEL_HEIGHT);
btnMarkBad = findViewById(R.id.btn_mark_bad);
+ btnColor = findViewById(R.id.btn_color);
clDrawMain = findViewById(R.id.cl_draw_main);
navView = findViewById(R.id.nav_view);
navView.setNavigationItemSelectedListener(this);
@@ -209,13 +212,11 @@ protected void onCreate(Bundle savedInstanceState) {
// }
constraintSet.clone(clDrawMain);
- dp56 = dpToPx(56);
+ dp56 = Util.dpToPx(56, getResources().getDisplayMetrics());
fabSend = findViewById(R.id.fab_send);
barSend = findViewById(R.id.pbar_send);
- // init the view with the model object
drawView.setModel(drawModel);
- // give it a touch listener to activate when the user taps
drawView.setOnTouchListener(this);
/* Re-adjust the height to be almost the same as screen width */
@@ -229,13 +230,19 @@ protected void onCreate(Bundle savedInstanceState) {
/* Google Play Game */
gAcct = GoogleSignIn.getLastSignedInAccount(this);
- if (gAcct != null) {
+ if (gAcct != null && isGoogleSignIn) {
Games.getGamesClient(this, gAcct).setViewForPopups(clDrawMain);
- }
- if (isGoogleSignIn) {
mAchClient = Games.getAchievementsClient(this, gAcct);
mLeadClient = Games.getLeaderboardsClient(this, gAcct);
}
+
+ sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+ btnColor.setVisibility(sharedPref.getBoolean("draw_in_color", false) ?
+ View.VISIBLE : View.INVISIBLE);
+
+ SharedData.lineColor =
+ sharedPref.getInt("line_color", Color.parseColor("#FF2646"));
+ btnColor.setBackgroundTintList(ColorStateList.valueOf(SharedData.lineColor));
}
@Override
@@ -245,6 +252,8 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
showAchievements();
} else if (id == R.id.nav_leaderboard && isGoogleSignIn) {
showLeaderBoard();
+ } else if (id == R.id.nav_wurm_meter) {
+ showWurmMeter();
} else if (id == R.id.nav_gplay_setting && isGoogleSignIn) {
showGPlaySettings();
} else if (id == R.id.nav_logout) {
@@ -260,6 +269,11 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
return true;
}
+ private void showWurmMeter() {
+ Intent intent = new Intent(this, WurmMeterActivity.class);
+ startActivity(intent);
+ }
+
private void showAchievements() {
mAchClient.getAchievementsIntent()
@@ -306,17 +320,15 @@ private void feedbackScreen() {
}
@Override
- // OnResume() is called when the user resumes his Activity which he left a while ago,
- // say he presses home button and then comes back to app, onResume() is called.
protected void onResume() {
drawView.onResume();
- updateLeaderBoard();
-
if (GoogleSignIn.getLastSignedInAccount(this) == null) {
FirebaseAuth.getInstance().signOut();
Intent i = new Intent(this, LoginActivity.class);
startActivity(i);
}
+ btnColor.setVisibility(sharedPref.getBoolean("draw_in_color", false) ?
+ View.VISIBLE : View.INVISIBLE);
mUser.reload().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
navUserName.setText(mUser.getDisplayName());
@@ -327,19 +339,11 @@ protected void onResume() {
}
@Override
- // OnPause() is called when the user receives an event like a call or a text message,
- // when onPause() is called the Activity may be partially or completely hidden.
protected void onPause() {
drawView.onPause();
super.onPause();
}
- @Override
- protected void onStop() {
- updateLeaderBoard();
- super.onStop();
- }
-
@Override
public void onBackPressed() {
if (drawer.isDrawerOpen(GravityCompat.START)) {
@@ -367,6 +371,27 @@ private void showAbout() {
startActivity(intent);
}
+ public void changeColor(View v) {
+ ColorPickerView.WHEEL_TYPE wheelType = sharedPref.getInt("wheel_type", 0) == 0 ?
+ ColorPickerView.WHEEL_TYPE.FLOWER : ColorPickerView.WHEEL_TYPE.CIRCLE;
+ ColorPickerDialogBuilder
+ .with(this)
+ .setTitle("Pick Color")
+ .initialColor(SharedData.lineColor)
+ .wheelType(wheelType)
+ .lightnessSliderOnly()
+ .density(16)
+ .setOnColorSelectedListener(selectedColor -> {})
+ .setPositiveButton("ok", (dialog, selectedColor, allColors) -> {
+ SharedData.lineColor = selectedColor;
+ sharedPref.edit().putInt("line_color", selectedColor).apply();
+ btnColor.setBackgroundTintList(ColorStateList.valueOf(selectedColor));
+ })
+ .setNegativeButton("cancel", (dialog, which) -> {})
+ .build()
+ .show();
+ }
+
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction() & MotionEvent.ACTION_MASK;
@@ -378,6 +403,7 @@ public boolean onTouch(View v, MotionEvent event) {
return true;
} else if (action == MotionEvent.ACTION_UP) {
processTouchUp();
+ v.performClick();
return true;
}
return false;
@@ -387,28 +413,25 @@ private void processTouchDown(MotionEvent event) {
if (!alreadyDrawn) {
mLastX = event.getX();
mLastY = event.getY();
- drawView.calcPos(mLastX, mLastY, mTmpPoint);
- float lastConvX = mTmpPoint.x;
- float lastConvY = mTmpPoint.y;
- drawModel.startLine(lastConvX, lastConvY);
+ drawView.calcPos(mLastX, mLastY, mTmpPt);
+ float lastX = mTmpPt.x;
+ float lastY = mTmpPt.y;
+ drawModel.startLine(lastX, lastY);
}
}
/**
- * The main drawing function
- * it actually stores all the drawing positions
- * into the drawModel object
- * we actually render the drawing from that object
- * in the drawRenderer class
+ * The main drawing function, stores all the drawing positions into the drawModel object
+ * Render the drawing from that object in the drawRenderer class
* @param event motion event
*/
private void processTouchMove(MotionEvent event) {
float x = event.getX();
float y = event.getY();
- drawView.calcPos(x, y, mTmpPoint);
- float newConvX = mTmpPoint.x;
- float newConvY = mTmpPoint.y;
+ drawView.calcPos(x, y, mTmpPt);
+ float newConvX = mTmpPt.x;
+ float newConvY = mTmpPt.y;
drawModel.addLineElem(newConvX, newConvY);
mLastX = x;
@@ -491,9 +514,10 @@ public void sendImage(View v) {
/* Update User Score internally, with FireBase and with Google Play Games */
userScore++;
+ SharedData.userScore = userScore;
updateWurmsAchievements();
+ updateLeaderBoard();
- tvUserScore.setText(String.valueOf(userScore));
mDatabase.child("user_scores").child(mUser.getUid()).setValue(userScore);
mFirebaseAnalytics.setUserProperty("user_score", String.valueOf(userScore));
@@ -556,6 +580,10 @@ private void updateWurmsAchievements() {
if (isGoogleSignIn) {
mAchClient.increment(getString(R.string.achievement_newbie_1_id), 1);
mAchClient.increment(getString(R.string.achievement_newbie_2_id), 1);
+ if (userScore == 125) {
+ mAchClient.unlock(getString(R.string.achievement_colorful_id));
+ btnColor.setVisibility(View.VISIBLE);
+ }
mAchClient.increment(getString(R.string.achievement_growing_1_id), 1);
mAchClient.increment(getString(R.string.achievement_growing_2_id), 1);
mAchClient.increment(getString(R.string.achievement_silver_id), 1);
@@ -577,7 +605,7 @@ private void updateReporterAchievements() {
private void updateLeaderBoard() {
if (isGoogleSignIn && userScore > 0) {
- mLeadClient.submitScore(getString(R.string.leaderboard_wurm_scores_id), RC_LEADERBOARD_SCORE);
+ mLeadClient.submitScore(getString(R.string.leaderboard_wurm_scores_id), userScore);
}
}
@@ -600,7 +628,6 @@ private void fireBaseRetrieveUserScore() {
public void onDataChange(DataSnapshot dataSnapshot) {
readUserScore((HashMap)dataSnapshot.getValue());
}
-
@Override
public void onCancelled(DatabaseError databaseError) {
}
@@ -618,11 +645,11 @@ private void readUserScore(HashMap dict) {
Long score = (Long)dict.get(mUser.getUid());
userScore = score.intValue();
mFirebaseAnalytics.setUserProperty("user_score", String.valueOf(userScore));
- tvUserScore.setText(String.valueOf(userScore));
} else {
/* First time again */
mDatabase.child("user_scores").child(mUser.getUid()).setValue(userScore);
}
+ SharedData.userScore = userScore;
}
}
@@ -636,7 +663,7 @@ private void initWithImage(HashMap dict) {
int randKey = rand.nextInt(keyLen);
currBatchName = keyArray[randKey];
- currBatchSize = longToInt((Long) dict.get(currBatchName));
+ currBatchSize = Util.longToInt((Long) dict.get(currBatchName));
currImgNo = rand.nextInt(currBatchSize) + 1;
tvImageName.setText(String.format(Locale.getDefault(), "%s / %d.png", currBatchName, currImgNo));
@@ -662,7 +689,7 @@ public void nextImage(View v) {
Random rand = new Random();
int randKey = rand.nextInt(keyLen);
currBatchName = keyArray[randKey];
- currBatchSize = longToInt((Long) uploadsDict.get(currBatchName));
+ currBatchSize = Util.longToInt((Long) uploadsDict.get(currBatchName));
currImgNo = rand.nextInt(currBatchSize) + 1;
tvImageName.setText(String.format(Locale.getDefault(),"%s / %d.png", currBatchName, currImgNo));
@@ -679,22 +706,4 @@ public void nextImage(View v) {
}
}
-
- /**
- * Converts dp into pixel values
- * @param dp display pixels
- * @return pixel values
- */
- private int dpToPx(int dp) {
- return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
- dp, getResources().getDisplayMetrics());
- }
-
- private int longToInt(long l) {
- if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
- throw new IllegalArgumentException
- (l + " cannot be cast to int without changing its value.");
- }
- return (int) l;
- }
}
diff --git a/app/src/main/java/com/example/caden/drawingtest/FCMService.java b/app/src/main/java/com/example/caden/drawingtest/FCMService.java
index ffdc39a..b4bc3ae 100644
--- a/app/src/main/java/com/example/caden/drawingtest/FCMService.java
+++ b/app/src/main/java/com/example/caden/drawingtest/FCMService.java
@@ -15,39 +15,14 @@ public class FCMService extends FirebaseMessagingService {
final int RC_Notify_ID = 1733;
- /**
- * Called when message is received.
- *
- * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
- */
+
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
- /*
- There are two types of messages data messages and notification messages. Data messages are handled
- here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
- traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
- is in the foreground. When the app is in the background an automatically generated notification is displayed.
- When the user taps on the notification they are returned to the app. Messages containing both notification
- and data payloads are treated as notification messages. The Firebase console always sends notification
- messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
- */
-
- /* Not getting messages here? See why this may be: https://goo.gl/39bRN */
- /* Messages are from: remoteMessage.getFrom()) */
-
- /* Check if message contains a data payload. */
-
- /* Check if message contains a notification payload. */
if (remoteMessage.getNotification() != null) {
sendNotification(remoteMessage.getNotification().getBody());
}
}
- /**
- * Create and show a simple notification containing the received FCM message.
- *
- * @param messageBody FCM message body received.
- */
private void sendNotification(String messageBody) {
Intent intent = new Intent(this, DrawingActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -56,14 +31,13 @@ private void sendNotification(String messageBody) {
String channelId = getString(R.string.default_notification_channel_id);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
- NotificationCompat.Builder notificationBuilder =
- new NotificationCompat.Builder(this, channelId)
- .setSmallIcon(R.mipmap.ic_launcher)
- .setContentTitle(getString(R.string.app_name))
- .setContentText(messageBody)
- .setAutoCancel(true)
- .setSound(defaultSoundUri)
- .setContentIntent(pendingIntent);
+ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
+ .setSmallIcon(R.mipmap.ic_launcher)
+ .setContentTitle(getString(R.string.app_name))
+ .setContentText(messageBody)
+ .setAutoCancel(true)
+ .setSound(defaultSoundUri)
+ .setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
diff --git a/app/src/main/java/com/example/caden/drawingtest/FIDService.java b/app/src/main/java/com/example/caden/drawingtest/FIDService.java
index 8f0c295..26a7ebd 100644
--- a/app/src/main/java/com/example/caden/drawingtest/FIDService.java
+++ b/app/src/main/java/com/example/caden/drawingtest/FIDService.java
@@ -4,28 +4,12 @@
import com.google.firebase.iid.FirebaseInstanceIdService;
public class FIDService extends FirebaseInstanceIdService {
- /**
- * Called if InstanceID token is updated. This may occur if the security of
- * the previous token had been compromised. Note that this is called when the InstanceID token
- * is initially generated so this is where you would retrieve the token.
- */
+
@Override
public void onTokenRefresh() {
- // If you want to send messages to this application instance or
- // manage this apps subscriptions on the server side, send the
- // Instance ID token to your app server.
sendRegistrationToServer(FirebaseInstanceId.getInstance().getToken());
}
- /**
- * Persist token to third-party servers.
- *
- * Modify this method to associate the user's FCM InstanceID token with any server-side account
- * maintained by your application.
- *
- * @param token The new token.
- */
private void sendRegistrationToServer(String token) {
- // Send token to app server.
}
}
diff --git a/app/src/main/java/com/example/caden/drawingtest/LoginActivity.java b/app/src/main/java/com/example/caden/drawingtest/LoginActivity.java
index 9ea73ab..af2acb7 100644
--- a/app/src/main/java/com/example/caden/drawingtest/LoginActivity.java
+++ b/app/src/main/java/com/example/caden/drawingtest/LoginActivity.java
@@ -112,7 +112,7 @@ public void updateUI(boolean delay) {
Intent i = new Intent(this, DrawingActivity.class);
startActivity(i);
},
- 300);
+ 250);
} else {
Intent i = new Intent(this, DrawingActivity.class);
startActivity(i);
diff --git a/app/src/main/java/com/example/caden/drawingtest/PasswordResetActivity.java b/app/src/main/java/com/example/caden/drawingtest/PasswordResetActivity.java
index f85ad61..ff1f296 100644
--- a/app/src/main/java/com/example/caden/drawingtest/PasswordResetActivity.java
+++ b/app/src/main/java/com/example/caden/drawingtest/PasswordResetActivity.java
@@ -86,9 +86,7 @@ public void resetPassword(View v) {
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
Snackbar.make(v, "Reset email sent", Snackbar.LENGTH_LONG)
- .setAction("Back to login", view -> {
- backToLogin(v);
- })
+ .setAction("Back to login", view -> backToLogin(v))
.show();
} else {
Snackbar.make(v, "User may not exist, please enter correct email",
diff --git a/app/src/main/java/com/example/caden/drawingtest/SettingsActivity.java b/app/src/main/java/com/example/caden/drawingtest/SettingsActivity.java
index d7e3a31..a2e75d7 100644
--- a/app/src/main/java/com/example/caden/drawingtest/SettingsActivity.java
+++ b/app/src/main/java/com/example/caden/drawingtest/SettingsActivity.java
@@ -4,47 +4,35 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
+import android.preference.SwitchPreference;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBar;
-import android.util.DisplayMetrics;
-import android.util.Log;
import android.view.MenuItem;
+import android.view.View;
-import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.UserInfo;
import com.google.firebase.auth.UserProfileChangeRequest;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-
public class SettingsActivity extends AppCompatPreferenceActivity {
private static FirebaseUser user;
private static String userName;
private static SharedPreferences sharedPrefs;
- /**
- * A preference value change listener that updates the preference's summary
- * to reflect its new value.
- */
private static Preference.OnPreferenceChangeListener sBindPrefSummaryToValListener = (pref, val) -> {
String strVal = val.toString();
if (pref instanceof ListPreference) {
- // For list preferences, look up the correct display value in
- // the preference's 'entries' list.
ListPreference listPreference = (ListPreference) pref;
int index = listPreference.findIndexOfValue(strVal);
- // Set the summary to reflect the new value.
+ sharedPrefs.edit().putInt("wheel_type", index).apply();
pref.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
} else if (pref instanceof EditTextPreference) {
if (pref.getKey().equals("user_name")) {
@@ -56,42 +44,22 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
pref.setSummary(strVal);
} else {
- // For all other preferences, set the summary to the value's
- // simple string representation.
pref.setSummary(strVal);
}
return true;
};
- /**
- * Helper method to determine if the device has an extra-large screen. For
- * example, 10" tablets are extra-large.
- */
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
- /**
- * Binds a preference's summary to its value. More specifically, when the
- * preference's value is changed, its summary (line of text below the
- * preference title) is updated to reflect the value. The summary is also
- * immediately updated upon calling this method. The exact display format is
- * dependent on the type of preference.
- *
- * @see #sBindPrefSummaryToValListener
- */
private static void bindPreferenceSummaryToValue(Preference preference) {
- // Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(sBindPrefSummaryToValListener);
-
- // Trigger the listener immediately with the preference's
- // current value.
- sBindPrefSummaryToValListener.onPreferenceChange(preference,
- PreferenceManager
- .getDefaultSharedPreferences(preference.getContext())
- .getString(preference.getKey(), ""));
+ sBindPrefSummaryToValListener.onPreferenceChange(preference, PreferenceManager
+ .getDefaultSharedPreferences(preference.getContext())
+ .getString(preference.getKey(), ""));
}
@Override
@@ -135,10 +103,6 @@ public boolean onIsMultiPane() {
return isXLargeTablet(this);
}
- /**
- * This method stops fragment injection in malicious applications.
- * Make sure to deny any unknown fragments here.
- */
protected boolean isValidFragment(String fragmentName) {
return PreferenceFragment.class.getName().equals(fragmentName)
|| WurmPrefFragment.class.getName().equals(fragmentName);
@@ -159,6 +123,26 @@ public void onCreate(Bundle savedInstanceState) {
}
bindPreferenceSummaryToValue(findPreference("user_name"));
bindPreferenceSummaryToValue(findPreference("user_email"));
+ bindPreferenceSummaryToValue(findPreference("draw_color_type"));
+
+ SwitchPreference colorPref = (SwitchPreference) findPreference("draw_color");
+ if (SharedData.userScore < 125) {
+ colorPref.setEnabled(false);
+ } else {
+ colorPref.setEnabled(true);
+ /* Set true to it only one time */
+ if(sharedPrefs.getBoolean("color_enabled_first_time", false)) {
+ colorPref.setChecked(true);
+ sharedPrefs.edit()
+ .putBoolean("color_enabled_first_time", true)
+ .putBoolean("draw_in_color", true).apply();
+ }
+ /* Set Listener for further changes */
+ colorPref.setOnPreferenceChangeListener(((p, o) -> {
+ sharedPrefs.edit().putBoolean("draw_in_color", (boolean) o).apply();
+ return true;
+ }));
+ }
}
@Override
diff --git a/app/src/main/java/com/example/caden/drawingtest/SharedData.java b/app/src/main/java/com/example/caden/drawingtest/SharedData.java
index 075d8e7..7178bf7 100644
--- a/app/src/main/java/com/example/caden/drawingtest/SharedData.java
+++ b/app/src/main/java/com/example/caden/drawingtest/SharedData.java
@@ -9,4 +9,7 @@
class SharedData {
static byte[] imgData;
static List lineData;
+ static int lineColor;
+ static int userScore;
+ static boolean isGoogleSignIn;
}
diff --git a/app/src/main/java/com/example/caden/drawingtest/Util.java b/app/src/main/java/com/example/caden/drawingtest/Util.java
index 56e1964..fc47a0b 100644
--- a/app/src/main/java/com/example/caden/drawingtest/Util.java
+++ b/app/src/main/java/com/example/caden/drawingtest/Util.java
@@ -1,5 +1,8 @@
package com.example.caden.drawingtest;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+
import java.util.regex.Pattern;
/**
@@ -14,8 +17,8 @@ class Util {
/**
* RFC822 Compliant Email Validation
*
- * @param s email string
- * @return whether email is valid
+ * @param s email string
+ * @return whether email is valid
*/
static boolean isEmailValid(String s) {
return emailPtr.matcher(s).matches();
@@ -24,10 +27,32 @@ static boolean isEmailValid(String s) {
/**
* Checks if password is at least 8 characters
*
- * @param s password string
- * @return whether password is valid
+ * @param s password string
+ * @return whether password is valid
*/
static boolean isPasswordValid(String s) {
return passwordPtr.matcher(s).matches();
}
+
+ /**
+ * Converts dp into pixel values
+ * @param dp display pixels
+ * @param dm display metrics
+ * @return pixel values
+ */
+ static int dpToPx(int dp, DisplayMetrics dm) {
+ return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, dm);
+ }
+
+ /**
+ * Safely converts long to ints
+ * @param l long
+ * @return ints
+ */
+ static int longToInt(long l) {
+ if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException(l + " cannot cast to int");
+ }
+ return (int) l;
+ }
}
diff --git a/app/src/main/java/com/example/caden/drawingtest/WurmMeterActivity.java b/app/src/main/java/com/example/caden/drawingtest/WurmMeterActivity.java
new file mode 100644
index 0000000..2594f48
--- /dev/null
+++ b/app/src/main/java/com/example/caden/drawingtest/WurmMeterActivity.java
@@ -0,0 +1,76 @@
+package com.example.caden.drawingtest;
+
+import android.os.Bundle;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.TextView;
+
+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 java.util.HashMap;
+import java.util.Locale;
+
+public class WurmMeterActivity extends AppCompatActivity {
+
+ DatabaseReference mDatabase;
+ TextView tvInfo;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_wurm_meter);
+
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setElevation(0);
+ }
+
+ TextView tvScore = findViewById(R.id.tv_score);
+ tvScore.setText(String.valueOf(SharedData.userScore));
+ TextView tvHours = findViewById(R.id.tv_hours);
+ float hr = (float) SharedData.userScore / 15;
+ tvHours.setText(String.format(Locale.getDefault(), "%.1f", hr));
+ tvInfo = findViewById(R.id.tv_info);
+
+ if (SharedData.isGoogleSignIn) {
+ findViewById(R.id.iv_tip).setVisibility(View.INVISIBLE);
+ findViewById(R.id.tv_tip).setVisibility(View.INVISIBLE);
+ }
+
+ mDatabase = FirebaseDatabase.getInstance().getReference();
+ mDatabase.child("user_scores").addValueEventListener(new ValueEventListener() {
+ @Override
+ public void onDataChange(DataSnapshot dataSnapshot) {
+ updateTotal((HashMap) dataSnapshot.getValue());
+ }
+ @Override
+ public void onCancelled(DatabaseError databaseError) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onSupportNavigateUp() {
+ onBackPressed();
+ return true;
+ }
+
+ private void updateTotal(HashMap dict) {
+ int total = 0;
+ if (dict != null) {
+ for (Object i : dict.values()) {
+ total += Util.longToInt((Long) i);
+ }
+ }
+ float contribution = (float) SharedData.userScore / total;
+ tvInfo.setText(String.format(Locale.getDefault(),
+ "%d Wurms annotated so far, you have contributed %.2f%% to the Wurm Community!",
+ total, contribution * 100));
+ }
+}
diff --git a/app/src/main/res/drawable/ic_color_lens.xml b/app/src/main/res/drawable/ic_color_lens.xml
new file mode 100644
index 0000000..4abeea5
--- /dev/null
+++ b/app/src/main/res/drawable/ic_color_lens.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_lightbulb.xml b/app/src/main/res/drawable/ic_lightbulb.xml
new file mode 100644
index 0000000..6c22586
--- /dev/null
+++ b/app/src/main/res/drawable/ic_lightbulb.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_quote.xml b/app/src/main/res/drawable/ic_quote.xml
new file mode 100644
index 0000000..ee70715
--- /dev/null
+++ b/app/src/main/res/drawable/ic_quote.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_wurm_meter.xml b/app/src/main/res/drawable/ic_wurm_meter.xml
new file mode 100644
index 0000000..9aa2124
--- /dev/null
+++ b/app/src/main/res/drawable/ic_wurm_meter.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_drawing.xml b/app/src/main/res/layout/activity_drawing.xml
index 004f898..983dd44 100644
--- a/app/src/main/res/layout/activity_drawing.xml
+++ b/app/src/main/res/layout/activity_drawing.xml
@@ -18,7 +18,7 @@
tools:context="com.example.caden.drawingtest.DrawingActivity"
tools:layout_editor_absoluteY="81dp">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ app:layout_constraintHorizontal_bias="0.0"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/cv_drawview">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_nav_drawer.xml b/app/src/main/res/menu/menu_nav_drawer.xml
index 8425dca..68dd3d5 100644
--- a/app/src/main/res/menu/menu_nav_drawer.xml
+++ b/app/src/main/res/menu/menu_nav_drawer.xml
@@ -3,38 +3,41 @@
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
-
+
-
+
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 9986c18..2ec7fe4 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -10,20 +10,32 @@
或没账号?注册吧!用户@wurmpaint.co
- 注销随机下图
- Mark as bad
+ 坏图标注Any reasons for marking this image?
- ###/###.pngwurm.painter@gmail.com
- my_channel_01重设密码重新输入您的电邮清除颜色
- Reset
+ 重设虫涂涂 用户虫涂涂 设置关于 虫涂涂更改语言
+ 玩家
+ 我的成就
+ 我的排名
+ 虫的记录
+ Google Play 设置
+ 注销
+ 管理
+ 设置
+ 意见回馈
+ 帮助
+ 关于
+ Wurm-o-Meter
+ Google account for more achievement and compete with your friends on the leaderboard!]]>
+ Light bulb graphic
+ 颜色圈类型
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4b7241f..01ad3f4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -15,16 +15,15 @@
Clearuser@wurmpaint.co
- Sign OutNext Random
- Mark as bad
+ Mark As BadAny reasons for marking this image?
- ###/###.png
+ ###/###.pngOpen navigation drawerClose navigation drawerwurm.painter@gmail.com
- my_channel_01
+ my_channel_01Reset PasswordRe-enter your emailReset
@@ -34,6 +33,7 @@
CgkI75C0pcMBEAIQAQCgkI75C0pcMBEAIQBA
+ CgkI75C0pcMBEAIQDwCgkI75C0pcMBEAIQBQCgkI75C0pcMBEAIQBgCgkI75C0pcMBEAIQBw
@@ -49,20 +49,49 @@
CgkI75C0pcMBEAIQAw
-
Wurm PainterWurm Settings
+ Change Language
+ Color Wheel Type
+
+ Flower
+ Circle
+
+
+ 0
+ 1
+
- System sync settings
- Add friends to messages
-
+
+ Player
+ Achievements
+ Leaderboard
+ Wurm-o-Meter
+ Wurm Logbook
+ Google Play Settings
+ Log Out
+ Manage
+ Settings
+ Send Feedback
+ Help
+ About
Changelog
+
1.08 (2018-04-24)
+
+ - Added about screen
+ - Redesigned navigation drawer layout
+ - Added user preferences
+ - Update navigation drawer based on whether user is signed in via Google or otherwise
+ - App automatically signs out if Google Account is signed out.
+ - Added more Google Play Achievements
+
+
1.07 (2018-04-14)
- Added user scores in FireBase
@@ -109,7 +138,7 @@
- Removed brush color functionality
- Images expanded to fill the screen
- User restricted to drawing single strokes
- - User can mark images as bad and provide a reason
+ - User can mark images as bad and provide a reason v
- Optimized for tablet displays
1.01 (2017-12-01)
@@ -136,5 +165,8 @@
]]>
-
+
+ Switch to a Google account for more achievement and compete with your friends on the leaderboard!
+
+ Light bulb graphic
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 4f0f319..02e6c3d 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -23,6 +23,13 @@
false
+
+
diff --git a/app/src/main/res/xml/pref_wurm.xml b/app/src/main/res/xml/pref_wurm.xml
index 48329c4..23c10c9 100644
--- a/app/src/main/res/xml/pref_wurm.xml
+++ b/app/src/main/res/xml/pref_wurm.xml
@@ -1,9 +1,7 @@
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-