Working with big huge buttons

This commit is contained in:
Neale Pickett 2012-12-08 18:33:50 -07:00
parent 15787dee79
commit 4a46c159fc
4 changed files with 39 additions and 41 deletions

View File

@ -29,9 +29,9 @@ define(row, `<LinearLayout
/>
</LinearLayout>')
row(jl, jr)
row(bl1, br1)
row(bl2, br2)
row(bl3, br3)
row(b1l, b1r)
row(b2l, b2r)
row(b3l, b3r)
<Button
android:id="@+id/pause"
android:text="Jam End"

View File

@ -1,6 +1,7 @@
package org.woozle.penaltytimer;
import android.content.Context;
import android.widget.Button;
import android.view.View;
import android.view.View.*;
@ -10,12 +11,12 @@ public class JammerButton extends TimerButton
public boolean penalized = false;
private JammerButton peer;
public JammerButton(Context context, long now) {
super(context, now);
public JammerButton(Context context, Button btn, long now) {
super(context, btn, now);
}
public String str(long remain, boolean tenths) {
return bstr(remain, tenths) + " J";
return bstr(remain, tenths) + " ";
}
public void setOther(JammerButton other) {

View File

@ -1,8 +1,7 @@
package org.woozle.penaltytimer;
import android.app.Activity;
import android.view.View;
import android.widget.Toast;
import android.view.*;
import android.widget.*;
import android.os.*;
import java.lang.Math;
@ -16,6 +15,14 @@ public class PenaltyTimer extends Activity
private TimerButton[] tbs = new TimerButton[8];
private boolean paused = false;
private int[] btns = {
R.id.jl, R.id.jr,
R.id.b1l, R.id.b1r,
R.id.b2l, R.id.b2r,
R.id.b3l, R.id.b3r,
};
private Runnable pulse = new Runnable() {
public void run() {
long now = SystemClock.uptimeMillis();
@ -39,45 +46,36 @@ public class PenaltyTimer extends Activity
Persistence p = (Persistence)getLastNonConfigurationInstance();
long now = SystemClock.uptimeMillis();
LinearLayout top;
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 0, (float)2.0);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
top = (LinearLayout)findViewById(R.id.main);
// Create all the buttons
for (int i = 0; i < 4; i += 1) {
LinearLayout tr = new LinearLayout(this);
top.addView(tr, i);
for (int j = 0; j < 2; j += 1) {
// Set up all the buttons
for (int i = 0; i < 8; i += 1) {
Button btn = (Button)findViewById(btns[i]);
TimerButton b;
TextView v;
if (i == 0) {
JammerButton jb = new JammerButton(this, now);
if (i < 2) {
JammerButton jb = new JammerButton(this, btn, now);
if (p != null) {
jb.penalized = p.penalized[j];
jb.penalized = p.penalized[i];
}
jbs[j] = jb;
jbs[i] = jb;
b = jb;
} else {
b = new TimerButton(this, now);
b = new TimerButton(this, btn, now);
}
if (p != null) {
int idx = i*2 + j;
b.startTime = p.startTime[idx];
b.duration = p.duration[idx];
b.running = p.running[idx];
b.startTime = p.startTime[i];
b.duration = p.duration[i];
b.running = p.running[i];
}
tr.addView(b.getButton());
tbs[i*2 + j] = b;
}
tbs[i] = b;
}

View File

@ -29,11 +29,10 @@ public class TimerButton
static ColorFilter standColor = new PorterDuffColorFilter(0xffffff88, PorterDuff.Mode.MULTIPLY);
static ColorFilter normalColor = new PorterDuffColorFilter(0xffff8888, PorterDuff.Mode.MULTIPLY);
public TimerButton(Context context, long now) {
b = new Button(context);
public TimerButton(Context context, Button btn, long now) {
vibr = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
b = btn;
b.setText("--:--");
b.setTextSize(24);
b.setGravity(Gravity.CENTER);