reformat code though Android Studio
This commit is contained in:
parent
b3410dcebe
commit
4be1926459
|
@ -80,7 +80,7 @@ public class AppManagerActivity extends Activity {
|
|||
List<GBDeviceApp> systemApps = new ArrayList<>();
|
||||
systemApps.add(new GBDeviceApp(UUID.fromString("4dab81a6-d2fc-458a-992c-7a1f3b96a970"), "Sports (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
|
||||
systemApps.add(new GBDeviceApp(UUID.fromString("cf1e816a-9db0-4511-bbb8-f60c48ca8fac"), "Golf (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
|
||||
if (mGBDevice != null && !"aplite".equals(PebbleUtils.getPlatformName(mGBDevice.getFirmwareVersion()))) {
|
||||
if (mGBDevice != null && !"aplite".equals(PebbleUtils.getPlatformName(mGBDevice.getFirmwareVersion()))) {
|
||||
systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_PEBBLE_HEALTH, "Health (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ public class ExternalPebbleJSActivity extends Activity {
|
|||
return super.onConsoleMessage(consoleMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private class GBWebClient extends WebViewClient {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
|
|
|
@ -16,7 +16,6 @@ import com.github.mikephil.charting.components.YAxis;
|
|||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.ChartData;
|
||||
import com.github.mikephil.charting.data.CombinedData;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
|
|
|
@ -12,14 +12,12 @@ import android.widget.ListView;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails;
|
||||
|
||||
/**
|
||||
|
@ -126,7 +124,7 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
|||
return view;
|
||||
}
|
||||
|
||||
public void justifyListViewHeightBasedOnChildren (ListView listView) {
|
||||
public void justifyListViewHeightBasedOnChildren(ListView listView) {
|
||||
ArrayAdapter adapter = (ArrayAdapter) listView.getAdapter();
|
||||
|
||||
if (adapter == null) {
|
||||
|
|
|
@ -30,6 +30,7 @@ public class ItemWithDetailsAdapter extends ArrayAdapter<ItemWithDetails> {
|
|||
public void setHorizontalAlignment(boolean horizontalAlignment) {
|
||||
this.horizontalAlignment = horizontalAlignment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
ItemWithDetails item = getItem(position);
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.database.schema;
|
||||
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBUpdateScript;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_CUSTOM_SHORT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_GBACTIVITYSAMPLES;
|
||||
|
||||
/**
|
||||
* Bugfix for users who installed 0.8.1 cleanly, i.e. without any previous
|
||||
* database. Perform Update script 6 again.
|
||||
|
|
|
@ -26,8 +26,12 @@ public class MiBandFWHelper {
|
|||
|
||||
private final Uri uri;
|
||||
private final ContentResolver cr;
|
||||
private final @NonNull AbstractMiFirmwareInfo firmwareInfo;
|
||||
private final @NonNull byte[] fw;
|
||||
private final
|
||||
@NonNull
|
||||
AbstractMiFirmwareInfo firmwareInfo;
|
||||
private final
|
||||
@NonNull
|
||||
byte[] fw;
|
||||
|
||||
/**
|
||||
* Provides a different notification API which is also used on Mi1A devices.
|
||||
|
@ -125,12 +129,13 @@ public class MiBandFWHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param wholeFirmwareBytes
|
||||
* @return
|
||||
* @throws IllegalArgumentException when the data is not recognized as firmware data
|
||||
*/
|
||||
public static @NonNull AbstractMiFirmwareInfo determineFirmwareInfoFor(byte[] wholeFirmwareBytes) {
|
||||
public static
|
||||
@NonNull
|
||||
AbstractMiFirmwareInfo determineFirmwareInfoFor(byte[] wholeFirmwareBytes) {
|
||||
return AbstractMiFirmwareInfo.determineFirmwareInfoFor(wholeFirmwareBytes);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
|||
|
||||
public class MiBandSampleProvider implements SampleProvider {
|
||||
public static final int TYPE_DEEP_SLEEP = 5;
|
||||
public static final int TYPE_LIGHT_SLEEP = 4;
|
||||
public static final int TYPE_ACTIVITY = -1;
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
public static final int TYPE_NONWEAR = 3;
|
||||
public static final int TYPE_CHARGING = 6;
|
||||
public static final int TYPE_LIGHT_SLEEP = 4;
|
||||
public static final int TYPE_ACTIVITY = -1;
|
||||
public static final int TYPE_UNKNOWN = -1;
|
||||
public static final int TYPE_NONWEAR = 3;
|
||||
public static final int TYPE_CHARGING = 6;
|
||||
|
||||
// public static final byte TYPE_NREM = 5; // DEEP SLEEP
|
||||
// public static final byte TYPE_ONBED = 7;
|
||||
|
|
|
@ -11,6 +11,7 @@ public interface ItemWithDetails extends Parcelable, Comparable<ItemWithDetails>
|
|||
|
||||
/**
|
||||
* Equality is based on #getName() only.
|
||||
*
|
||||
* @param other
|
||||
*/
|
||||
boolean equals(Object other);
|
||||
|
|
|
@ -3,7 +3,6 @@ package nodomain.freeyourgadget.gadgetbridge.service;
|
|||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
|
|
@ -5,9 +5,6 @@ import android.support.annotation.NonNull;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
|
||||
/**
|
||||
* Some helper methods for Mi1 and Mi1A firmware.
|
||||
*/
|
||||
|
@ -21,18 +18,15 @@ public abstract class AbstractMi1FirmwareInfo extends AbstractMiFirmwareInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getFirmwareOffset()
|
||||
{
|
||||
public int getFirmwareOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getFirmwareLength()
|
||||
{
|
||||
public int getFirmwareLength() {
|
||||
return wholeFirmwareBytes.length;
|
||||
}
|
||||
|
||||
public int getFirmwareVersion()
|
||||
{
|
||||
public int getFirmwareVersion() {
|
||||
return (wholeFirmwareBytes[getOffsetFirmwareVersionMajor()] << 24)
|
||||
| (wholeFirmwareBytes[getOffsetFirmwareVersionMinor()] << 16)
|
||||
| (wholeFirmwareBytes[getOffsetFirmwareVersionRevision()] << 8)
|
||||
|
|
|
@ -8,12 +8,13 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|||
|
||||
public abstract class AbstractMiFirmwareInfo {
|
||||
/**
|
||||
*
|
||||
* @param wholeFirmwareBytes
|
||||
* @return
|
||||
* @throws IllegalArgumentException when the data is not recognized as firmware data
|
||||
*/
|
||||
public static @NonNull AbstractMiFirmwareInfo determineFirmwareInfoFor(byte[] wholeFirmwareBytes) {
|
||||
public static
|
||||
@NonNull
|
||||
AbstractMiFirmwareInfo determineFirmwareInfoFor(byte[] wholeFirmwareBytes) {
|
||||
AbstractMiFirmwareInfo[] candidates = getFirmwareInfoCandidatesFor(wholeFirmwareBytes);
|
||||
if (candidates.length == 0) {
|
||||
throw new IllegalArgumentException("Unsupported data (maybe not even a firmware?).");
|
||||
|
@ -59,7 +60,9 @@ public abstract class AbstractMiFirmwareInfo {
|
|||
|
||||
public abstract boolean isGenerallyCompatibleWith(GBDevice device);
|
||||
|
||||
public @NonNull byte[] getFirmwareBytes() {
|
||||
public
|
||||
@NonNull
|
||||
byte[] getFirmwareBytes() {
|
||||
return Arrays.copyOfRange(wholeFirmwareBytes, getFirmwareOffset(), getFirmwareLength());
|
||||
}
|
||||
|
||||
|
@ -85,6 +88,7 @@ public abstract class AbstractMiFirmwareInfo {
|
|||
}
|
||||
throw new UnsupportedOperationException(getClass().getName() + " must override getFirst() and getSecond()");
|
||||
}
|
||||
|
||||
public AbstractMiFirmwareInfo getSecond() {
|
||||
if (isSingleMiBandFirmware()) {
|
||||
throw new UnsupportedOperationException(getClass().getName() + " only supports on firmware");
|
||||
|
|
|
@ -87,7 +87,7 @@ public class DeviceInfo extends AbstractInfo {
|
|||
", hwVersion=" + hwVersion +
|
||||
", feature=" + feature +
|
||||
", appearance=" + appearance +
|
||||
", fw2Version (hr)=" + fw2Version+
|
||||
", fw2Version (hr)=" + fw2Version +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ public class Mi1SFirmwareInfo extends AbstractMi1SFirmwareInfo {
|
|||
return fw2Info;
|
||||
}
|
||||
|
||||
public static @Nullable Mi1SFirmwareInfo getInstance(byte[] wholeFirmwareBytes) {
|
||||
public static
|
||||
@Nullable
|
||||
Mi1SFirmwareInfo getInstance(byte[] wholeFirmwareBytes) {
|
||||
Mi1SFirmwareInfo info = new Mi1SFirmwareInfo(wholeFirmwareBytes);
|
||||
if (info.isGenerallySupportedFirmware()) {
|
||||
return info;
|
||||
|
|
|
@ -15,8 +15,7 @@ public class Mi1SFirmwareInfoFW1 extends AbstractMi1SFirmwareInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getFirmwareOffset()
|
||||
{
|
||||
public int getFirmwareOffset() {
|
||||
return (wholeFirmwareBytes[12] & 255) << 24
|
||||
| (wholeFirmwareBytes[13] & 255) << 16
|
||||
| (wholeFirmwareBytes[14] & 255) << 8
|
||||
|
@ -24,8 +23,7 @@ public class Mi1SFirmwareInfoFW1 extends AbstractMi1SFirmwareInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getFirmwareLength()
|
||||
{
|
||||
public int getFirmwareLength() {
|
||||
return (wholeFirmwareBytes[16] & 255) << 24
|
||||
| (wholeFirmwareBytes[17] & 255) << 16
|
||||
| (wholeFirmwareBytes[18] & 255) << 8
|
||||
|
@ -33,15 +31,14 @@ public class Mi1SFirmwareInfoFW1 extends AbstractMi1SFirmwareInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getFirmwareVersion()
|
||||
{
|
||||
public int getFirmwareVersion() {
|
||||
return (wholeFirmwareBytes[8] & 255) << 24
|
||||
| (wholeFirmwareBytes[9] & 255) << 16
|
||||
| (wholeFirmwareBytes[10] & 255) << 8
|
||||
| wholeFirmwareBytes[11] & 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected boolean isGenerallySupportedFirmware() {
|
||||
try {
|
||||
int majorVersion = getFirmwareVersionMajor();
|
||||
|
@ -49,5 +46,5 @@ public class Mi1SFirmwareInfoFW1 extends AbstractMi1SFirmwareInfo {
|
|||
} catch (IllegalArgumentException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ public class Mi1SFirmwareInfoFW2 extends AbstractMi1SFirmwareInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getFirmwareOffset()
|
||||
{
|
||||
public int getFirmwareOffset() {
|
||||
return (wholeFirmwareBytes[26] & 255) << 24
|
||||
| (wholeFirmwareBytes[27] & 255) << 16
|
||||
| (wholeFirmwareBytes[28] & 255) << 8
|
||||
|
@ -22,8 +21,7 @@ public class Mi1SFirmwareInfoFW2 extends AbstractMi1SFirmwareInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getFirmwareLength()
|
||||
{
|
||||
public int getFirmwareLength() {
|
||||
return (wholeFirmwareBytes[30] & 255) << 24
|
||||
| (wholeFirmwareBytes[31] & 255) << 16
|
||||
| (wholeFirmwareBytes[32] & 255) << 8
|
||||
|
@ -41,8 +39,7 @@ public class Mi1SFirmwareInfoFW2 extends AbstractMi1SFirmwareInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getFirmwareVersion()
|
||||
{
|
||||
public int getFirmwareVersion() {
|
||||
return (wholeFirmwareBytes[22] & 255) << 24
|
||||
| (wholeFirmwareBytes[23] & 255) << 16
|
||||
| (wholeFirmwareBytes[24] & 255) << 8
|
||||
|
|
|
@ -30,7 +30,6 @@ import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandDateConverter;
|
|||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBAlarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice.State;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
|||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleColor;
|
||||
|
||||
public class AppMessageHandlerPebStyle extends AppMessageHandler {
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.ArrayList;
|
|||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
|
||||
public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
|
||||
public static final int KEY_SETTING_SIDEBAR_LEFT = 9;
|
||||
|
|
|
@ -12,6 +12,7 @@ public class PebbleUtils {
|
|||
}
|
||||
return platformName;
|
||||
}
|
||||
|
||||
public static String getModel(String hwRev) {
|
||||
//TODO: get real data?
|
||||
String model;
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class AbstractServiceTestCase<T extends Service> {
|
|||
private NotificationManager mNotificationManager;
|
||||
private MockHelper mMockHelper;
|
||||
|
||||
protected AbstractServiceTestCase(Class<T> serviceClass) {
|
||||
protected AbstractServiceTestCase(Class<T> serviceClass) {
|
||||
mServiceClass = serviceClass;
|
||||
Assert.assertNotNull(serviceClass);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class FirmwareTest {
|
|||
private static final int DOUBLE = 2;
|
||||
|
||||
@Test
|
||||
public void testFirmwareMi1() throws Exception{
|
||||
public void testFirmwareMi1() throws Exception {
|
||||
byte[] wholeFw = getFirmwareMi();
|
||||
Assert.assertNotNull(wholeFw);
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class FirmwareTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFirmwareMi1A() throws Exception{
|
||||
public void testFirmwareMi1A() throws Exception {
|
||||
byte[] wholeFw = getFirmwareMi1A();
|
||||
Assert.assertNotNull(wholeFw);
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class FirmwareTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFirmwareMi1S() throws Exception{
|
||||
public void testFirmwareMi1S() throws Exception {
|
||||
byte[] wholeFw = getFirmwareMi1S();
|
||||
Assert.assertNotNull(wholeFw);
|
||||
|
||||
|
@ -84,7 +84,8 @@ public class FirmwareTest {
|
|||
try {
|
||||
info.getFirmwareVersion();
|
||||
Assert.fail("should not get fw version from AbstractMi1SFirmwareInfo");
|
||||
} catch (UnsupportedOperationException expected) {}
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
|
||||
Assert.assertNotEquals(info.getFirst().getFirmwareOffset(), info.getSecond().getFirmwareOffset());
|
||||
Assert.assertFalse(Arrays.equals(info.getFirst().getFirmwareBytes(), info.getSecond().getFirmwareBytes()));
|
||||
|
@ -99,7 +100,8 @@ public class FirmwareTest {
|
|||
try {
|
||||
info.getSecond();
|
||||
Assert.fail("should throw UnsuportedOperationException");
|
||||
} catch (UnsupportedOperationException expected) {}
|
||||
} catch (UnsupportedOperationException expected) {
|
||||
}
|
||||
int calculatedLength = info.getFirmwareLength();
|
||||
Assert.assertTrue("Unexpected firmware length: " + wholeFw.length, calculatedLength <= wholeFw.length);
|
||||
break;
|
||||
|
|
|
@ -19,6 +19,7 @@ public class GBMockApplication extends MockApplication {
|
|||
public Context getApplicationContext() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageManager getPackageManager() {
|
||||
return mPackageManager;
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
|
||||
public class GBMockIntent extends Intent {
|
||||
private String mAction;
|
||||
private final Map<String,Object> extras = new HashMap<>();
|
||||
private final Map<String, Object> extras = new HashMap<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue