コード例 #1
0
ファイル: SoundboardMenu.java プロジェクト: Mikuz/Boarder
  private void loadGlobalSettings() {

    int fadeIn = 0;
    try {
      Cursor variableCursor =
          mGlobalVariableDbHelper.fetchVariable(GlobalVariablesDbAdapter.FADE_IN_DURATION_KEY);
      startManagingCursor(variableCursor);
      fadeIn = variableCursor.getInt(variableCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA));
    } catch (Exception e) {
      mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.FADE_IN_DURATION_KEY, 0);
      Log.d(TAG, "Couldn't get fade-in", e);
    }
    GlobalSettings.setFadeInDuration(fadeIn);
    int fadeOut = 0;
    try {
      Cursor variableCursor =
          mGlobalVariableDbHelper.fetchVariable(GlobalVariablesDbAdapter.FADE_OUT_DURATION_KEY);
      startManagingCursor(variableCursor);
      fadeOut =
          variableCursor.getInt(variableCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA));
    } catch (Exception e) {
      mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.FADE_OUT_DURATION_KEY, 0);
      Log.d(TAG, "Couldn't get fadeOut", e);
    }
    GlobalSettings.setFadeOutDuration(fadeOut);
    boolean sensitiveLogging = false;
    try {
      Cursor variableCursor =
          mGlobalVariableDbHelper.fetchVariable(GlobalVariablesDbAdapter.SENSITIVE_LOGGING);
      startManagingCursor(variableCursor);
      sensitiveLogging =
          variableCursor.getInt(variableCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)) > 0;
    } catch (Exception e) {
      mGlobalVariableDbHelper.createBooleanVariable(
          GlobalVariablesDbAdapter.SENSITIVE_LOGGING, false);
      Log.d(TAG, "Couldn't get sensitiveLogging", e);
    }
    GlobalSettings.setSensitiveLogging(sensitiveLogging);
  }
コード例 #2
0
ファイル: SoundboardMenu.java プロジェクト: Mikuz/Boarder
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_add_board:
        addBoard();
        return true;

      case R.id.menu_help:
        AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
        helpBuilder.setTitle("Help");

        ScrollView scroll = new ScrollView(this);
        helpBuilder.setView(scroll);

        LinearLayout helpLayout = new LinearLayout(this);
        helpLayout.setOrientation(LinearLayout.VERTICAL);
        scroll.addView(helpLayout);

        TextView tv = new TextView(this);
        tv.setText(Html.fromHtml(getResources().getString(R.string.menu_help_text)));
        tv.setMovementMethod(LinkMovementMethod.getInstance());

        Button introductionButton = new Button(this);
        introductionButton.setText("Introduction");
        introductionButton.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                Intent i = new Intent(SoundboardMenu.this, Introduction.class);
                startActivity(i);
              }
            });

        helpLayout.addView(introductionButton);
        helpLayout.addView(tv);

        AlertDialog helpAlert = helpBuilder.create();
        helpAlert.show();
        return true;

      case R.id.menu_about:
        AlertDialog.Builder aboutBuilder = new AlertDialog.Builder(this);
        aboutBuilder.setTitle("About");
        aboutBuilder.setMessage(
            "Boarder is an opensource project administrated by Mikael Lindlöf.\n\n"
                + "Source code is hosted to Github. You can view and contribute to it there.\n\n"
                + "I'd like to talk with you. You can email us to seek for help or say hello.\n\n"
                + "You should also post on XDA-forums to meet other soundboard loving people :)\n\n"
                + "Find Boarder wiki on Help Center. You are most welcome to explore and improve it.\n\n"
                + "You can find link to these medias in the same menu with About.");
        AlertDialog aboutAlert = aboutBuilder.create();
        aboutAlert.show();
        return true;

      case R.id.menu_play_pause:
        SoundPlayerControl.togglePlayPause(super.mContext);
        return true;

      case R.id.menu_internet:
        Intent i = new Intent(this, InternetMenu.class);
        startActivityForResult(i, 0);
        return true;

      case R.id.menu_dropbox:
        Intent iDrop = new Intent(this, DropboxMenu.class);
        startActivity(iDrop);
        return true;

      case R.id.menu_global_settings:
        LayoutInflater inflater =
            (LayoutInflater) SoundboardMenu.this.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout =
            inflater.inflate(
                R.layout.soundboard_menu_alert_global_settings,
                (ViewGroup) findViewById(R.id.alert_settings_root));

        final EditText fadeInInput = (EditText) layout.findViewById(R.id.fadeInInput);
        fadeInInput.setText(Integer.toString(GlobalSettings.getFadeInDuration()));

        final EditText fadeOutInput = (EditText) layout.findViewById(R.id.fadeOutInput);
        fadeOutInput.setText(Integer.toString(GlobalSettings.getFadeOutDuration()));

        final CheckBox sensitiveLoggingCheckbox =
            (CheckBox) layout.findViewById(R.id.sensitiveLoggingCheckbox);
        sensitiveLoggingCheckbox.setChecked(GlobalSettings.getSensitiveLogging());

        AlertDialog.Builder builder = new AlertDialog.Builder(SoundboardMenu.this);
        builder.setView(layout);
        builder.setTitle("Sound settings");

        builder.setPositiveButton(
            "Ok",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
                try {
                  int fadeIn = Integer.valueOf(fadeInInput.getText().toString()).intValue();
                  mGlobalVariableDbHelper.updateIntVariable(
                      GlobalVariablesDbAdapter.FADE_IN_DURATION_KEY, fadeIn);

                  int fadeOut = Integer.valueOf(fadeOutInput.getText().toString()).intValue();
                  mGlobalVariableDbHelper.updateIntVariable(
                      GlobalVariablesDbAdapter.FADE_OUT_DURATION_KEY, fadeOut);

                  mGlobalVariableDbHelper.updateBooleanVariable(
                      GlobalVariablesDbAdapter.SENSITIVE_LOGGING,
                      sensitiveLoggingCheckbox.isChecked());

                  loadGlobalSettings();
                } catch (NumberFormatException nfe) {
                  Toast.makeText(
                          SoundboardMenu.super.mContext, "Incorrect value", Toast.LENGTH_SHORT)
                      .show();
                }
              }
            });

        builder.setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {}
            });

        builder.show();
        return true;

      case R.id.menu_support_links:
        CharSequence[] pageItems = {"Email us", "Github", "Donate", "Rate"};

        AlertDialog.Builder pageBuilder = new AlertDialog.Builder(SoundboardMenu.this);
        pageBuilder.setTitle("Support & links");
        pageBuilder.setItems(
            pageItems,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int item) {
                if (item == 0) { // Email us
                  ExternalIntent.openEmail(SoundboardMenu.super.mContext);

                } else if (item == 1) { // Github
                  ExternalIntent.openGithub(SoundboardMenu.super.mContext);

                } else if (item == 2) { // Donate
                  showDonateNotification();

                } else if (item == 3) { // Rate
                  ExternalIntent.openGooglePlay(SoundboardMenu.super.mContext);
                }
              }
            });
        pageBuilder.show();
        return true;
    }

    return super.onMenuItemSelected(featureId, item);
  }
コード例 #3
0
ファイル: SoundboardMenu.java プロジェクト: Mikuz/Boarder
  @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();
  }