mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-06 08:14:24 +01:00
Migration to Java 1.8 and support lib 26+
+ lambdas + removing casts in findViewById + using support views as based for custom views (#34)
This commit is contained in:
@@ -71,14 +71,14 @@ public class FeaturesActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_features);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// ensure that Bluetooth exists
|
||||
if (!ensureBLEExists())
|
||||
finish();
|
||||
|
||||
final DrawerLayout drawer = mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
final DrawerLayout drawer = mDrawerLayout = findViewById(R.id.drawer_layout);
|
||||
drawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
|
||||
// Set the drawer toggle as the DrawerListener
|
||||
@@ -95,7 +95,7 @@ public class FeaturesActivity extends AppCompatActivity {
|
||||
setupPluginsInDrawer((ViewGroup) drawer.findViewById(R.id.plugin_container));
|
||||
|
||||
// configure the app grid
|
||||
final GridView grid = (GridView) findViewById(R.id.grid);
|
||||
final GridView grid = findViewById(R.id.grid);
|
||||
grid.setAdapter(new AppAdapter(this));
|
||||
grid.setEmptyView(findViewById(android.R.id.empty));
|
||||
|
||||
@@ -165,28 +165,25 @@ public class FeaturesActivity extends AppCompatActivity {
|
||||
final ResolveInfo nrfConnectInfo = pm.resolveActivity(nrfConnectIntent, 0);
|
||||
|
||||
// configure link to nRF Connect
|
||||
final TextView nrfConnectItem = (TextView) container.findViewById(R.id.link_mcp);
|
||||
final TextView nrfConnectItem = container.findViewById(R.id.link_mcp);
|
||||
if (nrfConnectInfo == null) {
|
||||
nrfConnectItem.setTextColor(Color.GRAY);
|
||||
ColorMatrix grayscale = new ColorMatrix();
|
||||
grayscale.setSaturation(0.0f);
|
||||
nrfConnectItem.getCompoundDrawables()[0].mutate().setColorFilter(new ColorMatrixColorFilter(grayscale));
|
||||
}
|
||||
nrfConnectItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
Intent action = nrfConnectIntent;
|
||||
if (nrfConnectInfo == null)
|
||||
action = new Intent(Intent.ACTION_VIEW, Uri.parse(NRF_CONNECT_MARKET_URI));
|
||||
action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
startActivity(action);
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
mDrawerLayout.closeDrawers();
|
||||
nrfConnectItem.setOnClickListener(v -> {
|
||||
Intent action = nrfConnectIntent;
|
||||
if (nrfConnectInfo == null)
|
||||
action = new Intent(Intent.ACTION_VIEW, Uri.parse(NRF_CONNECT_MARKET_URI));
|
||||
action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
startActivity(action);
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
mDrawerLayout.closeDrawers();
|
||||
});
|
||||
|
||||
// look for other plug-ins
|
||||
@@ -196,21 +193,18 @@ public class FeaturesActivity extends AppCompatActivity {
|
||||
final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0);
|
||||
for (final ResolveInfo info : appList) {
|
||||
final View item = inflater.inflate(R.layout.drawer_plugin, container, false);
|
||||
final ImageView icon = (ImageView) item.findViewById(android.R.id.icon);
|
||||
final TextView label = (TextView) item.findViewById(android.R.id.text1);
|
||||
final ImageView icon = item.findViewById(android.R.id.icon);
|
||||
final TextView label = item.findViewById(android.R.id.text1);
|
||||
|
||||
label.setText(info.loadLabel(pm));
|
||||
icon.setImageDrawable(info.loadIcon(pm));
|
||||
item.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
final Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
mDrawerLayout.closeDrawers();
|
||||
}
|
||||
item.setOnClickListener(v -> {
|
||||
final Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
mDrawerLayout.closeDrawers();
|
||||
});
|
||||
container.addView(item);
|
||||
}
|
||||
|
||||
@@ -40,39 +40,36 @@ public class SplashscreenActivity extends Activity {
|
||||
setContentView(R.layout.activity_splashscreen);
|
||||
|
||||
// Jump to SensorsActivity after DELAY milliseconds
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Intent newIntent = new Intent(SplashscreenActivity.this, FeaturesActivity.class);
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
new Handler().postDelayed(() -> {
|
||||
final Intent newIntent = new Intent(SplashscreenActivity.this, FeaturesActivity.class);
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
|
||||
// Handle NFC message, if app was opened using NFC AAR record
|
||||
final Intent intent = getIntent();
|
||||
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
|
||||
final Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
|
||||
if (rawMsgs != null) {
|
||||
for (int i = 0; i < rawMsgs.length; i++) {
|
||||
final NdefMessage msg = (NdefMessage) rawMsgs[i];
|
||||
final NdefRecord[] records = msg.getRecords();
|
||||
// Handle NFC message, if app was opened using NFC AAR record
|
||||
final Intent intent = getIntent();
|
||||
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
|
||||
final Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
|
||||
if (rawMsgs != null) {
|
||||
for (Parcelable rawMsg : rawMsgs) {
|
||||
final NdefMessage msg = (NdefMessage) rawMsg;
|
||||
final NdefRecord[] records = msg.getRecords();
|
||||
|
||||
for (NdefRecord record : records) {
|
||||
if (record.getTnf() == NdefRecord.TNF_MIME_MEDIA) {
|
||||
switch (record.toMimeType()) {
|
||||
case FeaturesActivity.EXTRA_APP:
|
||||
newIntent.putExtra(FeaturesActivity.EXTRA_APP, new String(record.getPayload()));
|
||||
break;
|
||||
case FeaturesActivity.EXTRA_ADDRESS:
|
||||
newIntent.putExtra(FeaturesActivity.EXTRA_ADDRESS, invertEndianness(record.getPayload()));
|
||||
break;
|
||||
}
|
||||
for (NdefRecord record : records) {
|
||||
if (record.getTnf() == NdefRecord.TNF_MIME_MEDIA) {
|
||||
switch (record.toMimeType()) {
|
||||
case FeaturesActivity.EXTRA_APP:
|
||||
newIntent.putExtra(FeaturesActivity.EXTRA_APP, new String(record.getPayload()));
|
||||
break;
|
||||
case FeaturesActivity.EXTRA_ADDRESS:
|
||||
newIntent.putExtra(FeaturesActivity.EXTRA_ADDRESS, invertEndianness(record.getPayload()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
startActivity(newIntent);
|
||||
finish();
|
||||
}
|
||||
startActivity(newIntent);
|
||||
finish();
|
||||
}, DELAY);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ public class AppAdapter extends BaseAdapter {
|
||||
|
||||
final ViewHolder holder = new ViewHolder();
|
||||
holder.view = view;
|
||||
holder.icon = (ImageView) view.findViewById(R.id.icon);
|
||||
holder.label = (TextView) view.findViewById(R.id.label);
|
||||
holder.icon = view.findViewById(R.id.icon);
|
||||
holder.label = view.findViewById(R.id.label);
|
||||
view.setTag(holder);
|
||||
}
|
||||
|
||||
@@ -102,14 +102,11 @@ public class AppAdapter extends BaseAdapter {
|
||||
final ViewHolder holder = (ViewHolder) view.getTag();
|
||||
holder.icon.setImageDrawable(info.loadIcon(pm));
|
||||
holder.label.setText(info.loadLabel(pm).toString().toUpperCase(Locale.US));
|
||||
holder.view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
holder.view.setOnClickListener(v -> {
|
||||
final Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
mContext.startActivity(intent);
|
||||
});
|
||||
|
||||
return view;
|
||||
|
||||
@@ -197,7 +197,7 @@ public class ExpandableListActivity extends AppCompatActivity implements
|
||||
public void onContentChanged() {
|
||||
super.onContentChanged();
|
||||
View emptyView = findViewById(R.id.empty);
|
||||
mList = (ExpandableListView) findViewById(R.id.list);
|
||||
mList = findViewById(R.id.list);
|
||||
if (mList == null) {
|
||||
throw new RuntimeException(
|
||||
"Your content must have a ExpandableListView whose id attribute is " +
|
||||
|
||||
@@ -53,14 +53,14 @@ public class BPMActivity extends BleProfileActivity implements BPMManagerCallbac
|
||||
}
|
||||
|
||||
private void setGUI() {
|
||||
mSystolicView = (TextView) findViewById(R.id.systolic);
|
||||
mSystolicUnitView = (TextView) findViewById(R.id.systolic_unit);
|
||||
mDiastolicView = (TextView) findViewById(R.id.diastolic);
|
||||
mDiastolicUnitView = (TextView) findViewById(R.id.diastolic_unit);
|
||||
mMeanAPView = (TextView) findViewById(R.id.mean_ap);
|
||||
mMeanAPUnitView = (TextView) findViewById(R.id.mean_ap_unit);
|
||||
mPulseView = (TextView) findViewById(R.id.pulse);
|
||||
mTimestampView = (TextView) findViewById(R.id.timestamp);
|
||||
mSystolicView = findViewById(R.id.systolic);
|
||||
mSystolicUnitView = findViewById(R.id.systolic_unit);
|
||||
mDiastolicView = findViewById(R.id.diastolic);
|
||||
mDiastolicUnitView = findViewById(R.id.diastolic_unit);
|
||||
mMeanAPView = findViewById(R.id.mean_ap);
|
||||
mMeanAPUnitView = findViewById(R.id.mean_ap_unit);
|
||||
mPulseView = findViewById(R.id.pulse);
|
||||
mTimestampView = findViewById(R.id.timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,59 +114,47 @@ public class BPMActivity extends BleProfileActivity implements BPMManagerCallbac
|
||||
|
||||
@Override
|
||||
public void onBloodPressureMeasurementRead(final BluetoothDevice device, final float systolic, final float diastolic, final float meanArterialPressure, final int unit) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mSystolicView.setText(String.valueOf(systolic));
|
||||
mDiastolicView.setText(String.valueOf(diastolic));
|
||||
mMeanAPView.setText(String.valueOf(meanArterialPressure));
|
||||
runOnUiThread(() -> {
|
||||
mSystolicView.setText(String.valueOf(systolic));
|
||||
mDiastolicView.setText(String.valueOf(diastolic));
|
||||
mMeanAPView.setText(String.valueOf(meanArterialPressure));
|
||||
|
||||
mSystolicUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
mDiastolicUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
mMeanAPUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
}
|
||||
mSystolicUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
mDiastolicUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
mMeanAPUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateCuffPressureRead(final BluetoothDevice device, final float cuffPressure, final int unit) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mSystolicView.setText(String.valueOf(cuffPressure));
|
||||
mDiastolicView.setText(R.string.not_available_value);
|
||||
mMeanAPView.setText(R.string.not_available_value);
|
||||
runOnUiThread(() -> {
|
||||
mSystolicView.setText(String.valueOf(cuffPressure));
|
||||
mDiastolicView.setText(R.string.not_available_value);
|
||||
mMeanAPView.setText(R.string.not_available_value);
|
||||
|
||||
mSystolicUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
mDiastolicUnitView.setText(null);
|
||||
mMeanAPUnitView.setText(null);
|
||||
}
|
||||
mSystolicUnitView.setText(unit == UNIT_mmHG ? R.string.bpm_unit_mmhg : R.string.bpm_unit_kpa);
|
||||
mDiastolicUnitView.setText(null);
|
||||
mMeanAPUnitView.setText(null);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPulseRateRead(final BluetoothDevice device, final float pulseRate) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (pulseRate >= 0)
|
||||
mPulseView.setText(String.valueOf(pulseRate));
|
||||
else
|
||||
mPulseView.setText(R.string.not_available_value);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (pulseRate >= 0)
|
||||
mPulseView.setText(String.valueOf(pulseRate));
|
||||
else
|
||||
mPulseView.setText(R.string.not_available_value);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimestampRead(final BluetoothDevice device, final Calendar calendar) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (calendar != null)
|
||||
mTimestampView.setText(getString(R.string.bpm_timestamp, calendar));
|
||||
else
|
||||
mTimestampView.setText(R.string.not_available);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (calendar != null)
|
||||
mTimestampView.setText(getString(R.string.bpm_timestamp, calendar));
|
||||
else
|
||||
mTimestampView.setText(R.string.not_available);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,49 +62,37 @@ public class CGMSActivity extends BleProfileServiceReadyActivity<CGMService.CGMS
|
||||
}
|
||||
|
||||
private void setGUI() {
|
||||
mRecordsListView = (ListView) findViewById(R.id.list);
|
||||
mRecordsListView = findViewById(R.id.list);
|
||||
mControlPanelStd = findViewById(R.id.cgms_control_std);
|
||||
mControlPanelAbort = findViewById(R.id.cgms_control_abort);
|
||||
|
||||
findViewById(R.id.action_last).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
clearRecords();
|
||||
if (mBinder != null) {
|
||||
mBinder.clear();
|
||||
mBinder.getLastRecord();
|
||||
}
|
||||
findViewById(R.id.action_last).setOnClickListener(v -> {
|
||||
clearRecords();
|
||||
if (mBinder != null) {
|
||||
mBinder.clear();
|
||||
mBinder.getLastRecord();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.action_all).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
findViewById(R.id.action_all).setOnClickListener(v -> {
|
||||
clearRecords();
|
||||
if (mBinder != null) {
|
||||
clearRecords();
|
||||
if (mBinder != null) {
|
||||
clearRecords();
|
||||
mBinder.getAllRecords();
|
||||
}
|
||||
mBinder.getAllRecords();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.action_abort).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mBinder != null) {
|
||||
mBinder.abort();
|
||||
}
|
||||
findViewById(R.id.action_abort).setOnClickListener(v -> {
|
||||
if (mBinder != null) {
|
||||
mBinder.abort();
|
||||
}
|
||||
});
|
||||
|
||||
// create popup menu attached to the button More
|
||||
findViewById(R.id.action_more).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupMenu menu = new PopupMenu(CGMSActivity.this, v);
|
||||
menu.setOnMenuItemClickListener(CGMSActivity.this);
|
||||
MenuInflater inflater = menu.getMenuInflater();
|
||||
inflater.inflate(R.menu.gls_more, menu.getMenu());
|
||||
menu.show();
|
||||
}
|
||||
findViewById(R.id.action_more).setOnClickListener(v -> {
|
||||
PopupMenu menu = new PopupMenu(CGMSActivity.this, v);
|
||||
menu.setOnMenuItemClickListener(CGMSActivity.this);
|
||||
MenuInflater inflater = menu.getMenuInflater();
|
||||
inflater.inflate(R.menu.gls_more, menu.getMenu());
|
||||
menu.show();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -171,13 +159,10 @@ public class CGMSActivity extends BleProfileServiceReadyActivity<CGMService.CGMS
|
||||
}
|
||||
|
||||
private void setOperationInProgress(final boolean progress) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// setSupportProgressBarIndeterminateVisibility(progress);
|
||||
mControlPanelStd.setVisibility(!progress ? View.VISIBLE : View.GONE);
|
||||
mControlPanelAbort.setVisibility(progress ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
// setSupportProgressBarIndeterminateVisibility(progress);
|
||||
mControlPanelStd.setVisibility(!progress ? View.VISIBLE : View.GONE);
|
||||
mControlPanelAbort.setVisibility(progress ? View.VISIBLE : View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,6 @@ import no.nordicsemi.android.nrftoolbox.parser.RecordAccessControlPointParser;
|
||||
import no.nordicsemi.android.nrftoolbox.profile.BleManager;
|
||||
import no.nordicsemi.android.nrftoolbox.utility.DebugLogger;
|
||||
|
||||
/**
|
||||
* Created by rora on 10.05.2016.
|
||||
*/
|
||||
public class CGMSManager extends BleManager<CGMSManagerCallbacks> {
|
||||
private static final String TAG = "CGMSManager";
|
||||
|
||||
|
||||
@@ -26,9 +26,6 @@ import android.bluetooth.BluetoothDevice;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.profile.BleManagerCallbacks;
|
||||
|
||||
/**
|
||||
* Created by rora on 10.05.2016.
|
||||
*/
|
||||
public interface CGMSManagerCallbacks extends BleManagerCallbacks {
|
||||
/**
|
||||
* Called when new CGM value has been obtained from the sensor.
|
||||
|
||||
@@ -3,9 +3,6 @@ package no.nordicsemi.android.nrftoolbox.cgms;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Created by rora on 02.09.2016.
|
||||
*/
|
||||
public class CGMSRecord implements Parcelable{
|
||||
/** Record sequence number. */
|
||||
protected int sequenceNumber;
|
||||
|
||||
@@ -15,9 +15,6 @@ import java.util.Locale;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
/**
|
||||
* Created by rora on 02.09.2016.
|
||||
*/
|
||||
public class CGMSRecordsAdapter extends BaseAdapter {
|
||||
private final static SimpleDateFormat mTimeFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.US);
|
||||
|
||||
@@ -50,9 +47,9 @@ public class CGMSRecordsAdapter extends BaseAdapter {
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.activity_feature_cgms_item, parent, false);
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.concentration = (TextView) convertView.findViewById(R.id.cgms_concentration);
|
||||
viewHolder.time = (TextView) convertView.findViewById(R.id.time);
|
||||
viewHolder.details = (TextView) convertView.findViewById(R.id.details);
|
||||
viewHolder.concentration = convertView.findViewById(R.id.cgms_concentration);
|
||||
viewHolder.time = convertView.findViewById(R.id.time);
|
||||
viewHolder.details = convertView.findViewById(R.id.details);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
|
||||
@@ -18,9 +18,6 @@ import no.nordicsemi.android.nrftoolbox.R;
|
||||
import no.nordicsemi.android.nrftoolbox.profile.BleManager;
|
||||
import no.nordicsemi.android.nrftoolbox.profile.BleProfileService;
|
||||
|
||||
/**
|
||||
* Created by rora on 05.09.2016.
|
||||
*/
|
||||
public class CGMService extends BleProfileService implements CGMSManagerCallbacks {
|
||||
private static final String ACTION_DISCONNECT = "no.nordicsemi.android.nrftoolbox.cgms.ACTION_DISCONNECT";
|
||||
public static final String BROADCAST_NEW_CGMS_VALUE = "no.nordicsemi.android.nrftoolbox.cgms.BROADCAST_NEW_CGMS_VALUE";
|
||||
|
||||
@@ -71,14 +71,14 @@ public class CSCActivity extends BleProfileServiceReadyActivity<CSCService.CSCBi
|
||||
}
|
||||
|
||||
private void setGui() {
|
||||
mSpeedView = (TextView) findViewById(R.id.speed);
|
||||
mSpeedUnitView = (TextView) findViewById(R.id.speed_unit);
|
||||
mCadenceView = (TextView) findViewById(R.id.cadence);
|
||||
mDistanceView = (TextView) findViewById(R.id.distance);
|
||||
mDistanceUnitView = (TextView) findViewById(R.id.distance_unit);
|
||||
mTotalDistanceView = (TextView) findViewById(R.id.distance_total);
|
||||
mTotalDistanceUnitView = (TextView) findViewById(R.id.distance_total_unit);
|
||||
mGearRatioView = (TextView) findViewById(R.id.ratio);
|
||||
mSpeedView = findViewById(R.id.speed);
|
||||
mSpeedUnitView = findViewById(R.id.speed_unit);
|
||||
mCadenceView = findViewById(R.id.cadence);
|
||||
mDistanceView = findViewById(R.id.distance);
|
||||
mDistanceUnitView = findViewById(R.id.distance_unit);
|
||||
mTotalDistanceView = findViewById(R.id.distance_total);
|
||||
mTotalDistanceUnitView = findViewById(R.id.distance_total_unit);
|
||||
mGearRatioView = findViewById(R.id.ratio);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
@@ -179,15 +179,12 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks<Cu
|
||||
mTextPercentage.setText(R.string.dfu_status_completed);
|
||||
if (mResumed) {
|
||||
// let's wait a bit until we cancel the notification. When canceled immediately it will be recreated by service again.
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onTransferCompleted();
|
||||
new Handler().postDelayed(() -> {
|
||||
onTransferCompleted();
|
||||
|
||||
// if this activity is still open and upload process was completed, cancel the notification
|
||||
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(DfuService.NOTIFICATION_ID);
|
||||
}
|
||||
// if this activity is still open and upload process was completed, cancel the notification
|
||||
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(DfuService.NOTIFICATION_ID);
|
||||
}, 200);
|
||||
} else {
|
||||
// Save that the DFU process has finished
|
||||
@@ -199,15 +196,12 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks<Cu
|
||||
public void onDfuAborted(final String deviceAddress) {
|
||||
mTextPercentage.setText(R.string.dfu_status_aborted);
|
||||
// let's wait a bit until we cancel the notification. When canceled immediately it will be recreated by service again.
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onUploadCanceled();
|
||||
new Handler().postDelayed(() -> {
|
||||
onUploadCanceled();
|
||||
|
||||
// if this activity is still open and upload process was completed, cancel the notification
|
||||
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(DfuService.NOTIFICATION_ID);
|
||||
}
|
||||
// if this activity is still open and upload process was completed, cancel the notification
|
||||
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(DfuService.NOTIFICATION_ID);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
@@ -228,13 +222,10 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks<Cu
|
||||
showErrorMessage(message);
|
||||
|
||||
// We have to wait a bit before canceling notification. This is called before DfuService creates the last notification.
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// if this activity is still open and upload process was completed, cancel the notification
|
||||
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(DfuService.NOTIFICATION_ID);
|
||||
}
|
||||
new Handler().postDelayed(() -> {
|
||||
// if this activity is still open and upload process was completed, cancel the notification
|
||||
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(DfuService.NOTIFICATION_ID);
|
||||
}, 200);
|
||||
} else {
|
||||
mDfuError = message;
|
||||
@@ -303,22 +294,22 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks<Cu
|
||||
}
|
||||
|
||||
private void setGUI() {
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mDeviceNameView = (TextView) findViewById(R.id.device_name);
|
||||
mFileNameView = (TextView) findViewById(R.id.file_name);
|
||||
mFileTypeView = (TextView) findViewById(R.id.file_type);
|
||||
mFileSizeView = (TextView) findViewById(R.id.file_size);
|
||||
mFileStatusView = (TextView) findViewById(R.id.file_status);
|
||||
mSelectFileButton = (Button) findViewById(R.id.action_select_file);
|
||||
mDeviceNameView = findViewById(R.id.device_name);
|
||||
mFileNameView = findViewById(R.id.file_name);
|
||||
mFileTypeView = findViewById(R.id.file_type);
|
||||
mFileSizeView = findViewById(R.id.file_size);
|
||||
mFileStatusView = findViewById(R.id.file_status);
|
||||
mSelectFileButton = findViewById(R.id.action_select_file);
|
||||
|
||||
mUploadButton = (Button) findViewById(R.id.action_upload);
|
||||
mConnectButton = (Button) findViewById(R.id.action_connect);
|
||||
mTextPercentage = (TextView) findViewById(R.id.textviewProgress);
|
||||
mTextUploading = (TextView) findViewById(R.id.textviewUploading);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar_file);
|
||||
mUploadButton = findViewById(R.id.action_upload);
|
||||
mConnectButton = findViewById(R.id.action_connect);
|
||||
mTextPercentage = findViewById(R.id.textviewProgress);
|
||||
mTextUploading = findViewById(R.id.textviewUploading);
|
||||
mProgressBar = findViewById(R.id.progressbar_file);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (isDfuServiceRunning()) {
|
||||
@@ -575,21 +566,15 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks<Cu
|
||||
// Ask the user for the Init packet file if HEX or BIN files are selected. In case of a ZIP file the Init packets should be included in the ZIP.
|
||||
if (statusOk && fileType != DfuService.TYPE_AUTO) {
|
||||
new AlertDialog.Builder(this).setTitle(R.string.dfu_file_init_title).setMessage(R.string.dfu_file_init_message)
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
mInitFilePath = null;
|
||||
mInitFileStreamUri = null;
|
||||
}
|
||||
}).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType(DfuService.MIME_TYPE_OCTET_STREAM);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
startActivityForResult(intent, SELECT_INIT_FILE_REQ);
|
||||
}
|
||||
}).show();
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> {
|
||||
mInitFilePath = null;
|
||||
mInitFileStreamUri = null;
|
||||
}).setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType(DfuService.MIME_TYPE_OCTET_STREAM);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
startActivityForResult(intent, SELECT_INIT_FILE_REQ);
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,35 +612,24 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks<Cu
|
||||
}
|
||||
// Show a dialog with file types
|
||||
new AlertDialog.Builder(this).setTitle(R.string.dfu_file_type_title)
|
||||
.setSingleChoiceItems(R.array.dfu_file_type, index, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
mFileTypeTmp = DfuService.TYPE_AUTO;
|
||||
break;
|
||||
case 1:
|
||||
mFileTypeTmp = DfuService.TYPE_SOFT_DEVICE;
|
||||
break;
|
||||
case 2:
|
||||
mFileTypeTmp = DfuService.TYPE_BOOTLOADER;
|
||||
break;
|
||||
case 3:
|
||||
mFileTypeTmp = DfuService.TYPE_APPLICATION;
|
||||
break;
|
||||
}
|
||||
.setSingleChoiceItems(R.array.dfu_file_type, index, (dialog, which) -> {
|
||||
switch (which) {
|
||||
case 0:
|
||||
mFileTypeTmp = DfuService.TYPE_AUTO;
|
||||
break;
|
||||
case 1:
|
||||
mFileTypeTmp = DfuService.TYPE_SOFT_DEVICE;
|
||||
break;
|
||||
case 2:
|
||||
mFileTypeTmp = DfuService.TYPE_BOOTLOADER;
|
||||
break;
|
||||
case 3:
|
||||
mFileTypeTmp = DfuService.TYPE_APPLICATION;
|
||||
break;
|
||||
}
|
||||
}).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
openFileChooser();
|
||||
}
|
||||
}).setNeutralButton(R.string.dfu_file_info, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
final ZipInfoFragment fragment = new ZipInfoFragment();
|
||||
fragment.show(getSupportFragmentManager(), "help_fragment");
|
||||
}
|
||||
}).setPositiveButton(R.string.ok, (dialog, which) -> openFileChooser()).setNeutralButton(R.string.dfu_file_info, (dialog, which) -> {
|
||||
final ZipInfoFragment fragment = new ZipInfoFragment();
|
||||
fragment.show(getSupportFragmentManager(), "help_fragment");
|
||||
}).setNegativeButton(R.string.cancel, null).show();
|
||||
}
|
||||
|
||||
@@ -669,27 +643,19 @@ public class DfuActivity extends AppCompatActivity implements LoaderCallbacks<Cu
|
||||
} else {
|
||||
// there is no any file browser app, let's try to download one
|
||||
final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null);
|
||||
final ListView appsList = (ListView) customView.findViewById(android.R.id.list);
|
||||
final ListView appsList = customView.findViewById(android.R.id.list);
|
||||
appsList.setAdapter(new FileBrowserAppsAdapter(this));
|
||||
appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
appsList.setItemChecked(0, true);
|
||||
new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView)
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
dialog.dismiss();
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||
final int pos = appsList.getCheckedItemPosition();
|
||||
if (pos >= 0) {
|
||||
final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos];
|
||||
final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
|
||||
startActivity(storeIntent);
|
||||
}
|
||||
}).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
final int pos = appsList.getCheckedItemPosition();
|
||||
if (pos >= 0) {
|
||||
final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos];
|
||||
final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
|
||||
startActivity(storeIntent);
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class UploadCancelFragment extends DialogFragment {
|
||||
private CancelFragmentListener mListener;
|
||||
|
||||
public interface CancelFragmentListener {
|
||||
public void onCancelUpload();
|
||||
void onCancelUpload();
|
||||
}
|
||||
|
||||
public static UploadCancelFragment getInstance() {
|
||||
@@ -66,22 +66,14 @@ public class UploadCancelFragment extends DialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity()).setTitle(R.string.dfu_confirmation_dialog_title).setMessage(R.string.dfu_upload_dialog_cancel_message).setCancelable(false)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int whichButton) {
|
||||
final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getActivity());
|
||||
final Intent pauseAction = new Intent(DfuService.BROADCAST_ACTION);
|
||||
pauseAction.putExtra(DfuService.EXTRA_ACTION, DfuService.ACTION_ABORT);
|
||||
manager.sendBroadcast(pauseAction);
|
||||
.setPositiveButton(R.string.yes, (dialog, whichButton) -> {
|
||||
final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getActivity());
|
||||
final Intent pauseAction = new Intent(DfuService.BROADCAST_ACTION);
|
||||
pauseAction.putExtra(DfuService.EXTRA_ACTION, DfuService.ACTION_ABORT);
|
||||
manager.sendBroadcast(pauseAction);
|
||||
|
||||
mListener.onCancelUpload();
|
||||
}
|
||||
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
dialog.cancel();
|
||||
}
|
||||
}).create();
|
||||
mListener.onCancelUpload();
|
||||
}).setNegativeButton(R.string.no, (dialog, which) -> dialog.cancel()).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ public class ExpandableRecordAdapter extends BaseExpandableListAdapter {
|
||||
view = mInflater.inflate(R.layout.activity_feature_gls_item, parent, false);
|
||||
|
||||
final GroupViewHolder holder = new GroupViewHolder();
|
||||
holder.time = (TextView) view.findViewById(R.id.time);
|
||||
holder.details = (TextView) view.findViewById(R.id.details);
|
||||
holder.concentration = (TextView) view.findViewById(R.id.gls_concentration);
|
||||
holder.time = view.findViewById(R.id.time);
|
||||
holder.details = view.findViewById(R.id.details);
|
||||
holder.concentration = view.findViewById(R.id.gls_concentration);
|
||||
view.setTag(holder);
|
||||
}
|
||||
final GlucoseRecord record = (GlucoseRecord) getGroup(position);
|
||||
@@ -172,8 +172,8 @@ public class ExpandableRecordAdapter extends BaseExpandableListAdapter {
|
||||
if (view == null) {
|
||||
view = mInflater.inflate(R.layout.activity_feature_gls_subitem, parent, false);
|
||||
final ChildViewHolder holder = new ChildViewHolder();
|
||||
holder.title = (TextView) view.findViewById(android.R.id.text1);
|
||||
holder.details = (TextView) view.findViewById(android.R.id.text2);
|
||||
holder.title = view.findViewById(android.R.id.text1);
|
||||
holder.details = view.findViewById(android.R.id.text2);
|
||||
view.setTag(holder);
|
||||
}
|
||||
final Pair<String, String> value = (Pair<String, String>) getChild(groupPosition, childPosition);
|
||||
|
||||
@@ -58,39 +58,21 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements
|
||||
}
|
||||
|
||||
private void setGUI() {
|
||||
mUnitView = (TextView) findViewById(R.id.unit);
|
||||
mUnitView = findViewById(R.id.unit);
|
||||
mControlPanelStd = findViewById(R.id.gls_control_std);
|
||||
mControlPanelAbort = findViewById(R.id.gls_control_abort);
|
||||
|
||||
findViewById(R.id.action_last).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mGlucoseManager.getLastRecord();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.action_all).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mGlucoseManager.getAllRecords();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.action_abort).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mGlucoseManager.abort();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.action_last).setOnClickListener(v -> mGlucoseManager.getLastRecord());
|
||||
findViewById(R.id.action_all).setOnClickListener(v -> mGlucoseManager.getAllRecords());
|
||||
findViewById(R.id.action_abort).setOnClickListener(v -> mGlucoseManager.abort());
|
||||
|
||||
// create popup menu attached to the button More
|
||||
findViewById(R.id.action_more).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupMenu menu = new PopupMenu(GlucoseActivity.this, v);
|
||||
menu.setOnMenuItemClickListener(GlucoseActivity.this);
|
||||
MenuInflater inflater = menu.getMenuInflater();
|
||||
inflater.inflate(R.menu.gls_more, menu.getMenu());
|
||||
menu.show();
|
||||
}
|
||||
findViewById(R.id.action_more).setOnClickListener(v -> {
|
||||
PopupMenu menu = new PopupMenu(GlucoseActivity.this, v);
|
||||
menu.setOnMenuItemClickListener(GlucoseActivity.this);
|
||||
MenuInflater inflater = menu.getMenuInflater();
|
||||
inflater.inflate(R.menu.gls_more, menu.getMenu());
|
||||
menu.show();
|
||||
});
|
||||
|
||||
setListAdapter(mAdapter = new ExpandableRecordAdapter(this, mGlucoseManager));
|
||||
@@ -148,13 +130,9 @@ public class GlucoseActivity extends BleProfileExpandableListActivity implements
|
||||
}
|
||||
|
||||
private void setOperationInProgress(final boolean progress) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// setSupportProgressBarIndeterminateVisibility(progress);
|
||||
mControlPanelStd.setVisibility(!progress ? View.VISIBLE : View.GONE);
|
||||
mControlPanelAbort.setVisibility(progress ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
mControlPanelStd.setVisibility(!progress ? View.VISIBLE : View.GONE);
|
||||
mControlPanelAbort.setVisibility(progress ? View.VISIBLE : View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -233,16 +233,13 @@ public class GlucoseManager extends BleManager<GlucoseManagerCallbacks> {
|
||||
// record.context.HbA1c = 213.3f;
|
||||
|
||||
// data set modifications must be done in UI thread
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// insert the new record to storage
|
||||
mRecords.put(record.sequenceNumber, record);
|
||||
mHandler.post(() -> {
|
||||
// insert the new record to storage
|
||||
mRecords.put(record.sequenceNumber, record);
|
||||
|
||||
// if there is no context information following the measurement data, notify callback about the new record
|
||||
if (!contextInfoFollows)
|
||||
mCallbacks.onDatasetChanged(gatt.getDevice());
|
||||
}
|
||||
// if there is no context information following the measurement data, notify callback about the new record
|
||||
if (!contextInfoFollows)
|
||||
mCallbacks.onDatasetChanged(gatt.getDevice());
|
||||
});
|
||||
} else if (GM_CONTEXT_CHARACTERISTIC.equals(uuid)) {
|
||||
Logger.a(mLogSession, "\"" + GlucoseMeasurementContextParser.parse(characteristic) + "\" received");
|
||||
|
||||
@@ -76,14 +76,14 @@ public class HRSActivity extends BleProfileActivity implements HRSManagerCallbac
|
||||
|
||||
private void setGUI() {
|
||||
mLineGraph = LineGraphView.getLineGraphView();
|
||||
mHRSValue = (TextView) findViewById(R.id.text_hrs_value);
|
||||
mHRSPosition = (TextView) findViewById(R.id.text_hrs_position);
|
||||
mHRSValue = findViewById(R.id.text_hrs_value);
|
||||
mHRSPosition = findViewById(R.id.text_hrs_position);
|
||||
showGraph();
|
||||
}
|
||||
|
||||
private void showGraph() {
|
||||
mGraphView = mLineGraph.getView(this);
|
||||
ViewGroup layout = (ViewGroup) findViewById(R.id.graph_hrs);
|
||||
ViewGroup layout = findViewById(R.id.graph_hrs);
|
||||
layout.addView(mGraphView);
|
||||
}
|
||||
|
||||
@@ -184,27 +184,21 @@ public class HRSActivity extends BleProfileActivity implements HRSManagerCallbac
|
||||
}
|
||||
|
||||
private void setHRSValueOnView(final int value) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (value >= MIN_POSITIVE_VALUE && value <= MAX_HR_VALUE) {
|
||||
mHRSValue.setText(Integer.toString(value));
|
||||
} else {
|
||||
mHRSValue.setText(R.string.not_available_value);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (value >= MIN_POSITIVE_VALUE && value <= MAX_HR_VALUE) {
|
||||
mHRSValue.setText(Integer.toString(value));
|
||||
} else {
|
||||
mHRSValue.setText(R.string.not_available_value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setHRSPositionOnView(final String position) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (position != null) {
|
||||
mHRSPosition.setText(position);
|
||||
} else {
|
||||
mHRSPosition.setText(R.string.not_available);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (position != null) {
|
||||
mHRSPosition.setText(position);
|
||||
} else {
|
||||
mHRSPosition.setText(R.string.not_available);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -233,13 +227,10 @@ public class HRSActivity extends BleProfileActivity implements HRSManagerCallbac
|
||||
@Override
|
||||
public void onDeviceDisconnected(final BluetoothDevice device) {
|
||||
super.onDeviceDisconnected(device);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mHRSValue.setText(R.string.not_available_value);
|
||||
mHRSPosition.setText(R.string.not_available);
|
||||
stopShowGraph();
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
mHRSValue.setText(R.string.not_available_value);
|
||||
mHRSPosition.setText(R.string.not_available);
|
||||
stopShowGraph();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -87,8 +87,8 @@ public class HTSActivity extends BleProfileServiceReadyActivity<HTSService.RSCBi
|
||||
}
|
||||
|
||||
private void setGUI() {
|
||||
mHTSValue = (TextView) findViewById(R.id.text_hts_value);
|
||||
mHTSUnit = (TextView) findViewById(R.id.text_hts_unit);
|
||||
mHTSValue = findViewById(R.id.text_hts_value);
|
||||
mHTSUnit = findViewById(R.id.text_hts_unit);
|
||||
|
||||
if (mValueC != null)
|
||||
mHTSValue.setText(String.valueOf(mValueC));
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
@@ -1188,15 +1188,12 @@ public abstract class BleManager<E extends BleManagerCallbacks> implements ILogg
|
||||
final int delay = bonded ? 1600 : 0; // around 1600 ms is required when connection interval is ~45ms.
|
||||
if (delay > 0)
|
||||
Logger.d(mLogSession, "wait(" + delay + ")");
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Some proximity tags (e.g. nRF PROXIMITY) initialize bonding automatically when connected.
|
||||
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_BONDING) {
|
||||
Logger.v(mLogSession, "Discovering Services...");
|
||||
Logger.d(mLogSession, "gatt.discoverServices()");
|
||||
gatt.discoverServices();
|
||||
}
|
||||
mHandler.postDelayed(() -> {
|
||||
// Some proximity tags (e.g. nRF PROXIMITY) initialize bonding automatically when connected.
|
||||
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_BONDING) {
|
||||
Logger.v(mLogSession, "Discovering Services...");
|
||||
Logger.d(mLogSession, "gatt.discoverServices()");
|
||||
gatt.discoverServices();
|
||||
}
|
||||
}, delay);
|
||||
} else {
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
// The onCreateView class should... create the view
|
||||
onCreateView(savedInstanceState);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// Common nRF Toolbox view references are obtained here
|
||||
@@ -127,9 +127,9 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
protected final void setUpView() {
|
||||
// set GUI
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mConnectButton = (Button) findViewById(R.id.action_connect);
|
||||
mDeviceNameView = (TextView) findViewById(R.id.device_name);
|
||||
mBatteryLevelView = (TextView) findViewById(R.id.battery);
|
||||
mConnectButton = findViewById(R.id.action_connect);
|
||||
mDeviceNameView = findViewById(R.id.device_name);
|
||||
mBatteryLevelView = findViewById(R.id.battery);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,12 +256,7 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
@Override
|
||||
public void onDeviceConnected(final BluetoothDevice device) {
|
||||
mDeviceConnected = true;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mConnectButton.setText(R.string.action_disconnect);
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnect));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,25 +268,19 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
public void onDeviceDisconnected(final BluetoothDevice device) {
|
||||
mDeviceConnected = false;
|
||||
mBleManager.close();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mConnectButton.setText(R.string.action_connect);
|
||||
mDeviceNameView.setText(getDefaultDeviceName());
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
mConnectButton.setText(R.string.action_connect);
|
||||
mDeviceNameView.setText(getDefaultDeviceName());
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLinklossOccur(final BluetoothDevice device) {
|
||||
mDeviceConnected = false;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -323,12 +312,9 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
|
||||
@Override
|
||||
public void onBatteryValueReceived(final BluetoothDevice device, final int value) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(getString(R.string.battery, value));
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(getString(R.string.battery, value));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -349,12 +335,7 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
* @param message a message to be shown
|
||||
*/
|
||||
protected void showToast(final String message) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleProfileActivity.this, message, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,12 +344,7 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
* @param messageResId an resource id of the message to be shown
|
||||
*/
|
||||
protected void showToast(final int messageResId) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileActivity.this, messageResId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleProfileActivity.this, messageResId, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,12 +404,9 @@ public abstract class BleProfileActivity extends AppCompatActivity implements Bl
|
||||
* @see #getFilterUUID()
|
||||
*/
|
||||
private void showDeviceScanningDialog(final UUID filter) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ScannerFragment dialog = ScannerFragment.getInstance(filter);
|
||||
dialog.show(getSupportFragmentManager(), "scan_fragment");
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
final ScannerFragment dialog = ScannerFragment.getInstance(filter);
|
||||
dialog.show(getSupportFragmentManager(), "scan_fragment");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
// The onCreateView class should... create the view
|
||||
onCreateView(savedInstanceState);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// Common nRF Toolbox view references are obtained here
|
||||
@@ -127,9 +127,9 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
protected final void setUpView() {
|
||||
// set GUI
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mConnectButton = (Button) findViewById(R.id.action_connect);
|
||||
mDeviceNameView = (TextView) findViewById(R.id.device_name);
|
||||
mBatteryLevelView = (TextView) findViewById(R.id.battery);
|
||||
mConnectButton = findViewById(R.id.action_connect);
|
||||
mDeviceNameView = findViewById(R.id.device_name);
|
||||
mBatteryLevelView = findViewById(R.id.battery);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,12 +256,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
@Override
|
||||
public void onDeviceConnected(final BluetoothDevice device) {
|
||||
mDeviceConnected = true;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mConnectButton.setText(R.string.action_disconnect);
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> mConnectButton.setText(R.string.action_disconnect));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,25 +268,19 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
public void onDeviceDisconnected(final BluetoothDevice device) {
|
||||
mDeviceConnected = false;
|
||||
mBleManager.close();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mConnectButton.setText(R.string.action_connect);
|
||||
mDeviceNameView.setText(getDefaultDeviceName());
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
mConnectButton.setText(R.string.action_connect);
|
||||
mDeviceNameView.setText(getDefaultDeviceName());
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLinklossOccur(final BluetoothDevice device) {
|
||||
mDeviceConnected = false;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(R.string.not_available);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -323,12 +312,9 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
|
||||
@Override
|
||||
public void onBatteryValueReceived(final BluetoothDevice device, final int value) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(getString(R.string.battery, value));
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (mBatteryLevelView != null)
|
||||
mBatteryLevelView.setText(getString(R.string.battery, value));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -349,12 +335,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
* @param message a message to be shown
|
||||
*/
|
||||
protected void showToast(final String message) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileExpandableListActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleProfileExpandableListActivity.this, message, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,12 +344,7 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
* @param messageResId an resource id of the message to be shown
|
||||
*/
|
||||
protected void showToast(final int messageResId) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileExpandableListActivity.this, messageResId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleProfileExpandableListActivity.this, messageResId, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,12 +404,9 @@ public abstract class BleProfileExpandableListActivity extends ExpandableListAct
|
||||
* @see #getFilterUUID()
|
||||
*/
|
||||
private void showDeviceScanningDialog(final UUID filter) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ScannerFragment dialog = ScannerFragment.getInstance(filter);
|
||||
dialog.show(getSupportFragmentManager(), "scan_fragment");
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
final ScannerFragment dialog = ScannerFragment.getInstance(filter);
|
||||
dialog.show(getSupportFragmentManager(), "scan_fragment");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -531,12 +531,7 @@ public abstract class BleProfileService extends Service implements BleManagerCal
|
||||
* an resource id of the message to be shown
|
||||
*/
|
||||
protected void showToast(final int messageResId) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileService.this, messageResId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
mHandler.post(() -> Toast.makeText(BleProfileService.this, messageResId, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,12 +541,7 @@ public abstract class BleProfileService extends Service implements BleManagerCal
|
||||
* a message to be shown
|
||||
*/
|
||||
protected void showToast(final String message) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileService.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
mHandler.post(() -> Toast.makeText(BleProfileService.this, message, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -235,7 +235,7 @@ public abstract class BleProfileServiceReadyActivity<E extends BleProfileService
|
||||
// The onCreateView class should... create the view
|
||||
onCreateView(savedInstanceState);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// Common nRF Toolbox view references are obtained here
|
||||
@@ -363,9 +363,9 @@ public abstract class BleProfileServiceReadyActivity<E extends BleProfileService
|
||||
protected final void setUpView() {
|
||||
// set GUI
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mConnectButton = (Button) findViewById(R.id.action_connect);
|
||||
mDeviceNameView = (TextView) findViewById(R.id.device_name);
|
||||
mBatteryLevelView = (TextView) findViewById(R.id.battery);
|
||||
mConnectButton = findViewById(R.id.action_connect);
|
||||
mDeviceNameView = findViewById(R.id.device_name);
|
||||
mBatteryLevelView = findViewById(R.id.battery);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -578,12 +578,7 @@ public abstract class BleProfileServiceReadyActivity<E extends BleProfileService
|
||||
* @param message a message to be shown
|
||||
*/
|
||||
protected void showToast(final String message) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileServiceReadyActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleProfileServiceReadyActivity.this, message, Toast.LENGTH_LONG).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,12 +587,7 @@ public abstract class BleProfileServiceReadyActivity<E extends BleProfileService
|
||||
* @param messageResId an resource id of the message to be shown
|
||||
*/
|
||||
protected void showToast(final int messageResId) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleProfileServiceReadyActivity.this, messageResId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleProfileServiceReadyActivity.this, messageResId, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,12 +91,7 @@ public abstract class BleMulticonnectProfileService extends Service implements B
|
||||
// On older phones (tested on Nexus 4 with Android 5.0.1) the Bluetooth requires some time
|
||||
// after it has been enabled before some operations can start. Starting the GATT server here
|
||||
// without a delay is very likely to cause a DeadObjectException from BluetoothManager#openGattServer(...).
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onBluetoothEnabled();
|
||||
}
|
||||
}, 600);
|
||||
mHandler.postDelayed(() -> onBluetoothEnabled(), 600);
|
||||
break;
|
||||
case BluetoothAdapter.STATE_TURNING_OFF:
|
||||
case BluetoothAdapter.STATE_OFF:
|
||||
@@ -556,12 +551,7 @@ public abstract class BleMulticonnectProfileService extends Service implements B
|
||||
* an resource id of the message to be shown
|
||||
*/
|
||||
protected void showToast(final int messageResId) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleMulticonnectProfileService.this, messageResId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
mHandler.post(() -> Toast.makeText(BleMulticonnectProfileService.this, messageResId, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -571,12 +561,7 @@ public abstract class BleMulticonnectProfileService extends Service implements B
|
||||
* a message to be shown
|
||||
*/
|
||||
protected void showToast(final String message) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleMulticonnectProfileService.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
mHandler.post(() -> Toast.makeText(BleMulticonnectProfileService.this, message, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -197,7 +197,7 @@ public abstract class BleMulticonnectProfileServiceReadyActivity<E extends BleMu
|
||||
// The onCreateView class should... create the view
|
||||
onCreateView(savedInstanceState);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// Common nRF Toolbox view references are obtained here
|
||||
@@ -466,12 +466,7 @@ public abstract class BleMulticonnectProfileServiceReadyActivity<E extends BleMu
|
||||
* @param message a message to be shown
|
||||
*/
|
||||
protected void showToast(final String message) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleMulticonnectProfileServiceReadyActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleMulticonnectProfileServiceReadyActivity.this, message, Toast.LENGTH_LONG).show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,12 +475,7 @@ public abstract class BleMulticonnectProfileServiceReadyActivity<E extends BleMu
|
||||
* @param messageResId an resource id of the message to be shown
|
||||
*/
|
||||
protected void showToast(final int messageResId) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(BleMulticonnectProfileServiceReadyActivity.this, messageResId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
runOnUiThread(() -> Toast.makeText(BleMulticonnectProfileServiceReadyActivity.this, messageResId, Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,33 +97,27 @@ public class DeviceAdapter extends RecyclerView.Adapter<DeviceAdapter.ViewHolder
|
||||
public ViewHolder(final View itemView) {
|
||||
super(itemView);
|
||||
|
||||
nameView = (TextView) itemView.findViewById(R.id.name);
|
||||
addressView = (TextView) itemView.findViewById(R.id.address);
|
||||
batteryView = (TextView) itemView.findViewById(R.id.battery);
|
||||
actionButton = (ImageButton) itemView.findViewById(R.id.action_find_silent);
|
||||
nameView = itemView.findViewById(R.id.name);
|
||||
addressView = itemView.findViewById(R.id.address);
|
||||
batteryView = itemView.findViewById(R.id.battery);
|
||||
actionButton = itemView.findViewById(R.id.action_find_silent);
|
||||
|
||||
// Configure FIND / SILENT button
|
||||
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
final int position = getAdapterPosition();
|
||||
final BluetoothDevice device = mDevices.get(position);
|
||||
final boolean on = mService.toggleImmediateAlert(device);
|
||||
actionButton.setOnClickListener(v -> {
|
||||
final int position = getAdapterPosition();
|
||||
final BluetoothDevice device = mDevices.get(position);
|
||||
final boolean on = mService.toggleImmediateAlert(device);
|
||||
|
||||
actionButton.setImageResource(on ? R.drawable.ic_stat_notify_proximity_silent : R.drawable.ic_stat_notify_proximity_find);
|
||||
}
|
||||
actionButton.setImageResource(on ? R.drawable.ic_stat_notify_proximity_silent : R.drawable.ic_stat_notify_proximity_find);
|
||||
});
|
||||
|
||||
// Configure Disconnect button
|
||||
itemView.findViewById(R.id.action_disconnect).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
final int position = getAdapterPosition();
|
||||
final BluetoothDevice device = mDevices.get(position);
|
||||
mService.disconnect(device);
|
||||
// The device might have not been connected, so there will be no callback
|
||||
onDeviceRemoved(device);
|
||||
}
|
||||
itemView.findViewById(R.id.action_disconnect).setOnClickListener(v -> {
|
||||
final int position = getAdapterPosition();
|
||||
final BluetoothDevice device = mDevices.get(position);
|
||||
mService.disconnect(device);
|
||||
// The device might have not been connected, so there will be no callback
|
||||
onDeviceRemoved(device);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ProximityActivity extends BleMulticonnectProfileServiceReadyActivit
|
||||
}
|
||||
|
||||
private void setGUI() {
|
||||
final RecyclerView recyclerView = mDevicesView = (RecyclerView) findViewById(android.R.id.list);
|
||||
final RecyclerView recyclerView = mDevicesView = findViewById(android.R.id.list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
|
||||
}
|
||||
|
||||
@@ -201,18 +201,15 @@ public class ProximityServerManager {
|
||||
public void onServiceAdded(final int status, final BluetoothGattService service) {
|
||||
if (status == BluetoothGatt.GATT_SUCCESS) {
|
||||
// Adding another service from callback thread fails on Samsung S4 with Android 4.3
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (IMMEDIATE_ALERT_SERVICE_UUID.equals(service.getUuid())) {
|
||||
addLinklossService();
|
||||
} else {
|
||||
mServerReady = true;
|
||||
// Both services has been added
|
||||
if (mOnServerOpenCallback != null)
|
||||
mOnServerOpenCallback.onGattServerOpen();
|
||||
mOnServerOpenCallback = null;
|
||||
}
|
||||
mHandler.post(() -> {
|
||||
if (IMMEDIATE_ALERT_SERVICE_UUID.equals(service.getUuid())) {
|
||||
addLinklossService();
|
||||
} else {
|
||||
mServerReady = true;
|
||||
// Both services has been added
|
||||
if (mOnServerOpenCallback != null)
|
||||
mOnServerOpenCallback.onGattServerOpen();
|
||||
mOnServerOpenCallback = null;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -72,15 +72,15 @@ public class RSCActivity extends BleProfileServiceReadyActivity<RSCService.RSCBi
|
||||
}
|
||||
|
||||
private void setGui() {
|
||||
mSpeedView = (TextView) findViewById(R.id.speed);
|
||||
mSpeedUnitView = (TextView) findViewById(R.id.speed_unit);
|
||||
mCadenceView = (TextView) findViewById(R.id.cadence);
|
||||
mDistanceView = (TextView) findViewById(R.id.distance);
|
||||
mDistanceUnitView = (TextView) findViewById(R.id.distance_unit);
|
||||
mTotalDistanceView = (TextView) findViewById(R.id.total_distance);
|
||||
mTotalDistanceUnitView = (TextView) findViewById(R.id.total_distance_unit);
|
||||
mStridesCountView = (TextView) findViewById(R.id.strides);
|
||||
mActivityView = (TextView) findViewById(R.id.activity);
|
||||
mSpeedView = findViewById(R.id.speed);
|
||||
mSpeedUnitView = findViewById(R.id.speed_unit);
|
||||
mCadenceView = findViewById(R.id.cadence);
|
||||
mDistanceView = findViewById(R.id.distance);
|
||||
mDistanceUnitView = findViewById(R.id.distance_unit);
|
||||
mTotalDistanceView = findViewById(R.id.total_distance);
|
||||
mTotalDistanceUnitView = findViewById(R.id.total_distance_unit);
|
||||
mStridesCountView = findViewById(R.id.strides);
|
||||
mActivityView = findViewById(R.id.activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
@@ -182,9 +182,9 @@ public class DeviceListAdapter extends BaseAdapter {
|
||||
if (view == null) {
|
||||
view = inflater.inflate(R.layout.device_list_row, parent, false);
|
||||
final ViewHolder holder = new ViewHolder();
|
||||
holder.name = (TextView) view.findViewById(R.id.name);
|
||||
holder.address = (TextView) view.findViewById(R.id.address);
|
||||
holder.rssi = (ImageView) view.findViewById(R.id.rssi);
|
||||
holder.name = view.findViewById(R.id.name);
|
||||
holder.address = view.findViewById(R.id.address);
|
||||
holder.rssi = view.findViewById(R.id.rssi);
|
||||
view.setTag(holder);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
package no.nordicsemi.android.nrftoolbox.scanner;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
@@ -150,35 +149,29 @@ public class ScannerFragment extends DialogFragment {
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_device_selection, null);
|
||||
final ListView listview = (ListView) dialogView.findViewById(android.R.id.list);
|
||||
final ListView listview = dialogView.findViewById(android.R.id.list);
|
||||
|
||||
listview.setEmptyView(dialogView.findViewById(android.R.id.empty));
|
||||
listview.setAdapter(mAdapter = new DeviceListAdapter(getActivity()));
|
||||
|
||||
builder.setTitle(R.string.scanner_title);
|
||||
final AlertDialog dialog = builder.setView(dialogView).create();
|
||||
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
|
||||
stopScan();
|
||||
dialog.dismiss();
|
||||
final ExtendedBluetoothDevice d = (ExtendedBluetoothDevice) mAdapter.getItem(position);
|
||||
mListener.onDeviceSelected(d.device, d.name);
|
||||
}
|
||||
listview.setOnItemClickListener((parent, view, position, id) -> {
|
||||
stopScan();
|
||||
dialog.dismiss();
|
||||
final ExtendedBluetoothDevice d = (ExtendedBluetoothDevice) mAdapter.getItem(position);
|
||||
mListener.onDeviceSelected(d.device, d.name);
|
||||
});
|
||||
|
||||
mPermissionRationale = dialogView.findViewById(R.id.permission_rationale); // this is not null only on API23+
|
||||
|
||||
mScanButton = (Button) dialogView.findViewById(R.id.action_cancel);
|
||||
mScanButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.action_cancel) {
|
||||
if (mIsScanning) {
|
||||
dialog.cancel();
|
||||
} else {
|
||||
startScan();
|
||||
}
|
||||
mScanButton = dialogView.findViewById(R.id.action_cancel);
|
||||
mScanButton.setOnClickListener(v -> {
|
||||
if (v.getId() == R.id.action_cancel) {
|
||||
if (mIsScanning) {
|
||||
dialog.cancel();
|
||||
} else {
|
||||
startScan();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -246,12 +239,9 @@ public class ScannerFragment extends DialogFragment {
|
||||
scanner.startScan(filters, settings, scanCallback);
|
||||
|
||||
mIsScanning = true;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mIsScanning) {
|
||||
stopScan();
|
||||
}
|
||||
mHandler.postDelayed(() -> {
|
||||
if (mIsScanning) {
|
||||
stopScan();
|
||||
}
|
||||
}, SCAN_DURATION);
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class TemplateActivity extends BleProfileServiceReadyActivity<TemplateSer
|
||||
|
||||
private void setGUI() {
|
||||
// TODO assign your views to fields
|
||||
mValueView = (TextView) findViewById(R.id.value);
|
||||
mValueUnitView = (TextView) findViewById(R.id.value_unit);
|
||||
mValueView = findViewById(R.id.value);
|
||||
mValueUnitView = findViewById(R.id.value_unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar_actionbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
@@ -189,27 +189,24 @@ public class UARTActivity extends BleProfileServiceReadyActivity<UARTService.UAR
|
||||
return;
|
||||
|
||||
if (!mPreferences.getBoolean(PREFS_WEAR_SYNCED, false)) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Cursor cursor = mDatabaseHelper.getConfigurations();
|
||||
try {
|
||||
while (cursor.moveToNext()) {
|
||||
final long id = cursor.getLong(0 /* _ID */);
|
||||
try {
|
||||
final String xml = cursor.getString(2 /* XML */);
|
||||
final Format format = new Format(new HyphenStyle());
|
||||
final Serializer serializer = new Persister(format);
|
||||
final UartConfiguration configuration = serializer.read(UartConfiguration.class, xml);
|
||||
mWearableSynchronizer.onConfigurationAddedOrEdited(id, configuration).await();
|
||||
} catch (final Exception e) {
|
||||
Log.w(TAG, "Deserializing configuration with id " + id + " failed", e);
|
||||
}
|
||||
new Thread(() -> {
|
||||
final Cursor cursor = mDatabaseHelper.getConfigurations();
|
||||
try {
|
||||
while (cursor.moveToNext()) {
|
||||
final long id = cursor.getLong(0 /* _ID */);
|
||||
try {
|
||||
final String xml = cursor.getString(2 /* XML */);
|
||||
final Format format = new Format(new HyphenStyle());
|
||||
final Serializer serializer = new Persister(format);
|
||||
final UartConfiguration configuration = serializer.read(UartConfiguration.class, xml);
|
||||
mWearableSynchronizer.onConfigurationAddedOrEdited(id, configuration).await();
|
||||
} catch (final Exception e) {
|
||||
Log.w(TAG, "Deserializing configuration with id " + id + " failed", e);
|
||||
}
|
||||
mPreferences.edit().putBoolean(PREFS_WEAR_SYNCED, true).apply();
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
mPreferences.edit().putBoolean(PREFS_WEAR_SYNCED, true).apply();
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
@@ -235,7 +232,7 @@ public class UARTActivity extends BleProfileServiceReadyActivity<UARTService.UAR
|
||||
setContentView(R.layout.activity_feature_uart);
|
||||
|
||||
// Setup the sliding pane if it exists
|
||||
final SlidingPaneLayout slidingPane = mSlider = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
|
||||
final SlidingPaneLayout slidingPane = mSlider = findViewById(R.id.sliding_pane);
|
||||
if (slidingPane != null) {
|
||||
slidingPane.setSliderFadeColor(Color.TRANSPARENT);
|
||||
slidingPane.setShadowResourceLeft(R.drawable.shadow_r);
|
||||
@@ -392,14 +389,11 @@ public class UARTActivity extends BleProfileServiceReadyActivity<UARTService.UAR
|
||||
mWearableSynchronizer.onConfigurationDeleted(id);
|
||||
refreshConfigurations();
|
||||
|
||||
final Snackbar snackbar = Snackbar.make(mSlider, R.string.uart_configuration_deleted, Snackbar.LENGTH_INDEFINITE).setAction(R.string.uart_action_undo, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
final long id = mDatabaseHelper.restoreDeletedServerConfiguration(name);
|
||||
if (id >= 0)
|
||||
mWearableSynchronizer.onConfigurationAddedOrEdited(id, removedConfiguration);
|
||||
refreshConfigurations();
|
||||
}
|
||||
final Snackbar snackbar = Snackbar.make(mContainer, R.string.uart_configuration_deleted, Snackbar.LENGTH_INDEFINITE).setAction(R.string.uart_action_undo, v -> {
|
||||
final long id1 = mDatabaseHelper.restoreDeletedServerConfiguration(name);
|
||||
if (id1 >= 0)
|
||||
mWearableSynchronizer.onConfigurationAddedOrEdited(id1, removedConfiguration);
|
||||
refreshConfigurations();
|
||||
});
|
||||
snackbar.setDuration(5000); // This is not an error
|
||||
snackbar.show();
|
||||
@@ -489,24 +483,16 @@ public class UARTActivity extends BleProfileServiceReadyActivity<UARTService.UAR
|
||||
} else {
|
||||
// there is no any file browser app, let's try to download one
|
||||
final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null);
|
||||
final ListView appsList = (ListView) customView.findViewById(android.R.id.list);
|
||||
final ListView appsList = customView.findViewById(android.R.id.list);
|
||||
appsList.setAdapter(new FileBrowserAppsAdapter(this));
|
||||
appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
appsList.setItemChecked(0, true);
|
||||
new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
final int pos = appsList.getCheckedItemPosition();
|
||||
if (pos >= 0) {
|
||||
final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos];
|
||||
final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
|
||||
startActivity(storeIntent);
|
||||
}
|
||||
new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView).setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()).setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
final int pos = appsList.getCheckedItemPosition();
|
||||
if (pos >= 0) {
|
||||
final String query = getResources().getStringArray(R.array.dfu_app_file_browser_action)[pos];
|
||||
final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
|
||||
startActivity(storeIntent);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
@@ -677,12 +663,7 @@ public class UARTActivity extends BleProfileServiceReadyActivity<UARTService.UAR
|
||||
|
||||
final ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
|
||||
anim.setDuration(200);
|
||||
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(final ValueAnimator animation) {
|
||||
getWindow().setStatusBarColor((Integer) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
anim.addUpdateListener(animation -> getWindow().setStatusBarColor((Integer) animation.getAnimatedValue()));
|
||||
anim.start();
|
||||
}
|
||||
|
||||
@@ -734,12 +715,7 @@ public class UARTActivity extends BleProfileServiceReadyActivity<UARTService.UAR
|
||||
final long id = mDatabaseHelper.addConfiguration(name, xml);
|
||||
mWearableSynchronizer.onConfigurationAddedOrEdited(id, configuration);
|
||||
refreshConfigurations();
|
||||
new Handler().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
selectConfiguration(mConfigurationsAdapter.getItemPosition(id));
|
||||
}
|
||||
});
|
||||
new Handler().post(() -> selectConfiguration(mConfigurationsAdapter.getItemPosition(id)));
|
||||
} else {
|
||||
Toast.makeText(this, R.string.uart_configuration_name_already_taken, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CursorAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
@@ -38,8 +37,8 @@ public class UARTConfigurationsAdapter extends CursorAdapter {
|
||||
final ActionListener mListener;
|
||||
|
||||
public interface ActionListener {
|
||||
public void onNewConfigurationClick();
|
||||
public void onImportClick();
|
||||
void onNewConfigurationClick();
|
||||
void onImportClick();
|
||||
}
|
||||
|
||||
public UARTConfigurationsAdapter(final Context context, final ActionListener listener, final Cursor c) {
|
||||
@@ -115,18 +114,8 @@ public class UARTConfigurationsAdapter extends CursorAdapter {
|
||||
|
||||
public View newToolbarView(final Context context, final ViewGroup parent) {
|
||||
final View view = LayoutInflater.from(context).inflate(R.layout.feature_uart_dropdown_title, parent, false);
|
||||
view.findViewById(R.id.action_add).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
mListener.onNewConfigurationClick();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.action_import).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
mListener.onImportClick();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.action_add).setOnClickListener(v -> mListener.onNewConfigurationClick());
|
||||
view.findViewById(R.id.action_import).setOnClickListener(v -> mListener.onImportClick());
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,17 +22,11 @@
|
||||
|
||||
package no.nordicsemi.android.nrftoolbox.uart;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
@@ -85,7 +79,7 @@ public class UARTControlFragment extends Fragment implements GridView.OnItemClic
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
final View view = inflater.inflate(R.layout.fragment_feature_uart_control, container, false);
|
||||
|
||||
final GridView grid = (GridView) view.findViewById(R.id.grid);
|
||||
final GridView grid = view.findViewById(R.id.grid);
|
||||
grid.setAdapter(mAdapter = new UARTButtonAdapter(mConfiguration));
|
||||
grid.setOnItemClickListener(this);
|
||||
mAdapter.setEditMode(mEditMode);
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -85,20 +84,17 @@ public class UARTEditDialog extends DialogFragment implements View.OnClickListen
|
||||
|
||||
// Create view
|
||||
final View view = inflater.inflate(R.layout.feature_uart_dialog_edit, null);
|
||||
final EditText field = mField = (EditText) view.findViewById(R.id.field);
|
||||
final GridView grid = (GridView) view.findViewById(R.id.grid);
|
||||
final CheckBox checkBox = mActiveCheckBox = (CheckBox) view.findViewById(R.id.active);
|
||||
checkBox.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
|
||||
field.setEnabled(isChecked);
|
||||
grid.setEnabled(isChecked);
|
||||
if (mIconAdapter != null)
|
||||
mIconAdapter.notifyDataSetChanged();
|
||||
}
|
||||
final EditText field = mField = view.findViewById(R.id.field);
|
||||
final GridView grid = view.findViewById(R.id.grid);
|
||||
final CheckBox checkBox = mActiveCheckBox = view.findViewById(R.id.active);
|
||||
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
field.setEnabled(isChecked);
|
||||
grid.setEnabled(isChecked);
|
||||
if (mIconAdapter != null)
|
||||
mIconAdapter.notifyDataSetChanged();
|
||||
});
|
||||
|
||||
final RadioGroup eolGroup = mEOLGroup = (RadioGroup) view.findViewById(R.id.uart_eol);
|
||||
final RadioGroup eolGroup = mEOLGroup = view.findViewById(R.id.uart_eol);
|
||||
switch (Command.Eol.values()[eol]) {
|
||||
case CR_LF:
|
||||
eolGroup.check(R.id.uart_eol_cr_lf);
|
||||
|
||||
@@ -58,8 +58,8 @@ public class UARTLogAdapter extends CursorAdapter {
|
||||
final View view = LayoutInflater.from(context).inflate(R.layout.log_item, parent, false);
|
||||
|
||||
final ViewHolder holder = new ViewHolder();
|
||||
holder.time = (TextView) view.findViewById(R.id.time);
|
||||
holder.data = (TextView) view.findViewById(R.id.data);
|
||||
holder.time = view.findViewById(R.id.time);
|
||||
holder.data = view.findViewById(R.id.data);
|
||||
view.setTag(holder);
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -183,25 +183,17 @@ public class UARTLogFragment extends ListFragment implements LoaderManager.Loade
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
final View view = inflater.inflate(R.layout.fragment_feature_uart_log, container, false);
|
||||
|
||||
final EditText field = mField = (EditText) view.findViewById(R.id.field);
|
||||
field.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
onSendClicked();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
final EditText field = mField = view.findViewById(R.id.field);
|
||||
field.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
onSendClicked();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
final Button sendButton = mSendButton = (Button) view.findViewById(R.id.action_send);
|
||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
onSendClicked();
|
||||
}
|
||||
});
|
||||
final Button sendButton = mSendButton = view.findViewById(R.id.action_send);
|
||||
sendButton.setOnClickListener(v -> onSendClicked());
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,15 +99,10 @@ public class UARTNewConfigurationDialogFragment extends DialogFragment implement
|
||||
|
||||
final LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||
final View view = inflater.inflate(R.layout.feature_uart_dialog_new_configuration, null);
|
||||
final EditText editText = mEditText = (EditText) view.findViewById(R.id.name);
|
||||
final EditText editText = mEditText = view.findViewById(R.id.name);
|
||||
editText.setText(args.getString(NAME));
|
||||
final View actionClear = view.findViewById(R.id.action_clear);
|
||||
actionClear.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
editText.setText(null);
|
||||
}
|
||||
});
|
||||
actionClear.setOnClickListener(v -> editText.setText(null));
|
||||
|
||||
final AlertDialog dialog = new AlertDialog.Builder(context).setTitle(titleResId).setView(view).setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.ok, null).setCancelable(false).show(); // this must be show() or the getButton() below will return null.
|
||||
|
||||
@@ -42,7 +42,6 @@ import com.google.android.gms.wearable.Node;
|
||||
import com.google.android.gms.wearable.NodeApi;
|
||||
import com.google.android.gms.wearable.Wearable;
|
||||
|
||||
import no.nordicsemi.android.log.ILogSession;
|
||||
import no.nordicsemi.android.log.Logger;
|
||||
import no.nordicsemi.android.nrftoolbox.FeaturesActivity;
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
@@ -196,23 +195,20 @@ public class UARTService extends BleProfileService implements UARTManagerCallbac
|
||||
*/
|
||||
private void sendMessageToWearables(final @NonNull String path, final @NonNull String message) {
|
||||
if(mGoogleApiClient.isConnected()) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
|
||||
for(Node node : nodes.getNodes()) {
|
||||
Logger.v(getLogSession(), "[WEAR] Sending message '" + path + "' to " + node.getDisplayName());
|
||||
final MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(mGoogleApiClient, node.getId(), path, message.getBytes()).await();
|
||||
if(result.getStatus().isSuccess()){
|
||||
Logger.i(getLogSession(), "[WEAR] Message sent");
|
||||
} else {
|
||||
Logger.w(getLogSession(), "[WEAR] Sending message failed: " + result.getStatus().getStatusMessage());
|
||||
Log.w(TAG, "Failed to send " + path + " to " + node.getDisplayName());
|
||||
}
|
||||
new Thread(() -> {
|
||||
NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
|
||||
for(Node node : nodes.getNodes()) {
|
||||
Logger.v(getLogSession(), "[WEAR] Sending message '" + path + "' to " + node.getDisplayName());
|
||||
final MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(mGoogleApiClient, node.getId(), path, message.getBytes()).await();
|
||||
if(result.getStatus().isSuccess()){
|
||||
Logger.i(getLogSession(), "[WEAR] Message sent");
|
||||
} else {
|
||||
Logger.w(getLogSession(), "[WEAR] Sending message failed: " + result.getStatus().getStatusMessage());
|
||||
Log.w(TAG, "Failed to send " + path + " to " + node.getDisplayName());
|
||||
}
|
||||
if (Constants.UART.DEVICE_DISCONNECTED.equals(path))
|
||||
stopService();
|
||||
}
|
||||
if (Constants.UART.DEVICE_DISCONNECTED.equals(path))
|
||||
stopService();
|
||||
}).start();
|
||||
} else {
|
||||
if (Constants.UART.DEVICE_DISCONNECTED.equals(path))
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ConfigurationContract {
|
||||
|
||||
protected interface ConfigurationColumns {
|
||||
/** The XML with configuration. */
|
||||
public final static String XML = "xml";
|
||||
String XML = "xml";
|
||||
}
|
||||
|
||||
public final class Configuration implements BaseColumns, NameColumns, ConfigurationColumns, UndoColumns {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DatabaseHelper {
|
||||
|
||||
private interface Tables {
|
||||
/** Configurations table. See {@link ConfigurationContract.Configuration} for column names. */
|
||||
public static final String CONFIGURATIONS = "configurations";
|
||||
String CONFIGURATIONS = "configurations";
|
||||
}
|
||||
|
||||
private static final String[] ID_PROJECTION = new String[] { BaseColumns._ID };
|
||||
|
||||
@@ -24,5 +24,5 @@ package no.nordicsemi.android.nrftoolbox.uart.database;
|
||||
|
||||
public interface NameColumns {
|
||||
/** The name */
|
||||
public final static String NAME = "name";
|
||||
String NAME = "name";
|
||||
}
|
||||
@@ -23,5 +23,5 @@ package no.nordicsemi.android.nrftoolbox.uart.database;
|
||||
|
||||
public interface UndoColumns {
|
||||
/** The 'deleted' flag */
|
||||
public final static String DELETED = "deleted";
|
||||
String DELETED = "deleted";
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Spinner;
|
||||
|
||||
public class ClosableSpinner extends Spinner {
|
||||
public class ClosableSpinner extends android.support.v7.widget.AppCompatSpinner {
|
||||
public ClosableSpinner(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ForegroundLinearLayout extends LinearLayout {
|
||||
public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundRelativeLayout,
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLinearLayout,
|
||||
defStyle, 0);
|
||||
|
||||
final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground);
|
||||
|
||||
@@ -28,7 +28,7 @@ import android.widget.TextView;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class TrebuchetBoldTextView extends TextView {
|
||||
public class TrebuchetBoldTextView extends android.support.v7.widget.AppCompatTextView {
|
||||
|
||||
public TrebuchetBoldTextView(Context context) {
|
||||
super(context);
|
||||
|
||||
@@ -28,7 +28,7 @@ import android.widget.TextView;
|
||||
|
||||
import no.nordicsemi.android.nrftoolbox.R;
|
||||
|
||||
public class TrebuchetTextView extends TextView {
|
||||
public class TrebuchetTextView extends android.support.v7.widget.AppCompatTextView {
|
||||
|
||||
public TrebuchetTextView(Context context) {
|
||||
super(context);
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="middle"
|
||||
android:freezesText="true"
|
||||
android:lines="1"/>
|
||||
android:singleLine="true"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
android:ellipsize="marquee"
|
||||
android:layout_toRightOf="@+id/icon"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@android:color/black"/>
|
||||
android:textColor="@android:color/black"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/address"
|
||||
|
||||
Reference in New Issue
Block a user