private TextView mTvDebug;
private void makeDebugText() {
- final StringBuffer sb = new StringBuffer("");
+ final StringBuffer sb = new StringBuffer();
sb.append("Android host version: ");
sb.append(Build.VERSION.RELEASE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
- mTvDebug = (TextView) findViewById(R.id.about_debug_tv);
+ mTvDebug = findViewById(R.id.about_debug_tv);
makeDebugText();
ActionBar ab = getSupportActionBar();
});
{
- final WebView wv = (WebView) findViewById(R.id.about_text);
+ final WebView wv = findViewById(R.id.about_text);
wv.loadData(getResources().getString(R.string.about_text),
"text/html", null);
}
{
- final WebView wv = (WebView) findViewById(R.id.about_licenses);
+ final WebView wv = findViewById(R.id.about_licenses);
wv.loadUrl("file:///android_asset/licenses.html");
}
- TabHost th = (TabHost) findViewById(R.id.about_tab_host);
+ TabHost th = findViewById(R.id.about_tab_host);
th.setup();
th.addTab(th.newTabSpec(TAB_PROG)
return true;
}
- private MainService.Observer mSrvObs = new MainService.Observer() {
+ private final MainService.Observer mSrvObs = new MainService.Observer() {
@Override
public void onMqttServerChanged(MainService.LocalBinder b, String sURL) {
}
};
- private CtFwSGameStateManager.Observer mCtFwSObs = new CtFwSGameStateManager.Observer() {
+ private final CtFwSGameStateManager.Observer mCtFwSObs = new CtFwSGameStateManager.Observer() {
@Override
public void onCtFwSConfigure(CtFwSGameStateManager game) {
makeDebugText();
if (Build.VERSION.SDK_INT >= 24) {
return Html.fromHtml(String.format(rs.getString(id), args), 0);
} else {
+ //noinspection deprecation
return Html.fromHtml(String.format(rs.getString(id), args));
}
}
package com.acmetensortoys.ctfwstimer;
-import android.content.Context;
import android.os.AsyncTask;
import java.io.BufferedInputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
-import java.nio.file.NoSuchFileException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
byte[] data = new byte[4096];
+ //noinspection StatementWithEmptyBody
while (is.read(data) != -1) { ; }
if (java.util.Arrays.equals(is.getMessageDigest().digest(), dl.sha256)) {
* Something has gone really wrong.
* Unlink the file and try to fetch it
*/
+ //noinspection ResultOfMethodCallIgnored
dl.dest.delete();
}
os = new FileOutputStream(oft);
} catch (IOException ioe) {
dl.result = Result.ERR_WRITE;
+ //noinspection ResultOfMethodCallIgnored
oft.delete();
continue;
}
);
} catch (IOException ioe) {
dl.result = Result.ERR_HOSTUNREACH;
+ //noinspection ResultOfMethodCallIgnored
oft.delete();
continue;
}
is.close();
os.close();
dl.result = Result.ERR_TOO_LONG;
+ //noinspection ResultOfMethodCallIgnored
oft.delete();
continue dlfor;
}
os.close();
} catch (IOException ioe) {
dl.result = Result.ERR_XFER;
+ //noinspection ResultOfMethodCallIgnored
oft.delete();
continue;
}
if (!java.util.Arrays.equals(is.getMessageDigest().digest(), dl.sha256)) {
dl.result = Result.ERR_CHECKSUM;
+ //noinspection ResultOfMethodCallIgnored
oft.delete();
continue;
}
if (!oft.renameTo(dl.dest)) {
dl.result = Result.ERR_WRITE;
+ //noinspection ResultOfMethodCallIgnored
oft.delete();
continue;
}
final IMqttMessageListener onConfig = new IMqttMessageListener() {
@Override
- public void messageArrived(String topic, MqttMessage message) throws Exception {
+ public void messageArrived(String topic, MqttMessage message) {
String tm = message.toString().trim();
Log.d("CtFwS", "Message(Config): " + tm);
mCgs.fromMqttConfigMessage(tm);
final IMqttMessageListener onEnd = new IMqttMessageListener() {
@Override
- public void messageArrived(String topic, MqttMessage message) throws Exception {
+ public void messageArrived(String topic, MqttMessage message) {
Log.d("CtFwS", "Message(End): " + message);
long endT;
try {
final IMqttMessageListener onFlags = new IMqttMessageListener() {
@Override
- public void messageArrived(String topic, MqttMessage message) throws Exception {
+ public void messageArrived(String topic, MqttMessage message) {
String tm = message.toString().trim();
Log.d("CtFwS", "Message(Flags): " + tm);
mCgs.fromMqttFlagsMessage(tm);
final IMqttMessageListener onMessage = new IMqttMessageListener() {
@Override
- public void messageArrived(String topic, MqttMessage message) throws Exception {
+ public void messageArrived(String topic, MqttMessage message) {
String str = message.toString();
Log.d("CtFwS", "Message(Broadcast): " + str);
mCgs.onNewMessage(str);
final IMqttMessageListener onPlayerMessage = new IMqttMessageListener() {
@Override
- public void messageArrived(String topic, MqttMessage message) throws Exception {
+ public void messageArrived(String topic, MqttMessage message) {
String str = message.toString();
Log.d("CtFwS", "Message(Players): " + str);
mCgs.onNewMessage(str);
final IMqttMessageListener onMessageReset = new IMqttMessageListener() {
@Override
- public void messageArrived(String topic, MqttMessage message) throws Exception {
+ public void messageArrived(String topic, MqttMessage message) {
String str = message.toString();
Log.d("CtFwS", "Message(Reset): " + str);
long before;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
-import android.text.Html;
import android.text.Spanned;
import android.text.format.DateUtils;
import android.util.Log;
final private Activity mAct;
String gameStateLabelText;
- private StunTimer stun_short, stun_long;
+ private final StunTimer stun_short, stun_long;
CtFwSDisplayLocal(Activity a) {
mAct = a;
sfx = rs.getString(R.string.notify_game_afoot);
}
break;
- case NR_NOT_CONFIG:
- // Handled above; fallthru to placate static analysers
default:
sfx = "";
}
final StringBuffer sb = new StringBuffer();
for (CtFwSGameStateManager.Msg m : msgs) {
+ //noinspection StatementWithEmptyBody
if (m.when == 0 || !gs.isConfigured()) {
// leave out the time stamp
} else if (m.when <= gs.getFirstRoundStartT()) {
import com.acmetensortoys.ctfwstimer.lib.CtFwSGameStateManager;
-import java.util.List;
-import java.util.Locale;
import java.util.SortedSet;
/*
import android.support.v4.util.Consumer;
import android.util.Log;
-import com.acmetensortoys.ctfwstimer.CheckedAsyncDownloader;
-
import org.eclipse.paho.client.mqttv3.IMqttAsyncClient;
import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
-import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
public class HandbookDownloader implements IMqttMessageListener {
- private static String TAG = "HandbookDownloader";
+ private static final String TAG = "HandbookDownloader";
private static final long HAND_MAX_LEN = 1024*1024; /* 1 MiB */
private final Context mCtx;
private final Consumer<CheckedAsyncDownloader.DL> mDLFiniCB;
private IMqttAsyncClient mMqc;
- private Handler mHdl;
+ private final Handler mHdl;
private Runnable nextSubRunnable;
public HandbookDownloader(Context ctx, Handler hdl,
// Handbook fetch logic; this is a singleton for the service, even as connections come and go.
private CheckedAsyncDownloader.DL lastHandDL;
- private HandbookDownloader mHandDL = new HandbookDownloader(this,
+ private final HandbookDownloader mHandDL = new HandbookDownloader(this,
new Handler(Looper.getMainLooper()),
new Consumer<CheckedAsyncDownloader.DL>() {
@Override
import com.acmetensortoys.ctfwstimer.lib.CtFwSGameStateManager;
import java.text.NumberFormat;
-import java.util.List;
import java.util.SortedSet;
class MainServiceNotification {
String txt;
switch(now.rationale) {
default:
- case NR_GAME_IN_PROGRESS:
- case NR_START_FUTURE:
txt = "";
break;
case NR_TIME_UP:
</LinearLayout>
- <LinearLayout
+ <TableLayout
android:id="@+id/connmeta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:orientation="vertical">
+ android:stretchColumns="1">
- <TableLayout
+ <TableRow
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:stretchColumns="1">
-
- <TableRow
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="end"
- android:text="@string/mqtt_uri_label" />
-
- <TextView
- android:id="@+id/tv_mqtt_server_uri"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center" />
- </TableRow>
+ android:layout_height="match_parent">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:text="@string/mqtt_uri_label" />
+
+ <TextView
+ android:id="@+id/tv_mqtt_server_uri"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center" />
+ </TableRow>
+
+ <TableRow
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
- <TableRow
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:text="@string/mqtt_state_label" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="end"
- android:text="@string/mqtt_state_label" />
+ <TextView
+ android:id="@+id/tv_mqtt_state"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center" />
- <TextView
- android:id="@+id/tv_mqtt_state"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center" />
+ </TableRow>
- </TableRow>
-
- </TableLayout>
- </LinearLayout>
+ </TableLayout>
</RelativeLayout>