File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -273,20 +273,21 @@ public static ViewGroup getLayout() {
273273 @ Override
274274 public boolean onKeyDown (int keyCode , KeyEvent event ) {
275275 // Check if the key event was the Back button and if there's history
276- if ((keyCode == KeyEvent .KEYCODE_BACK ) && mWebView .canGoBack ()) {
277- mWebView .goBack ();
278- return true ;
276+ if ((keyCode == KeyEvent .KEYCODE_BACK )) {
277+ if (mWebView .canGoBack ()) {
278+ mWebView .goBack ();
279+ return true ;
280+ }
281+ if (SystemClock .elapsedRealtime () - lastBackClick > 2000 ){
282+ lastBackClick = SystemClock .elapsedRealtime ();
283+ Toast .makeText (this , "Click again to close the app" ,
284+ Toast .LENGTH_LONG ).show ();
285+ return true ;
286+ }
279287 }
288+
280289 // If it wasn't the Back key or there's no web page history, bubble up to the default
281290 // system behavior (probably exit the activity)
282- if (SystemClock .elapsedRealtime () - lastBackClick > 2000 ){
283- lastBackClick = SystemClock .elapsedRealtime ();
284- Toast .makeText (this , "Click again to close the app" ,
285- Toast .LENGTH_LONG ).show ();
286- return true ;
287- }
288-
289- lastBackClick = SystemClock .elapsedRealtime ();
290291 return super .onKeyDown (keyCode , event );
291292 }
292293
You can’t perform that action at this time.
0 commit comments