Skip to content

Commit 8a073dc

Browse files
committed
more animations
1 parent 7505d12 commit 8a073dc

File tree

5 files changed

+76
-14
lines changed

5 files changed

+76
-14
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
<activity
4444
android:name=".DrawingActivity"
4545
android:screenOrientation="portrait"
46-
android:theme="@style/AppTheme" />
47-
48-
46+
android:theme="@style/AppTheme.NoActionBar" />
4947

5048
</application>
5149

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

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
import android.support.constraint.ConstraintLayout;
88
import android.support.constraint.ConstraintSet;
99
import android.support.design.widget.FloatingActionButton;
10+
import android.support.v7.app.AlertDialog;
1011
import android.support.v7.app.AppCompatActivity;
12+
import android.support.v7.widget.Toolbar;
1113
import android.transition.TransitionManager;
1214
import android.util.TypedValue;
15+
import android.view.Menu;
16+
import android.view.MenuItem;
1317
import android.view.MotionEvent;
1418
import android.view.View;
1519
import android.widget.ProgressBar;
@@ -31,7 +35,8 @@
3135

3236
public class DrawingActivity extends AppCompatActivity implements View.OnTouchListener {
3337

34-
final int dp56 = dpToPx(56);
38+
/* Constants */
39+
int dp56;
3540

3641
// views
3742
private DrawModel drawModel;
@@ -49,6 +54,7 @@ public class DrawingActivity extends AppCompatActivity implements View.OnTouchLi
4954
private FirebaseAuth mAuth;
5055
private DatabaseReference mDatabase;
5156

57+
Toolbar toolbar;
5258
private ProgressBar barSend;
5359
private FloatingActionButton fabSend;
5460

@@ -62,13 +68,16 @@ public class DrawingActivity extends AppCompatActivity implements View.OnTouchLi
6268
protected void onCreate(Bundle savedInstanceState) {
6369
super.onCreate(savedInstanceState);
6470
setContentView(R.layout.activity_drawing);
71+
toolbar = findViewById(R.id.drawing_toolbar);
72+
setSupportActionBar(toolbar);
6573

6674
//get drawing view from XML (where the finger writes the number)
6775
drawView = findViewById(R.id.draw);
6876
//get the model object
6977
drawModel = new DrawModel(PIXEL_WIDTH, PIXEL_WIDTH);
7078
clDrawMain = findViewById(R.id.cl_draw_main);
7179
constraintSet.clone(clDrawMain);
80+
dp56 = dpToPx(56);
7281

7382
//init the view with the model object
7483
drawView.setModel(drawModel);
@@ -86,6 +95,28 @@ protected void onCreate(Bundle savedInstanceState) {
8695
mDatabase = FirebaseDatabase.getInstance().getReference();
8796
}
8897

98+
@Override
99+
public boolean onCreateOptionsMenu(Menu menu) {
100+
getMenuInflater().inflate(R.menu.standard_menu, menu);
101+
return true;
102+
}
103+
104+
@Override
105+
public boolean onOptionsItemSelected(MenuItem item) {
106+
if (item.getItemId() == R.id.menu_info) {
107+
about_screen();
108+
}
109+
return super.onOptionsItemSelected(item);
110+
}
111+
112+
private void about_screen() {
113+
new AlertDialog.Builder(this)
114+
.setMessage(R.string.about_text)
115+
.setTitle(R.string.app_name)
116+
.setPositiveButton("OK", (dialog, id) -> dialog.cancel())
117+
.show();
118+
}
119+
89120
@Override
90121
//OnResume() is called when the user resumes his Activity which he left a while ago,
91122
// //say he presses home button and then comes back to app, onResume() is called.
@@ -178,21 +209,17 @@ public void clear(View v) {
178209

179210
public void sendImage(View v) {
180211

181-
int height = findViewById(R.id.cv_drawview).getHeight();
212+
int dvHeight = findViewById(R.id.cv_drawview).getHeight();
182213

183214
TransitionManager.beginDelayedTransition(clDrawMain);
184215
constraintSet.constrainHeight(R.id.fab_send, 0);
185216
constraintSet.constrainWidth(R.id.fab_send, 0);
186217
constraintSet.constrainWidth(R.id.pbar_send, dp56);
187218
constraintSet.constrainHeight(R.id.pbar_send, dp56);
188-
189219
constraintSet.constrainHeight(R.id.cv_drawview, 0);
190-
220+
constraintSet.constrainHeight(R.id.drawing_ll, dvHeight / 2);
191221
constraintSet.applyTo(clDrawMain);
192222

193-
194-
195-
196223
Bitmap bmp = drawView.getBitmapData();
197224
ByteArrayOutputStream baos = new ByteArrayOutputStream();
198225
bmp.compress(Bitmap.CompressFormat.JPEG, 80, baos);
@@ -219,9 +246,9 @@ public void sendImage(View v) {
219246
constraintSet.constrainHeight(R.id.pbar_send, 0);
220247
constraintSet.constrainHeight(R.id.fab_send, dp56);
221248
constraintSet.constrainWidth(R.id.fab_send, dp56);
222-
constraintSet.constrainHeight(R.id.cv_drawview, height);
249+
constraintSet.constrainHeight(R.id.cv_drawview, dvHeight);
250+
constraintSet.constrainHeight(R.id.drawing_ll, 0);
223251
constraintSet.applyTo(clDrawMain);
224-
225252
});
226253

227254
/* Update Database Reference */
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle" >
4+
5+
<gradient
6+
android:angle="90"
7+
android:endColor="#549eff"
8+
android:startColor="#007ee6"
9+
android:type="linear" />
10+
11+
</shape>

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,41 @@
88
tools:context="com.example.caden.drawingtest.DrawingActivity"
99
tools:layout_editor_absoluteY="81dp">
1010

11+
<LinearLayout
12+
android:id="@+id/drawing_ll"
13+
android:layout_width="0dp"
14+
android:layout_height="0dp"
15+
android:background="@drawable/color_primary_gradient"
16+
android:orientation="vertical"
17+
app:layout_constraintEnd_toEndOf="parent"
18+
app:layout_constraintStart_toStartOf="parent" />
19+
20+
<android.support.design.widget.AppBarLayout
21+
android:id="@+id/drawing_appBarLayout"
22+
android:layout_width="match_parent"
23+
android:layout_height="wrap_content"
24+
android:layout_marginTop="0dp"
25+
android:theme="@style/AppTheme.AppBarOverlay"
26+
app:layout_constraintTop_toBottomOf="@+id/drawing_ll">
27+
28+
<android.support.v7.widget.Toolbar
29+
android:id="@+id/drawing_toolbar"
30+
android:layout_width="match_parent"
31+
android:layout_height="?attr/actionBarSize"
32+
android:background="?attr/colorPrimary"
33+
app:popupTheme="@style/AppTheme.PopupOverlay" />
34+
</android.support.design.widget.AppBarLayout>
35+
1136
<android.support.v7.widget.CardView
1237
android:id="@+id/cv_drawview"
1338
android:layout_width="0dp"
1439
android:layout_height="wrap_content"
40+
android:layout_marginTop="0dp"
1541
app:cardBackgroundColor="#E0E0E0"
1642
app:cardCornerRadius="0dp"
1743
app:layout_constraintEnd_toEndOf="parent"
1844
app:layout_constraintStart_toStartOf="parent"
19-
app:layout_constraintTop_toTopOf="parent">
45+
app:layout_constraintTop_toBottomOf="@+id/drawing_appBarLayout">
2046

2147
<com.example.caden.drawingtest.DrawView
2248
android:id="@+id/draw"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="colorPrimary">#549eff</color>
4-
<color name="colorPrimaryDark">#0070cb</color>
4+
<color name="colorPrimaryDark">#0091ea</color>
55
<color name="colorAccent">#ff2646</color>
66
</resources>

0 commit comments

Comments
 (0)