Exemplo n.º 1
0
 private void onApplicationModePress(View v) {
   final QuickAction mQuickAction = new QuickAction(v);
   mQuickAction.setOnAnchorOnTop(true);
   List<ApplicationMode> vls =
       ApplicationMode.values(mapActivity.getMyApplication().getSettings());
   final ApplicationMode[] modes = vls.toArray(new ApplicationMode[vls.size()]);
   Drawable[] icons = new Drawable[vls.size()];
   int[] values = new int[vls.size()];
   for (int k = 0; k < modes.length; k++) {
     icons[k] = app.getIconsCache().getIcon(modes[k].getSmallIconDark(), R.color.icon_color);
     values[k] = modes[k].getStringResource();
   }
   for (int i = 0; i < modes.length; i++) {
     final ActionItem action = new ActionItem();
     action.setTitle(mapActivity.getResources().getString(values[i]));
     action.setIcon(icons[i]);
     final int j = i;
     action.setOnClickListener(
         new OnClickListener() {
           @Override
           public void onClick(View v) {
             mapActivity.getMyApplication().getSettings().APPLICATION_MODE.set(modes[j]);
             mQuickAction.dismiss();
           }
         });
     mQuickAction.addActionItem(action);
   }
   mQuickAction.setAnimStyle(QuickAction.ANIM_AUTO);
   mQuickAction.show();
 }
Exemplo n.º 2
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {

    if (!isSelectFavoriteMode()) {
      QuickAction qa = new QuickAction(v);
      FavouritePoint point = favouritesAdapter.getItem(position);
      String name = getString(R.string.favorite) + ": " + point.getName();
      LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
      View.OnClickListener onshow =
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              settings.SHOW_FAVORITES.set(true);
            }
          };
      MapActivityActions.createDirectionsActions(
          qa, location, point, name, settings.getLastKnownMapZoom(), this, true, onshow);
      qa.show();
    } else {
      Intent intent = getIntent();
      intent.putExtra(SELECT_FAVORITE_POINT_INTENT_KEY, favouritesAdapter.getItem(position));
      setResult(SELECT_FAVORITE_POINT_RESULT_OK, intent);
      finish();
    }
  }
Exemplo n.º 3
0
 private void onApplicationModePress() {
   final QuickAction mQuickAction = new QuickAction(backToMenuButton);
   int[] icons =
       new int[] {
         R.drawable.default_mode_small,
         R.drawable.car_small,
         R.drawable.bicycle_small,
         R.drawable.pedestrian_small
       };
   int[] values =
       new int[] {
         R.string.app_mode_default,
         R.string.app_mode_car,
         R.string.app_mode_bicycle,
         R.string.app_mode_pedestrian
       };
   final ApplicationMode[] modes =
       new ApplicationMode[] {
         ApplicationMode.DEFAULT,
         ApplicationMode.CAR,
         ApplicationMode.BICYCLE,
         ApplicationMode.PEDESTRIAN
       };
   for (int i = 0; i < 4; i++) {
     final ActionItem action = new ActionItem();
     action.setTitle(view.getResources().getString(values[i]));
     action.setIcon(view.getResources().getDrawable(icons[i]));
     final int j = i;
     action.setOnClickListener(
         new OnClickListener() {
           @Override
           public void onClick(View v) {
             view.getSettings().APPLICATION_MODE.set(modes[j]);
             activity.updateApplicationModeSettings();
             view.refreshMap(true);
             mQuickAction.dismiss();
           }
         });
     mQuickAction.addActionItem(action);
   }
   mQuickAction.setAnimStyle(QuickAction.ANIM_AUTO);
   mQuickAction.show();
 }
