Beispiel #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    final String ID = intent.getStringExtra("ID");
    final String name = intent.getStringExtra("Name");
    final ActionBar actionBar = getSupportActionBar();

    setContentView(R.layout.individual_colour_change_layout);

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    ColH = settings.getInt("houCol" + ID, getResources().getColor(R.color.clokH));
    ColM = settings.getInt("minCol" + ID, getResources().getColor(R.color.clokM));
    ColS = settings.getInt("secCol" + ID, getResources().getColor(R.color.clokS));
    String currentTitle = name + ": " + getString(R.string.chsColour);
    if (actionBar != null) {
      actionBar.setTitle(currentTitle);
      actionBar.setDisplayUseLogoEnabled(false);
    }

    draw();

    Button reset = (Button) findViewById(R.id.reset);
    reset.setOnClickListener(
        v -> {
          Editor editor = settings.edit();
          ColH = IndividualColourChange.this.getResources().getColor(R.color.clokH);
          ColM = IndividualColourChange.this.getResources().getColor(R.color.clokM);
          ColS = IndividualColourChange.this.getResources().getColor(R.color.clokS);
          editor.putInt("houCol" + ID, ColH);
          editor.putInt("minCol" + ID, ColM);
          editor.putInt("secCol" + ID, ColS);
          editor.apply();
          IndividualColourChange.this.draw();
        });

    ImageView colPickH = (ImageView) findViewById(R.id.colorHou);
    colPickH.setClickable(true);
    colPickH.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColH = color;
                    Editor editor = settings.edit();
                    editor.putInt("houCol" + ID, ColH);
                    editor.apply();
                    draw();
                  },
                  ColH);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.hHandCol));
          dlg.show();
        });

    ImageView colPickM = (ImageView) findViewById(R.id.colorMin);
    colPickM.setClickable(true);
    colPickM.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColM = color;
                    Editor editor = settings.edit();
                    editor.putInt("minCol" + ID, ColM);
                    editor.apply();
                    draw();
                  },
                  ColM);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.mHandCol));
          dlg.show();
        });

    ImageView colPickS = (ImageView) findViewById(R.id.colorSec);
    colPickS.setClickable(true);
    colPickS.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColS = color;
                    Editor editor = settings.edit();
                    editor.putInt("minCol" + ID, ColS);
                    editor.apply();
                    draw();
                  },
                  ColS);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.sHandCol));
          dlg.show();
        });
  }