package com.google.zxing.client.android.result;
import android.app.Activity;
-
import com.google.zxing.client.android.R;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.WifiParsedResult;
* @author viki@google.com (Vikram Aggarwal)
*/
public final class WifiResultHandler extends ResultHandler {
- Activity parentActivity = null;
+ final Activity parent;
+
public WifiResultHandler(Activity activity, ParsedResult result) {
super(activity, result);
- parentActivity = activity;
+ parent = activity;
}
@Override
@Override
public int getButtonText(int index) {
- switch (index) {
- case 0:
+ if (index == 0) {
return R.string.button_wifi;
- default:
- throw new ArrayIndexOutOfBoundsException();
}
+ throw new ArrayIndexOutOfBoundsException();
}
@Override
public void handleButtonPress(int index) {
// Get the underlying wifi config
- WifiParsedResult wifiResult = (WifiParsedResult) getResult();
- switch (index) {
- case 0:
+ final WifiParsedResult wifiResult = (WifiParsedResult) getResult();
+ if (index == 0) {
wifiConnect(wifiResult);
- break;
- default:
- break;
}
}
// Display the name of the network and the network type to the user.
@Override
public CharSequence getDisplayContents() {
- WifiParsedResult wifiResult = (WifiParsedResult) getResult();
+ final WifiParsedResult wifiResult = (WifiParsedResult) getResult();
StringBuffer contents = new StringBuffer();
- ParsedResult.maybeAppend(wifiResult.getSsid(), contents);
- ParsedResult.maybeAppend(wifiResult.getNetworkEncryption(), contents);
+ final String wifiLabel = parent.getString(R.string.wifi_ssid_label);
+ ParsedResult.maybeAppend(wifiLabel + "\n" + wifiResult.getSsid(), contents);
+ final String typeLabel = parent.getString(R.string.wifi_type_label);
+ ParsedResult.maybeAppend(typeLabel + "\n" + wifiResult.getNetworkEncryption(), contents);
return contents.toString();
}