Adding units settings to CSC, RSC, HTM.

This commit is contained in:
Aleksander Nowakowski
2015-03-02 14:25:51 +01:00
parent bc520dcc5e
commit c245a33c48
31 changed files with 706 additions and 87 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="nRFToolbox" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
@@ -9,6 +9,7 @@
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
@@ -24,6 +25,7 @@
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />

View File

@@ -9,8 +9,8 @@ android {
applicationId "no.nordicsemi.android.nrftoolbox"
minSdkVersion 18
targetSdkVersion 21
versionCode 27
versionName "1.11.4"
versionCode 28
versionName "1.11.5"
}
buildTypes {
release {

View File

@@ -23,8 +23,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="no.nordicsemi.android.nrftoolbox"
android:installLocation="auto"
android:versionCode="27"
android:versionName="1.11.4" >
android:versionCode="28"
android:versionName="1.11.5" >
<uses-sdk
android:minSdkVersion="18"
@@ -96,6 +96,9 @@
<category android:name="no.nordicsemi.android.nrftoolbox.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="no.nordicsemi.android.nrftoolbox.hts.settings.SettingsActivity"
android:label="@string/hts_settings_title" />
<activity
android:name="no.nordicsemi.android.nrftoolbox.bpm.BPMActivity"
android:icon="@drawable/ic_bpm_feature"
@@ -138,6 +141,9 @@
<category android:name="no.nordicsemi.android.nrftoolbox.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="no.nordicsemi.android.nrftoolbox.rsc.settings.SettingsActivity"
android:label="@string/rsc_settings_title" />
<activity
android:name="no.nordicsemi.android.nrftoolbox.csc.CSCActivity"
android:icon="@drawable/ic_csc_feature"
@@ -149,6 +155,9 @@
<category android:name="no.nordicsemi.android.nrftoolbox.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="no.nordicsemi.android.nrftoolbox.csc.settings.SettingsActivity"
android:label="@string/csc_settings_title" />
<activity
android:name="no.nordicsemi.android.nrftoolbox.uart.UARTActivity"
android:icon="@drawable/ic_uart_feature"
@@ -161,9 +170,6 @@
<category android:name="no.nordicsemi.android.nrftoolbox.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="no.nordicsemi.android.nrftoolbox.csc.settings.SettingsActivity"
android:label="@string/csc_settings_title" />
<service
android:name="no.nordicsemi.android.nrftoolbox.proximity.ProximityService"

View File

@@ -50,6 +50,7 @@ import android.widget.TextView;
import android.widget.Toast;
public class FeaturesActivity extends ActionBarActivity {
private static final String MCP_CATEGORY = "no.nordicsemi.android.nrftoolbox.LAUNCHER";
private static final String UTILS_CATEGORY = "no.nordicsemi.android.nrftoolbox.UTILS";
private static final String MCP_PACKAGE = "no.nordicsemi.android.mcp";
private static final String MCP_CLASS = MCP_PACKAGE + ".DeviceListActivity";
@@ -127,6 +128,7 @@ public class FeaturesActivity extends ActionBarActivity {
// look for Master Control Panel
final Intent mcpIntent = new Intent(Intent.ACTION_MAIN);
mcpIntent.addCategory(MCP_CATEGORY);
mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS);
final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0);
@@ -136,7 +138,7 @@ public class FeaturesActivity extends ActionBarActivity {
mcpItem.setTextColor(Color.GRAY);
ColorMatrix grayscale = new ColorMatrix();
grayscale.setSaturation(0.0f);
mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale));
mcpItem.getCompoundDrawables()[0].mutate().setColorFilter(new ColorMatrixColorFilter(grayscale));
}
mcpItem.setOnClickListener(new View.OnClickListener() {
@Override
@@ -145,6 +147,7 @@ public class FeaturesActivity extends ActionBarActivity {
if (mcpInfo == null)
action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI));
action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
action.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(action);
} catch (final ActivityNotFoundException e) {
@@ -172,6 +175,7 @@ public class FeaturesActivity extends ActionBarActivity {
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();
}

View File

@@ -26,23 +26,28 @@ import java.util.UUID;
import no.nordicsemi.android.nrftoolbox.R;
import no.nordicsemi.android.nrftoolbox.csc.settings.SettingsActivity;
import no.nordicsemi.android.nrftoolbox.csc.settings.SettingsFragment;
import no.nordicsemi.android.nrftoolbox.profile.BleProfileService;
import no.nordicsemi.android.nrftoolbox.profile.BleProfileServiceReadyActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.view.Menu;
import android.widget.TextView;
public class CSCActivity extends BleProfileServiceReadyActivity<CSCService.CSCBinder> {
private TextView mSpeedView;
private TextView mSpeedUnitView;
private TextView mCadenceView;
private TextView mDistanceView;
private TextView mDistanceUnitView;
private TextView mTotalDistanceView;
private TextView mTotalDistanceUnitView;
private TextView mGearRatioView;
@Override
@@ -64,21 +69,53 @@ 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);
}
@Override
protected void onResume() {
super.onResume();
setDefaultUI();
}
@Override
protected void setDefaultUI() {
mSpeedView.setText(R.string.not_available_value);
mCadenceView.setText(R.string.not_available_value);
mDistanceView.setText(R.string.not_available_value);
mDistanceUnitView.setText(R.string.csc_distance_unit_m);
mTotalDistanceView.setText(R.string.not_available_value);
mGearRatioView.setText(R.string.not_available_value);
setUnits();
}
private void setUnits() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final int unit = Integer.parseInt(preferences.getString(SettingsFragment.SETTINGS_UNIT, String.valueOf(SettingsFragment.SETTINGS_UNIT_DEFAULT)));
switch (unit) {
case SettingsFragment.SETTINGS_UNIT_M_S: // [m/s]
mSpeedUnitView.setText(R.string.csc_speed_unit_m_s);
mDistanceUnitView.setText(R.string.csc_distance_unit_m);
mTotalDistanceUnitView.setText(R.string.csc_total_distance_unit_km);
break;
case SettingsFragment.SETTINGS_UNIT_KM_H: // [km/h]
mSpeedUnitView.setText(R.string.csc_speed_unit_km_h);
mDistanceUnitView.setText(R.string.csc_distance_unit_m);
mTotalDistanceUnitView.setText(R.string.csc_total_distance_unit_km);
break;
case SettingsFragment.SETTINGS_UNIT_MPH: // [mph]
mSpeedUnitView.setText(R.string.csc_speed_unit_mph);
mDistanceUnitView.setText(R.string.csc_distance_unit_yd);
mTotalDistanceUnitView.setText(R.string.csc_total_distance_unit_mile);
break;
}
}
@Override
@@ -98,7 +135,7 @@ public class CSCActivity extends BleProfileServiceReadyActivity<CSCService.CSCBi
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.csc_menu, menu);
getMenuInflater().inflate(R.menu.settings_and_about, menu);
return true;
}
@@ -138,8 +175,15 @@ public class CSCActivity extends BleProfileServiceReadyActivity<CSCService.CSCBi
// not used
}
private void onMeasurementReceived(final float speed, final float distance, final float totalDistance) {
mSpeedView.setText(String.format("%.1f", speed));
private void onMeasurementReceived(float speed, float distance, float totalDistance) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final int unit = Integer.parseInt(preferences.getString(SettingsFragment.SETTINGS_UNIT, String.valueOf(SettingsFragment.SETTINGS_UNIT_DEFAULT)));
switch (unit) {
case SettingsFragment.SETTINGS_UNIT_KM_H:
speed = speed * 3.6f;
// pass through intended
case SettingsFragment.SETTINGS_UNIT_M_S:
if (distance < 1000) { // 1 km in m
mDistanceView.setText(String.format("%.0f", distance));
mDistanceUnitView.setText(R.string.csc_distance_unit_m);
@@ -149,6 +193,22 @@ public class CSCActivity extends BleProfileServiceReadyActivity<CSCService.CSCBi
}
mTotalDistanceView.setText(String.format("%.2f", totalDistance / 1000.0f));
break;
case SettingsFragment.SETTINGS_UNIT_MPH:
speed = speed * 2.2369f;
if (distance < 1760) { // 1 mile in yrs
mDistanceView.setText(String.format("%.0f", distance));
mDistanceUnitView.setText(R.string.csc_distance_unit_yd);
} else {
mDistanceView.setText(String.format("%.2f", distance / 1760.0f));
mDistanceUnitView.setText(R.string.csc_distance_unit_mile);
}
mTotalDistanceView.setText(String.format("%.2f", totalDistance / 1609.31f));
break;
}
mSpeedView.setText(String.format("%.1f", speed));
}
private void onGearRatioUpdate(final float ratio, final int cadence) {
@@ -162,7 +222,7 @@ public class CSCActivity extends BleProfileServiceReadyActivity<CSCService.CSCBi
final String action = intent.getAction();
if (CSCService.BROADCAST_WHEEL_DATA.equals(action)) {
final float speed = intent.getFloatExtra(CSCService.EXTRA_SPEED, 0.0f);
final float speed = intent.getFloatExtra(CSCService.EXTRA_SPEED, 0.0f); // [m/s]
final float distance = intent.getFloatExtra(CSCService.EXTRA_DISTANCE, CSCManagerCallbacks.NOT_AVAILABLE);
final float totalDistance = intent.getFloatExtra(CSCService.EXTRA_TOTAL_DISTANCE, CSCManagerCallbacks.NOT_AVAILABLE);
// Update GUI

View File

@@ -31,6 +31,12 @@ import android.preference.PreferenceScreen;
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final String SETTINGS_WHEEL_SIZE = "settings_wheel_size";
public static final int SETTINGS_WHEEL_SIZE_DEFAULT = 2340;
public static final String SETTINGS_UNIT = "settings_csc_unit";
public static final int SETTINGS_UNIT_M_S = 0; // [m/s]
public static final int SETTINGS_UNIT_KM_H = 1; // [m/s]
public static final int SETTINGS_UNIT_MPH = 2; // [m/s]
public static final int SETTINGS_UNIT_DEFAULT = SETTINGS_UNIT_KM_H;
@Override
public void onCreate(final Bundle savedInstanceState) {

View File

@@ -417,7 +417,7 @@ public class DfuActivity extends ActionBarActivity implements LoaderCallbacks<Cu
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.dfu_menu, menu);
getMenuInflater().inflate(R.menu.settings_and_about, menu);
return true;
}

View File

@@ -25,14 +25,20 @@ import java.text.DecimalFormat;
import java.util.UUID;
import no.nordicsemi.android.nrftoolbox.R;
import no.nordicsemi.android.nrftoolbox.hts.settings.SettingsFragment;
import no.nordicsemi.android.nrftoolbox.profile.BleProfileService;
import no.nordicsemi.android.nrftoolbox.profile.BleProfileServiceReadyActivity;
import no.nordicsemi.android.nrftoolbox.hts.settings.SettingsActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.view.Menu;
import android.widget.TextView;
/**
@@ -43,17 +49,34 @@ public class HTSActivity extends BleProfileServiceReadyActivity<HTSService.RSCBi
@SuppressWarnings("unused")
private final String TAG = "HTSActivity";
private static final String VALUE = "value";
private static final DecimalFormat mFormattedTemp = new DecimalFormat("#0.00");
private TextView mHTSValue;
private TextView mHTSUnit;
private Double mValueC;
@Override
protected void onCreateView(Bundle savedInstanceState) {
protected void onCreateView(final Bundle savedInstanceState) {
setContentView(R.layout.activity_feature_hts);
setGUI();
}
@Override
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
if (mValueC != null)
outState.putDouble(VALUE, mValueC);
}
@Override
protected void onInitialize(final Bundle savedInstanceState) {
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, makeIntentFilter());
if (savedInstanceState != null) {
if (savedInstanceState.containsKey(VALUE))
mValueC = savedInstanceState.getDouble(VALUE);
}
}
@Override
@@ -64,6 +87,43 @@ 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);
if (mValueC != null)
mHTSValue.setText(String.valueOf(mValueC));
}
@Override
protected void onResume() {
super.onResume();
setUnits();
}
@Override
protected void setDefaultUI() {
mValueC = null;
mHTSValue.setText(R.string.not_available_value);
setUnits();
}
private void setUnits() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final int unit = Integer.parseInt(preferences.getString(SettingsFragment.SETTINGS_UNIT, String.valueOf(SettingsFragment.SETTINGS_UNIT_DEFAULT)));
switch (unit) {
case SettingsFragment.SETTINGS_UNIT_C:
mHTSUnit.setText(R.string.hts_unit_celsius);
break;
case SettingsFragment.SETTINGS_UNIT_F:
mHTSUnit.setText(R.string.hts_unit_fahrenheit);
break;
case SettingsFragment.SETTINGS_UNIT_K:
mHTSUnit.setText(R.string.hts_unit_kelvin);
break;
}
if (mValueC != null)
setHTSValueOnView(mValueC);
}
@Override
@@ -81,6 +141,23 @@ public class HTSActivity extends BleProfileServiceReadyActivity<HTSService.RSCBi
return R.string.hts_about_text;
}
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.settings_and_about, menu);
return true;
}
@Override
protected boolean onOptionsItemSelected(final int itemId) {
switch (itemId) {
case R.id.action_settings:
final Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
break;
}
return true;
}
@Override
protected int getDefaultDeviceName() {
return R.string.hts_default_name;
@@ -101,14 +178,22 @@ public class HTSActivity extends BleProfileServiceReadyActivity<HTSService.RSCBi
// this may notify user or show some views
}
private void setHTSValueOnView(final double value) {
DecimalFormat formattedTemp = new DecimalFormat("#0.00");
mHTSValue.setText(formattedTemp.format(value));
}
private void setHTSValueOnView(double value) {
mValueC = value;
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final int unit = Integer.parseInt(preferences.getString(SettingsFragment.SETTINGS_UNIT, String.valueOf(SettingsFragment.SETTINGS_UNIT_DEFAULT)));
@Override
protected void setDefaultUI() {
mHTSValue.setText(R.string.not_available_value);
switch (unit) {
case SettingsFragment.SETTINGS_UNIT_F:
value = value * 1.8 + 32;
break;
case SettingsFragment.SETTINGS_UNIT_K:
value += 273.15;
break;
case SettingsFragment.SETTINGS_UNIT_C:
break;
}
mHTSValue.setText(mFormattedTemp.format(value));
}
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {

View File

@@ -169,11 +169,7 @@ public class HTSManager implements BleManager<HTSManagerCallbacks> {
gatt.disconnect();
return;
}
if (mBatteryCharacteristic != null) {
readBatteryLevel();
} else {
enableHTIndication();
}
} else {
mCallbacks.onError(ERROR_DISCOVERY_SERVICE, status);
}
@@ -185,8 +181,6 @@ public class HTSManager implements BleManager<HTSManagerCallbacks> {
if (characteristic.getUuid().equals(BATTERY_LEVEL_CHARACTERISTIC)) {
int batteryValue = characteristic.getValue()[0];
mCallbacks.onBatteryValueReceived(batteryValue);
enableHTIndication();
}
} else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_NONE) {
@@ -213,7 +207,7 @@ public class HTSManager implements BleManager<HTSManagerCallbacks> {
@Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
// HT indications has been enabled
readBatteryLevel();
} else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
mCallbacks.onBondingRequired();

View File

@@ -66,7 +66,7 @@ public class HTSService extends BleProfileService implements HTSManagerCallbacks
@Override
protected BleManager<HTSManagerCallbacks> initializeManager() {
return mManager = new HTSManager();
return mManager = HTSManager.getHTSManager();
}
@Override

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package no.nordicsemi.android.nrftoolbox.hts.settings;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
public class SettingsActivity extends ActionBarActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Display the fragment as the main content.
getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package no.nordicsemi.android.nrftoolbox.hts.settings;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import no.nordicsemi.android.nrftoolbox.R;
public class SettingsFragment extends PreferenceFragment {
public static final String SETTINGS_UNIT = "settings_hts_unit";
public static final int SETTINGS_UNIT_C = 0; // [C]
public static final int SETTINGS_UNIT_F = 1; // [F]
public static final int SETTINGS_UNIT_K = 2; // [K]
public static final int SETTINGS_UNIT_DEFAULT = SETTINGS_UNIT_C;
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings_hts);
}
}

View File

@@ -25,22 +25,29 @@ package no.nordicsemi.android.nrftoolbox.rsc;
import java.util.UUID;
import no.nordicsemi.android.nrftoolbox.R;
import no.nordicsemi.android.nrftoolbox.rsc.settings.SettingsFragment;
import no.nordicsemi.android.nrftoolbox.rsc.settings.SettingsActivity;
import no.nordicsemi.android.nrftoolbox.profile.BleProfileService;
import no.nordicsemi.android.nrftoolbox.profile.BleProfileServiceReadyActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.view.Menu;
import android.widget.TextView;
public class RSCActivity extends BleProfileServiceReadyActivity<RSCService.RSCBinder> {
private TextView mSpeedView;
private TextView mSpeedUnitView;
private TextView mCadenceView;
private TextView mDistanceView;
private TextView mDistanceUnitView;
private TextView mTotalDistanceView;
private TextView mTotalDistanceUnitView;
private TextView mStridesCountView;
private TextView mActivityView;
@@ -63,23 +70,55 @@ 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);
}
@Override
protected void onResume() {
super.onResume();
setDefaultUI();
}
@Override
protected void setDefaultUI() {
mSpeedView.setText(R.string.not_available_value);
mCadenceView.setText(R.string.not_available_value);
mDistanceView.setText(R.string.not_available_value);
mDistanceUnitView.setText(R.string.rsc_distance_unit_m);
mTotalDistanceView.setText(R.string.not_available_value);
mStridesCountView.setText(R.string.not_available_value);
mActivityView.setText(R.string.not_available);
setUnits();
}
private void setUnits() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final int unit = Integer.parseInt(preferences.getString(SettingsFragment.SETTINGS_UNIT, String.valueOf(SettingsFragment.SETTINGS_UNIT_DEFAULT)));
switch (unit) {
case SettingsFragment.SETTINGS_UNIT_M_S: // [m/s]
mSpeedUnitView.setText(R.string.csc_speed_unit_m_s);
mDistanceUnitView.setText(R.string.csc_distance_unit_m);
mTotalDistanceUnitView.setText(R.string.csc_total_distance_unit_km);
break;
case SettingsFragment.SETTINGS_UNIT_KM_H: // [km/h]
mSpeedUnitView.setText(R.string.csc_speed_unit_km_h);
mDistanceUnitView.setText(R.string.csc_distance_unit_m);
mTotalDistanceUnitView.setText(R.string.csc_total_distance_unit_km);
break;
case SettingsFragment.SETTINGS_UNIT_MPH: // [mph]
mSpeedUnitView.setText(R.string.csc_speed_unit_mph);
mDistanceUnitView.setText(R.string.csc_distance_unit_yd);
mTotalDistanceUnitView.setText(R.string.csc_total_distance_unit_mile);
break;
}
}
@Override
@@ -97,6 +136,23 @@ public class RSCActivity extends BleProfileServiceReadyActivity<RSCService.RSCBi
return R.string.rsc_about_text;
}
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.settings_and_about, menu);
return true;
}
@Override
protected boolean onOptionsItemSelected(final int itemId) {
switch (itemId) {
case R.id.action_settings:
final Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
break;
}
return true;
}
@Override
protected Class<? extends BleProfileService> getServiceClass() {
return RSCService.class;
@@ -122,29 +178,70 @@ public class RSCActivity extends BleProfileServiceReadyActivity<RSCService.RSCBi
// not used
}
private void onMeasurementReceived(final float speed, final int cadence, final float totalDistance, final int activity) {
mSpeedView.setText(String.format("%.1f", speed));
mCadenceView.setText(String.format("%d", cadence));
private void onMeasurementReceived(float speed, int cadence, float totalDistance, final int activity) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final int unit = Integer.parseInt(preferences.getString(SettingsFragment.SETTINGS_UNIT, String.valueOf(SettingsFragment.SETTINGS_UNIT_DEFAULT)));
switch (unit) {
case SettingsFragment.SETTINGS_UNIT_KM_H:
speed = speed * 3.6f;
// pass through intended
case SettingsFragment.SETTINGS_UNIT_M_S:
if (totalDistance == RSCManagerCallbacks.NOT_AVAILABLE) {
mTotalDistanceView.setText(R.string.not_available);
mTotalDistanceUnitView.setText(null);
} else {
mTotalDistanceView.setText(String.format("%.2f", totalDistance / 10000.0f)); // 1km in dm
mTotalDistanceView.setText(String.format("%.2f", totalDistance / 1000.0f)); // 1 km in m
mTotalDistanceUnitView.setText(R.string.rsc_total_distance_unit_km);
}
break;
case SettingsFragment.SETTINGS_UNIT_MPH:
speed = speed * 2.2369f;
if (totalDistance == RSCManagerCallbacks.NOT_AVAILABLE) {
mTotalDistanceView.setText(R.string.not_available);
mTotalDistanceUnitView.setText(null);
} else {
mTotalDistanceView.setText(String.format("%.2f", totalDistance / 1609.31f)); // 1 mile in m
mTotalDistanceUnitView.setText(R.string.rsc_total_distance_unit_mile);
}
break;
}
mSpeedView.setText(String.format("%.1f", speed));
mCadenceView.setText(String.format("%d", cadence));
mActivityView.setText(activity == RSCManagerCallbacks.ACTIVITY_RUNNING ? R.string.rsc_running : R.string.rsc_walking);
}
private void onStripsesUpdate(final float distance, final int strides) {
private void onStripesUpdate(final float distance, final int strides) {
if (distance == RSCManagerCallbacks.NOT_AVAILABLE) {
mDistanceView.setText(R.string.not_available);
mDistanceUnitView.setText(R.string.rsc_distance_unit_m);
} else if (distance < 100000) { // 1 km in cm
} else {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final int unit = Integer.parseInt(preferences.getString(SettingsFragment.SETTINGS_UNIT, String.valueOf(SettingsFragment.SETTINGS_UNIT_DEFAULT)));
switch (unit) {
case SettingsFragment.SETTINGS_UNIT_KM_H:
case SettingsFragment.SETTINGS_UNIT_M_S:
if (distance < 100000) { // 1 km in cm
mDistanceView.setText(String.format("%.0f", distance / 100.0f));
mDistanceUnitView.setText(R.string.rsc_distance_unit_m);
} else {
mDistanceView.setText(String.format("%.2f", distance / 100000.0f));
mDistanceUnitView.setText(R.string.rsc_distance_unit_km);
}
break;
case SettingsFragment.SETTINGS_UNIT_MPH:
if (distance < 160931) { // 1 mile in cm
mDistanceView.setText(String.format("%.0f", distance / 91.4392f));
mDistanceUnitView.setText(R.string.rsc_distance_unit_yd);
} else {
mDistanceView.setText(String.format("%.2f", distance / 160931.23f));
mDistanceUnitView.setText(R.string.rsc_distance_unit_mile);
}
break;
}
}
mStridesCountView.setText(String.valueOf(strides));
}
@@ -165,7 +262,7 @@ public class RSCActivity extends BleProfileServiceReadyActivity<RSCService.RSCBi
final int strides = intent.getIntExtra(RSCService.EXTRA_STRIDES, 0);
final float distance = intent.getFloatExtra(RSCService.EXTRA_DISTANCE, 0);
// Update GUI
onStripsesUpdate(distance, strides);
onStripesUpdate(distance, strides);
}
}
};

View File

@@ -190,22 +190,22 @@ public class RSCManager implements BleManager<RSCManagerCallbacks> {
final boolean tdPreset = (flags & TOTAL_DISTANCE_PRESENT) > 0;
final boolean running = (flags & WALKING_OR_RUNNING_STATUS_BITS) > 0;
final float instantaneousSpeed = (float) characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset) / 256.0f * 3.6f; // 1/256 m/s in km/h
final float instantaneousSpeed = (float) characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset) / 256.0f; // 1/256 m/s in [m/s]
offset += 2;
final int instantaneousCadence = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset);
final int instantaneousCadence = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset); // [SPM]
offset += 1;
float instantaneousStrideLength = RSCManagerCallbacks.NOT_AVAILABLE;
if (islmPresent) {
instantaneousStrideLength = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset);
instantaneousStrideLength = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset); // [cm]
offset += 2;
}
float totalDistance = RSCManagerCallbacks.NOT_AVAILABLE;
if (tdPreset) {
totalDistance = (float) characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, offset) / 10.0f;
offset += 4;
totalDistance = (float) characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, offset) / 10.0f; // 1/10 m in [m]
//offset += 4;
}
// Notify listener about the new measurement

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package no.nordicsemi.android.nrftoolbox.rsc.settings;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
public class SettingsActivity extends ActionBarActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Display the fragment as the main content.
getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package no.nordicsemi.android.nrftoolbox.rsc.settings;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import no.nordicsemi.android.nrftoolbox.R;
public class SettingsFragment extends PreferenceFragment {
public static final String SETTINGS_UNIT = "settings_rsc_unit";
public static final int SETTINGS_UNIT_M_S = 0; // [m/s]
public static final int SETTINGS_UNIT_KM_H = 1; // [m/s]
public static final int SETTINGS_UNIT_MPH = 2; // [m/s]
public static final int SETTINGS_UNIT_DEFAULT = SETTINGS_UNIT_KM_H;
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings_rsc);
}
}

View File

@@ -119,11 +119,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/speed_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/csc_speed_unit" />
android:text="@string/csc_speed_unit_km_h" />
</TableRow>
<TableRow
@@ -234,11 +235,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/distance_total_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/csc_total_distance_unit" />
android:text="@string/csc_total_distance_unit_km" />
</TableRow>
<TableRow

View File

@@ -79,6 +79,7 @@
android:textSize="80sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/text_hts_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"

View File

@@ -119,11 +119,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/speed_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/rsc_speed_unit" />
android:text="@string/rsc_speed_unit_km_h" />
</TableRow>
<TableRow
@@ -234,11 +235,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/total_distance_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/rsc_total_distance_unit" />
android:text="@string/rsc_total_distance_unit_km" />
</TableRow>
<TableRow

View File

@@ -110,11 +110,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/speed_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/csc_speed_unit" />
android:text="@string/csc_speed_unit_km_h" />
</TableRow>
<TableRow
@@ -198,11 +199,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/distance_total_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/csc_total_distance_unit" />
android:text="@string/csc_total_distance_unit_km" />
</TableRow>
<TableRow

View File

@@ -115,11 +115,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/speed_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/rsc_speed_unit" />
android:text="@string/rsc_speed_unit_km_h" />
</TableRow>
<TableRow
@@ -203,11 +204,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/total_distance_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/rsc_total_distance_unit" />
android:text="@string/rsc_total_distance_unit_km" />
</TableRow>
<TableRow

View File

@@ -110,11 +110,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/speed_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/csc_speed_unit" />
android:text="@string/csc_speed_unit_km_h" />
</TableRow>
<TableRow
@@ -198,11 +199,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/distance_total_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/csc_total_distance_unit" />
android:text="@string/csc_total_distance_unit_km" />
</TableRow>
<TableRow

View File

@@ -79,6 +79,7 @@
android:textSize="80sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/text_hts_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"

View File

@@ -115,11 +115,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/speed_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/rsc_speed_unit" />
android:text="@string/rsc_speed_unit_km_h" />
</TableRow>
<TableRow
@@ -203,11 +204,12 @@
android:textSize="36sp" />
<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
android:id="@+id/total_distance_unit"
android:layout_width="45dp"
android:layout_height="match_parent"
android:freezesText="true"
android:gravity="bottom"
android:text="@string/rsc_total_distance_unit" />
android:text="@string/rsc_total_distance_unit_km" />
</TableRow>
<TableRow

View File

@@ -0,0 +1,37 @@
<!--
~ Copyright (c) 2015, Nordic Semiconductor
~ All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
~
~ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
~
~ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~
~ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
~ software without specific prior written permission.
~
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
~ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
~ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
~ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_menu_settings"
app:showAsAction="always"
android:title="@string/action_settings"/>
<item
android:id="@+id/action_about"
android:icon="@drawable/ic_menu_about"
app:showAsAction="always"
android:title="@string/action_about"/>
</menu>

View File

@@ -29,21 +29,25 @@
<string name="csc_section_csc_header">SPEED AND CADENCE</string>
<string name="csc_speed">SPEED</string>
<string name="csc_speed_unit">km/h</string>
<string name="csc_speed_unit_m_s">m/s</string>
<string name="csc_speed_unit_km_h">km/h</string>
<string name="csc_speed_unit_mph">mph</string>
<string name="csc_cadence">CADENCE</string>
<string name="csc_cadence_unit">RPM</string>
<string name="csc_distance">DISTANCE</string>
<string name="csc_distance_unit_m">m</string>
<string name="csc_distance_unit_km">km</string>
<string name="csc_distance_unit_yd">yd</string>
<string name="csc_distance_unit_mile">mile</string>
<string name="csc_total_distance">TOTAL DISTANCE</string>
<string name="csc_total_distance_unit">km</string>
<string name="csc_total_distance_unit_km">km</string>
<string name="csc_total_distance_unit_mile">mile</string>
<string name="csc_gear_ratio">GEAR RATIO</string>
<string name="csc_default_name">DEFAULT CSC</string>
<string name="csc_notification_action_disconnect">Disconnect</string>
<string name="csc_notification_connected_message">%s is connected.</string>
<string name="csc_settings_wheel_diameter">Wheel size</string>
<string name="csc_settings_wheel_diameter_title">Wheel size</string>
<string name="csc_settings_wheel_diameter_summary">Wheel circumference: %s mm</string>
<string-array name="csc_settings_wheel_diameters">
@@ -152,6 +156,19 @@
<item>1272</item>
</string-array>
<string name="csc_settings_units_title">Units</string>
<string name="csc_settings_units_summary">%s</string>
<string-array name="csc_settings_units">
<item>m/s</item>
<item>km/h</item>
<item>mph</item>
</string-array>
<string-array name="csc_settings_units_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string name="csc_about_text">CSC (Cycling Speed and Cadence) profile allows you to connect to your bike activity sensor.
\nIt reads wheel and crank data if they are supported by the sensor and calculates speed, cadence, total and trip distance and gear ratio. Set up your wheel size in the settings to get correct readings.
\nYou may exit the application when connected while still getting notifications.</string>

View File

@@ -22,16 +22,32 @@
-->
<resources>
<string name="hts_feature_title">HTM</string>
<string name="hts_settings_title">HTM Settings</string>
<string name="hts_feature_title_long">HEALTH THERMOMETER MONITOR</string>
<dimen name="hts_feature_title_long_margin">-236dp</dimen>
<string name="hts_default_name">DEFAULT HTM</string>
<string name="hts_unit_celsius">°C</string>
<string name="hts_unit_fahrenheit">°F</string>
<string name="hts_unit_kelvin">°K</string>
<string name="hts_notification_action_disconnect">Disconnect</string>
<string name="hts_notification_connected_message">%s is connected.</string>
<string name="hts_settings_units_title">Units</string>
<string name="hts_settings_units_summary">%s</string>
<string-array name="hts_settings_units">
<item>Celsius</item>
<item>Fahrenheit</item>
<item>Kelvin</item>
</string-array>
<string-array name="hts_settings_units_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string name="hts_about_text">HTM (Health Thermometer Monitor) profile allows you to connect to your Health Thermometer sensor.
It shows you the temperature value in Celsius.</string>
</resources>

View File

@@ -22,21 +22,27 @@
-->
<resources>
<string name="rsc_feature_title">RSC</string>
<string name="rsc_settings_title">RSC Settings</string>
<string name="rsc_feature_title_long">RUNNING SPEED &amp; CADENCE</string>
<dimen name="rsc_feature_title_long_margin">-192dp</dimen>
<string name="rsc_section_rsc_header">SPEED AND CADENCE</string>
<string name="rsc_speed">SPEED</string>
<string name="rsc_speed_unit">km/h</string>
<string name="rsc_speed_unit_m_s">km/h</string>
<string name="rsc_speed_unit_km_h">km/h</string>
<string name="rsc_speed_unit_mph">mph</string>
<string name="rsc_cadence">CADENCE</string>
<string name="rsc_cadence_unit">SPM</string>
<string name="rsc_distance">DISTANCE</string>
<string name="rsc_distance_unit_m">m</string>
<string name="rsc_distance_unit_km">km</string>
<string name="rsc_distance_unit_yd">yd</string>
<string name="rsc_distance_unit_mile">mile</string>
<string name="rsc_section_strides_header"></string>
<string name="rsc_total_distance">TOTAL DISTANCE</string>
<string name="rsc_total_distance_unit">km</string>
<string name="rsc_total_distance_unit_km">km</string>
<string name="rsc_total_distance_unit_mile">mile</string>
<string name="rsc_strides">STEPS</string>
<string name="rsc_section_activity_header">ACTIVITY</string>
@@ -47,6 +53,19 @@
<string name="rsc_notification_action_disconnect">Disconnect</string>
<string name="rsc_notification_connected_message">%s is connected.</string>
<string name="rsc_settings_units_title">Units</string>
<string name="rsc_settings_units_summary">%s</string>
<string-array name="rsc_settings_units">
<item>m/s</item>
<item>km/h</item>
<item>mph</item>
</string-array>
<string-array name="rsc_settings_units_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string name="rsc_about_text">RSC (Running Speed and Cadence) profile allows you to connect to your activity sensor.
\nIt reads speed and cadence values from the sensor and calculates trip distance if stride length is supported. Strides count is calculated basing on the cadence and the time.
\nYou may exit the application when connected while still getting notifications.</string>

View File

@@ -23,13 +23,19 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/csc_settings_wheel_diameter" >
<ListPreference
android:title="@string/csc_settings_units_title"
android:summary="@string/csc_settings_units_summary"
android:defaultValue="1"
android:entries="@array/csc_settings_units"
android:entryValues="@array/csc_settings_units_values"
android:key="settings_csc_unit" />
<ListPreference
android:title="@string/csc_settings_wheel_diameter_title"
android:defaultValue="2340"
android:entries="@array/csc_settings_wheel_diameters"
android:entryValues="@array/csc_settings_wheel_diameter_values"
android:key="settings_wheel_size" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015, Nordic Semiconductor
~ All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
~
~ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
~
~ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~
~ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
~ software without specific prior written permission.
~
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
~ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
~ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
~ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<ListPreference
android:title="@string/csc_settings_units_title"
android:summary="@string/csc_settings_units_summary"
android:defaultValue="0"
android:entries="@array/hts_settings_units"
android:entryValues="@array/hts_settings_units_values"
android:key="settings_hts_unit" />
</PreferenceScreen>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015, Nordic Semiconductor
~ All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
~
~ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
~
~ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~
~ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
~ software without specific prior written permission.
~
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
~ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
~ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
~ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<ListPreference
android:title="@string/csc_settings_units_title"
android:summary="@string/csc_settings_units_summary"
android:defaultValue="1"
android:entries="@array/rsc_settings_units"
android:entryValues="@array/rsc_settings_units_values"
android:key="settings_rsc_unit" />
</PreferenceScreen>