コード例 #1
0
ファイル: MainMenu.java プロジェクト: software04/sudowars
  /*
   * (non-Javadoc)
   * @see org.sudowars.Controller.Local.PoolBinder#onStop()
   */
  protected void onStop() {
    super.onStop();

    SharedPreferences preferences = getPreferences(Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();

    editor.putBoolean("firstStart", false);

    editor.commit();
  }
コード例 #2
0
ファイル: MainMenu.java プロジェクト: software04/sudowars
  /*
   * (non-Javadoc)
   * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
   */
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

    if (requestCode == REQUEST_ENABLE_BT) {
      if (resultCode == Activity.RESULT_OK) {
        startMultiplayerMenu();
      } else {
        Toast.makeText(
                getApplicationContext(), R.string.text_multiplayer_menu_cancled, Toast.LENGTH_LONG)
            .show();
      }
    }

    this.btnMultiplayer.setClickable(true);
  }
コード例 #3
0
ファイル: MainMenu.java プロジェクト: software04/sudowars
  /*
   * (non-Javadoc)
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main_menu);

    SharedPreferences preferences = getPreferences(Context.MODE_PRIVATE);

    if (preferences.getBoolean("firstStart", true)) {
      // Check, if this App is running in an emulator
      if (Build.PRODUCT.equals("sdk")) {
        PreferenceManager.setDefaultValues(
            getApplicationContext(), R.xml.preferences_emulator, true);
      }

      this.onBtnManualClick();
    }

    this.savedGames = new FileIO(this.getApplicationContext());
    this.constants = new Constants(this);

    this.setupButtons();
  }
コード例 #4
0
ファイル: MainMenu.java プロジェクト: software04/sudowars
  /*
   * (non-Javadoc)
   * @see android.app.Activity#onResume()
   */
  protected void onResume() {
    super.onResume();

    if (this.savedGames.hasSingleplayerGame() && this.layBtnSingleplayer.getChildCount() == 1) {
      // Get the screen's density scale
      final float scale = getResources().getDisplayMetrics().density;
      // Convert the dps to pixels, based on density scale
      int buttonWidth = (int) (60.0f * scale + 0.5f);

      this.layBtnSingleplayer.addView(this.btnSingleplayerContinue, 0);
      this.btnSingleplayer.setLayoutParams(
          new LinearLayout.LayoutParams(buttonWidth, LinearLayout.MarginLayoutParams.MATCH_PARENT));
      this.btnSingleplayer.setText(getString(R.string.button_singleplayer_symbol));
    } else if (!this.savedGames.hasSingleplayerGame()
        && this.layBtnSingleplayer.getChildCount() == 2) {
      this.layBtnSingleplayer.removeView(this.btnSingleplayerContinue);
      this.btnSingleplayer.setLayoutParams(
          new LinearLayout.LayoutParams(
              LinearLayout.MarginLayoutParams.FILL_PARENT,
              LinearLayout.MarginLayoutParams.FILL_PARENT));
      this.btnSingleplayer.setText(getString(R.string.button_singleplayer));
    }
  }