Android Open Source - androidwisprclient Android W I S Pr






From Project

Back to project page androidwisprclient.

License

The source code is released under:

GNU General Public License

If you think the Android project androidwisprclient 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

/*
 * This file is part of FONAccess.//  w w w .  jav a2 s .com
 * 
 * FONAccess is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * FONAccess is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with FONAccess. If not, see <http://www.gnu.org/licenses/>.
 */
package com.oakley.fon;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import com.oakley.fon.util.Utils;

public class AndroidWISPr extends PreferenceActivity {
  private static String TAG = AndroidWISPr.class.getSimpleName();

  public static final int CLOSE_ID = Menu.FIRST;

  public static final int LOGOFF_ID = CLOSE_ID + 1;

  public static final int ADVANCED_ID = LOGOFF_ID + 1;

  public static final int HELP_ID = ADVANCED_ID + 1;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.layout.preferences_main);
    setContentView(R.layout.preferences_header);
  }

  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    String logOffUrl = getLogOffUrl();
    MenuItem menuItem = menu.findItem(LOGOFF_ID);
    if (menuItem != null) {
      if (logOffUrl != null) {
        menuItem.setEnabled(true);
      } else {
        menuItem.setEnabled(false);
      }
    }

    return super.onPrepareOptionsMenu(menu);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    menu.add(Menu.NONE, CLOSE_ID, 0, R.string.menu_close).setIcon(android.R.drawable.ic_menu_save);
    menu.add(Menu.NONE, HELP_ID, 1, R.string.menu_help).setIcon(android.R.drawable.ic_menu_help);
    menu.add(Menu.NONE, LOGOFF_ID, 1, R.string.menu_logOff).setIcon(android.R.drawable.ic_menu_revert);
    menu.add(Menu.NONE, ADVANCED_ID, 2, R.string.menu_advanced).setIcon(android.R.drawable.ic_menu_preferences);

    return result;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    boolean res = true;
    switch (item.getItemId()) {
      case CLOSE_ID:
        finish();
        break;
      case LOGOFF_ID:
        logOff_clicked(item);
        break;
      case ADVANCED_ID:
        startActivity(new Intent(this, PreferencesAdvanced.class));
        break;
      case HELP_ID:
        showHelpWindow();
        break;
      default:
        res = super.onOptionsItemSelected(item);
    }

    return res;
  }

  private void showHelpWindow() {
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.help_window, (ViewGroup) findViewById(R.id.layout_help));

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setView(layout);
    builder.setTitle(R.string.help_title);
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
        dialog.cancel();
      }
    });
    AlertDialog alert = builder.create();
    alert.show();
  }

  private void logOff_clicked(MenuItem item) {
    String logOffUrl = getLogOffUrl();
    Log.d(TAG, "Logoff Button Clicked:" + logOffUrl);
    if (logOffUrl != null) {
      Intent logOffIntent = new Intent(this, LogOffService.class);
      logOffIntent.putExtra(this.getString(R.string.pref_logOffUrl), logOffUrl);
      this.startService(logOffIntent);
    }
    item.setEnabled(false);
  }

  private String getLogOffUrl() {
    String logOffUrl = Utils.getStringPreference(this, R.string.pref_logOffUrl, "");
    if (logOffUrl != null) {
      logOffUrl = logOffUrl.trim();
      if (logOffUrl.length() == 0) {
        logOffUrl = null;
      }
    }

    return logOffUrl;
  }
}




Java Source Code List

com.oakley.fon.AndroidWISPr.java
com.oakley.fon.LogOffService.java
com.oakley.fon.NetworkConnectivityReceiver.java
com.oakley.fon.NetworkScanReceiver.java
com.oakley.fon.NotificationCleaningService.java
com.oakley.fon.PreferencesAdvanced.java
com.oakley.fon.WISPrLoggerService.java
com.oakley.fon.handler.WISPrInfoHandler.java
com.oakley.fon.handler.WISPrResponseHandler.java
com.oakley.fon.logger.BTFonLogger.java
com.oakley.fon.logger.HTTPLogger.java
com.oakley.fon.logger.LivedoorLogger.java
com.oakley.fon.logger.LoggerResult.java
com.oakley.fon.logger.NeufLogger.java
com.oakley.fon.logger.SimpleHTTPLogger.java
com.oakley.fon.logger.WISPrLogger.java
com.oakley.fon.logger.WebLogger.java
com.oakley.fon.util.BackupAgentHelperWrapper.java
com.oakley.fon.util.BackupAgent.java
com.oakley.fon.util.FONUtils.java
com.oakley.fon.util.HttpResult.java
com.oakley.fon.util.HttpUtils.java
com.oakley.fon.util.LogRedirectHandler.java
com.oakley.fon.util.RemoveHttpsRedirectHandler.java
com.oakley.fon.util.Utils.java
com.oakley.fon.util.WISPrConstants.java
com.oakley.fon.util.WISPrUtil.java