reformat code though Android Studio
This commit is contained in:
parent
b3410dcebe
commit
4be1926459
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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,8 +31,7 @@ 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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue