mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
refactor onFetchActivityData() into onFetchRecordedData(dataTypes) to make it more generic
This removes misuse of testNewFunctionality() and support fetching GPS data and debug logs Fetching debug logs (Amazfit Bip/Cor) is now accessible in the debug activity Fetching GPS data can be done by swiping in the list activity. TODO: actually refresh list when fetching data is done :P Also fix some android studio warnings on the go...
This commit is contained in:
parent
c493df2423
commit
29a05f1d8f
@ -1,24 +1,10 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.adapter.AbstractItemAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.adapter.ItemWithDetailsAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummaryDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ItemWithDetails;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public abstract class AbstractListActivity<T> extends AbstractGBActivity {
|
||||
private AbstractItemAdapter<T> itemAdapter;
|
||||
@ -46,6 +32,6 @@ public abstract class AbstractListActivity<T> extends AbstractGBActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_list);
|
||||
itemListView = (ListView) findViewById(R.id.itemListView);
|
||||
itemListView = findViewById(R.id.itemListView);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -10,9 +11,13 @@ import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.adapter.ActivitySummariesAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySummary;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
@ -20,8 +25,18 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
|
||||
private int selectedIndex;
|
||||
|
||||
private GBDevice mGBDevice;
|
||||
private SwipeRefreshLayout swipeLayout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Must provide a device when invoking this activity");
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setItemAdapter(new ActivitySummariesAdapter(this));
|
||||
|
||||
@ -61,6 +76,13 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
return getItemListView().showContextMenu();
|
||||
}
|
||||
});
|
||||
swipeLayout = findViewById(R.id.list_activity_swipe_layout);
|
||||
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
fetchTrackData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void deleteItemAt(int position) {
|
||||
@ -79,4 +101,12 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
GB.toast(this, "Unable to display GPX track: " + e.getMessage(), Toast.LENGTH_LONG, GB.ERROR, e);
|
||||
}
|
||||
}
|
||||
private void fetchTrackData() {
|
||||
if (mGBDevice.isInitialized()) {
|
||||
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_GPS_TRACKS);
|
||||
} else {
|
||||
swipeLayout.setRefreshing(false);
|
||||
GB.toast(this, getString(R.string.device_not_connected), Toast.LENGTH_SHORT, GB.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Canvas;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@ -42,15 +41,14 @@ import android.support.v7.app.AppCompatDelegate;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import de.cketti.library.changelog.ChangeLog;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
@ -74,7 +72,6 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
private DeviceManager deviceManager;
|
||||
private ImageView background;
|
||||
|
||||
private List<GBDevice> deviceList;
|
||||
private GBDeviceAdapterv2 mGBDeviceAdapter;
|
||||
private RecyclerView deviceListView;
|
||||
|
||||
@ -84,7 +81,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
switch (action) {
|
||||
switch (Objects.requireNonNull(action)) {
|
||||
case GBApplication.ACTION_LANGUAGE_CHANGE:
|
||||
setLanguage(GBApplication.getLanguage(), true);
|
||||
break;
|
||||
@ -104,10 +101,10 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_controlcenterv2);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
FloatingActionButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -115,28 +112,30 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
}
|
||||
});
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.controlcenter_navigation_drawer_open, R.string.controlcenter_navigation_drawer_close);
|
||||
drawer.setDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
//end of material design boilerplate
|
||||
deviceManager = ((GBApplication) getApplication()).getDeviceManager();
|
||||
|
||||
deviceListView = (RecyclerView) findViewById(R.id.deviceListView);
|
||||
deviceListView = findViewById(R.id.deviceListView);
|
||||
deviceListView.setHasFixedSize(true);
|
||||
deviceListView.setLayoutManager(new LinearLayoutManager(this));
|
||||
background = (ImageView) findViewById(R.id.no_items_bg);
|
||||
background = findViewById(R.id.no_items_bg);
|
||||
|
||||
deviceList = deviceManager.getDevices();
|
||||
List<GBDevice> deviceList = deviceManager.getDevices();
|
||||
mGBDeviceAdapter = new GBDeviceAdapterv2(this, deviceList);
|
||||
|
||||
deviceListView.setAdapter(this.mGBDeviceAdapter);
|
||||
|
||||
/* uncomment to enable fixed-swipe to reveal more actions
|
||||
|
||||
ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
|
||||
ItemTouchHelper.LEFT , ItemTouchHelper.RIGHT) {
|
||||
@Override
|
||||
@ -167,9 +166,8 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
}
|
||||
});
|
||||
|
||||
//uncomment to enable fixed-swipe to reveal more actions
|
||||
//swipeToDismissTouchHelper.attachToRecyclerView(deviceListView);
|
||||
|
||||
swipeToDismissTouchHelper.attachToRecyclerView(deviceListView);
|
||||
*/
|
||||
|
||||
registerForContextMenu(deviceListView);
|
||||
|
||||
@ -226,7 +224,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
@ -237,7 +235,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
|
@ -40,16 +40,17 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_CHANNEL_ID;
|
||||
@ -63,23 +64,12 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
= "nodomain.freeyourgadget.gadgetbridge.DebugActivity.action.reply";
|
||||
|
||||
private Spinner sendTypeSpinner;
|
||||
private Button sendButton;
|
||||
private Button incomingCallButton;
|
||||
private Button outgoingCallButton;
|
||||
private Button startCallButton;
|
||||
private Button endCallButton;
|
||||
private Button testNotificationButton;
|
||||
private Button setMusicInfoButton;
|
||||
private Button setTimeButton;
|
||||
private Button rebootButton;
|
||||
private Button HeartRateButton;
|
||||
private Button testNewFunctionalityButton;
|
||||
|
||||
private EditText editContent;
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
switch (Objects.requireNonNull(intent.getAction())) {
|
||||
case ACTION_REPLY: {
|
||||
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
|
||||
CharSequence reply = remoteInput.getCharSequence(EXTRA_REPLY);
|
||||
@ -87,11 +77,9 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
GB.toast(context, "got wearable reply: " + reply, Toast.LENGTH_SHORT, GB.INFO);
|
||||
break;
|
||||
}
|
||||
case DeviceService.ACTION_HEARTRATE_MEASUREMENT: {
|
||||
int hrValue = intent.getIntExtra(DeviceService.EXTRA_HEART_RATE_VALUE, -1);
|
||||
GB.toast(DebugActivity.this, "Heart Rate measured: " + hrValue, Toast.LENGTH_LONG, GB.INFO);
|
||||
default:
|
||||
LOG.info("ignoring intent action " + intent.getAction());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -107,17 +95,17 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
|
||||
registerReceiver(mReceiver, filter); // for ACTION_REPLY
|
||||
|
||||
editContent = (EditText) findViewById(R.id.editContent);
|
||||
editContent = findViewById(R.id.editContent);
|
||||
|
||||
ArrayList<String> spinnerArray = new ArrayList<>();
|
||||
for (NotificationType notificationType : NotificationType.values()) {
|
||||
spinnerArray.add(notificationType.name());
|
||||
}
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, spinnerArray);
|
||||
sendTypeSpinner = (Spinner) findViewById(R.id.sendTypeSpinner);
|
||||
sendTypeSpinner = findViewById(R.id.sendTypeSpinner);
|
||||
sendTypeSpinner.setAdapter(spinnerArrayAdapter);
|
||||
|
||||
sendButton = (Button) findViewById(R.id.sendButton);
|
||||
Button sendButton = findViewById(R.id.sendButton);
|
||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -134,7 +122,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
incomingCallButton = (Button) findViewById(R.id.incomingCallButton);
|
||||
Button incomingCallButton = findViewById(R.id.incomingCallButton);
|
||||
incomingCallButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -144,7 +132,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
GBApplication.deviceService().onSetCallState(callSpec);
|
||||
}
|
||||
});
|
||||
outgoingCallButton = (Button) findViewById(R.id.outgoingCallButton);
|
||||
Button outgoingCallButton = findViewById(R.id.outgoingCallButton);
|
||||
outgoingCallButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -155,7 +143,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
startCallButton = (Button) findViewById(R.id.startCallButton);
|
||||
Button startCallButton = findViewById(R.id.startCallButton);
|
||||
startCallButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -164,7 +152,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
GBApplication.deviceService().onSetCallState(callSpec);
|
||||
}
|
||||
});
|
||||
endCallButton = (Button) findViewById(R.id.endCallButton);
|
||||
Button endCallButton = findViewById(R.id.endCallButton);
|
||||
endCallButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -174,15 +162,15 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
rebootButton = (Button) findViewById(R.id.rebootButton);
|
||||
Button rebootButton = findViewById(R.id.rebootButton);
|
||||
rebootButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
GBApplication.deviceService().onReboot();
|
||||
}
|
||||
});
|
||||
HeartRateButton = (Button) findViewById(R.id.HearRateButton);
|
||||
HeartRateButton.setOnClickListener(new View.OnClickListener() {
|
||||
Button heartRateButton = findViewById(R.id.HeartRateButton);
|
||||
heartRateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
GB.toast("Measuring heart rate, please wait...", Toast.LENGTH_LONG, GB.INFO);
|
||||
@ -190,7 +178,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
setMusicInfoButton = (Button) findViewById(R.id.setMusicInfoButton);
|
||||
Button setMusicInfoButton = findViewById(R.id.setMusicInfoButton);
|
||||
setMusicInfoButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -216,7 +204,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
setTimeButton = (Button) findViewById(R.id.setTimeButton);
|
||||
Button setTimeButton = findViewById(R.id.setTimeButton);
|
||||
setTimeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -224,7 +212,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
testNotificationButton = (Button) findViewById(R.id.testNotificationButton);
|
||||
Button testNotificationButton = findViewById(R.id.testNotificationButton);
|
||||
testNotificationButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -232,7 +220,15 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
testNewFunctionalityButton = (Button) findViewById(R.id.testNewFunctionality);
|
||||
Button fetchDebugLogsButton = findViewById(R.id.fetchDebugLogsButton);
|
||||
fetchDebugLogsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_DEBUGLOGS);
|
||||
}
|
||||
});
|
||||
|
||||
Button testNewFunctionalityButton = findViewById(R.id.testNewFunctionality);
|
||||
testNewFunctionalityButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -277,7 +273,9 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
.setContentIntent(pendingIntent)
|
||||
.extend(wearableExtender);
|
||||
|
||||
nManager.notify((int) System.currentTimeMillis(), ncomp.build());
|
||||
if (nManager != null) {
|
||||
nManager.notify((int) System.currentTimeMillis(), ncomp.build());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -297,7 +295,4 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
public interface DeviceSelectionCallback {
|
||||
void invoke(GBDevice device);
|
||||
}
|
||||
}
|
||||
|
@ -36,15 +36,12 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -52,6 +49,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.AbstractFragmentPagerAdap
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBFragmentActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
@ -59,16 +57,11 @@ import nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue;
|
||||
|
||||
public class ChartsActivity extends AbstractGBFragmentActivity implements ChartsHost {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChartsActivity.class);
|
||||
|
||||
private Button mPrevButton;
|
||||
private Button mNextButton;
|
||||
private TextView mDateControl;
|
||||
|
||||
private Date mStartDate;
|
||||
private Date mEndDate;
|
||||
private SwipeRefreshLayout swipeLayout;
|
||||
private NonSwipeableViewPager viewPager;
|
||||
|
||||
LimitedQueue mActivityAmountCache = new LimitedQueue(60);
|
||||
|
||||
@ -86,7 +79,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_charts_durationdialog);
|
||||
|
||||
durationLabel = (TextView) findViewById(R.id.charts_duration_label);
|
||||
durationLabel = findViewById(R.id.charts_duration_label);
|
||||
setDuration(mDuration);
|
||||
}
|
||||
|
||||
@ -103,7 +96,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
switch (action) {
|
||||
switch (Objects.requireNonNull(action)) {
|
||||
case GBDevice.ACTION_DEVICE_CHANGED:
|
||||
GBDevice dev = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
refreshBusyState(dev);
|
||||
@ -145,7 +138,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
||||
throw new IllegalArgumentException("Must provide a device when invoking this activity");
|
||||
}
|
||||
|
||||
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.activity_swipe_layout);
|
||||
swipeLayout = findViewById(R.id.activity_swipe_layout);
|
||||
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
@ -155,7 +148,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
||||
enableSwipeRefresh(true);
|
||||
|
||||
// Set up the ViewPager with the sections adapter.
|
||||
viewPager = (NonSwipeableViewPager) findViewById(R.id.charts_pager);
|
||||
NonSwipeableViewPager viewPager = findViewById(R.id.charts_pager);
|
||||
viewPager.setAdapter(getPagerAdapter());
|
||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
@ -172,8 +165,8 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
||||
}
|
||||
});
|
||||
|
||||
dateBar = (ViewGroup) findViewById(R.id.charts_date_bar);
|
||||
mDateControl = (TextView) findViewById(R.id.charts_text_date);
|
||||
dateBar = findViewById(R.id.charts_date_bar);
|
||||
mDateControl = findViewById(R.id.charts_text_date);
|
||||
mDateControl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -182,22 +175,20 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
||||
}
|
||||
});
|
||||
|
||||
mPrevButton = (Button) findViewById(R.id.charts_previous);
|
||||
Button mPrevButton = findViewById(R.id.charts_previous);
|
||||
mPrevButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
handlePrevButtonClicked();
|
||||
}
|
||||
});
|
||||
mNextButton = (Button) findViewById(R.id.charts_next);
|
||||
Button mNextButton = findViewById(R.id.charts_next);
|
||||
mNextButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
handleNextButtonClicked();
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout mainLayout = (LinearLayout) findViewById(R.id.charts_main_layout);
|
||||
}
|
||||
|
||||
private String formatDetailedDuration() {
|
||||
@ -284,7 +275,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
||||
|
||||
private void fetchActivityData() {
|
||||
if (getDevice().isInitialized()) {
|
||||
GBApplication.deviceService().onFetchActivityData();
|
||||
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_ACTIVITY);
|
||||
} else {
|
||||
swipeLayout.setRefreshing(false);
|
||||
GB.toast(this, getString(R.string.device_not_connected), Toast.LENGTH_SHORT, GB.ERROR);
|
||||
|
@ -22,6 +22,7 @@ import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v7.widget.CardView;
|
||||
@ -52,6 +53,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
@ -70,16 +72,16 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
this.deviceList = deviceList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public GBDeviceAdapterv2.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
public GBDeviceAdapterv2.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
this.parent = parent;
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.device_itemv2, parent, false);
|
||||
ViewHolder vh = new ViewHolder(view);
|
||||
return vh;
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, final int position) {
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
|
||||
final GBDevice device = deviceList.get(position);
|
||||
final DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
|
||||
|
||||
@ -144,7 +146,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showTransientSnackbar(R.string.busy_task_fetch_activity_data);
|
||||
GBApplication.deviceService().onFetchActivityData();
|
||||
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_ACTIVITY);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -364,45 +366,44 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
container = (CardView) view.findViewById(R.id.card_view);
|
||||
container = view.findViewById(R.id.card_view);
|
||||
|
||||
deviceImageView = (ImageView) view.findViewById(R.id.device_image);
|
||||
deviceNameLabel = (TextView) view.findViewById(R.id.device_name);
|
||||
deviceStatusLabel = (TextView) view.findViewById(R.id.device_status);
|
||||
deviceImageView = view.findViewById(R.id.device_image);
|
||||
deviceNameLabel = view.findViewById(R.id.device_name);
|
||||
deviceStatusLabel = view.findViewById(R.id.device_status);
|
||||
|
||||
//actions
|
||||
batteryStatusBox = (LinearLayout) view.findViewById(R.id.device_battery_status_box);
|
||||
batteryStatusLabel = (TextView) view.findViewById(R.id.battery_status);
|
||||
batteryIcon = (ImageView) view.findViewById(R.id.device_battery_status);
|
||||
fetchActivityDataBox = (LinearLayout) view.findViewById(R.id.device_action_fetch_activity_box);
|
||||
fetchActivityData = (ImageView) view.findViewById(R.id.device_action_fetch_activity);
|
||||
busyIndicator = (ProgressBar) view.findViewById(R.id.device_busy_indicator);
|
||||
takeScreenshotView = (ImageView) view.findViewById(R.id.device_action_take_screenshot);
|
||||
manageAppsView = (ImageView) view.findViewById(R.id.device_action_manage_apps);
|
||||
setAlarmsView = (ImageView) view.findViewById(R.id.device_action_set_alarms);
|
||||
showActivityGraphs = (ImageView) view.findViewById(R.id.device_action_show_activity_graphs);
|
||||
showActivityTracks = (ImageView) view.findViewById(R.id.device_action_show_activity_tracks);
|
||||
deviceInfoView = (ImageView) view.findViewById(R.id.device_info_image);
|
||||
batteryStatusBox = view.findViewById(R.id.device_battery_status_box);
|
||||
batteryStatusLabel = view.findViewById(R.id.battery_status);
|
||||
batteryIcon = view.findViewById(R.id.device_battery_status);
|
||||
fetchActivityDataBox = view.findViewById(R.id.device_action_fetch_activity_box);
|
||||
fetchActivityData = view.findViewById(R.id.device_action_fetch_activity);
|
||||
busyIndicator = view.findViewById(R.id.device_busy_indicator);
|
||||
takeScreenshotView = view.findViewById(R.id.device_action_take_screenshot);
|
||||
manageAppsView = view.findViewById(R.id.device_action_manage_apps);
|
||||
setAlarmsView = view.findViewById(R.id.device_action_set_alarms);
|
||||
showActivityGraphs = view.findViewById(R.id.device_action_show_activity_graphs);
|
||||
showActivityTracks = view.findViewById(R.id.device_action_show_activity_tracks);
|
||||
deviceInfoView = view.findViewById(R.id.device_info_image);
|
||||
|
||||
deviceInfoBox = (RelativeLayout) view.findViewById(R.id.device_item_infos_box);
|
||||
deviceInfoBox = view.findViewById(R.id.device_item_infos_box);
|
||||
//overflow
|
||||
deviceInfoList = (ListView) view.findViewById(R.id.device_item_infos);
|
||||
findDevice = (ImageView) view.findViewById(R.id.device_action_find);
|
||||
removeDevice = (ImageView) view.findViewById(R.id.device_action_remove);
|
||||
deviceInfoList = view.findViewById(R.id.device_item_infos);
|
||||
findDevice = view.findViewById(R.id.device_action_find);
|
||||
removeDevice = view.findViewById(R.id.device_action_remove);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void justifyListViewHeightBasedOnChildren(ListView listView) {
|
||||
private void justifyListViewHeightBasedOnChildren(ListView listView) {
|
||||
ArrayAdapter adapter = (ArrayAdapter) listView.getAdapter();
|
||||
|
||||
if (adapter == null) {
|
||||
return;
|
||||
}
|
||||
ViewGroup vg = listView;
|
||||
int totalHeight = 0;
|
||||
for (int i = 0; i < adapter.getCount(); i++) {
|
||||
View listItem = adapter.getView(i, null, vg);
|
||||
View listItem = adapter.getView(i, null, listView);
|
||||
listItem.measure(0, 0);
|
||||
totalHeight += listItem.getMeasuredHeight();
|
||||
}
|
||||
@ -444,11 +445,11 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
||||
private void showTransientSnackbar(int resource) {
|
||||
Snackbar snackbar = Snackbar.make(parent, resource, Snackbar.LENGTH_SHORT);
|
||||
|
||||
View snackbarView = snackbar.getView();
|
||||
//View snackbarView = snackbar.getView();
|
||||
|
||||
// change snackbar text color
|
||||
int snackbarTextId = android.support.design.R.id.snackbar_text;
|
||||
TextView textView = (TextView) snackbarView.findViewById(snackbarTextId);
|
||||
// change snackbar text color
|
||||
//int snackbarTextId = android.support.design.R.id.snackbar_text;
|
||||
//TextView textView = snackbarView.findViewById(snackbarTextId);
|
||||
//textView.setTextColor();
|
||||
//snackbarView.setBackgroundColor(Color.MAGENTA);
|
||||
snackbar.show();
|
||||
|
@ -67,7 +67,7 @@ public interface EventHandler {
|
||||
|
||||
void onAppReorder(UUID uuids[]);
|
||||
|
||||
void onFetchActivityData();
|
||||
void onFetchRecordedData(int dataTypes);
|
||||
|
||||
void onReboot();
|
||||
|
||||
|
@ -271,8 +271,9 @@ public class GBDeviceService implements DeviceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
Intent intent = createIntent().setAction(ACTION_FETCH_ACTIVITY_DATA);
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
Intent intent = createIntent().setAction(ACTION_FETCH_RECORDED_DATA)
|
||||
.putExtra(EXTRA_RECORDED_DATA_TYPES, dataTypes);
|
||||
invokeService(intent);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public interface DeviceService extends EventHandler {
|
||||
String ACTION_INSTALL = PREFIX + ".action.install";
|
||||
String ACTION_REBOOT = PREFIX + ".action.reboot";
|
||||
String ACTION_HEARTRATE_TEST = PREFIX + ".action.heartrate_test";
|
||||
String ACTION_FETCH_ACTIVITY_DATA = PREFIX + ".action.fetch_activity_data";
|
||||
String ACTION_FETCH_RECORDED_DATA = PREFIX + ".action.fetch_activity_data";
|
||||
String ACTION_DISCONNECT = PREFIX + ".action.disconnect";
|
||||
String ACTION_FIND_DEVICE = PREFIX + ".action.find_device";
|
||||
String ACTION_SET_CONSTANT_VIBRATION = PREFIX + ".action.set_constant_vibration";
|
||||
@ -103,8 +103,8 @@ public interface DeviceService extends EventHandler {
|
||||
String EXTRA_CONNECT_FIRST_TIME = "connect_first_time";
|
||||
String EXTRA_BOOLEAN_ENABLE = "enable_realtime_steps";
|
||||
String EXTRA_INTERVAL_SECONDS = "interval_seconds";
|
||||
|
||||
String EXTRA_WEATHER = "weather";
|
||||
String EXTRA_RECORDED_DATA_TYPES = "data_types";
|
||||
|
||||
/**
|
||||
* Use EXTRA_REALTIME_SAMPLE instead
|
||||
|
@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2018 Andreas Shimokawa
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
|
||||
public class RecordedDataTypes {
|
||||
public static int TYPE_ACTIVITY = 0x00000001;
|
||||
public static int TYPE_WORKOUTS = 0x00000002;
|
||||
public static int TYPE_GPS_TRACKS = 0x00000004;
|
||||
public static int TYPE_TEMPERATURE = 0x00000008;
|
||||
public static int TYPE_DEBUGLOGS = 0x00000010;
|
||||
|
||||
public static int TYPE_ALL = (int)0xffffffff;
|
||||
}
|
@ -86,7 +86,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_DI
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_ENABLE_HEARTRATE_SLEEP_SUPPORT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_ENABLE_REALTIME_HEARTRATE_MEASUREMENT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_ENABLE_REALTIME_STEPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_FETCH_ACTIVITY_DATA;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_FETCH_RECORDED_DATA;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_FIND_DEVICE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_HEARTRATE_TEST;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_INSTALL;
|
||||
@ -127,6 +127,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CAN
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES_TYPE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CONFIG;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CONNECT_FIRST_TIME;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_RECORDED_DATA_TYPES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FIND_START;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_INTERVAL_SECONDS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ALBUM;
|
||||
@ -401,8 +402,9 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
mDeviceSupport.onHeartRateTest();
|
||||
break;
|
||||
}
|
||||
case ACTION_FETCH_ACTIVITY_DATA: {
|
||||
mDeviceSupport.onFetchActivityData();
|
||||
case ACTION_FETCH_RECORDED_DATA: {
|
||||
int dataTypes = intent.getIntExtra(EXTRA_RECORDED_DATA_TYPES, 0);
|
||||
mDeviceSupport.onFetchRecordedData(dataTypes);
|
||||
break;
|
||||
}
|
||||
case ACTION_DISCONNECT: {
|
||||
|
@ -248,11 +248,11 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
if (checkBusy("fetch activity data")) {
|
||||
return;
|
||||
}
|
||||
delegate.onFetchActivityData();
|
||||
delegate.onFetchRecordedData(dataTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,11 +37,11 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiWeatherConditions
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
@ -49,9 +49,11 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.ConditionalWrit
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertCategory;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertNotificationProfile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.NewAlert;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.amazfitbip.operations.AmazfitBipFetchLogsOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiIcon;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationStrategy;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.FetchActivityOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.FetchSportsSummaryOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
||||
@ -283,12 +285,21 @@ public class AmazfitBipSupport extends MiBand2Support {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
try {
|
||||
// new AmazfitBipFetchLogsOperation(this).perform();
|
||||
new FetchSportsSummaryOperation(this).perform();
|
||||
// FIXME: currently only one data type supported, these are meant to be flags
|
||||
if (dataTypes == RecordedDataTypes.TYPE_ACTIVITY) {
|
||||
new FetchActivityOperation(this).perform();
|
||||
} else if (dataTypes == RecordedDataTypes.TYPE_GPS_TRACKS) {
|
||||
new FetchSportsSummaryOperation(this).perform();
|
||||
} else if (dataTypes == RecordedDataTypes.TYPE_DEBUGLOGS) {
|
||||
new AmazfitBipFetchLogsOperation(this).perform();
|
||||
}
|
||||
else {
|
||||
LOG.warn("fetching multiple data types at once is not supported yet");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to fetch logs", ex);
|
||||
LOG.error("Unable to fetch recorded data types" + dataTypes, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -539,7 +539,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
|
||||
if (syncHelper == null){
|
||||
syncHelper = new HPlusHandlerThread(gbDevice, getContext(), this);
|
||||
|
@ -362,7 +362,7 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
try {
|
||||
new FetchActivityOperation(this).perform();
|
||||
} catch (IOException ex) {
|
||||
|
@ -40,7 +40,6 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
@ -804,7 +803,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
try {
|
||||
new FetchActivityOperation(this).perform();
|
||||
} catch (IOException ex) {
|
||||
|
@ -299,7 +299,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
sendFetchCommand(No1F1Constants.CMD_FETCH_STEPS);
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* Copyright (C) 2018 ladbsoft
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* Copyright (C) 2018 ladbsoft
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.xwatch;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
@ -258,7 +258,7 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
try {
|
||||
if(builder == null) {
|
||||
builder = performInitialized("fetchActivityData");
|
||||
|
@ -180,7 +180,7 @@ public abstract class AbstractSerialDeviceSupport extends AbstractDeviceSupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
byte[] bytes = gbDeviceProtocol.encodeSynchronizeActivityData();
|
||||
sendToDevice(bytes);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class GB {
|
||||
PendingIntent disconnectPendingIntent = PendingIntent.getService(context, 0, deviceCommunicationServiceIntent, PendingIntent.FLAG_ONE_SHOT);
|
||||
builder.addAction(R.drawable.ic_notification_disconnected, context.getString(R.string.controlcenter_disconnect), disconnectPendingIntent);
|
||||
if (GBApplication.isRunningLollipopOrLater() && DeviceHelper.getInstance().getCoordinator(device).supportsActivityDataFetching()) { //for some reason this fails on KK
|
||||
deviceCommunicationServiceIntent.setAction(DeviceService.ACTION_FETCH_ACTIVITY_DATA);
|
||||
deviceCommunicationServiceIntent.setAction(DeviceService.ACTION_FETCH_RECORDED_DATA);
|
||||
PendingIntent fetchPendingIntent = PendingIntent.getService(context, 1, deviceCommunicationServiceIntent, PendingIntent.FLAG_ONE_SHOT);
|
||||
builder.addAction(R.drawable.ic_action_fetch_activity_data, context.getString(R.string.controlcenter_fetch_activity_data), fetchPendingIntent);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@
|
||||
android:text="set music info" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/HearRateButton"
|
||||
android:id="@+id/HeartRateButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
grid:layout_columnSpan="2"
|
||||
@ -124,7 +124,13 @@
|
||||
grid:layout_columnSpan="2"
|
||||
grid:layout_gravity="fill_horizontal"
|
||||
android:text="create test notification" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/fetchDebugLogsButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
grid:layout_columnSpan="2"
|
||||
grid:layout_gravity="fill_horizontal"
|
||||
android:text="Fetch device Debug Logs" />
|
||||
<Button
|
||||
android:id="@+id/testNewFunctionality"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -1,4 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/list_activity_swipe_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
@ -6,7 +10,7 @@
|
||||
<ListView
|
||||
android:id="@+id/itemListView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="false"></ListView>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
@ -49,7 +49,8 @@
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/controlcenter_delete_device"
|
||||
android:tint="?attr/textColorTertiary"
|
||||
card_view:srcCompat="@drawable/ic_remove_device" />
|
||||
card_view:srcCompat="@drawable/ic_remove_device"
|
||||
android:focusable="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
@ -63,7 +64,8 @@
|
||||
android:longClickable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:src="@drawable/ic_device_pebble"
|
||||
android:layout_marginTop="8dp" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:focusable="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/device_name"
|
||||
@ -104,7 +106,8 @@
|
||||
android:contentDescription="@string/candidate_item_device_image"
|
||||
android:tint="@color/secondarytext"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
card_view:srcCompat="@drawable/ic_more_vert" />
|
||||
card_view:srcCompat="@drawable/ic_more_vert"
|
||||
android:focusable="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/device_battery_status_box"
|
||||
@ -157,7 +160,8 @@
|
||||
android:contentDescription="@string/controlcenter_fetch_activity_data"
|
||||
android:scaleType="fitXY"
|
||||
android:tint="@color/secondarytext"
|
||||
card_view:srcCompat="@drawable/ic_action_fetch_activity_data" />
|
||||
card_view:srcCompat="@drawable/ic_action_fetch_activity_data"
|
||||
android:focusable="true" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/device_busy_indicator"
|
||||
@ -183,7 +187,8 @@
|
||||
android:padding="4dp"
|
||||
android:scaleType="fitXY"
|
||||
android:tint="@color/secondarytext"
|
||||
card_view:srcCompat="@drawable/ic_screenshot" />
|
||||
card_view:srcCompat="@drawable/ic_screenshot"
|
||||
android:focusable="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_manage_apps"
|
||||
@ -198,7 +203,8 @@
|
||||
android:padding="4dp"
|
||||
android:scaleType="fitXY"
|
||||
android:tint="@color/secondarytext"
|
||||
card_view:srcCompat="@drawable/ic_action_manage_apps" />
|
||||
card_view:srcCompat="@drawable/ic_action_manage_apps"
|
||||
android:focusable="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_set_alarms"
|
||||
@ -213,7 +219,8 @@
|
||||
android:padding="4dp"
|
||||
android:scaleType="fitXY"
|
||||
android:tint="@color/secondarytext"
|
||||
card_view:srcCompat="@drawable/ic_device_set_alarms" />
|
||||
card_view:srcCompat="@drawable/ic_device_set_alarms"
|
||||
android:focusable="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_show_activity_graphs"
|
||||
@ -228,7 +235,8 @@
|
||||
android:padding="4dp"
|
||||
android:scaleType="fitXY"
|
||||
android:tint="@color/secondarytext"
|
||||
card_view:srcCompat="@drawable/ic_activity_graphs" />
|
||||
card_view:srcCompat="@drawable/ic_activity_graphs"
|
||||
android:focusable="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_show_activity_tracks"
|
||||
@ -243,7 +251,8 @@
|
||||
android:padding="4dp"
|
||||
android:scaleType="fitXY"
|
||||
android:tint="@color/secondarytext"
|
||||
card_view:srcCompat="@drawable/ic_activity_tracks" />
|
||||
card_view:srcCompat="@drawable/ic_activity_tracks"
|
||||
android:focusable="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/device_action_find"
|
||||
@ -257,7 +266,8 @@
|
||||
android:padding="4dp"
|
||||
android:scaleType="fitXY"
|
||||
android:tint="@color/secondarytext"
|
||||
card_view:srcCompat="@drawable/ic_action_find_lost_device" />
|
||||
card_view:srcCompat="@drawable/ic_action_find_lost_device"
|
||||
android:focusable="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TestDeviceSupport extends AbstractDeviceSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchActivityData() {
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ import static org.junit.Assert.fail;
|
||||
*/
|
||||
public class LoggingTest extends TestBase {
|
||||
|
||||
public LoggingTest() throws Exception {
|
||||
public LoggingTest() {
|
||||
}
|
||||
|
||||
private Logging logging = GBApplication.getLogging();
|
||||
@ -38,8 +38,7 @@ public class LoggingTest extends TestBase {
|
||||
private File getLogFilesDir() {
|
||||
String dirName = System.getProperty(Logging.PROP_LOGFILES_DIR);
|
||||
if (dirName != null && dirName.length() > 5) {
|
||||
File dir = new File(dirName);
|
||||
return dir;
|
||||
return new File(dirName);
|
||||
}
|
||||
fail("Property " + Logging.PROP_LOGFILES_DIR + " has invalid value: " + dirName);
|
||||
return null; // not reached
|
||||
@ -48,7 +47,7 @@ public class LoggingTest extends TestBase {
|
||||
@Test
|
||||
public void testToggleLogging() {
|
||||
try {
|
||||
File dir = getLogFilesDir();
|
||||
getLogFilesDir();
|
||||
} catch (AssertionError ignored) {
|
||||
// expected, as not yet set up
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user