Exemplo n.º 4
0
 @Override
 public void onClick(View v) {
   qaChangeBook.show(v);
 }
  /**
   * Shows the context menu using the given region as an anchor point.
   *
   * @param displayRect
   */
  protected void showContextMenu(Rect displayRect) {

    // Don't show this twice
    if (mContextMenuVisible) {
      return;
    }

    // Don't use empty rect
    // if(displayRect.isEmpty()){
    if (displayRect.right <= displayRect.left) {
      return;
    }

    // Copy action item
    ActionItem buttonOne = new ActionItem();

    buttonOne.setTitle("Button 1");
    buttonOne.setActionId(1);
    buttonOne.setIcon(getResources().getDrawable(R.drawable.menu_search));

    // Highlight action item
    ActionItem buttonTwo = new ActionItem();

    buttonTwo.setTitle("Button 2");
    buttonTwo.setActionId(2);
    buttonTwo.setIcon(getResources().getDrawable(R.drawable.menu_info));

    ActionItem buttonThree = new ActionItem();

    buttonThree.setTitle("Button 3");
    buttonThree.setActionId(3);
    buttonThree.setIcon(getResources().getDrawable(R.drawable.menu_eraser));

    // The action menu
    mContextMenu = new QuickAction(getContext());
    mContextMenu.setOnDismissListener(this);

    // Add buttons
    mContextMenu.addActionItem(buttonOne);

    mContextMenu.addActionItem(buttonTwo);

    mContextMenu.addActionItem(buttonThree);

    // setup the action item click listener
    mContextMenu.setOnActionItemClickListener(
        new QuickAction.OnActionItemClickListener() {

          @Override
          public void onItemClick(QuickAction source, int pos, int actionId) {
            // TODO Auto-generated method stub
            if (actionId == 1) {
              // Do Button 1 stuff
              Log.i(TAG, "Hit Button 1");
            } else if (actionId == 2) {
              // Do Button 2 stuff
              Log.i(TAG, "Hit Button 2");
            } else if (actionId == 3) {
              // Do Button 3 stuff
              Log.i(TAG, "Hit Button 3");
            }

            mContextMenuVisible = false;
          }
        });

    mContextMenuVisible = true;
    mContextMenu.show(this, displayRect);
  }
Exemplo n.º 6
0
        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
          final File file = (File) mList.getItemAtPosition(position);
          mCurrent = file;
          if (file.isDirectory()) {
            mCurrentDir = file;
            mAdapter.notifyDataSetInvalidated();
            return;
          }
          if (FacadeConfiguration.getSdkLevel() <= 3
              || !mPreferences.getBoolean("use_quick_menu", true)) {
            doDialogMenu();
            return;
          }

          final QuickAction actionMenu = new QuickAction(view);

          ActionItem terminal = new ActionItem();
          terminal.setIcon(getResources().getDrawable(R.drawable.terminal));
          terminal.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  Intent intent = new Intent(ScriptManager.this, ScriptingLayerService.class);
                  intent.setAction(Constants.ACTION_LAUNCH_FOREGROUND_SCRIPT);
                  intent.putExtra(Constants.EXTRA_SCRIPT_PATH, file.getPath());
                  startService(intent);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem background = new ActionItem();
          background.setIcon(getResources().getDrawable(R.drawable.background));
          background.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  Intent intent = new Intent(ScriptManager.this, ScriptingLayerService.class);
                  intent.setAction(Constants.ACTION_LAUNCH_BACKGROUND_SCRIPT);
                  intent.putExtra(Constants.EXTRA_SCRIPT_PATH, file.getPath());
                  startService(intent);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem edit = new ActionItem();
          edit.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_edit));
          edit.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  editScript(file);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem delete = new ActionItem();
          delete.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_delete));
          delete.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  delete(file);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem rename = new ActionItem();
          rename.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_save));
          rename.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  rename(file);
                  dismissQuickActions(actionMenu);
                }
              });

          final ActionItem external = new ActionItem();
          external.setIcon(getResources().getDrawable(android.R.drawable.ic_menu_directions));
          external.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  // externalEditor(file);
                  dismissQuickActions(actionMenu);
                  if (!file.getAbsolutePath().endsWith(".pyc") && !file.isDirectory()) {
                    // 非文件夹或者非pyc文件提示无法反编译
                    Crouton.cancelAllCroutons();
                    Crouton.showText(
                        ScriptManager.this, getString(R.string.s_Cannotdecompile), Style.ALERT);
                  } else {
                    Decompile.show(ScriptManager.this, file.getAbsolutePath());
                  }
                }
              });

          actionMenu.addActionItems(terminal, background, edit, rename, delete, external);
          actionMenu.setAnimStyle(QuickAction.ANIM_GROW_FROM_CENTER);
          actionMenu.show();
        }