Permalink
Browse files

Require a second back press (with in 5 sec) to exit

  • Loading branch information...
rscottm committed Dec 16, 2012
1 parent 2e9ad11 commit 80ea800078afe1d5fafc4cbda3fef48b6a37dc42
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/org/ruboto/irb/IRB.java
@@ -99,7 +99,8 @@
private TabWidget tabWidget;
private final Handler handler = new Handler();
private PrintStream printStream;
-
+ private long timeBackPressed = 0;
+
/* IRB_Tab Elements */
public static TextView currentIrbOutput;
private TextView irbOutput;
@@ -156,6 +157,18 @@ public void onCreate(Bundle savedInstanceState) {
JRubyAdapter.setLocalVariableBehavior("PERSISTENT");
uiSetup();
}
+
+ @Override
+ public void onBackPressed() {
+ if (System.currentTimeMillis() - timeBackPressed < 5000) {
+ finish();
+ } else {
+ Toast.makeText(this,
+ "Press back again to exit.",
+ Toast.LENGTH_SHORT).show();
+ timeBackPressed = System.currentTimeMillis();
+ }
+ }
protected void fireRubotoActivity() {
JRubyAdapter.put("$irb", this);

0 comments on commit 80ea800

Please sign in to comment.