1- package com .shimmerresearch .shimmerserviceexample ;
1+ package com .shimmerresearch .shimmercapture ;
22
33import android .Manifest ;
44
@@ -90,6 +90,12 @@ public class MainActivity extends AppCompatActivity implements ConnectedShimmers
9090 final static String LOG_TAG = "Shimmer" ;
9191 final static String SERVICE_TAG = "ShimmerService" ;
9292 final static int REQUEST_CONNECT_SHIMMER = 2 ;
93+ public static APP_RELEASE_TYPE appReleaseType = APP_RELEASE_TYPE .PUBLIC ;
94+ public enum APP_RELEASE_TYPE {
95+ INTERNAL ,
96+ PUBLIC ,
97+ TESTING
98+ }
9399
94100 ShimmerDialogConfigurations dialog ;
95101 BluetoothAdapter btAdapter ;
@@ -114,6 +120,37 @@ public class MainActivity extends AppCompatActivity implements ConnectedShimmers
114120 @ Override
115121 protected void onCreate (Bundle savedInstanceState ) {
116122 super .onCreate (savedInstanceState );
123+ AlertDialog .Builder alertDialog = new AlertDialog .Builder (this );
124+ //alertDialog.setTitle("Device Info");
125+ alertDialog .setMessage ("Shimmer Capture App collect Location data to enable Bluetooth devices scanning on Android versions 11 and lower even when the app is closed or not in use." );
126+ alertDialog .setCancelable (false );
127+ alertDialog .setPositiveButton ("OK" , new DialogInterface .OnClickListener () {
128+ @ Override
129+ public void onClick (DialogInterface dialog , int which ) {
130+ requestPermissions ();
131+ }
132+ });
133+ alertDialog .show ();
134+
135+ //Check if Bluetooth is enabled
136+ /*if (!btAdapter.isEnabled()) {
137+ int REQUEST_ENABLE_BT = 1;
138+ Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
139+ startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
140+ }
141+ else {*/
142+
143+ //}
144+
145+
146+ /*
147+ if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE )!= PackageManager.PERMISSION_GRANTED) {
148+ requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
149+ PERMISSIONS_REQUEST_WRITE_STORAGE);
150+ }*/
151+ }
152+
153+ public void requestPermissions (){
117154
118155 int permissionCheck = ContextCompat .checkSelfPermission (this , Manifest .permission .BLUETOOTH_CONNECT );
119156 boolean permissionGranted = true ;
@@ -125,6 +162,7 @@ protected void onCreate(Bundle savedInstanceState) {
125162 if (permissionCheck != PackageManager .PERMISSION_GRANTED ) {
126163 permissionGranted = false ;
127164 }
165+
128166 permissionCheck = ContextCompat .checkSelfPermission (this , Manifest .permission .ACCESS_COARSE_LOCATION );
129167 if (permissionCheck != PackageManager .PERMISSION_GRANTED ) {
130168 permissionGranted = false ;
@@ -152,25 +190,7 @@ protected void onCreate(Bundle savedInstanceState) {
152190 mViewPager .setOffscreenPageLimit (5 ); //Ensure none of the fragments has their view destroyed when off-screen
153191 btAdapter = BluetoothAdapter .getDefaultAdapter ();
154192 dialog = new ShimmerDialogConfigurations ();
155-
156- //Check if Bluetooth is enabled
157- /*if (!btAdapter.isEnabled()) {
158- int REQUEST_ENABLE_BT = 1;
159- Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
160- startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
161- }
162- else {*/
163-
164- //}
165-
166-
167- /*
168- if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE )!= PackageManager.PERMISSION_GRANTED) {
169- requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
170- PERMISSIONS_REQUEST_WRITE_STORAGE);
171- }*/
172193 }
173-
174194 @ Override
175195 public boolean onCreateOptionsMenu (Menu menu ) {
176196 MenuInflater inflater = getMenuInflater ();
@@ -201,8 +221,11 @@ protected void startServiceandBTManager(){
201221
202222 @ Override
203223 public boolean onPrepareOptionsMenu (Menu menu ) {
204- if (mService != null ){
205- menu .findItem (R .id .connect_device ).setEnabled (mService .getListOfConnectedDevices ().isEmpty ());
224+
225+ if (appReleaseType .equals (APP_RELEASE_TYPE .PUBLIC )){
226+ if (mService != null ){
227+ menu .findItem (R .id .connect_device ).setEnabled (mService .getListOfConnectedDevices ().isEmpty ());
228+ }
206229 }
207230 MenuItem item1 = menu .findItem (R .id .data_sync );
208231 MenuItem item2 = menu .findItem (R .id .disable_logging );
@@ -214,6 +237,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
214237 MenuItem item8 = menu .findItem (R .id .start_sd_logging );
215238 MenuItem item9 = menu .findItem (R .id .stop_sd_logging );
216239 MenuItem item10 = menu .findItem (R .id .device_info );
240+ MenuItem item11 = menu .findItem (R .id .privacy_policy );
217241 if (selectedDeviceAddress != null ){
218242 ShimmerDevice device = mService .getShimmer (selectedDeviceAddress );
219243 if (device instanceof VerisenseDevice ) {
@@ -227,6 +251,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
227251 item8 .setVisible (false );
228252 item9 .setVisible (false );
229253 item10 .setVisible (false );
254+ item11 .setVisible (false );
230255 if (((VerisenseDevice )device ).isRecordingEnabled ()){
231256 item2 .setTitle ("Disable Logging" );
232257 return true ;
@@ -241,6 +266,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
241266 item8 .setVisible (true );
242267 item9 .setVisible (true );
243268 item10 .setVisible (true );
269+ item11 .setVisible (true );
244270 }
245271 }
246272 item1 .setVisible (false );
@@ -506,6 +532,10 @@ public void onClick(DialogInterface dialog, int id) {
506532 alertDialog .setMessage ("Shimmer Version: " +shimmerVersion + "\n \n Firmware Version: " +FWName );
507533 alertDialog .show ();
508534
535+ return true ;
536+ case R .id .privacy_policy :
537+ startActivity (new Intent (Intent .ACTION_VIEW ,Uri .parse ("https://www.shimmersensing.com/privacy/" )));
538+
509539 return true ;
510540 default :
511541 return super .onOptionsItemSelected (item );
@@ -531,8 +561,9 @@ public void onServiceConnected(ComponentName className, IBinder service) {
531561 Log .d (SERVICE_TAG , "Shimmer Service Bound" );
532562
533563 //if there is a device connected display it on the fragment
534- connectedShimmersListFragment .buildShimmersConnectedListView (mService .getListOfConnectedDevices (), getApplicationContext ());
535-
564+ if (connectedShimmersListFragment !=null ) {
565+ connectedShimmersListFragment .buildShimmersConnectedListView (mService .getListOfConnectedDevices (), getApplicationContext ());
566+ }
536567 }
537568
538569 public void onServiceDisconnected (ComponentName className ) {
@@ -620,8 +651,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
620651 if (deviceName .contains (VerisenseDevice .VERISENSE_PREFIX )){
621652
622653 } else {
623- showBtTypeConnectionOption ();
624-
654+ if (appReleaseType .equals (APP_RELEASE_TYPE .PUBLIC )){
655+ preferredBtType = ShimmerBluetoothManagerAndroid .BT_TYPE .BT_CLASSIC ;
656+ }else {
657+ showBtTypeConnectionOption ();
658+ }
625659 }
626660 mService .connectShimmer (macAdd ,deviceName ,preferredBtType ,this ); //Connect to the selected device, and set context to show progress dialog when pairing
627661 //mService.connectShimmer(macAdd,this); //Connect to the selected device, and set context to show progress dialog when pairing
@@ -640,7 +674,6 @@ public class SectionsPagerAdapter1 extends FragmentStatePagerAdapter {
640674
641675 public SectionsPagerAdapter1 (FragmentManager fm ) {
642676 super (fm );
643- dataSyncFragment = DataSyncFragment .newInstance ();
644677 connectedShimmersListFragment = ConnectedShimmersListFragment .newInstance ();
645678 sensorsEnabledFragment = SensorsEnabledFragment .newInstance (null , null );
646679 deviceConfigFragment = DeviceConfigFragment .newInstance ();
@@ -652,7 +685,10 @@ public SectionsPagerAdapter1(FragmentManager fm) {
652685 add (deviceConfigFragment , "Device Configuration" );
653686 add (plotFragment , "Plot" );
654687 add (signalsToPlotFragment , "Signals to Plot" );
655- add (dataSyncFragment , "Verisense Sync" );
688+ if (!(appReleaseType .equals (APP_RELEASE_TYPE .PUBLIC ))){
689+ dataSyncFragment = DataSyncFragment .newInstance ();
690+ add (dataSyncFragment , "Verisense Sync" );
691+ }
656692 }
657693
658694 @ Override
0 commit comments