Skip to content

Commit

Permalink
Merge tag '1.10.2' into develop
Browse files Browse the repository at this point in the history
Bug Fixes
-  Fixed error in bluetooth pairing and asking for location permission;
-  Added id to calorie and distance icons.
  • Loading branch information
douglasrafael committed Feb 7, 2020
2 parents db0ae4c + 5ae75dd commit bef83cf
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "br.edu.uepb.nutes.ocariot"
minSdkVersion 21
targetSdkVersion 28
versionCode 13
versionName "1.10.1"
versionCode 14
versionName "1.10.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

manifestPlaceholders = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public void setFitBitAccess(UserAccess fitBitAccess) {
public boolean isFitbitAccessValid() {
if (this.fitbitStatus == null) return false;
return fitbitStatus.equalsIgnoreCase(UserAccess.TokenStatus.VALID) ||
fitbitStatus.equalsIgnoreCase(UserAccess.TokenStatus.EXPIRED) ||
fitbitStatus.equalsIgnoreCase(UserAccess.TokenStatus.RATE_LIMIT);
fitbitStatus.equalsIgnoreCase(UserAccess.TokenStatus.EXPIRED);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -139,6 +141,12 @@ public class IotFragment extends Fragment implements View.OnClickListener, HRMan
@BindView(R.id.alert_enable_bluetooth)
FrameLayout mBoxEnableBluetooth;

@BindView(R.id.alert_enable_location)
FrameLayout mBoxEnableLocation;

@BindView(R.id.box_hr_progress_bar)
LinearLayout mBoxHRLoading;

/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
Expand Down Expand Up @@ -174,7 +182,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_iot, container, false);
ButterKnife.bind(this, view);

return view;
}

Expand All @@ -200,10 +207,14 @@ public void onResume() {

if (ConnectionUtils.isBluetoothAvailable()) {
mBoxEnableBluetooth.setVisibility(View.GONE);

if (!hasLocationPermissions()) {
requestLocationPermission();
return;
}
mBoxEnableLocation.setVisibility(View.GONE);
if (mHRManager.isConnected()) mBoxHRLoading.setVisibility(View.GONE);
else mBoxHRLoading.setVisibility(View.VISIBLE);
mScanner.stopScan();
mScanner.startScan(mScannerCallback);
}
Expand All @@ -230,6 +241,7 @@ private void initComponents() {
initChart();
initAnimation();
mBoxEnableBluetooth.setOnClickListener(this);
mBoxEnableLocation.setOnClickListener(this);
}

/**
Expand Down Expand Up @@ -484,6 +496,15 @@ public void onClick(View v) {
if (v.getId() == R.id.alert_enable_bluetooth) {
startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE),
REQUEST_ENABLE_BLUETOOTH);
} else if (v.getId() == R.id.alert_enable_location) {
startActivity(
new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts(
"package",
Objects.requireNonNull(getActivity()).getPackageName(),
null
))
);
}
}

Expand All @@ -505,6 +526,12 @@ private boolean hasLocationPermissions() {
* Request Location permission.
*/
private void requestLocationPermission() {
if (!shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)) {
if (mBoxEnableBluetooth.getVisibility() == View.GONE) {
mBoxEnableLocation.setVisibility(View.VISIBLE);
}
return;
}
ActivityCompat.requestPermissions(Objects.requireNonNull(getActivity()),
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_ENABLE_LOCATION);
}
Expand All @@ -517,10 +544,10 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
if ((requestCode == REQUEST_ENABLE_LOCATION) &&
(grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED)) {
Toast.makeText(mContext, R.string.message_permission_location, Toast.LENGTH_LONG).show();
requestLocationPermission();
return;
}
if (ConnectionUtils.isBluetoothAvailable()) {
mBoxEnableLocation.setVisibility(View.GONE);
mScanner.stopScan();
mScanner.startScan(mScannerCallback);
}
Expand All @@ -537,11 +564,13 @@ public void onReceive(Context context, Intent intent) {
switch (state) {
case BluetoothAdapter.STATE_OFF:
mBoxEnableBluetooth.setVisibility(View.VISIBLE);
mBoxHRLoading.setVisibility(View.GONE);
break;
case BluetoothAdapter.STATE_ON:
Timber.d("BluetoothAdapter.STATE_ON");
mBoxEnableBluetooth.setVisibility(View.GONE);
if (!hasLocationPermissions()) requestLocationPermission();
else mBoxHRLoading.setVisibility(View.VISIBLE);
mScanner.stopScan();
mScanner.startScan(mScannerCallback);
break;
Expand All @@ -560,13 +589,13 @@ public void onMeasurementReceived(@NonNull BluetoothDevice device, int heartRate
minHR = heartRate < minHR ? heartRate : minHR;
maxHR = heartRate > maxHR ? heartRate : maxHR;
}
mBoxHRLoading.setVisibility(View.GONE);
updateViewHR(heartRate, timestamp);
}

@Override
public void onConnected(@NonNull BluetoothDevice device) {
Timber.d("onConnected(): %s", device.getName());
device.createBond();
}

@Override
Expand All @@ -577,6 +606,7 @@ public void onDisconnected(@NonNull BluetoothDevice device) {
getResources().getColor(R.color.colorLineDivider)));
mBoxHR.setVisibility(View.GONE);
if (ConnectionUtils.isBluetoothAvailable()) {
mBoxHRLoading.setVisibility(View.VISIBLE);
mScanner.stopScan();
mScanner.startScan(mScannerCallback);
}
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/res/layout/fragment_iot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@
android:textColor="@android:color/white" />
</FrameLayout>

