Friday, December 17, 2010

Unofficial West Suburban Bank Mobile Application

http://mywsb.mobi has the wrong doc type, and thus displays poorly in a mobile browser. I contacted WSB to have them correct the doc type over two weeks ago, but as of today they have yet to do so. Because of this, i've created an app to make the mywsb.mobi experience a little better. All the app is, is a customized webview. Below is the code.

Visit here on your android browser to download

--- main activity code below
package com.kpf_software.wsb;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class wsb extends Activity {
WebView browser;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

String loadUrl = "http://mywsb.mobi";
browser = (WebView) findViewById(R.id.wsb_browser);
browser.setWebViewClient(new WebViewClient());
WebSettings websettings = browser.getSettings();
websettings.setJavaScriptEnabled(true);
websettings.setLoadWithOverviewMode(false);
websettings.setUseWideViewPort(false);
websettings.setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
browser.loadUrl(loadUrl);
// Sets the Chrome Client, and defines the onProgressChanged
// This makes the Progress bar be updated.
final Activity MyActivity = this;
browser.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
MyActivity.setTitle(R.string.app_name);
}
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the BACK key and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && browser.canGoBack()) {
browser.goBack();
return true;
}
// If it wasn't the BACK key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
MenuItem item1 = menu.add("Exit");
// item.setIcon(android.R.drawable.ic_menu_home);
item1.setIcon(R.drawable.ic_menu_close_clear_cancel);
MenuItem item2 = menu.add("About");
item2.setIcon(R.drawable.ic_menu_info_details);

return true;
}
public boolean onOptionsItemSelected(MenuItem item)
{
if (item.hasSubMenu() == false)
{
if (item.getTitle().toString().equals("Exit")){
finish();
}
if (item.getTitle().toString().equals("About")){
AlertDialog dialog=new AlertDialog.Builder(wsb.this).create();
dialog.setTitle("About");
dialog.setMessage("WSB\nVersion: 1.0\n\nCreated by KPF-Software. \n \nVisit website for more information.");
dialog.setButton("Website",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
/* Do some stuff */
Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://kpf-software.blogspot.com"));
startActivity(browserIntent);
}
});
dialog.setButton2("Done",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
/* Do some stuff */
}
});

dialog.show();
}
}
// Consume the selection event.
return true;
}
}

No comments:

Post a Comment