Android Open Source - android-vf-balance Vf Balance Configure






From Project

Back to project page android-vf-balance.

License

The source code is released under:

Apache License

If you think the Android project android-vf-balance listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2009 Alastair Porter/*from   www .  j  av a  2s .c om*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.alastair.vfbalance;

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

public class VfBalanceConfigure extends Activity implements View.OnClickListener {
  private Integer mAppWidgetId;

  public static final String PREFS_NAME = "com.github.alastair.vfbalance.VfBalance";

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
      mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
          AppWidgetManager.INVALID_APPWIDGET_ID);
    }

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.configure);

    Button ok = (Button) findViewById(R.id.conf_save);
    ok.setOnClickListener(this);
  }

  @Override
  public void onClick(View v) {
    switch (v.getId()) {
    case R.id.conf_save:
      Intent resultValue = new Intent();
      SharedPreferences.Editor prefs = getSharedPreferences(PREFS_NAME, 0)
          .edit();
      EditText input = (EditText)findViewById(R.id.conf_user);
      prefs.putString("user_" + mAppWidgetId, input.getText().toString());
      input = (EditText)findViewById(R.id.conf_pass);
      prefs.putString("password_" + mAppWidgetId, input.getText().toString());
      prefs.commit();
      resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
          mAppWidgetId);
      setResult(RESULT_OK, resultValue);
      finish();
      break;
    }
  }
}




Java Source Code List

com.github.alastair.vfbalance.VfBalanceConfigure.java
com.github.alastair.vfbalance.VfBalanceWidget.java