77import android .support .constraint .ConstraintLayout ;
88import android .support .constraint .ConstraintSet ;
99import android .support .design .widget .FloatingActionButton ;
10+ import android .support .v7 .app .AlertDialog ;
1011import android .support .v7 .app .AppCompatActivity ;
12+ import android .support .v7 .widget .Toolbar ;
1113import android .transition .TransitionManager ;
1214import android .util .TypedValue ;
15+ import android .view .Menu ;
16+ import android .view .MenuItem ;
1317import android .view .MotionEvent ;
1418import android .view .View ;
1519import android .widget .ProgressBar ;
3135
3236public 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 */
0 commit comments