예제 #1
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    boolean hideSoundboardMenu = mIntent.getBooleanExtra(EXTRA_HIDE_SOUNDBOARDMENU, false);
    if (hideSoundboardMenu) {
      finish();
      return;
    }
  }
예제 #2
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   if (mDbHelper != null) {
     mDbHelper.close();
   }
   if (mGlobalVariableDbHelper != null) {
     mGlobalVariableDbHelper.close();
   }
 }
예제 #3
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Cursor selection = mDbHelper.fetchBoard(id);
    startManagingCursor(selection);
    final String boardName =
        selection.getString(selection.getColumnIndexOrThrow(MenuDbAdapter.KEY_TITLE));
    int boardLocal = selection.getInt(selection.getColumnIndexOrThrow(MenuDbAdapter.KEY_LOCAL));
    File boardDir = new File(mSbDir, boardName);

    if (Intent.ACTION_CREATE_SHORTCUT.equals(mAction)) {

      Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
      shortcutIntent.setClassName(this, this.getClass().getName());
      shortcutIntent.putExtra(EXTRA_LAUNCH_BAORD_KEY, boardName);
      shortcutIntent.putExtra(EXTRA_HIDE_SOUNDBOARDMENU, true);
      shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

      Intent intent = new Intent();
      intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
      intent.putExtra(
          Intent.EXTRA_SHORTCUT_NAME,
          selection.getString(selection.getColumnIndexOrThrow(MenuDbAdapter.KEY_TITLE)));

      File icon = new File(mSbDir, boardName + "/icon.png");
      if (icon.exists()) {
        Bitmap bitmap = IconUtils.decodeIcon(super.mContext, icon);
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, IconUtils.resizeIcon(this, bitmap, (40 / 12)));
      } else {
        Parcelable iconResource =
            Intent.ShortcutIconResource.fromContext(this, R.drawable.board_icon);
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
      }

      setResult(RESULT_OK, intent);

      finish();
      return;

    } else if (mMoveBoard > -1) {

      Cursor moveFrom = mDbHelper.fetchBoard(mMoveBoard);
      startManagingCursor(moveFrom);

      String moveSourceTitle =
          moveFrom.getString(moveFrom.getColumnIndexOrThrow(MenuDbAdapter.KEY_TITLE));
      int moveSourceLocal =
          moveFrom.getInt(moveFrom.getColumnIndexOrThrow(MenuDbAdapter.KEY_LOCAL));

      mDbHelper.updateBoard((int) id, moveSourceTitle, moveSourceLocal);
      mDbHelper.updateBoard(mMoveBoard, boardName, boardLocal);

      mMoveBoard = -1;

      initializeBoardUpdateThread();

    } else {

      try {
        boolean boardFileFound = false;
        for (File boardDirContent : boardDir.listFiles()) {
          if (boardDirContent.getName().equals("graphicalBoard")) {
            Intent i = new Intent(this, BoardEditor.class);
            i.putExtra(MenuDbAdapter.KEY_TITLE, boardName);
            startActivity(i);
            boardFileFound = true;
            break;
          }
        }
        if (!boardFileFound) {
          Intent i = new Intent(this, BoardEditor.class);
          i.putExtra(MenuDbAdapter.KEY_TITLE, boardName);
          startActivity(i);
        }
      } catch (NullPointerException npe) {
        Log.e(SoundboardMenu.TAG, "Unable to list boards", npe);
      }
    }
  }
예제 #4
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.soundboard_menu_context, menu);
 }
예제 #5
0
 @Override
 protected void onResume() {
   super.onResume();
   initializeBoardUpdateThread();
 }
예제 #6
0
 @Override
 protected void onRestart() {
   ImageDrawing.registerCache(super.mContext);
   super.onRestart();
 }
예제 #7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    GlobalSettings.init(this);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.mContext = (Context) this;
    ImageDrawing.registerCache(super.mContext);

    Log.i(TAG, "Boarder storage directory is " + mSbDir.getAbsolutePath());

    super.onCreate(savedInstanceState);

    mIntent = getIntent();
    mAction = mIntent.getAction();

    if (Intent.ACTION_CREATE_SHORTCUT.equals(mAction)) {
      setTitle("Select shortcut target:");
    } else {
      setTitle("Soundboard Menu");
    }

    String launchExtra = mIntent.getStringExtra(EXTRA_LAUNCH_BAORD_KEY);
    if (launchExtra != null) {
      try {
        Intent i = null;

        for (File boardDirContent : new File(mSbDir, launchExtra).listFiles()) {
          if (boardDirContent.getName().equals("graphicalBoard")) {
            i = new Intent(this, BoardEditor.class);
            break;
          }
        }
        i.putExtra(MenuDbAdapter.KEY_TITLE, launchExtra);
        startActivity(i);
      } catch (NullPointerException e) {
        mIntent = new Intent();
        Log.e(SoundboardMenu.TAG, "Board not found", e);
        Toast.makeText(this, "Board not found", Toast.LENGTH_LONG).show();
      }
    }

    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mFunctionSounds.add(mPauseSoundFilePath);
    mFunctionSounds.add(mTopBlackBarSoundFilePath);
    mFunctionSounds.add(mBottomBlackBarSoundFilePath);
    mFunctionSounds.add(mLeftBlackBarSoundFilePath);
    mFunctionSounds.add(mRightBlackBarSoundFilePath);

    mDbHelper = new MenuDbAdapter(this);
    mDbHelper.open();

    mGlobalVariableDbHelper = new GlobalVariablesDbAdapter(this);
    mGlobalVariableDbHelper.open();

    loadGlobalSettings();

    if (!mSbDir.exists()) {
      mSbDir.mkdirs();
    }

    refreshMenu();
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout =
        inflater.inflate(
            R.layout.soundboard_menu_list, (ViewGroup) findViewById(R.id.soundboard_menu_root));
    Button enableNotificationButton = (Button) layout.findViewById(R.id.enableNotificationButton);
    Button disableNotificationButton = (Button) layout.findViewById(R.id.disableNotificationButton);

    enableNotificationButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            updateNotification(SoundboardMenu.this, "Soundboard Menu", null);
          }
        });

    disableNotificationButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            final NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.cancel(SoundboardMenu.TAG, mNotificationId);
          }
        });

    setContentView(layout);
    registerForContextMenu(getListView());

    firstStartIntroduction();
  }