Ejemplo n.º 1
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_FOCUS:
        if (mFirstTimeInitialized && event.getRepeatCount() == 0) {
          doFocus(true);
        }
        return true;
      case KeyEvent.KEYCODE_CAMERA:
        if (mFirstTimeInitialized && event.getRepeatCount() == 0) {
          doSnap();
        }
        return true;
      case KeyEvent.KEYCODE_DPAD_CENTER:
        // If we get a dpad center event without any focused view, move
        // the focus to the shutter button and press it.
        if (mFirstTimeInitialized && event.getRepeatCount() == 0) {
          // Start auto-focus immediately to reduce shutter lag. After
          // the shutter button gets the focus, doFocus() will be
          // called again but it is fine.
          doFocus(true);
          if (mShutterButton.isInTouchMode()) {
            mShutterButton.requestFocusFromTouch();
          } else {
            mShutterButton.requestFocus();
          }
          mShutterButton.setPressed(true);
        }
        return true;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 2
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
      if (hideKeyboard()) {
        return false;
      }

      if ((System.currentTimeMillis() - mExitTime) > 2000) {
        Toast.makeText(this, R.string.exit_once_more, 0).show();
        mExitTime = System.currentTimeMillis();
      } else {
        String sign = TeamMeetingApp.getMyself().getmAuthorization();
        // signout
        mNetWork.signOut(sign);
      }
      return true;
    }

    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 3
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Shortcuts that work no matter what is selected

    if (
    // TODO - when we move to android 2.0, uncomment this.
    // android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR &&

    keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && K9.manageBack()) {
      // Take care of calling this method on earlier versions of
      // the platform where it doesn't exist.
      onBackPressed();
      return true;
    }

    switch (keyCode) {
      case KeyEvent.KEYCODE_Q:
        // case KeyEvent.KEYCODE_BACK:
        {
          onAccounts();
          return true;
        }

      case KeyEvent.KEYCODE_S:
        {
          onEditAccount();
          return true;
        }

      case KeyEvent.KEYCODE_H:
        {
          Toast toast = Toast.makeText(this, R.string.folder_list_help_key, Toast.LENGTH_LONG);
          toast.show();
          return true;
        }

      case KeyEvent.KEYCODE_1:
        {
          setDisplayMode(FolderMode.FIRST_CLASS);
          return true;
        }
      case KeyEvent.KEYCODE_2:
        {
          setDisplayMode(FolderMode.FIRST_AND_SECOND_CLASS);
          return true;
        }
      case KeyEvent.KEYCODE_3:
        {
          setDisplayMode(FolderMode.NOT_SECOND_CLASS);
          return true;
        }
      case KeyEvent.KEYCODE_4:
        {
          setDisplayMode(FolderMode.ALL);
          return true;
        }
    } // switch

    return super.onKeyDown(keyCode, event);
  } // onKeyDown
Ejemplo n.º 4
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     ExitAppUtil.exit(this);
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 5
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) System.exit(0);

    return super.onKeyDown(keyCode, event);
  }
  private void handleKeyEvent(KeyEvent event) {
    if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0) {
      return;
    }

    switch (event.getKeyCode()) {
      case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
      case KeyEvent.KEYCODE_HEADSETHOOK:
        downloadService.togglePlayPause();
        break;
      case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        downloadService.previous();
        break;
      case KeyEvent.KEYCODE_MEDIA_NEXT:
        if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) {
          downloadService.next();
        }
        break;
      case KeyEvent.KEYCODE_MEDIA_STOP:
        downloadService.reset();
        break;
      case KeyEvent.KEYCODE_MEDIA_PLAY:
        downloadService.play();
        break;
      case KeyEvent.KEYCODE_MEDIA_PAUSE:
        downloadService.pause();
        break;
      default:
        break;
    }
  }
Ejemplo n.º 7
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
      Log.i(AnkiDroidApp.TAG, "CardBrowser - onBackPressed()");
      if (mSearchEditText.getText().length() == 0
          && !mShowOnlyMarSus
          && mSelectedTags.size() == 0) {
        setResult(RESULT_OK);
        finish();
        if (Integer.valueOf(android.os.Build.VERSION.SDK) > 4) {
          ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.RIGHT);
        }
      } else {
        mSearchEditText.setText("");
        mSearchEditText.setHint(R.string.downloaddeck_search);
        mSelectedTags.clear();
        mCards.clear();
        mCards.addAll(mAllCards);
        updateList();
      }
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 8
0
  // 监听键盘事件
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setMessage("确定要退出吗?");
      builder.setTitle("提示");
      builder.setPositiveButton(
          "确认",
          new android.content.DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();

              try {
                EcgBusiness.getInstance().stopTask(mainHandler); // 通知业务模块进行业务处理
                System.exit(0); // 退出程序
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          });
      builder.setNegativeButton(
          "取消",
          new android.content.DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
            }
          });
      builder.create().show();
    }
    return false;
  }
