Skip to content

Commit f895e09

Browse files
committed
Added about screen and code cleanups
1 parent 0a310e9 commit f895e09

25 files changed

+1000
-345
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Android drawing application for annotating the backbone of worms.
3131
- Added basic navigation drawer to access user profile
3232
- Google Sign-in now fully supported
3333
- Added push notification support
34-
- Firebase analytics
34+
- FireBase analytics
3535

3636
### 1.04 (2018-01-24)
3737
- Added quick options to marking bad images rather than just a general comment box

app/.idea/assetWizardSettings.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.

app/.idea/workspace.xml

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

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ android {
3131
}
3232

3333
dependencies {
34+
implementation 'com.android.support:support-v4:26.1.0'
3435
compile fileTree(include: ['*.jar'], dir: 'libs')
3536
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
3637
exclude group: 'com.android.support', module: 'support-annotations'
@@ -55,4 +56,4 @@ dependencies {
5556
compile 'com.google.firebase:firebase-core:15.0.0'
5657
}
5758

58-
apply plugin: 'com.google.gms.google-services'
59+
apply plugin: 'com.google.gms.google-services'

app/src/main/AndroidManifest.xml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
android:value="@string/default_notification_channel_id" />
2828

2929
<!-- Google Play Game Services -->
30-
<meta-data android:name="com.google.android.gms.games.APP_ID"
30+
<meta-data
31+
android:name="com.google.android.gms.games.APP_ID"
3132
android:value="@string/app_id" />
32-
<meta-data android:name="com.google.android.gms.version"
33-
android:value="@integer/google_play_services_version"/>
33+
<meta-data
34+
android:name="com.google.android.gms.version"
35+
android:value="@integer/google_play_services_version" />
3436

3537
<service
3638
android:name=".FCMService"
@@ -69,7 +71,21 @@
6971
<activity
7072
android:name=".PasswordResetActivity"
7173
android:screenOrientation="portrait"
72-
android:theme="@style/AppTheme"/>
74+
android:theme="@style/AppTheme" />
75+
<activity
76+
android:name=".SettingsActivity"
77+
android:screenOrientation="portrait"
78+
android:label="@string/title_activity_settings"
79+
android:parentActivityName=".DrawingActivity"
80+
android:theme="@style/AppTheme.Settings">
81+
<meta-data
82+
android:name="android.support.PARENT_ACTIVITY"
83+
android:value="com.example.caden.drawingtest.DrawingActivity" />
84+
</activity>
85+
<activity
86+
android:name=".AboutActivity"
87+
android:screenOrientation="portrait"
88+
android:theme="@style/AppTheme.Settings"/>
7389
</application>
7490

7591
</manifest>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.example.caden.drawingtest;
2+
3+
import android.support.v7.app.ActionBar;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.text.Html;
7+
import android.text.method.LinkMovementMethod;
8+
import android.widget.TextView;
9+
10+
public class AboutActivity extends AppCompatActivity {
11+
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
setContentView(R.layout.activity_about);
16+
17+
ActionBar actionBar = getSupportActionBar();
18+
if (actionBar != null) {
19+
actionBar.setDisplayHomeAsUpEnabled(true);
20+
}
21+
22+
TextView tvChangeLog = findViewById(R.id.tv_change_log);
23+
tvChangeLog.setText(Html.fromHtml(getString(R.string.about_screen_text)));
24+
tvChangeLog.setMovementMethod(LinkMovementMethod.getInstance());
25+
}
26+
27+
@Override
28+
public boolean onSupportNavigateUp() {
29+
onBackPressed();
30+
return true;
31+
}
32+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package com.example.caden.drawingtest;
2+
3+
import android.content.res.Configuration;
4+
import android.os.Bundle;
5+
import android.preference.PreferenceActivity;
6+
import android.support.annotation.LayoutRes;
7+
import android.support.annotation.Nullable;
8+
import android.support.v7.app.ActionBar;
9+
import android.support.v7.app.AppCompatDelegate;
10+
import android.support.v7.widget.Toolbar;
11+
import android.view.MenuInflater;
12+
import android.view.View;
13+
import android.view.ViewGroup;
14+
15+
/**
16+
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
17+
* to be used with AppCompat.
18+
*/
19+
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
20+
21+
private AppCompatDelegate mDelegate;
22+
23+
@Override
24+
protected void onCreate(Bundle savedInstanceState) {
25+
getDelegate().installViewFactory();
26+
getDelegate().onCreate(savedInstanceState);
27+
super.onCreate(savedInstanceState);
28+
}
29+
30+
@Override
31+
protected void onPostCreate(Bundle savedInstanceState) {
32+
super.onPostCreate(savedInstanceState);
33+
getDelegate().onPostCreate(savedInstanceState);
34+
}
35+
36+
public ActionBar getSupportActionBar() {
37+
return getDelegate().getSupportActionBar();
38+
}
39+
40+
public void setSupportActionBar(@Nullable Toolbar toolbar) {
41+
getDelegate().setSupportActionBar(toolbar);
42+
}
43+
44+
@Override
45+
public MenuInflater getMenuInflater() {
46+
return getDelegate().getMenuInflater();
47+
}
48+
49+
@Override
50+
public void setContentView(@LayoutRes int layoutResID) {
51+
getDelegate().setContentView(layoutResID);
52+
}
53+
54+
@Override
55+
public void setContentView(View view) {
56+
getDelegate().setContentView(view);
57+
}
58+
59+
@Override
60+
public void setContentView(View view, ViewGroup.LayoutParams params) {
61+
getDelegate().setContentView(view, params);
62+
}
63+
64+
@Override
65+
public void addContentView(View view, ViewGroup.LayoutParams params) {
66+
getDelegate().addContentView(view, params);
67+
}
68+
69+
@Override
70+
protected void onPostResume() {
71+
super.onPostResume();
72+
getDelegate().onPostResume();
73+
}
74+
75+
@Override
76+
protected void onTitleChanged(CharSequence title, int color) {
77+
super.onTitleChanged(title, color);
78+
getDelegate().setTitle(title);
79+
}
80+
81+
@Override
82+
public void onConfigurationChanged(Configuration newConfig) {
83+
super.onConfigurationChanged(newConfig);
84+
getDelegate().onConfigurationChanged(newConfig);
85+
}
86+
87+
@Override
88+
protected void onStop() {
89+
super.onStop();
90+
getDelegate().onStop();
91+
}
92+
93+
@Override
94+
protected void onDestroy() {
95+
super.onDestroy();
96+
getDelegate().onDestroy();
97+
}
98+
99+
public void invalidateOptionsMenu() {
100+
getDelegate().invalidateOptionsMenu();
101+
}
102+
103+
private AppCompatDelegate getDelegate() {
104+
if (mDelegate == null) {
105+
mDelegate = AppCompatDelegate.create(this, null);
106+
}
107+
return mDelegate;
108+
}
109+
}

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

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import android.view.MotionEvent;
2525
import android.view.View;
2626
import android.widget.Button;
27-
import android.widget.ImageView;
2827
import android.widget.ProgressBar;
2928
import android.widget.RadioButton;
3029
import android.widget.RadioGroup;
@@ -204,27 +203,12 @@ protected void onCreate(Bundle savedInstanceState) {
204203
/* Google Play Game */
205204
gAcct = GoogleSignIn.getLastSignedInAccount(this);
206205
if (gAcct != null) {
207-
Games.getGamesClient(this, gAcct).setViewForPopups(clDrawMain);
206+
// Games.getGamesClient(this, gAcct).setViewForPopups(clDrawMain);
208207
mAchClient = Games.getAchievementsClient(this, gAcct);
209208
mLeadClient = Games.getLeaderboardsClient(this, gAcct);
210209
}
211210
}
212211

