&& (this.endT == g.endT)
&& (this.flagsTotal == g.flagsTotal);
}
- };
+ }
private Game curstate = new Game();
public synchronized void fromMqttConfigMessage(String st) {
if (this.when == m.when) {
return this.msg.compareTo(m.msg);
}
- return (Long.valueOf(when).compareTo(Long.valueOf(m.when)));
+ return Long.compare(this.when, m.when);
}
@Override
<application
android:allowBackup="true"
+ android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_shield_1"
android:label="@string/app_name"
android:supportsRtl="true"
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<service android:name="org.eclipse.paho.android.service.MqttService" />
});
}
- public void timersToBundle(Bundle out, String key) {
+ void timersToBundle(Bundle out, String key) {
out.putLongArray(key, new long[]{ stun_short.wallEndMS, stun_long.wallEndMS });
}
- public void timersFromBundle(Bundle in, String key) {
+ void timersFromBundle(Bundle in, String key) {
long[] es = in.getLongArray(key);
if(es == null) { return; }
if(es.length > 0) { resumeTimer(stun_short, es[0]); }
gameStateLabelText = pfx;
}
- final TextView gstv = (TextView) mAct.findViewById(R.id.header_gamestate);
+ final TextView gstv = mAct.findViewById(R.id.header_gamestate);
gstv.post(new Runnable() {
@Override
public void run() {
// Upper line text
{
- final TextView tv_jb = (TextView) (mAct.findViewById(R.id.tv_jailbreak));
+ final TextView tv_jb = mAct.findViewById(R.id.tv_jailbreak);
tv_jb.post(new Runnable() {
@Override
public void run() {
// Upper progress bar and chronometer
{
- final ProgressBar pb_jb = (ProgressBar) (mAct.findViewById(R.id.pb_jailbreak));
+ final ProgressBar pb_jb = mAct.findViewById(R.id.pb_jailbreak);
pb_jb.post(new Runnable() {
@Override
public void run() {
}
});
- final Chronometer ch_jb = (Chronometer) (mAct.findViewById(R.id.ch_jailbreak));
+ final Chronometer ch_jb = mAct.findViewById(R.id.ch_jailbreak);
ch_jb.post(new Runnable() {
@Override
public void run() {
// Lower progress bar and chronometer
if (now.round > 0) {
- final ProgressBar pb_gp = (ProgressBar) (mAct.findViewById(R.id.pb_gameProgress));
+ final ProgressBar pb_gp = mAct.findViewById(R.id.pb_gameProgress);
pb_gp.post(new Runnable() {
@Override
public void run() {
}
});
- final Chronometer ch_gp = (Chronometer) (mAct.findViewById(R.id.ch_gameProgress));
+ final Chronometer ch_gp = mAct.findViewById(R.id.ch_gameProgress);
ch_gp.post(new Runnable() {
@Override
public void run() {
}
});
} else {
- final ProgressBar pb_gp = (ProgressBar) (mAct.findViewById(R.id.pb_gameProgress));
+ final ProgressBar pb_gp = mAct.findViewById(R.id.pb_gameProgress);
pb_gp.post(new Runnable() {
@Override
public void run() {
}
});
- final Chronometer ch_gp = (Chronometer) (mAct.findViewById(R.id.ch_gameProgress));
+ final Chronometer ch_gp = mAct.findViewById(R.id.ch_gameProgress);
ch_gp.post(new Runnable() {
@Override
public void run() {
});
}
{
- final TextView tv_flags = (TextView) (mAct.findViewById(R.id.tv_flags_label));
+ final TextView tv_flags = mAct.findViewById(R.id.tv_flags_label);
tv_flags.post(new Runnable() {
@Override
public void run() {
Log.d("CtFwS", "Display Reset");
{
- final Chronometer ch = (Chronometer) (mAct.findViewById(R.id.ch_jailbreak));
+ final Chronometer ch = mAct.findViewById(R.id.ch_jailbreak);
ch.post(new Runnable() {
@Override
public void run() {
});
}
{
- final Chronometer ch = (Chronometer) (mAct.findViewById(R.id.ch_gameProgress));
+ final Chronometer ch = mAct.findViewById(R.id.ch_gameProgress);
ch.post(new Runnable() {
@Override
public void run() {
});
}
{
- final ProgressBar pb = (ProgressBar) (mAct.findViewById(R.id.pb_jailbreak));
+ final ProgressBar pb = mAct.findViewById(R.id.pb_jailbreak);
pb.post(new Runnable() {
@Override
public void run() {
});
}
{
- final ProgressBar pb = (ProgressBar) (mAct.findViewById(R.id.pb_gameProgress));
+ final ProgressBar pb = mAct.findViewById(R.id.pb_gameProgress);
pb.post(new Runnable() {
@Override
public void run() {
}
}
- final TextView msgs = (TextView) (mAct.findViewById(R.id.tv_flags));
+ final TextView msgs = mAct.findViewById(R.id.tv_flags);
msgs.post(new Runnable() {
@Override
public void run() {
private CtFwSGameStateManager.Msg lastMsg;
@Override
public void onCtFwSMessage(CtFwSGameStateManager gs, List<CtFwSGameStateManager.Msg> msgs) {
- final TextView msgstv = (TextView) (mAct.findViewById(R.id.msgs));
+ final TextView msgstv = mAct.findViewById(R.id.msgs);
int s = msgs.size();
if (s == 0) {
package com.acmetensortoys.ctfwstimer;
-import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+ findViewById(R.id.connmeta).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onclick_connmeta(v);
+ }
+ });
+
+ findViewById(R.id.header_gamestate).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onclick_gamestate(v);
+ }
+ });
+
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
throw new AssertionError("Shared Preferences not sticking!");
}
- mTvSU = (TextView) findViewById(R.id.tv_mqtt_server_uri);
- mTvSS = (TextView) findViewById(R.id.tv_mqtt_state);
+ mTvSU = findViewById(R.id.tv_mqtt_server_uri);
+ mTvSS = findViewById(R.id.tv_mqtt_state);
mCdl = new CtFwSDisplayLocal(this);
}
// Every good application needs an easter egg
private boolean egg = false;
- @SuppressLint({"SetTextI18n"})
public void onclick_gamestate(View v) {
final TextView tv = (TextView) v;
// Cam: Because every good easter egg needs to be way over-engineered.
if (!egg) {
egg = true;
- tv.setText("DO NOT TAP ON GLASS");
+ tv.setText(R.string.header_egg);
tv.postDelayed(new Runnable() {
public void run() {
if (mCdl != null) {
}
// Kick the mqtt layer on a click on the status stuff
- public void onclick_connmeta(@SuppressWarnings("UnusedParameters") View v) {
+ public void onclick_connmeta(View v) {
if (mSrvBinder != null) {
mSrvBinder.connect(true);
}
}
- // TODO should we be using onClick instead for routing?
- // Cam: According to official documentation, this is the preferred way to into menus, so
- // we're (overall) fine.
@Override
public boolean onOptionsItemSelected(MenuItem mi) {
switch(mi.getItemId()) {
};
// And this handles making our subscriptions for us
private class MyMQTTCallbacks implements MqttCallbackExtended {
- public CtFwSCallbacksMQTT mCtfwscbs;
+ CtFwSCallbacksMQTT mCtfwscbs;
@Override
public void connectComplete(boolean reconnect, String serverURI) {
}
@Override
- public void messageArrived(String topic, MqttMessage message) throws Exception {
+ public void messageArrived(String topic, MqttMessage message) {
Log.d("CtFwS", "Message(Generic) " + topic + " : '" + message + "'" );
}
// Unused, as we never publish
Log.d("CtFwS", "Delivery OK");
}
- };
+ }
private final MyMQTTCallbacks mqttcb = new MyMQTTCallbacks();
// And this handles yet more about connecting
import android.preference.PreferenceFragment;\r
import android.os.Bundle;\r
\r
-// TODO (Cam): changing the server doesn't actually work yet\r
public class SettingsActivity extends PreferenceActivity {\r
@Override\r
protected void onCreate(Bundle savedInstanceState) {\r
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:onClick="onclick_connmeta"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
- android:onClick="onclick_gamestate"
android:text="@string/header_gamestate0" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:onClick="onclick_connmeta"
android:orientation="vertical">
<TextView
<string name="header_gamestate0">Game State:</string>
<string name="header_gamestateN" tools:ignore="PluralsCandidate">Game %1$d State:</string>
+ <string name="header_egg">DO NOT TAP ON GLASS</string>
<string name="header_gametimeela">Game\nTime\nElapsed</string>
<string name="header_messages">Messages:</string>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<full-backup-content>
+ <include domain="sharedpref" path="."/>
+</full-backup-content>
\ No newline at end of file