private QuickAction prepareDirAction(final SeafDirent dirent) {
    final QuickAction mQuickAction = new QuickAction(mActivity);
    Resources resources = mActivity.getResources();
    ActionItem shareAction;
    shareAction =
        new ActionItem(
            ACTION_ID_SHARE,
            resources.getString(R.string.file_action_share),
            resources.getDrawable(R.drawable.action_share));
    mQuickAction.addActionItem(shareAction);

    // setup the action item click listener
    mQuickAction.setOnActionItemClickListener(
        new QuickAction.OnActionItemClickListener() {
          @Override
          public void onItemClick(QuickAction quickAction, int pos, int actionId) {
            NavContext nav = mActivity.getNavContext();
            String repoName = nav.getRepoName();
            String repoID = nav.getRepoID();
            String dir = nav.getDirPath();
            String path = Utils.pathJoin(dir, dirent.name);
            switch (actionId) {
              case ACTION_ID_SHARE:
                mActivity.shareDir(repoID, path);
                break;
            }
          }
        });

    mQuickAction.mAnimateTrack(false);
    return mQuickAction;
  }
Exemple #2
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();
 }
  @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();
    }
  }
Exemple #4
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();
 }
        public void handleMessage(Message m) {

          if (getParent() != null && mContextMenu != null && mContextMenuVisible) {
            // This will throw an error if the webview is being redrawn.
            // No error handling needed, just need to stop the crash.
            try {
              mContextMenu.dismiss();
            } catch (Exception e) {

            }
          }
          mSelectionBounds = null;
          mLastTouchedSelectionHandle = -1;
          loadUrl("javascript: android.selection.clearSelection();");
          removeView(mSelectionDragLayer);
        }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    ActionItem nextItem =
        new ActionItem(ID_DOWN, "Next", getResources().getDrawable(R.drawable.menu_down_arrow));
    ActionItem prevItem =
        new ActionItem(ID_UP, "Prev", getResources().getDrawable(R.drawable.menu_up_arrow));
    ActionItem searchItem =
        new ActionItem(ID_SEARCH, "Find", getResources().getDrawable(R.drawable.menu_search));
    ActionItem infoItem =
        new ActionItem(ID_INFO, "Info", getResources().getDrawable(R.drawable.menu_info));
    ActionItem eraseItem =
        new ActionItem(ID_ERASE, "Clear", getResources().getDrawable(R.drawable.menu_eraser));
    ActionItem okItem = new ActionItem(ID_OK, "OK", getResources().getDrawable(R.drawable.menu_ok));

    // use setSticky(true) to disable QuickAction dialog being dismissed after an item is clicked
    prevItem.setSticky(true);
    nextItem.setSticky(true);

    // create QuickAction. Use QuickAction.VERTICAL or QuickAction.HORIZONTAL param to define layout
    // orientation
    final QuickAction quickAction = new QuickAction(this, QuickAction.VERTICAL);

    // add action items into QuickAction
    quickAction.addActionItem(nextItem);
    quickAction.addActionItem(prevItem);
    quickAction.addActionItem(searchItem);
    quickAction.addActionItem(infoItem);
    quickAction.addActionItem(eraseItem);
    quickAction.addActionItem(okItem);

    // Set listener for action item clicked
    quickAction.setOnActionItemClickListener(
        new QuickAction.OnActionItemClickListener() {
          // @Override
          public void onItemClick(QuickAction source, int pos, int actionId) {
            ActionItem actionItem = quickAction.getActionItem(pos);

            // here we can filter which action item was clicked with pos or actionId parameter
            if (actionId == ID_SEARCH) {
              Toast.makeText(
                      getApplicationContext(), "Let's do some search action", Toast.LENGTH_SHORT)
                  .show();
            } else if (actionId == ID_INFO) {
              Toast.makeText(
                      getApplicationContext(), "I have no info this time", Toast.LENGTH_SHORT)
                  .show();
            } else {
              Toast.makeText(
                      getApplicationContext(),
                      actionItem.getTitle() + " selected",
                      Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    // set listnener for on dismiss event, this listener will be called only if QuickAction dialog
    // was dismissed
    // by clicking the area outside the dialog.
    quickAction.setOnDismissListener(
        new QuickAction.OnDismissListener() {
          // @Override
          public void onDismiss() {
            Toast.makeText(getApplicationContext(), "Dismissed", Toast.LENGTH_SHORT).show();
          }
        });

    // show on btn1
    Button btn1 = (Button) this.findViewById(R.id.btn1);
    btn1.setOnClickListener(
        new View.OnClickListener() {
          // @Override
          public void onClick(View v) {
            // quickAction.show(v);
          }
        });

    Button btn2 = (Button) this.findViewById(R.id.btn2);
    btn2.setOnClickListener(
        new OnClickListener() {
          // @Override
          public void onClick(View v) {
            // quickAction.show(v);
          }
        });

    Button btn3 = (Button) this.findViewById(R.id.btn3);
    btn3.setOnClickListener(
        new OnClickListener() {
          // @Override
          public void onClick(View v) {
            // quickAction.show(v);
            quickAction.setAnimStyle(QuickAction.ANIM_REFLECT);
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_song_view);

    setTitle(R.string.sn_songs_activity_title);

    song_container = V.get(this, R.id.song_container);
    no_song_data_container = V.get(this, R.id.no_song_data_container);
    bChangeBook = V.get(this, R.id.bChangeBook);
    bChangeCode = V.get(this, R.id.bChangeCode);
    bSearch = V.get(this, R.id.bSearch);
    bDownload = V.get(this, R.id.bDownload);

    qaChangeBook = SongBookUtil.getSongBookQuickAction(this, false);
    qaChangeBook.setOnActionItemClickListener(
        SongBookUtil.getOnActionItemConverter(songBookSelected));

    codeKeypad = new SongCodePopup(this);

    bChangeBook.setOnClickListener(bChangeBook_click);
    bChangeCode.setOnClickListener(bChangeCode_click);
    bSearch.setOnClickListener(bSearch_click);
    bDownload.setOnClickListener(bDownload_click);

    // for colors of bg, text, etc
    V.get(this, android.R.id.content).setBackgroundColor(S.applied.backgroundColor);

    templateCustomVars = new Bundle();
    templateCustomVars.putString(
        "background_color",
        String.format("#%06x", S.applied.backgroundColor & 0xffffff)); // $NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "text_color",
        String.format("#%06x", S.applied.fontColor & 0xffffff)); // $NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "verse_number_color",
        String.format("#%06x", S.applied.verseNumberColor & 0xffffff)); // $NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "text_size",
        S.applied.fontSize2dp
            + "px"); // somehow this is automatically scaled to dp. //$NON-NLS-1$ //$NON-NLS-2$
    templateCustomVars.putString(
        "line_spacing_mult", String.valueOf(S.applied.lineSpacingMult)); // $NON-NLS-1$

    {
      String fontName = Preferences.getString(getString(R.string.pref_jenisHuruf_key), null);
      if (FontManager.isCustomFont(fontName)) {
        templateCustomVars.putString(
            "custom_font_loader",
            String.format(
                "@font-face{ font-family: '%s'; src: url('%s'); }",
                fontName, FontManager.getCustomFontUri(fontName))); // $NON-NLS-1$ //$NON-NLS-2$
      } else {
        templateCustomVars.putString("custom_font_loader", ""); // $NON-NLS-1$ //$NON-NLS-2$
      }
      templateCustomVars.putString("text_font", fontName); // $NON-NLS-1$
    }

    { // show latest viewed song
      String bookName =
          Preferences.getString(Prefkey.song_last_bookName, null); // let KJ become the default.
      String code = Preferences.getString(Prefkey.song_last_code, null);

      if (bookName == null || code == null) {
        displaySong(null, null);
      } else {
        displaySong(bookName, S.getSongDb().getSong(bookName, code));
      }
    }
  }
 @Override
 public void onClick(View v) {
   qaChangeBook.show(v);
 }
  private void initViews() {
    tvSelect = (TextView) findViewById(R.id.tv_select);
    // ivRecommend = (ImageView)findViewById(R.id.iv_recommend);

    Drawable recommend = getResources().getDrawable(R.drawable.recommend);
    /*Bitmap bitmap = ((BitmapDrawable)tmp).getBitmap();
    Drawable recommend = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, 35, 35, true));*/

    ActionItem commentItem = new ActionItem(FLAG_RECOMMEND, "熱門推薦", recommend);
    ActionItem firstItem = new ActionItem(FLAG_HOT, "依播放次數");
    ActionItem secondItem = new ActionItem(FLAG_NEW, "依上架時間");
    ActionItem thisweekItem = new ActionItem(FLAG_2013, "2013年");
    ActionItem recentItem = new ActionItem(FLAG_2012, "2012年");
    ActionItem topItem = new ActionItem(FLAG_BEFORE, "2011年以前");

    quickAction = new QuickAction(this, QuickAction.VERTICAL);

    // add action items into QuickAction
    quickAction.addActionItem(commentItem);
    quickAction.addActionItem(firstItem);
    quickAction.addActionItem(secondItem);
    quickAction.addActionItem(thisweekItem);
    quickAction.addActionItem(recentItem);
    quickAction.addActionItem(topItem);

    // Set listener for action item clicked
    quickAction.setOnActionItemClickListener(
        new QuickAction.OnActionItemClickListener() {
          public void onItemClick(QuickAction source, int pos, int actionId) {
            quickAction.getActionItem(pos);
            setActionText(actionId);
            sortDataTask = new SortDataTask();
            if (Build.VERSION.SDK_INT < 11) sortDataTask.execute();
            else sortDataTask.executeOnExecutor(LoadDataTask.THREAD_POOL_EXECUTOR, 0);
          }
        });

    // set listnener for on dismiss event, this listener will be called only if QuickAction dialog
    // was dismissed
    // by clicking the area outside the dialog.
    quickAction.setOnDismissListener(
        new QuickAction.OnDismissListener() {
          public void onDismiss() {
            // Toast.makeText(getApplicationContext(), "Dismissed", Toast.LENGTH_SHORT).show();
          }
        });

    llSelect = (LinearLayout) findViewById(R.id.ll_select);
    llSelect.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            quickAction.show(v);
          }
        });

    topbar_text = (TextView) findViewById(R.id.topbar_text);
    topbar_text.setText(getResources().getString(R.string.app_name));

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    cursorWidth = dm.widthPixels / listnumber - cursorOffset * 2;

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(cursorWidth, 15);
    lp.setMargins(cursorOffset, 0, cursorOffset, 0);
    cursor = (ImageView) findViewById(R.id.arrow_1);
    cursor.setLayoutParams(lp);

    buttonTaiwan = (Button) findViewById(R.id.button_drama_taiwan);
    buttonKoera = (Button) findViewById(R.id.button_drama_koera);
    buttonJapan = (Button) findViewById(R.id.button_drama_japan);
    buttonChina = (Button) findViewById(R.id.button_drama_china);

    viewpager = (ViewPager) findViewById(R.id.viewpager_tvchannel);
    viewpager.setOffscreenPageLimit(listnumber);

    imageButtonRefresh = (ImageButton) findViewById(R.id.refresh);
    imageButtonRefresh.setOnClickListener(
        new OnClickListener() {
          public void onClick(View arg0) {
            updatetask = new updateDataTask();
            if (Build.VERSION.SDK_INT < 11) updatetask.execute();
            else updatetask.executeOnExecutor(updateDataTask.THREAD_POOL_EXECUTOR, 0);
          }
        });
  }
 public void addItem(String s, int i, int j, int k)
 {
     mQuickActions.addActionItem(new ActionItem(j, s));
 }
  private QuickAction prepareFileAction(final SeafDirent dirent, boolean cacheExists) {
    final QuickAction mQuickAction = new QuickAction(mActivity);
    Resources resources = mActivity.getResources();
    ActionItem shareAction, downloadAction, updateAction, exportAction, renameAction, deleteAction;

    shareAction =
        new ActionItem(
            ACTION_ID_SHARE,
            resources.getString(R.string.file_action_share),
            resources.getDrawable(R.drawable.action_share));
    mQuickAction.addActionItem(shareAction);

    // deleteAction = new ActionItem(ACTION_ID_DELETE,
    //                               resources.getString(R.string.file_action_delete),
    //                               resources.getDrawable(R.drawable.action_delete));
    // mQuickAction.addActionItem(deleteAction);

    renameAction =
        new ActionItem(
            ACTION_ID_RENAME,
            resources.getString(R.string.file_action_rename),
            resources.getDrawable(R.drawable.action_rename));
    mQuickAction.addActionItem(renameAction);

    exportAction =
        new ActionItem(
            ACTION_ID_EXPORT,
            resources.getString(R.string.file_action_export),
            resources.getDrawable(R.drawable.action_export));
    mQuickAction.addActionItem(exportAction);

    if (cacheExists) {
      if (mActivity.hasRepoWritePermission()) {
        updateAction =
            new ActionItem(
                ACTION_ID_UPDATE,
                resources.getString(R.string.file_action_update),
                resources.getDrawable(R.drawable.action_update));
        mQuickAction.addActionItem(updateAction);
      }

    } else {
      downloadAction =
          new ActionItem(
              ACTION_ID_DOWNLOAD,
              resources.getString(R.string.file_action_download),
              resources.getDrawable(R.drawable.action_download));
      mQuickAction.addActionItem(downloadAction);
    }

    // setup the action item click listener
    mQuickAction.setOnActionItemClickListener(
        new QuickAction.OnActionItemClickListener() {
          @Override
          public void onItemClick(QuickAction quickAction, int pos, int actionId) {
            NavContext nav = mActivity.getNavContext();
            String repoName = nav.getRepoName();
            String repoID = nav.getRepoID();
            String dir = nav.getDirPath();
            String path = Utils.pathJoin(dir, dirent.name);
            DataManager dataManager = mActivity.getDataManager();
            String localPath = dataManager.getLocalRepoFile(repoName, repoID, path).getPath();
            switch (actionId) {
              case ACTION_ID_SHARE:
                mActivity.shareFile(repoID, path);
                break;
              case ACTION_ID_EXPORT:
                mActivity.exportFile(dirent.name);
                break;
              case ACTION_ID_DOWNLOAD:
                mActivity.onFileSelected(dirent);
                break;
              case ACTION_ID_UPDATE:
                mActivity.addUpdateTask(repoID, repoName, dir, localPath);
                break;
              case ACTION_ID_RENAME:
                mActivity.renameFile(repoID, repoName, path);
                break;
            }
          }
        });

    mQuickAction.mAnimateTrack(false);
    return mQuickAction;
  }
  /**
   * 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);
  }
Exemple #13
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();
        }