213-
214-
@Override
215-
public boolean onCreateOptionsMenu(Menu menu) {
216-
getMenuInflater().inflate(R.menu.standard_menu, menu);
217-
return true;
218-
}
219-
220-
@Override
221-
public boolean onOptionsItemSelected(MenuItem item) {
222-
if (item.getItemId() == R.id.menu_info) {
223-
aboutScreen();
224-
}
225-
return super.onOptionsItemSelected(item);
226-
}
227-
228212
@Override
229213
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
230214
int id = item.getItemId();
@@ -234,8 +218,12 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
234218
showLeaderBoard();
235219
} else if (id == R.id.nav_logout) {
236220
logOut();
221+
} else if (id == R.id.nav_settings) {
222+
showSettings();
223+
} else if (id == R.id.nav_send_feedback) {
224+
feedbackScreen();
237225
} else if (id == R.id.nav_about) {
238-
aboutScreen();
226+
showAbout();
239227
}
240228
drawer.closeDrawer(GravityCompat.START);
241229
return true;
@@ -255,9 +243,14 @@ private void showLeaderBoard() {
255243
}
256244
}
257245

258-
private void aboutScreen() {
246+
private void showSettings() {
247+
Intent intent = new Intent(this, SettingsActivity.class);
248+
startActivity(intent);
249+
}
250+
251+
private void feedbackScreen() {
259252
View aboutDialogView =
260-
getLayoutInflater().inflate(R.layout.about_dialog,
253+
getLayoutInflater().inflate(R.layout.dialog_feedback,
261254
new ConstraintLayout(this), false);
262255

263256
TextView feedbackText = aboutDialogView.findViewById(R.id.tv_feedback);
@@ -317,47 +310,34 @@ private void logOut() {
317310
.show();
318311
}
319312

313+
private void showAbout() {
314+
Intent intent = new Intent(this, AboutActivity.class);
315+
startActivity(intent);
316+
}
317+
320318
@Override
321-
// this method detects which direction a user is moving
322-
// their finger and draws a line accordingly in that
323-
// direction
324319
public boolean onTouch(View v, MotionEvent event) {
325-
//get the action and store it as an int
326320
int action = event.getAction() & MotionEvent.ACTION_MASK;
327-
//actions have predefined ints, lets match
328-
//to detect, if the user has touched, which direction the users finger is
329-
//moving, and if they've stopped moving
330-
331-
//if touched
332321
if (action == MotionEvent.ACTION_DOWN) {
333-
//begin drawing line
334322
processTouchDown(event);
335323
return true;
336-
//draw line in every direction the user moves
337324
} else if (action == MotionEvent.ACTION_MOVE) {
338325
processTouchMove(event);
339326
return true;
340-
//if finger is lifted, stop drawing
341327
} else if (action == MotionEvent.ACTION_UP) {
342328
processTouchUp();
343329
return true;
344330
}
345331
return false;
346332
}
347333

348-
// draw line down
349334
private void processTouchDown(MotionEvent event) {
350335
if (!alreadyDrawn) {
351-
//calculate the x, y coordinates where the user has touched
352336
mLastX = event.getX();
353337
mLastY = event.getY();
354-
//user them to calculate the position
355338
drawView.calcPos(mLastX, mLastY, mTmpPoint);
356-
//store them in memory to draw a line between the
357-
//difference in positions
358339
float lastConvX = mTmpPoint.x;
359340
float lastConvY = mTmpPoint.y;
360-
//and begin the line drawing
361341
drawModel.startLine(lastConvX, lastConvY);
362342
}
363343
}
@@ -484,7 +464,7 @@ public void sendImage(View v) {
484464
public void markAsBad(View v) {
485465
/* Update Database Reference */
486466
View aboutDialogView =
487-
getLayoutInflater().inflate(R.layout.image_comments_dialog,
467+
getLayoutInflater().inflate(R.layout.dialog_img_comments,
488468
new ConstraintLayout(this), false);
489469
TextView reasonText = aboutDialogView.findViewById(R.id.tv_mark_reason);
490470
reasonText.setEnabled(false);

0 commit comments

Comments
 (0)