Exemplo n.º 1
0
 private void firstStartIntroduction() {
   Cursor variableCursor =
       mGlobalVariableDbHelper.fetchVariable(GlobalVariablesDbAdapter.FIRST_START_KEY);
   startManagingCursor(variableCursor);
   int firstStart = 1;
   try {
     firstStart =
         variableCursor.getInt(
             variableCursor.getColumnIndexOrThrow(GlobalVariablesDbAdapter.KEY_DATA));
   } catch (Exception e) {
     mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.FIRST_START_KEY, 0);
   }
   if (firstStart == 1) {
     Intent i = new Intent(SoundboardMenu.this, Introduction.class);
     startActivity(i);
   }
 }
Exemplo n.º 2
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   if (mDbHelper != null) {
     mDbHelper.close();
   }
   if (mGlobalVariableDbHelper != null) {
     mGlobalVariableDbHelper.close();
   }
 }
Exemplo n.º 3
0
  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);
  }
Exemplo n.º 4
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();
  }