1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

reformat code

This commit is contained in:
Andreas Shimokawa 2015-06-30 12:09:29 +02:00
parent 594bf8c45b
commit b25d771ee9
8 changed files with 44 additions and 49 deletions

View File

@ -30,7 +30,6 @@ import java.util.List;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.activities.ConfigureAlarms;
import nodomain.freeyourgadget.gadgetbridge.activities.ChartsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.SleepChartActivity;
import nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapter;
import nodomain.freeyourgadget.gadgetbridge.discovery.DiscoveryActivity;

View File

@ -14,7 +14,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;

View File

@ -31,7 +31,7 @@ public class GBAlarm implements Parcelable, Comparable {
public static final byte ALARM_SAT = 32;
public static final byte ALARM_SUN = 64;
public static final String[] DEFAULT_ALARMS = {"2,false,false,0,15,30","1,false,false,96,8,0","0,false,true,31,7,30"};
public static final String[] DEFAULT_ALARMS = {"2,false,false,0,15,30", "1,false,false,96,8,0", "0,false,true,31,7,30"};
public GBAlarm(int index, boolean enabled, boolean smartWakeup, byte repetition, int hour, int minute) {
@ -43,13 +43,13 @@ public class GBAlarm implements Parcelable, Comparable {
this.minute = minute;
}
public GBAlarm(String fromPreferences){
public GBAlarm(String fromPreferences) {
String[] tokens = fromPreferences.split(",");
//TODO: sanify the string!
this.index = Integer.parseInt(tokens[0]);
this.enabled = Boolean.parseBoolean(tokens[1]);
this.smartWakeup = Boolean.parseBoolean(tokens[2]);
this.repetition = Integer.parseInt(tokens[3]);
this.repetition = Integer.parseInt(tokens[3]);
this.hour = Integer.parseInt(tokens[4]);
this.minute = Integer.parseInt(tokens[5]);
}
@ -61,13 +61,13 @@ public class GBAlarm implements Parcelable, Comparable {
int repetition = pc.readInt();
int hour = pc.readInt();
int minute = pc.readInt();
return new GBAlarm(index, enabled, smartWakeup, (byte)repetition, hour, minute);
return new GBAlarm(index, enabled, smartWakeup, (byte) repetition, hour, minute);
}
@Override
public boolean equals(Object o) {
if (o instanceof GBAlarm) {
GBAlarm comp = (GBAlarm)o;
GBAlarm comp = (GBAlarm) o;
return comp.getIndex() == getIndex();
} else {
return false;
@ -96,9 +96,9 @@ public class GBAlarm implements Parcelable, Comparable {
@Override
public int compareTo(Object another) {
if (this.getIndex() < ((GBAlarm)another).getIndex()) {
if (this.getIndex() < ((GBAlarm) another).getIndex()) {
return -1;
}else if (this.getIndex() > ((GBAlarm)another).getIndex()) {
} else if (this.getIndex() > ((GBAlarm) another).getIndex()) {
return 1;
}
return 0;
@ -109,16 +109,17 @@ public class GBAlarm implements Parcelable, Comparable {
}
public String getTime() {
return String.format("%02d",this.hour) + ":" + String.format("%02d",this.minute);
return String.format("%02d", this.hour) + ":" + String.format("%02d", this.minute);
}
public int getHour(){
public int getHour() {
return this.hour;
}
public int getMinute(){
public int getMinute() {
return this.minute;
}
public Calendar getAlarmCal() {
Calendar alarm = Calendar.getInstance();
alarm.set(Calendar.HOUR_OF_DAY, this.hour);
@ -143,11 +144,11 @@ public class GBAlarm implements Parcelable, Comparable {
}
public String toPreferences() {
return String.valueOf(this.index)+','+
String.valueOf(this.enabled)+','+
String.valueOf(this.smartWakeup)+','+
String.valueOf(this.repetition)+','+
String.valueOf(this.hour)+','+
return String.valueOf(this.index) + ',' +
String.valueOf(this.enabled) + ',' +
String.valueOf(this.smartWakeup) + ',' +
String.valueOf(this.repetition) + ',' +
String.valueOf(this.hour) + ',' +
String.valueOf(this.minute);
}
@ -188,7 +189,7 @@ public class GBAlarm implements Parcelable, Comparable {
while (iterator.hasNext()) {
String alarmString = iterator.next();
if(this.equals(new GBAlarm(alarmString))) {
if (this.equals(new GBAlarm(alarmString))) {
iterator.remove();
break;
}

View File

@ -1,19 +1,12 @@
package nodomain.freeyourgadget.gadgetbridge.activities;
import java.util.Locale;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -21,6 +14,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.R;
public class ChartsActivity extends FragmentActivity {

View File

@ -13,7 +13,6 @@ import android.widget.TextView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.GBAlarm;
@ -34,13 +33,13 @@ public class GBAlarmListAdapter extends ArrayAdapter<GBAlarm> {
this.alarmList = alarmList;
}
public GBAlarmListAdapter(Context context,Set<String> preferencesAlarmListSet) {
public GBAlarmListAdapter(Context context, Set<String> preferencesAlarmListSet) {
super(context, 0, new ArrayList<GBAlarm>());
this.mContext = context;
alarmList = new ArrayList<GBAlarm>();
for (String alarmString : preferencesAlarmListSet) {
for (String alarmString : preferencesAlarmListSet) {
alarmList.add(new GBAlarm(alarmString));
}
@ -50,7 +49,7 @@ public class GBAlarmListAdapter extends ArrayAdapter<GBAlarm> {
public void setAlarmList(Set<String> preferencesAlarmListSet) {
alarmList = new ArrayList<GBAlarm>();
for (String alarmString : preferencesAlarmListSet) {
for (String alarmString : preferencesAlarmListSet) {
alarmList.add(new GBAlarm(alarmString));
}
@ -64,8 +63,8 @@ public class GBAlarmListAdapter extends ArrayAdapter<GBAlarm> {
public void update(GBAlarm alarm) {
for (GBAlarm a : alarmList) {
if(alarm.equals(a)) {
a = alarm;
if (alarm.equals(a)) {
a = alarm;
}
}
alarm.store();
@ -129,12 +128,12 @@ public class GBAlarmListAdapter extends ArrayAdapter<GBAlarm> {
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((ConfigureAlarms)mContext).configureAlarm(alarm);
((ConfigureAlarms) mContext).configureAlarm(alarm);
}
});
alarmTime.setText(alarm.getTime());
isEnabled.setChecked(alarm.isEnabled());
if(alarm.isSmartWakeup()) {
if (alarm.isSmartWakeup()) {
isSmartWakeup.setVisibility(TextView.VISIBLE);
} else {
isSmartWakeup.setVisibility(TextView.GONE);

View File

@ -10,7 +10,7 @@ import com.github.mikephil.charting.utils.ViewPortHandler;
/**
* A legend renderer that does *not* calculate the labels and colors automatically
* from the data sets or the data entries.
*
* <p/>
* Instead, they have to be provided manually, because otherwise the legend will
* be empty.
*/

View File

@ -152,12 +152,13 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
/**
* Sends a custom notification to the Mi Band.
*
* @param vibrationProfile specifies how and how often the Band shall vibrate.
* @param flashTimes
* @param flashColour
* @param originalColour
* @param flashDuration
* @param extraAction an extra action to be executed after every vibration and flash sequence. Allows to abort the repetition, for example.
* @param extraAction an extra action to be executed after every vibration and flash sequence. Allows to abort the repetition, for example.
* @param builder
*/
private void sendCustomNotification(VibrationProfile vibrationProfile, int flashTimes, int flashColour, int originalColour, long flashDuration, BtLEAction extraAction, TransactionBuilder builder) {
@ -566,10 +567,10 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
private void queueAlarm(GBAlarm alarm, TransactionBuilder builder, BluetoothGattCharacteristic characteristic) {
Calendar alarmCal = alarm.getAlarmCal();
byte[] alarmMessage = new byte[] {
byte[] alarmMessage = new byte[]{
(byte) MiBandService.COMMAND_SET_TIMER,
(byte) alarm.getIndex(),
(byte) (alarm.isEnabled() ? 1: 0),
(byte) (alarm.isEnabled() ? 1 : 0),
(byte) (alarmCal.get(Calendar.YEAR) - 2000),
(byte) alarmCal.get(Calendar.MONTH),
(byte) alarmCal.get(Calendar.DATE),

View File

@ -20,22 +20,22 @@ public class VibrationProfile {
return new VibrationProfile(id, new int[]{100, 0}, repeat);
}
if (ID_SHORT.equals(id)) {
return new VibrationProfile(id, new int[] {200, 200}, repeat);
return new VibrationProfile(id, new int[]{200, 200}, repeat);
}
if (ID_LONG.equals(id)) {
return new VibrationProfile(id, new int[] {500, 1000}, repeat);
return new VibrationProfile(id, new int[]{500, 1000}, repeat);
}
if (ID_WATERDROP.equals(id)) {
return new VibrationProfile(id, new int[] {100, 1500}, repeat);
return new VibrationProfile(id, new int[]{100, 1500}, repeat);
}
if (ID_RING.equals(id)) {
return new VibrationProfile(id, new int[]{300, 200, 600, 2000}, repeat);
}
if (ID_ALARM_CLOCK.equals(id)) {
return new VibrationProfile(id, new int[] {30, 35, 30, 35, 30, 35, 30, 800}, repeat);
return new VibrationProfile(id, new int[]{30, 35, 30, 35, 30, 35, 30, 800}, repeat);
}
// medium
return new VibrationProfile(id, new int[] {300, 600}, repeat);
return new VibrationProfile(id, new int[]{300, 600}, repeat);
}
private final String id;
@ -45,9 +45,10 @@ public class VibrationProfile {
/**
* Creates a new profile instance.
* @param id the ID, used as preference key.
*
* @param id the ID, used as preference key.
* @param onOffSequence a sequence of alternating on and off durations, in milliseconds
* @param repeat how ofoften the sequence shall be repeated
* @param repeat how ofoften the sequence shall be repeated
*/
public VibrationProfile(String id, int[] onOffSequence, short repeat) {
this.id = id;