Ejemplo n.º 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();
        });
  }
Ejemplo n.º 2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    try {
      mSharedPreferences = Prefs.getSharedPreferences(this);
    } catch (NullPointerException e) {
      if (BuildConfig.DEBUG) {
        Log.w("[" + TAG + "]", "mSharedPreferences == NullPointerException :" + e.getMessage());
      }
    }

    mSharedPreferences.registerOnSharedPreferenceChangeListener(this);

    if (Prefs.getThemeType(this) == false) {
      mThemeId = R.style.AppTheme_Light;
      setTheme(mThemeId);
    } else {
      mThemeId = R.style.AppTheme_Dark;
      setTheme(mThemeId);
    }

    // Eula.showDisclaimer( this );
    Eula.showEula(this, getApplicationContext());

    mActionBar = getActionBar();
    if (mActionBar != null) {
      mActionBar.setDisplayHomeAsUpEnabled(false);
      mActionBar.setDisplayShowHomeEnabled(true);
      mActionBar.setDisplayShowTitleEnabled(true);
    } else {
      if (BuildConfig.DEBUG) {
        Log.w("[" + TAG + "]", "mActionBar == null");
      }
    }

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name));
    } else {
      this.setTitle(" :: " + getString(R.string.app_name));
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tvDisplay = (TextView) findViewById(R.id.tvDisplay);

    bRename = (Button) findViewById(R.id.bRename);
    bSettings = (Button) findViewById(R.id.bSettings);
    bHelp = (Button) findViewById(R.id.bHelp);
    bExit = (Button) findViewById(R.id.bExit);

    bRename.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent openAndroidFileBrowser = new Intent("com.scto.filerenamer.ANDROIDFILEBROWSER");
            openAndroidFileBrowser.putExtra("what", "renamer");
            openAndroidFileBrowser.putExtra("theme", mThemeId);
            startActivity(openAndroidFileBrowser);
          }
        });

    bSettings.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent openPreferencesActivity = new Intent("com.scto.filerenamer.PREFERENCESACTIVITY");
            startActivity(openPreferencesActivity);
          }
        });

    bHelp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            HelpDialog helpDialog = new HelpDialog();
            helpDialog.show(fm, "dlg_help");
          }
        });

    bExit.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            ExitDialog exitDialog = new ExitDialog();
            exitDialog.show(fm, "dlg_exit");
          }
        });

    /*
    ChangeLog cl = new ChangeLog( this );
    if( cl.firstRun() )
    {
    	cl.getLogDialog().show();
    }
    */
    init();
  }