/* * jorm.properties * --------------- * database.moria.dataSource=org.apache.tomcat.jdbc.pool.DataSource * database.moria.dataSource.driverClassName=org.postgresql.Driver * database.moria.dataSource.url=jdbc:postgresql://localhost:5432/moria * database.moria.dataSource.username=gandalf * database.moria.dataSource.password=mellon * * database.lothlorien.dataSource=org.apache.tomcat.jdbc.pool.DataSource * database.lothlorien.dataSource.driverClassName=org.postgresql.Driver * database.lothlorien.dataSource.url=jdbc:postgresql://localhost:5432/lothlorien * database.lothlorien.dataSource.username=galadriel * database.lothlorien.dataSource.password=nenya * * [email protected]=jdbc:postgresql://sjhdb05b.jajja.local:5432/moria_development * [email protected]=dev * [email protected]=$43CR37 * * [email protected]=jdbc:postgresql://sjhdb05b.jajja.local:5432/moria_production * [email protected]=prod * [email protected]=$43CR37:P455 * * database.context= * database.moria.context=production */ private void __configure() { try { Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources("jorm.properties"); List<URL> locals = new LinkedList<URL>(); while (urls.hasMoreElements()) { URL url = urls.nextElement(); if (url.getProtocol().equals("jar")) { logger.log(Level.FINE, "Found jorm configuration @ " + url.toString()); __configure(url); } else { locals.add(url); } } for (URL url : locals) { logger.log(Level.FINE, "Found jorm configuration @ " + url.toString()); __configure(url); } for (Entry<String, Configuration> entry : configurations.entrySet()) { String database = entry.getKey(); Configuration configuration = entry.getValue(); int index = database.indexOf(Context.CONTEXT_SEPARATOR); if (index > 0) { Configuration base = configurations.get(database.substring(0, index)); if (base != null) { configuration.inherit(base); } } configuration.init(); __configure(database, configuration.dataSource); Logger.getLogger(Database.class.getName()).log(Level.FINE, "Configured " + configuration); } } catch (IOException ex) { throw new RuntimeException("Failed to configure from jorm.properties", ex); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); receiver = new UpdatedReceiver(); Configuration.init(this); if (Configuration.username.equals("") || Configuration.vin.equals("")) { Intent intent = new Intent(this, LoginActivity.class); startActivity(intent); finish(); return; } setContentView(R.layout.activity_my); final Context context = this; final Spinner spinner = (Spinner) findViewById(R.id.spinner_chargelevel); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.charge_levels, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner.setAdapter(adapter); spinner.setSelection(Configuration.defaultChargeLevel); spinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { save(); } @Override public void onNothingSelected(AdapterView<?> adapterView) {} }); final Button button = (Button) findViewById(R.id.button); button.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { save(); updateCarStatusAsync(); button.setEnabled(false); showToast("Saved, updating vehicle status..."); } }); int interval = Configuration.interval; final SeekBar seekbar = (SeekBar) findViewById(R.id.seekBar); seekbar.setProgress(interval); setProgressText(interval); seekbar.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { setProgressText(i); findViewById(R.id.button).setEnabled(true); save(); } @Override public void onStartTrackingTouch(SeekBar seekBar) {} @Override public void onStopTrackingTouch(SeekBar seekBar) {} }); CheckBox permanent = (CheckBox) (findViewById(R.id.permanent)); permanent.setChecked(Configuration.showPermanent); permanent.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { save(); } }); CheckBox notifyonly = ((CheckBox) (findViewById(R.id.notifyonlycharging))); notifyonly.setChecked(Configuration.notifyOnlyWhenCharging); notifyonly.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { save(); } }); CheckBox alwaysShowStartHVAC = ((CheckBox) (findViewById(R.id.alwaysshowstarthvac))); alwaysShowStartHVAC.setChecked(Configuration.alwaysShowStartHVAC); alwaysShowStartHVAC.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { save(); } }); CheckBox checkbox = ((CheckBox) (findViewById(R.id.checkBox))); checkbox.setChecked(Configuration.autoUpdate); checkbox.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { findViewById(R.id.button).setEnabled(true); seekbar.setEnabled(b); save(); } }); Carwings carwings = new Carwings(this); if (carwings.lastUpdateTime.equals("")) { updateCarStatusAsync(); } else { updateCarStatusUI(carwings); LeafNotification.sendNotification(context, carwings); } }