1515import android .content .SharedPreferences ;
1616import android .content .res .AssetManager ;
1717import android .content .ClipboardManager ;
18- import android . content . ClipData ;
18+
1919
2020import android .graphics .Canvas ;
2121
3030import android .view .inputmethod .EditorInfo ;
3131import android .view .MenuItem ;
3232import android .view .ViewGroup ;
33+ import android .view .GestureDetector ;
3334
3435import androidx .security .crypto .EncryptedSharedPreferences ;
3536import androidx .security .crypto .MasterKey ;
@@ -168,6 +169,7 @@ public class pen_activity extends Activity {
168169 private SharedPreferences m_sharedPrefs ;
169170 private boolean m_canUseSharedPrefs ;
170171
172+ public boolean tapped = false ;
171173 public String clipboard_string = "" ;
172174 public boolean paste_enabled = false ;
173175 final float [] lastTouch = new float [2 ];
@@ -261,6 +263,7 @@ protected void onCreate(Bundle arg0) {
261263 getWindow ().setDecorFitsSystemWindows (false );
262264 getWindow ().setStatusBarColor (android .graphics .Color .TRANSPARENT );
263265 getWindow ().addFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
266+ getWindow ().getDecorView ().setSystemUiVisibility (View .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR );
264267
265268 init (this );
266269 FMOD .init (this );
@@ -277,20 +280,34 @@ protected void onCreate(Bundle arg0) {
277280 // paste menu on long click
278281 m_surfaceView .setLongClickable (true );
279282
283+ GestureDetector gestureDetector = new GestureDetector (m_context ,
284+ new GestureDetector .SimpleOnGestureListener () {
285+ @ Override
286+ public boolean onSingleTapConfirmed (MotionEvent e ) {
287+ tapped = true ;
288+ return true ;
289+ }
290+ }
291+ );
292+
280293 m_surfaceView .setOnTouchListener (new View .OnTouchListener () {
281294 @ Override
282295 public boolean onTouch (View v , MotionEvent event ) {
283296 if (event .getAction () == MotionEvent .ACTION_DOWN ) {
284297 lastTouch [0 ] = event .getX ();
285298 lastTouch [1 ] = event .getY ();
286299 }
300+ gestureDetector .onTouchEvent (event );
287301 return false ; // IMPORTANT: do not block long-press detection
288302 }
289303 });
290304
291305 m_surfaceView .setOnLongClickListener (new View .OnLongClickListener () {
292306 @ Override
293307 public boolean onLongClick (View v ) {
308+ if (!paste_enabled )
309+ return false ;
310+
294311 showPastePopup (v , (int )lastTouch [0 ], (int )lastTouch [1 ]);
295312 return true ;
296313 }
@@ -315,7 +332,7 @@ protected void onResume() {
315332 @ Override
316333 protected void onPause () {
317334 super .onPause ();
318-
335+
319336 // kill the process when app is backgrounded
320337 android .os .Process .killProcess (android .os .Process .myPid ());
321338 System .exit (0 );
@@ -399,7 +416,7 @@ public static void createDirectory(String strdir)
399416 {
400417 File dir = new File (strdir );
401418 if (!dir .exists ()) {
402- dir .mkdirs ();
419+ dir .mkdirs ();
403420 }
404421 }
405422
@@ -459,4 +476,11 @@ void clearClipboardString()
459476 {
460477 clipboard_string = "" ;
461478 }
479+
480+ boolean wasTapped ()
481+ {
482+ boolean res = tapped ;
483+ tapped = false ;
484+ return res ;
485+ }
462486}
0 commit comments