<FrameLayout
android:id="@+id/alert_enable_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWarning"
android:orientation="vertical"
android:padding="@dimen/default_padding"
android:visibility="gone">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:gravity="center"
android:text="@string/alert_enable_location"
android:textColor="@android:color/white" />
</FrameLayout>

<include
android:id="@+id/box_no_data"
layout="@layout/no_data"
Expand Down Expand Up @@ -154,6 +172,21 @@
android:src="@drawable/heart"
android:tint="@color/colorLineDivider" />

<LinearLayout
android:id="@+id/box_hr_progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">

<ProgressBar
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="5dp"/>
</LinearLayout>

<LinearLayout
android:id="@+id/box_hr"
android:layout_width="match_parent"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/physical_activity_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
android:layout_height="wrap_content">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/calories_img"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginStart="25dp"
Expand Down Expand Up @@ -125,6 +126,7 @@
android:layout_height="wrap_content">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/distance_img"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginStart="25dp"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
<string name="alert_no_token_fitbit">Για να συλλέξετε δεδομένα Fitbit από τα παιδια \"%s\", πρέπει πρώτα να δώσετε εξουσιοδότηση για τη συλλογή των δεδομένων.</string>
<string name="alert_access_blocked">Λυπούμαστε, αυτή η εφαρμογή δεν υποστηρίζει αυτον τον τύπο χρηστη. Επιτρέπονται μόνο οικογένειες, εκπαιδευτικοί και επαγγελματίες υγείας&#8230;</string>
<string name="alert_revoke_fitbit_success">Η πρόσβαση Fitbit ακυρώθηκε με επιτυχία. Δεν θα είστε πλέον σε θέση να πραγματοποιήσετε συγχρονισμό δεδομένων.</string>
<string name="alert_enable_bluetooth">Αν θέλετε να εμφανίζονται αυτόματα τα δεδομένα της καρδιακής συχνότητας (Polar OH1) σε αυτήν την οθόνη, κάντε κλικ εδώ για να ενεργοποιήσετε το Bluetooth&#8230;</string>
<string name="alert_enable_bluetooth">Αν θέλετε να εμφανίζονται αυτόματα τα δεδομένα της καρδιακής συχνότητας (Polar OH1, H10&#8230;) σε αυτήν την οθόνη, κάντε κλικ εδώ για να ενεργοποιήσετε το Bluetooth&#8230;</string>
<string name="alert_enable_location">If you want your Heart Rate (Polar OH1, H10&#8230;) data to be displayed automatically on this screen, you must grant access to your location. Click here to grant&#8230;</string>
<string name="alert_back_confirm">Πατήστε ξανά για έξοδο!</string>

<!-- MENU -->
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
<string name="alert_no_token_fitbit">Para recopilar datos de Fitbit del niño \"%s\", primero debe proporcionar autorización.</string>
<string name="alert_access_blocked">Lo sentimos, esta aplicación sólo permite el acceso a la familia, educador o profesional de la salud&#8230;</string>
<string name="alert_revoke_fitbit_success">Acceso a Fitbit revocado correctamente. Ya no podrá realizar la sincronización de datos.</string>
<string name="alert_enable_bluetooth">Si desea que sus datos de frecuencia cardíaca (Polar OH1) se muestren automáticamente en esta pantalla, haga clic aquí para habilitar Bluetooth&#8230;</string>
<string name="alert_enable_bluetooth">Si desea que sus datos de frecuencia cardíaca (Polar OH1, H10&#8230;) se muestren automáticamente en esta pantalla, haga clic aquí para habilitar Bluetooth&#8230;</string>
<string name="alert_enable_location">Si desea que sus datos de frecuencia cardíaca (Polar OH1, H10&#8230;) se muestren automáticamente en esta pantalla, debe otorgar acceso a su ubicación. Haga clic aquí para otorgar&#8230;</string>
<string name="alert_back_confirm">Toque de nuevo para salir!</string>

<!-- MENU -->
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
<string name="alert_no_token_fitbit">Para coletar dados Fitbit da criança \"%s\", você deve primeiro fornecer autorização para coletar os dados.</string>
<string name="alert_access_blocked">Desculpe, este aplicativo permite apenas acesso a família, educador ou profissional de saúde&#8230;</string>
<string name="alert_revoke_fitbit_success">Acesso Fitbit revogado com sucesso. Não será mais possível executar a sincronização dos dados.</string>
<string name="alert_enable_bluetooth">Se você deseja que os dados de Frequência Cardíaca (Polar OH1) sejam exibidos automaticamente nesta tela, clique aqui para ativar o Bluetooth&#8230;</string>
<string name="alert_enable_bluetooth">Se você deseja que os dados de Frequência Cardíaca (Polar OH1, H10&#8230;) sejam exibidos automaticamente nesta tela, clique aqui para ativar o Bluetooth&#8230;</string>
<string name="alert_enable_location">Se você deseja que os dados de Frequência Cardíaca (Polar OH1, H10&#8230;) sejam exibidos automaticamente nesta tela, é necessário conceder acesso a sua localização. Clique aqui para conceder&#8230;</string>
<string name="alert_back_confirm">Toque novamente para sair!</string>

<!-- MENU -->
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<string name="key_signout" translatable="false">key_signout</string>
<string name="key_sync_data" translatable="false">key_sync_data</string>
<string name="key_children" translatable="false">key_children_manager</string>
<string name="settings_summary_version" translatable="false">1.10.1</string>
<string name="settings_summary_version" translatable="false">1.10.2</string>
<string name="login_with_fitbit">Provide access to Fitbit</string>
<string name="login_do_not_user_fitbit">Do not currently use Fitbit</string>
<string name="settings_title">Settings</string>
Expand Down Expand Up @@ -135,7 +135,8 @@
<string name="alert_no_token_fitbit">To collect Fitbit data from child \"%s\", you must first provide authorization to collect the data.</string>
<string name="alert_access_blocked">Sorry, this app only allows access to family, educator or health professional.&#8230;</string>
<string name="alert_revoke_fitbit_success">Fitbit access successfully revoked. You will no longer be able to perform data synchronization.</string>
<string name="alert_enable_bluetooth">If you want your Heart Rate (Polar OH1) data to be automatically displayed on this screen, click here to enable Bluetooth&#8230;</string>
<string name="alert_enable_bluetooth">If you want your Heart Rate (Polar OH1, H10&#8230;) data to be automatically displayed on this screen, click here to enable Bluetooth&#8230;</string>
<string name="alert_enable_location">If you want your Heart Rate (Polar OH1, H10&#8230;) data to be displayed automatically on this screen, you must grant access to your location. Click here to grant&#8230;</string>
<string name="alert_back_confirm">Tap again to exit!</string>

<!-- MENU -->
Expand Down

0 comments on commit bef83cf

Please sign in to comment.