Ejemplo n.º 9
0
  @Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (event.getRepeatCount() == 0
        && event.isDown()
        && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE)) {
      doPauseResume();
      show(sDefaultTimeout);
      if (mPauseButton != null) {
        mPauseButton.requestFocus();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
      if (mPlayer.isPlaying()) {
        mPlayer.pause();
        updatePausePlay();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
      // don't show the controls for volume adjustment
      return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
      hide();

      return true;
    } else {
      show(sDefaultTimeout);
    }
    return super.dispatchKeyEvent(event);
  }
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     if (currentFragment == FragmentsAvailable.DIALER
         || currentFragment == FragmentsAvailable.CONTACTS
         || currentFragment == FragmentsAvailable.HISTORY
         || currentFragment == FragmentsAvailable.CHATLIST
         || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
         || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS) {
       boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled();
       if (!isBackgroundModeActive) {
         stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
         finish();
       } else if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) {
         return true;
       }
     } else {
       if (isTablet()) {
         if (currentFragment == FragmentsAvailable.SETTINGS) {
           updateAnimationsState();
         }
       }
     }
   } else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
     if (event.getRepeatCount() < 1) {
       statusFragment.openOrCloseStatusBar(true);
     }
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 11
0
 public boolean onKey(DialogInterface dialoginterface, int i, KeyEvent keyevent) {
   if (i == 82 || i == 4) {
     if (keyevent.getAction() == 0 && keyevent.getRepeatCount() == 0) {
       dialoginterface = mDialog.getWindow();
       if (dialoginterface != null) {
         dialoginterface = dialoginterface.getDecorView();
         if (dialoginterface != null) {
           dialoginterface = dialoginterface.getKeyDispatcherState();
           if (dialoginterface != null) {
             dialoginterface.startTracking(keyevent, this);
             return true;
           }
         }
       }
     } else if (keyevent.getAction() == 1 && !keyevent.isCanceled()) {
       Object obj = mDialog.getWindow();
       if (obj != null) {
         obj = ((Window) (obj)).getDecorView();
         if (obj != null) {
           obj = ((View) (obj)).getKeyDispatcherState();
           if (obj != null
               && ((android.view.KeyEvent.DispatcherState) (obj)).isTracking(keyevent)) {
             mMenu.close(true);
             dialoginterface.dismiss();
             return true;
           }
         }
       }
     }
   }
   return mMenu.performShortcut(i, keyevent, 0);
 }
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     MyMapGroup.group.back();
   }
   return true;
 }
Ejemplo n.º 13
0
 @Override
 public boolean onKeyPreIme(int keyCode, @NonNull KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && isSheetShowing()) {
     if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
       KeyEvent.DispatcherState state = getKeyDispatcherState();
       if (state != null) {
         state.startTracking(event, this);
       }
       return true;
     } else if (event.getAction() == KeyEvent.ACTION_UP) {
       KeyEvent.DispatcherState dispatcherState = getKeyDispatcherState();
       if (dispatcherState != null) {
         dispatcherState.handleUpEvent(event);
       }
       if (isSheetShowing() && event.isTracking() && !event.isCanceled()) {
         if (state == State.EXPANDED && peekOnDismiss) {
           peekSheet();
         } else {
           dismissSheet();
         }
         return true;
       }
     }
   }
   return super.onKeyPreIme(keyCode, event);
 }
Ejemplo n.º 14
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     exitApp();
   }
   return false;
 }
Ejemplo n.º 15
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_HOME && event.getRepeatCount() == 0) {
     return true;
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 16
0
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     finish();
     return false;
   }
   return false;
 }
Ejemplo n.º 17
0
 public boolean onKeyDown(int i, KeyEvent keyEvent) {
   if (VERSION.SDK_INT >= 5 || i != 4 || keyEvent.getRepeatCount() != 0) {
     return super.onKeyDown(i, keyEvent);
   }
   onBackPressed();
   return true;
 }
Ejemplo n.º 18
0
 @Override
 public boolean onKeyPreIme(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     // special case for the back key, we do not even try to send it
     // to the drop down list but instead, consume it immediately
     if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
       KeyEvent.DispatcherState state = getKeyDispatcherState();
       if (state != null) {
         state.startTracking(event, this);
       }
       return true;
     } else if (event.getAction() == KeyEvent.ACTION_UP) {
       KeyEvent.DispatcherState state = getKeyDispatcherState();
       if (state != null) {
         state.handleUpEvent(event);
       }
       if (event.isTracking() && !event.isCanceled()) {
         mSearchView.clearFocus();
         mSearchView.setImeVisibility(false);
         return true;
       }
     }
   }
   return super.onKeyPreIme(keyCode, event);
 }
