mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 02:25:50 +01:00
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);
|
return super.onConsoleMessage(consoleMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GBWebClient extends WebViewClient {
|
private class GBWebClient extends WebViewClient {
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
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.BarData;
|
||||||
import com.github.mikephil.charting.data.BarDataSet;
|
import com.github.mikephil.charting.data.BarDataSet;
|
||||||
import com.github.mikephil.charting.data.BarEntry;
|
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.CombinedData;
|
||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.data.LineData;
|
import com.github.mikephil.charting.data.LineData;
|
||||||
|
@ -12,14 +12,12 @@ import android.widget.ListView;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails;
|
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +30,7 @@ public class ItemWithDetailsAdapter extends ArrayAdapter<ItemWithDetails> {
|
|||||||
public void setHorizontalAlignment(boolean horizontalAlignment) {
|
public void setHorizontalAlignment(boolean horizontalAlignment) {
|
||||||
this.horizontalAlignment = horizontalAlignment;
|
this.horizontalAlignment = horizontalAlignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View view, ViewGroup parent) {
|
public View getView(int position, View view, ViewGroup parent) {
|
||||||
ItemWithDetails item = getItem(position);
|
ItemWithDetails item = getItem(position);
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.database.schema;
|
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
|
* Bugfix for users who installed 0.8.1 cleanly, i.e. without any previous
|
||||||
* database. Perform Update script 6 again.
|
* database. Perform Update script 6 again.
|
||||||
|
@ -26,8 +26,12 @@ public class MiBandFWHelper {
|
|||||||
|
|
||||||
private final Uri uri;
|
private final Uri uri;
|
||||||
private final ContentResolver cr;
|
private final ContentResolver cr;
|
||||||
private final @NonNull AbstractMiFirmwareInfo firmwareInfo;
|
private final
|
||||||
private final @NonNull byte[] fw;
|
@NonNull
|
||||||
|
AbstractMiFirmwareInfo firmwareInfo;
|
||||||
|
private final
|
||||||
|
@NonNull
|
||||||
|
byte[] fw;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a different notification API which is also used on Mi1A devices.
|
* Provides a different notification API which is also used on Mi1A devices.
|
||||||
@ -125,12 +129,13 @@ public class MiBandFWHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param wholeFirmwareBytes
|
* @param wholeFirmwareBytes
|
||||||
* @return
|
* @return
|
||||||
* @throws IllegalArgumentException when the data is not recognized as firmware data
|
* @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);
|
return AbstractMiFirmwareInfo.determineFirmwareInfoFor(wholeFirmwareBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ public interface ItemWithDetails extends Parcelable, Comparable<ItemWithDetails>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Equality is based on #getName() only.
|
* Equality is based on #getName() only.
|
||||||
|
*
|
||||||
* @param other
|
* @param other
|
||||||
*/
|
*/
|
||||||
boolean equals(Object other);
|
boolean equals(Object other);
|
||||||
|
@ -3,7 +3,6 @@ package nodomain.freeyourgadget.gadgetbridge.service;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
@ -5,9 +5,6 @@ import android.support.annotation.NonNull;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.
|
* Some helper methods for Mi1 and Mi1A firmware.
|
||||||
*/
|
*/
|
||||||
@ -21,18 +18,15 @@ public abstract class AbstractMi1FirmwareInfo extends AbstractMiFirmwareInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirmwareOffset()
|
public int getFirmwareOffset() {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirmwareLength()
|
public int getFirmwareLength() {
|
||||||
{
|
|
||||||
return wholeFirmwareBytes.length;
|
return wholeFirmwareBytes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirmwareVersion()
|
public int getFirmwareVersion() {
|
||||||
{
|
|
||||||
return (wholeFirmwareBytes[getOffsetFirmwareVersionMajor()] << 24)
|
return (wholeFirmwareBytes[getOffsetFirmwareVersionMajor()] << 24)
|
||||||
| (wholeFirmwareBytes[getOffsetFirmwareVersionMinor()] << 16)
|
| (wholeFirmwareBytes[getOffsetFirmwareVersionMinor()] << 16)
|
||||||
| (wholeFirmwareBytes[getOffsetFirmwareVersionRevision()] << 8)
|
| (wholeFirmwareBytes[getOffsetFirmwareVersionRevision()] << 8)
|
||||||
|
@ -8,12 +8,13 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|||||||
|
|
||||||
public abstract class AbstractMiFirmwareInfo {
|
public abstract class AbstractMiFirmwareInfo {
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param wholeFirmwareBytes
|
* @param wholeFirmwareBytes
|
||||||
* @return
|
* @return
|
||||||
* @throws IllegalArgumentException when the data is not recognized as firmware data
|
* @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);
|
AbstractMiFirmwareInfo[] candidates = getFirmwareInfoCandidatesFor(wholeFirmwareBytes);
|
||||||
if (candidates.length == 0) {
|
if (candidates.length == 0) {
|
||||||
throw new IllegalArgumentException("Unsupported data (maybe not even a firmware?).");
|
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 abstract boolean isGenerallyCompatibleWith(GBDevice device);
|
||||||
|
|
||||||
public @NonNull byte[] getFirmwareBytes() {
|
public
|
||||||
|
@NonNull
|
||||||
|
byte[] getFirmwareBytes() {
|
||||||
return Arrays.copyOfRange(wholeFirmwareBytes, getFirmwareOffset(), getFirmwareLength());
|
return Arrays.copyOfRange(wholeFirmwareBytes, getFirmwareOffset(), getFirmwareLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +88,7 @@ public abstract class AbstractMiFirmwareInfo {
|
|||||||
}
|
}
|
||||||
throw new UnsupportedOperationException(getClass().getName() + " must override getFirst() and getSecond()");
|
throw new UnsupportedOperationException(getClass().getName() + " must override getFirst() and getSecond()");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractMiFirmwareInfo getSecond() {
|
public AbstractMiFirmwareInfo getSecond() {
|
||||||
if (isSingleMiBandFirmware()) {
|
if (isSingleMiBandFirmware()) {
|
||||||
throw new UnsupportedOperationException(getClass().getName() + " only supports on firmware");
|
throw new UnsupportedOperationException(getClass().getName() + " only supports on firmware");
|
||||||
|
@ -31,7 +31,9 @@ public class Mi1SFirmwareInfo extends AbstractMi1SFirmwareInfo {
|
|||||||
return fw2Info;
|
return fw2Info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable Mi1SFirmwareInfo getInstance(byte[] wholeFirmwareBytes) {
|
public static
|
||||||
|
@Nullable
|
||||||
|
Mi1SFirmwareInfo getInstance(byte[] wholeFirmwareBytes) {
|
||||||
Mi1SFirmwareInfo info = new Mi1SFirmwareInfo(wholeFirmwareBytes);
|
Mi1SFirmwareInfo info = new Mi1SFirmwareInfo(wholeFirmwareBytes);
|
||||||
if (info.isGenerallySupportedFirmware()) {
|
if (info.isGenerallySupportedFirmware()) {
|
||||||
return info;
|
return info;
|
||||||
|
@ -15,8 +15,7 @@ public class Mi1SFirmwareInfoFW1 extends AbstractMi1SFirmwareInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirmwareOffset()
|
public int getFirmwareOffset() {
|
||||||
{
|
|
||||||
return (wholeFirmwareBytes[12] & 255) << 24
|
return (wholeFirmwareBytes[12] & 255) << 24
|
||||||
| (wholeFirmwareBytes[13] & 255) << 16
|
| (wholeFirmwareBytes[13] & 255) << 16
|
||||||
| (wholeFirmwareBytes[14] & 255) << 8
|
| (wholeFirmwareBytes[14] & 255) << 8
|
||||||
@ -24,8 +23,7 @@ public class Mi1SFirmwareInfoFW1 extends AbstractMi1SFirmwareInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirmwareLength()
|
public int getFirmwareLength() {
|
||||||
{
|
|
||||||
return (wholeFirmwareBytes[16] & 255) << 24
|
return (wholeFirmwareBytes[16] & 255) << 24
|
||||||
| (wholeFirmwareBytes[17] & 255) << 16
|
| (wholeFirmwareBytes[17] & 255) << 16
|
||||||
| (wholeFirmwareBytes[18] & 255) << 8
|
| (wholeFirmwareBytes[18] & 255) << 8
|
||||||
@ -33,8 +31,7 @@ public class Mi1SFirmwareInfoFW1 extends AbstractMi1SFirmwareInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirmwareVersion()
|
public int getFirmwareVersion() {
|
||||||
{
|
|
||||||
return (wholeFirmwareBytes[8] & 255) << 24
|
return (wholeFirmwareBytes[8] & 255) << 24
|
||||||
| (wholeFirmwareBytes[9] & 255) << 16
|
| (wholeFirmwareBytes[9] & 255) << 16
|
||||||
| (wholeFirmwareBytes[10] & 255) << 8
|
| (wholeFirmwareBytes[10] & 255) << 8
|
||||||
|
@ -13,8 +13,7 @@ public class Mi1SFirmwareInfoFW2 extends AbstractMi1SFirmwareInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirmwareOffset()
|
public int getFirmwareOffset() {
|
||||||
{
|
|
||||||
return (wholeFirmwareBytes[26] & 255) << 24
|
return (wholeFirmwareBytes[26] & 255) << 24
|
||||||
| (wholeFirmwareBytes[27] & 255) << 16
|
| (wholeFirmwareBytes[27] & 255) << 16
|
||||||
| (wholeFirmwareBytes[28] & 255) << 8
|
| (wholeFirmwareBytes[28] & 255) << 8
|
||||||
@ -22,8 +21,7 @@ public class Mi1SFirmwareInfoFW2 extends AbstractMi1SFirmwareInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirmwareLength()
|
public int getFirmwareLength() {
|
||||||
{
|
|
||||||
return (wholeFirmwareBytes[30] & 255) << 24
|
return (wholeFirmwareBytes[30] & 255) << 24
|
||||||
| (wholeFirmwareBytes[31] & 255) << 16
|
| (wholeFirmwareBytes[31] & 255) << 16
|
||||||
| (wholeFirmwareBytes[32] & 255) << 8
|
| (wholeFirmwareBytes[32] & 255) << 8
|
||||||
@ -41,8 +39,7 @@ public class Mi1SFirmwareInfoFW2 extends AbstractMi1SFirmwareInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFirmwareVersion()
|
public int getFirmwareVersion() {
|
||||||
{
|
|
||||||
return (wholeFirmwareBytes[22] & 255) << 24
|
return (wholeFirmwareBytes[22] & 255) << 24
|
||||||
| (wholeFirmwareBytes[23] & 255) << 16
|
| (wholeFirmwareBytes[23] & 255) << 16
|
||||||
| (wholeFirmwareBytes[24] & 255) << 8
|
| (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.MiBandFWHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandService;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile;
|
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;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice.State;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice.State;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
|
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleColor;
|
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleColor;
|
||||||
|
|
||||||
public class AppMessageHandlerPebStyle extends AppMessageHandler {
|
public class AppMessageHandlerPebStyle extends AppMessageHandler {
|
||||||
|
@ -11,7 +11,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
|
||||||
|
|
||||||
public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
|
public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
|
||||||
public static final int KEY_SETTING_SIDEBAR_LEFT = 9;
|
public static final int KEY_SETTING_SIDEBAR_LEFT = 9;
|
||||||
|
@ -12,6 +12,7 @@ public class PebbleUtils {
|
|||||||
}
|
}
|
||||||
return platformName;
|
return platformName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getModel(String hwRev) {
|
public static String getModel(String hwRev) {
|
||||||
//TODO: get real data?
|
//TODO: get real data?
|
||||||
String model;
|
String model;
|
||||||
|
@ -84,7 +84,8 @@ public class FirmwareTest {
|
|||||||
try {
|
try {
|
||||||
info.getFirmwareVersion();
|
info.getFirmwareVersion();
|
||||||
Assert.fail("should not get fw version from AbstractMi1SFirmwareInfo");
|
Assert.fail("should not get fw version from AbstractMi1SFirmwareInfo");
|
||||||
} catch (UnsupportedOperationException expected) {}
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
|
||||||
Assert.assertNotEquals(info.getFirst().getFirmwareOffset(), info.getSecond().getFirmwareOffset());
|
Assert.assertNotEquals(info.getFirst().getFirmwareOffset(), info.getSecond().getFirmwareOffset());
|
||||||
Assert.assertFalse(Arrays.equals(info.getFirst().getFirmwareBytes(), info.getSecond().getFirmwareBytes()));
|
Assert.assertFalse(Arrays.equals(info.getFirst().getFirmwareBytes(), info.getSecond().getFirmwareBytes()));
|
||||||
@ -99,7 +100,8 @@ public class FirmwareTest {
|
|||||||
try {
|
try {
|
||||||
info.getSecond();
|
info.getSecond();
|
||||||
Assert.fail("should throw UnsuportedOperationException");
|
Assert.fail("should throw UnsuportedOperationException");
|
||||||
} catch (UnsupportedOperationException expected) {}
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
int calculatedLength = info.getFirmwareLength();
|
int calculatedLength = info.getFirmwareLength();
|
||||||
Assert.assertTrue("Unexpected firmware length: " + wholeFw.length, calculatedLength <= wholeFw.length);
|
Assert.assertTrue("Unexpected firmware length: " + wholeFw.length, calculatedLength <= wholeFw.length);
|
||||||
break;
|
break;
|
||||||
|
@ -19,6 +19,7 @@ public class GBMockApplication extends MockApplication {
|
|||||||
public Context getApplicationContext() {
|
public Context getApplicationContext() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PackageManager getPackageManager() {
|
public PackageManager getPackageManager() {
|
||||||
return mPackageManager;
|
return mPackageManager;
|
||||||
|
Loading…
Reference in New Issue
Block a user