package com.acmetensortoys.ctfwstimer;
import android.app.Activity;
+import android.graphics.Color;
+import android.os.Build;
import android.os.SystemClock;
import android.text.format.DateUtils;
import android.util.Log;
}
// Upper progress bar and chronometer
- // TODO: Older devices cannot count down in Chronometer, so will see only zeros, I
- // think. This should be fixed by making those devices count up (and still rendering
- // the progress bar rotated for decreasing, one assumes).
{
final ProgressBar pb_jb = (ProgressBar) (mAct.findViewById(R.id.pb_jailbreak));
pb_jb.post(new Runnable() {
ch_jb.post(new Runnable() {
@Override
public void run() {
- ch_jb.setBase((now.roundEnd + 1) * 1000 - tbcf);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ ch_jb.setBase((now.roundEnd + 1) * 1000 - tbcf);
+ ch_jb.setCountDown(true);
+ } else {
+ ch_jb.setBase(now.roundStart * 1000 - tbcf);
+ ch_jb.setBackgroundColor(Color.BLACK);
+ ch_jb.setTextColor(Color.WHITE);
+ }
ch_jb.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer c) {
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.res.Resources;
+import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
@Override
public void onCtFwSNow(CtFwSGameState game, CtFwSGameState.Now now) {
- userNoteBuilder.setWhen((now.roundEnd + 1) * 1000);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ userNoteBuilder.setWhen((now.roundEnd + 1) * 1000);
+ } else {
+ userNoteBuilder.setWhen(now.roundStart * 1000);
+ }
userNoteBuilder.setUsesChronometer(true);
if (now.rationale == null || !now.stop) {
// game is afoot or in the future!
<Chronometer
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:id="@+id/ch_jailbreak"
- android:countDown="true" />
+ android:id="@+id/ch_jailbreak" />
</TableRow>