diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2058f378..bbeeac46 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,13 @@ + + + + + + + { + + // Check access permission to openScale + int OPENSCALE_REQUEST_CODE = 2; + int openHealthPermission = ContextCompat.checkSelfPermission(mActivity,"com.health.openscale.READ_WRITE_DATA"); + if (openHealthPermission != PackageManager.PERMISSION_GRANTED) { + + // Request access permisson + ActivityCompat.requestPermissions((Activity) mActivity, + new String[]{"com.health.openscale.READ_WRITE_DATA"}, + OPENSCALE_REQUEST_CODE); + pullToRefresh.setRefreshing(false); + return; + } + + // Import openScale data + OpenScaleSync openScaleSync = new OpenScaleSync(mActivity.getBaseContext(), getActivity()); + if (openScaleSync.importDatabase()) { + // Refresh view after loading data + refreshData(); + } + pullToRefresh.setRefreshing(false); + }); + } catch (Exception ignored){ + + } + /* Views Initialisation */ weightEdit = view.findViewById(R.id.weightInput); fatEdit = view.findViewById(R.id.fatInput); diff --git a/app/src/main/java/com/easyfitness/utils/MusicController.java b/app/src/main/java/com/easyfitness/utils/MusicController.java index b9f4347f..49fc6ccf 100644 --- a/app/src/main/java/com/easyfitness/utils/MusicController.java +++ b/app/src/main/java/com/easyfitness/utils/MusicController.java @@ -1,6 +1,7 @@ package com.easyfitness.utils; import android.Manifest; +import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ContentUris; import android.content.Context; @@ -33,6 +34,7 @@ import androidx.core.content.ContextCompat; import androidx.documentfile.provider.DocumentFile; +import com.easyfitness.DAO.export.OpenScaleSync; import com.easyfitness.MainActivity; import com.easyfitness.R; @@ -457,6 +459,7 @@ private boolean isExternalStoragePermissionDenied() { private void requestPermissionForReading() { int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 103; + ActivityCompat.requestPermissions(mActivity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); diff --git a/app/src/main/res/layout/tab_weight.xml b/app/src/main/res/layout/tab_weight.xml index 9448d5ff..4a4a4ce3 100644 --- a/app/src/main/res/layout/tab_weight.xml +++ b/app/src/main/res/layout/tab_weight.xml @@ -1,539 +1,547 @@ - - - + android:layout_height="match_parent"> + android:orientation="vertical" + android:paddingLeft="0dp" + android:paddingTop="0dp" + android:paddingRight="0dp" + android:paddingBottom="0dp"> - + android:layout_gravity="start" + android:gravity="center" + android:orientation="horizontal"> - + android:layout_margin="5dp" + android:layout_weight="1" + android:minWidth="70dp" + android:minHeight="70dp" + app:cardCornerRadius="5dp"> - + - + - + -