Ejemplo n.º 19
0
 private void onKeyEvent(
     KeyEvent event, int action, int savedMetaState, boolean isSynthesizedImeKey) {
   // Use a separate action argument so we can override the key's original action,
   // e.g. change ACTION_MULTIPLE to ACTION_DOWN. That way we don't have to allocate
   // a new key event just to change its action field.
   //
   // Normally we expect event.getMetaState() to reflect the current meta-state; however,
   // some software-generated key events may not have event.getMetaState() set, e.g. key
   // events from Swype. Therefore, it's necessary to combine the key's meta-states
   // with the meta-states that we keep separately in KeyListener
   final int metaState = event.getMetaState() | savedMetaState;
   final int unmodifiedMetaState =
       metaState & ~(KeyEvent.META_ALT_MASK | KeyEvent.META_CTRL_MASK | KeyEvent.META_META_MASK);
   final int unicodeChar = event.getUnicodeChar(metaState);
   final int domPrintableKeyValue =
       unicodeChar >= ' '
           ? unicodeChar
           : unmodifiedMetaState != metaState ? event.getUnicodeChar(unmodifiedMetaState) : 0;
   onKeyEvent(
       action,
       event.getKeyCode(),
       event.getScanCode(),
       metaState,
       event.getEventTime(),
       unicodeChar,
       // e.g. for Ctrl+A, Android returns 0 for unicodeChar,
       // but Gecko expects 'a', so we return that in baseUnicodeChar.
       event.getUnicodeChar(0),
       domPrintableKeyValue,
       event.getRepeatCount(),
       event.getFlags(),
       isSynthesizedImeKey);
 }
 // 监听返回键
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     backOrWait();
     return true;
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 21
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     onBackPressed();
   }
   return super.onKeyDown(keyCode, event);
 }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

      AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
      builder1.setTitle("ALERT!!");
      builder1.setMessage("Do you want to abort the quiz?.");
      builder1.setCancelable(true);
      builder1.setPositiveButton(
          "Yes",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();

              finish();
              Intent intent = new Intent(getApplicationContext(), Listactivity.class); // inside!!
              startActivity(intent);
            }
          });
      builder1.setNegativeButton(
          "No",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
              // onResume();
            }
          });

      AlertDialog alert11 = builder1.create();
      alert11.show();
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 23
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
      Log.i(AnkiDroidApp.TAG, "CardBrowser - onBackPressed()");
      if (mSearchEditText.getText().length() == 0
          && !mShowOnlyMarSus
          && mSelectedTags.size() == 0) {
        // if (mPrefCacheCardBrowser) {
        // sCachedDeckPath = mDeck.getDeckPath();
        // sAllCardsCache = new ArrayList<HashMap<String, String>>();
        // sAllCardsCache.addAll(mAllCards);
        // }
        closeCardBrowser();
      } else {
        mSearchEditText.setText("");
        mSearchEditText.setHint(R.string.downloaddeck_search);
        mSelectedTags.clear();
        mCards.clear();
        mCards.addAll(mAllCards);
        updateList();
      }
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 24
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     dialog();
     return true;
   }
   return true;
 }
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (((SdkVersionHelper.getSdkInt() < 5) && (keyCode == KeyEvent.KEYCODE_BACK))
       && (event.getRepeatCount() == 0)) {
     onBackPressed();
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 26
0
 /** Called when a key is pressed */
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   // Check to see if it was the back button, if it is call the quit logger
   // method
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     quitLogger();
   }
   return super.onKeyDown(keyCode, event);
 }
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     event.startTracking();
     return true;
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 28
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     //            startActivity(new Intent(this, Search.class));
     this.finish();
   }
   return false;
 }
Ejemplo n.º 29
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && app.getInternalAPI().accessibilityEnabled()) {
     if (!uiHandler.hasMessages(LONG_KEYPRESS_MSG_ID)) {
       Message msg =
           Message.obtain(
               uiHandler,
               new Runnable() {
                 @Override
                 public void run() {
                   app.getLocationProvider().emitNavigationHint();
                 }
               });
       msg.what = LONG_KEYPRESS_MSG_ID;
       uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY);
     }
     return true;
   } else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
     mapActions.openOptionsMenuAsList();
     return true;
   } else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
     Intent newIntent = new Intent(MapActivity.this, OsmandIntents.getSearchActivity());
     // causes wrong position caching:  newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
     LatLon loc = getMapLocation();
     newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
     newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
     startActivity(newIntent);
     newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
     return true;
   } else if (!app.getRoutingHelper().isFollowingMode()
       && OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) != null) {
     // Find more appropriate plugin for it?
     if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
       if (mapView.isZooming()) {
         changeZoom(mapView.getZoom() + 2);
       } else {
         changeZoom(mapView.getZoom() + 1);
       }
       return true;
     } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && event.getRepeatCount() == 0) {
       changeZoom(mapView.getZoom() - 1);
       return true;
     }
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 30
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     deleteFiles(true, false);
     closeFeedback();
   }
   return super.onKeyDown(keyCode, event);
 }