diff --git a/app/src/main/java/io/pslab/activity/AccelerometerActivity.java b/app/src/main/java/io/pslab/activity/AccelerometerActivity.java index 744dc6650..45b6a5e29 100644 --- a/app/src/main/java/io/pslab/activity/AccelerometerActivity.java +++ b/app/src/main/java/io/pslab/activity/AccelerometerActivity.java @@ -1,26 +1,307 @@ package io.pslab.activity; +import android.Manifest; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.location.Location; +import android.location.LocationManager; import android.os.Bundle; +import android.os.Handler; +import android.support.annotation.NonNull; +import android.support.design.widget.BottomSheetBehavior; +import android.support.design.widget.CoordinatorLayout; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.GestureDetector; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import com.github.mikephil.charting.data.Entry; + +import java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; import io.pslab.R; import io.pslab.adapters.AccelerometerAdapter; +import io.pslab.others.CSVLogger; +import io.pslab.others.CustomSnackBar; +import io.pslab.others.GPSLogger; +import io.pslab.others.MathUtils; +import io.pslab.others.SwipeGestureDetector; public class AccelerometerActivity extends AppCompatActivity { + private static final String PREF_NAME = "AccelerometerPreferences"; + + private static final int MY_PERMISSIONS_REQUEST_STORAGE_FOR_DATA = 101; + private static final int MY_PERMISSIONS_REQUEST_STORAGE_FOR_MAPS = 102; + + public boolean recordData = false; + public boolean locationPref; + private boolean checkGpsOnResume = false; + private boolean isRecordingStarted = false; + private boolean isDataRecorded = false; + public GPSLogger gpsLogger; + public CSVLogger accLogger; + + private Menu menu; + AccelerometerAdapter adapter; + + BottomSheetBehavior bottomSheetBehavior; + GestureDetector gestureDetector; + + @BindView(R.id.accel_toolbar) + Toolbar mToolbar; + @BindView(R.id.accel_coordinator_layout) + CoordinatorLayout coordinatorLayout; + @BindView(R.id.bottom_sheet) + LinearLayout bottomSheet; + @BindView(R.id.shadow) + View tvShadow; + @BindView(R.id.img_arrow) + ImageView arrowUpDown; + @BindView(R.id.sheet_slide_text) + TextView bottomSheetSlideText; + @BindView(R.id.guide_title) + TextView bottomSheetGuideTitle; + @BindView(R.id.custom_dialog_text) + TextView bottomSheetText; + @BindView(R.id.custom_dialog_schematic) + ImageView bottomSheetSchematic; + @BindView(R.id.custom_dialog_desc) + TextView bottomSheetDesc; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_accelerometer); + setContentView(R.layout.activity_accelerometer_main); + ButterKnife.bind(this); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - AccelerometerAdapter adapter = new AccelerometerAdapter(new String[]{"X axis", "Y axis", "Z axis"}, getApplicationContext()); + setUpBottomSheet(); + setSupportActionBar(mToolbar); + + adapter = new AccelerometerAdapter(new String[]{"X axis", "Y axis", "Z axis"}, getApplicationContext()); RecyclerView recyclerView = this.findViewById(R.id.accelerometer_recycler_view); LinearLayoutManager layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.data_log_menu, menu); + this.menu = menu; + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.record_pause_data: + if (ContextCompat.checkSelfPermission(this, + Manifest.permission.WRITE_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_STORAGE_FOR_DATA); + return true; + } + if (recordData) { + item.setIcon(R.drawable.record_icon); + adapter.setRecordingStatus(false); + recordData = false; + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_paused), null, null); + } else { + isDataRecorded = true; + item.setIcon(R.drawable.pause_icon); + adapter.setRecordingStatus(true); + if (!isRecordingStarted) { + accLogger = new CSVLogger(getString(R.string.accelerometer)); + accLogger.writeCSVFile("Timestamp,X,Y,Z\n"); + isRecordingStarted = true; + recordData = true; + } + if (locationPref) { + gpsLogger = new GPSLogger(this, (LocationManager) getSystemService(Context.LOCATION_SERVICE)); + if (gpsLogger.isGPSEnabled()) { + recordData = true; + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_enabled), null, null); + } else { + checkGpsOnResume = true; + } + gpsLogger.startFetchingLocation(); + } else { + recordData = true; + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_disabled), null, null); + } + } + break; + case R.id.record_csv_data: + if (isDataRecorded) { + MenuItem item1 = menu.findItem(R.id.record_pause_data); + item1.setIcon(R.drawable.record_icon); + + // Export Data + ArrayList dataX = adapter.getEntries(0); + ArrayList dataY = adapter.getEntries(1); + ArrayList dataZ = adapter.getEntries(2); + int length = Math.min(Math.min(dataX.size(), dataY.size()), dataZ.size()); + for (int i = 0; i < length; i++) { + accLogger.writeCSVFile(dataX.get(i).getX() + "," + dataX.get(i).getY() + "," + + dataY.get(i).getY() + "," + dataZ.get(i).getY() + "\n"); + } + if (locationPref && gpsLogger != null) { + String data; + Location location = gpsLogger.getBestLocation(); + if (location != null) { + data = "\nLocation" + "," + String.valueOf(location.getLatitude()) + "," + String.valueOf(location.getLongitude() + "\n"); + } else { + data = "\nLocation" + "," + "null" + "," + "null"; + } + accLogger.writeCSVFile(data); + gpsLogger.removeUpdate(); + } + CustomSnackBar.showSnackBar(coordinatorLayout, + getString(R.string.csv_store_text) + " " + accLogger.getCurrentFilePath() + , getString(R.string.delete_capital), new View.OnClickListener() { + @Override + public void onClick(View view) { + new AlertDialog.Builder(AccelerometerActivity.this, R.style.AlertDialogStyle) + .setTitle(R.string.delete_file) + .setMessage(R.string.delete_warning) + .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + accLogger.deleteFile(); + } + }) + .setNegativeButton(R.string.cancel, null) + .create() + .show(); + } + }); + adapter.setRecordingStatus(false); + isRecordingStarted = false; + recordData = false; + } else { + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.nothing_to_export), null, null); + } + break; + case R.id.delete_csv_data: + if (isDataRecorded) { + MenuItem item1 = menu.findItem(R.id.record_pause_data); + item1.setIcon(R.drawable.record_icon); + adapter.setRecordingStatus(false); + recordData = false; + isRecordingStarted = false; + isDataRecorded = false; + accLogger.deleteFile(); + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_deleted), null, null); + } else + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.nothing_to_delete), null, null); + break; + case R.id.show_map: + if (ContextCompat.checkSelfPermission(this, + Manifest.permission.WRITE_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_STORAGE_FOR_MAPS); + return true; + } + Intent MAP = new Intent(getApplicationContext(), MapsActivity.class); + startActivity(MAP); + break; + case R.id.settings: + startActivity(new Intent(this, SettingsActivity.class)); + break; + default: + break; + } + return true; + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if(isRecordingStarted) { + accLogger.deleteFile(); + isRecordingStarted = false; + } + } + + private void setUpBottomSheet() { + bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); + + final SharedPreferences settings = this.getSharedPreferences(PREF_NAME, MODE_PRIVATE); + Boolean isFirstTime = settings.getBoolean("AccelerometerFirstTime", true); + + bottomSheetGuideTitle.setText(R.string.accelerometer); + bottomSheetText.setText(R.string.accelerometer_intro); + bottomSheetSchematic.setImageResource(R.drawable.find_mobile_axis); + bottomSheetDesc.setText(R.string.accelerometer_description_text); + + if (isFirstTime) { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); + tvShadow.setAlpha(0.8f); + arrowUpDown.setRotation(180); + bottomSheetSlideText.setText(R.string.hide_guide_text); + SharedPreferences.Editor editor = settings.edit(); + editor.putBoolean("AccelerometerFirstTime", false); + editor.apply(); + } else { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); + } + + bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { + private Handler handler = new Handler(); + private Runnable runnable = new Runnable() { + @Override + public void run() { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); + } + }; + + @Override + public void onStateChanged(@NonNull final View bottomSheet, int newState) { + switch (newState) { + case BottomSheetBehavior.STATE_EXPANDED: + handler.removeCallbacks(runnable); + bottomSheetSlideText.setText(R.string.hide_guide_text); + break; + + case BottomSheetBehavior.STATE_COLLAPSED: + handler.postDelayed(runnable, 2000); + break; + + default: + handler.removeCallbacks(runnable); + bottomSheetSlideText.setText(R.string.show_guide_text); + } + } + + @Override + public void onSlide(@NonNull View bottomSheet, float slideOffset) { + Float value = (float) MathUtils.map((double) slideOffset, 0.0, 1.0, 0.0, 0.8); + tvShadow.setAlpha(value); + arrowUpDown.setRotation(slideOffset * 180); + } + }); + gestureDetector = new GestureDetector(this, new SwipeGestureDetector(bottomSheetBehavior)); + } } diff --git a/app/src/main/java/io/pslab/activity/LuxMeterActivity.java b/app/src/main/java/io/pslab/activity/LuxMeterActivity.java index 750ceff7b..34509c6e0 100644 --- a/app/src/main/java/io/pslab/activity/LuxMeterActivity.java +++ b/app/src/main/java/io/pslab/activity/LuxMeterActivity.java @@ -33,6 +33,7 @@ import io.pslab.R; import io.pslab.fragment.LuxMeterFragmentConfig; import io.pslab.fragment.LuxMeterFragmentData; +import io.pslab.others.CSVLogger; import io.pslab.others.CustomSnackBar; import io.pslab.others.GPSLogger; import io.pslab.others.MathUtils; @@ -43,19 +44,28 @@ import butterknife.ButterKnife; public class LuxMeterActivity extends AppCompatActivity { - BottomSheetBehavior bottomSheetBehavior; - GestureDetector gestureDetector; + private static final String PREF_NAME = "customDialogPreference"; private static final int MY_PERMISSIONS_REQUEST_STORAGE_FOR_DATA = 101; private static final int MY_PERMISSIONS_REQUEST_STORAGE_FOR_MAPS = 102; + public boolean recordData = false; + public boolean exportData = false; + public boolean recordingStarted = false; + public GPSLogger gpsLogger; + public boolean locationPref; + public CSVLogger luxLogger; + private Menu menu; + + BottomSheetBehavior bottomSheetBehavior; + GestureDetector gestureDetector; + @BindView(R.id.navigation_lux_meter) BottomNavigationView bottomNavigationView; @BindView(R.id.toolbar) Toolbar toolbar; @BindView(R.id.cl) CoordinatorLayout coordinatorLayout; - //bottomSheet @BindView(R.id.bottom_sheet) LinearLayout bottomSheet; @@ -73,11 +83,7 @@ public class LuxMeterActivity extends AppCompatActivity { ImageView bottomSheetSchematic; @BindView(R.id.custom_dialog_desc) TextView bottomSheetDesc; - - public boolean saveData = false; - public GPSLogger gpsLogger; private boolean checkGpsOnResume = false; - public boolean locationPref; @Override protected void onCreate(Bundle savedInstanceState) { @@ -193,13 +199,14 @@ public boolean onTouchEvent(MotionEvent event) { public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.data_log_menu, menu); + this.menu = menu; return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.save_csv_data: + case R.id.record_pause_data: if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { @@ -207,24 +214,53 @@ public boolean onOptionsItemSelected(MenuItem item) { new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_STORAGE_FOR_DATA); return true; } - if (saveData) { - saveData = false; + if (recordData) { + item.setIcon(R.drawable.record_icon); + recordData = false; + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_paused), null, null); } else { + item.setIcon(R.drawable.pause_icon); + if (!recordingStarted) { + luxLogger = new CSVLogger(getString(R.string.lux_meter)); + luxLogger.writeCSVFile("Timestamp,X,Y\n"); + recordingStarted = true; + } if (locationPref) { gpsLogger = new GPSLogger(this, (LocationManager) getSystemService(Context.LOCATION_SERVICE)); if (gpsLogger.isGPSEnabled()) { - saveData = true; + recordData = true; CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_enabled), null, null); } else { checkGpsOnResume = true; } gpsLogger.startFetchingLocation(); } else { - saveData = true; + recordData = true; CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_disabled), null, null); } } - invalidateOptionsMenu(); + break; + case R.id.record_csv_data: + if (recordingStarted) { + MenuItem item1 = menu.findItem(R.id.record_pause_data); + item1.setIcon(R.drawable.record_icon); + exportData = true; + recordingStarted = false; + recordData = false; + } else { + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.nothing_to_export), null, null); + } + break; + case R.id.delete_csv_data: + if (recordingStarted) { + MenuItem item1 = menu.findItem(R.id.record_pause_data); + item1.setIcon(R.drawable.record_icon); + luxLogger.deleteFile(); + recordingStarted = false; + recordData = false; + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_deleted), null, null); + } else + CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.nothing_to_delete), null, null); break; case R.id.show_map: if (ContextCompat.checkSelfPermission(this, @@ -251,10 +287,10 @@ protected void onResume() { super.onResume(); if (checkGpsOnResume) { if (gpsLogger.isGPSEnabled()) { - saveData = true; + recordData = true; CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start), null, null); } else { - saveData = false; + recordData = false; Toast.makeText(getApplicationContext(), getString(R.string.gps_not_enabled), Toast.LENGTH_SHORT).show(); } @@ -270,14 +306,14 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis if (locationPref) { gpsLogger = new GPSLogger(this, (LocationManager) getSystemService(Context.LOCATION_SERVICE)); if (gpsLogger.isGPSEnabled()) { - saveData = true; + recordData = true; CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_enabled), null, null); } else { checkGpsOnResume = true; } gpsLogger.startFetchingLocation(); } else { - saveData = true; + recordData = true; CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_disabled), null, null); } } else { diff --git a/app/src/main/java/io/pslab/adapters/AccelerometerAdapter.java b/app/src/main/java/io/pslab/adapters/AccelerometerAdapter.java index bf366ffda..1fe029076 100644 --- a/app/src/main/java/io/pslab/adapters/AccelerometerAdapter.java +++ b/app/src/main/java/io/pslab/adapters/AccelerometerAdapter.java @@ -46,6 +46,13 @@ public class AccelerometerAdapter extends RecyclerView.Adapter xAxis, yAxis, zAxis; + private boolean isRecording = false; + + public AccelerometerAdapter(String[] dataset, Context context) { + this.dataset = dataset; + this.context = context; + } @Override public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) { @@ -125,6 +132,23 @@ public void onSensorChanged(SensorEvent event) { holder.chart.moveViewToX(data.getEntryCount()); holder.chart.invalidate(); } + + switch (holder.getAdapterPosition()) { + case 0: + if (isRecording) + xAxis = holder.entries; + break; + case 1: + if (isRecording) + yAxis = holder.entries; + break; + case 2: + if (isRecording) + zAxis = holder.entries; + break; + default: + break; + } } @Override @@ -148,11 +172,6 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) { } } - public AccelerometerAdapter(String[] dataset, Context context) { - this.dataset = dataset; - this.context = context; - } - @NonNull @Override public AccelerometerAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { @@ -163,6 +182,28 @@ public AccelerometerAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup par return new ViewHolder(v); } + @Override + public int getItemCount() { + return dataset.length; + } + + public void setRecordingStatus(boolean status) { + this.isRecording = status; + } + + public ArrayList getEntries(int axis) { + switch (axis) { + case 0: + return this.xAxis; + case 1: + return this.yAxis; + case 2: + return this.zAxis; + default: + return this.xAxis; + } + } + static class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.axis_image) ImageView axisImage; @@ -188,9 +229,4 @@ public ViewHolder(View itemView) { ButterKnife.bind(this, itemView); } } - - @Override - public int getItemCount() { - return dataset.length; - } } diff --git a/app/src/main/java/io/pslab/fragment/LuxMeterFragmentData.java b/app/src/main/java/io/pslab/fragment/LuxMeterFragmentData.java index 7867fc6a0..f33296488 100644 --- a/app/src/main/java/io/pslab/fragment/LuxMeterFragmentData.java +++ b/app/src/main/java/io/pslab/fragment/LuxMeterFragmentData.java @@ -54,7 +54,6 @@ public class LuxMeterFragmentData extends Fragment { private static int highLimit = 2000; private static int updatePeriod = 100; private final Object lock = new Object(); - public CSVLogger lux_logger; @BindView(R.id.lux_stat_max) TextView statMax; @@ -81,7 +80,6 @@ public class LuxMeterFragmentData extends Fragment { private YAxis y; private volatile boolean monitor = true; private Unbinder unbinder; - private boolean logged = false, writeHeader = false; private long previousTimeElapsed = (System.currentTimeMillis() - startTime) / 1000; private GPSLogger gpsLogger; @@ -313,53 +311,48 @@ private void visualizeData() { final LuxMeterActivity parent = (LuxMeterActivity) getActivity(); for (Entry item : entries) { assert parent != null; - if (parent.saveData) { - if (!writeHeader) { - gpsLogger = parent.gpsLogger; - lux_logger = new CSVLogger(getString(R.string.lux_meter)); - lux_logger.writeCSVFile("Timestamp,X,Y\n"); - writeHeader = true; - } + + if (parent.recordData) { + gpsLogger = parent.gpsLogger; String data = String.valueOf(System.currentTimeMillis()) + "," + item.getX() + "," + item.getY() + "\n"; - lux_logger.writeCSVFile(data); - logged = true; - } else { - if (logged) { - writeHeader = false; - logged = false; - if (parent.locationPref && gpsLogger != null) { - String data; - Location location = gpsLogger.getBestLocation(); - if (location != null) { - data = "\nLocation" + "," + String.valueOf(location.getLatitude()) + "," + String.valueOf(location.getLongitude() + "\n"); - } else { - data = "\nLocation" + "," + "null" + "," + "null"; - } - lux_logger.writeCSVFile(data); - gpsLogger.removeUpdate(); + parent.luxLogger.writeCSVFile(data); + } + + if (parent.exportData) { + parent.exportData = false; + if (parent.locationPref && gpsLogger != null) { + String data; + Location location = gpsLogger.getBestLocation(); + if (location != null) { + data = "\nLocation" + "," + String.valueOf(location.getLatitude()) + "," + String.valueOf(location.getLongitude() + "\n"); + } else { + data = "\nLocation" + "," + "null" + "," + "null"; } - CustomSnackBar.showSnackBar((CoordinatorLayout) parent.findViewById(R.id.cl), - getString(R.string.csv_store_text) + " " + lux_logger.getCurrentFilePath() - , getString(R.string.delete_capital), new View.OnClickListener() { - @Override - public void onClick(View view) { - new AlertDialog.Builder(parent, R.style.AlertDialogStyle) - .setTitle(R.string.delete_file) - .setMessage(R.string.delete_warning) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - lux_logger.deleteFile(); - } - }) - .setNegativeButton(R.string.cancel, null) - .create() - .show(); - } - }); + parent.luxLogger.writeCSVFile(data); + gpsLogger.removeUpdate(); } + CustomSnackBar.showSnackBar((CoordinatorLayout) parent.findViewById(R.id.cl), + getString(R.string.csv_store_text) + " " + parent.luxLogger.getCurrentFilePath() + , getString(R.string.delete_capital), new View.OnClickListener() { + @Override + public void onClick(View view) { + new AlertDialog.Builder(parent, R.style.AlertDialogStyle) + .setTitle(R.string.delete_file) + .setMessage(R.string.delete_warning) + .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + parent.luxLogger.deleteFile(); + } + }) + .setNegativeButton(R.string.cancel, null) + .create() + .show(); + } + }); } + count++; sum += item.getY(); } diff --git a/app/src/main/java/io/pslab/others/GPSLogger.java b/app/src/main/java/io/pslab/others/GPSLogger.java index d6dbead31..4280b3119 100644 --- a/app/src/main/java/io/pslab/others/GPSLogger.java +++ b/app/src/main/java/io/pslab/others/GPSLogger.java @@ -59,7 +59,7 @@ public void onProviderEnabled(String s) { /**/} @Override public void onProviderDisabled(String s) { - callerActivity.saveData = false; + callerActivity.recordData = false; new AlertDialog.Builder(callerActivity, R.style.AlertDialogStyle) .setTitle(R.string.allow_gps) .setMessage(R.string.allow_gps_info) diff --git a/app/src/main/res/drawable/delete_icon.xml b/app/src/main/res/drawable/delete_icon.xml new file mode 100755 index 000000000..7e8e3ce02 --- /dev/null +++ b/app/src/main/res/drawable/delete_icon.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/pause_icon.xml b/app/src/main/res/drawable/pause_icon.xml new file mode 100755 index 000000000..1802dd3db --- /dev/null +++ b/app/src/main/res/drawable/pause_icon.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/record_icon.xml b/app/src/main/res/drawable/record_icon.xml new file mode 100755 index 000000000..76531d09f --- /dev/null +++ b/app/src/main/res/drawable/record_icon.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/activity_accelerometer.xml b/app/src/main/res/layout/activity_accelerometer.xml index 7bc47859f..e46d5a6b5 100644 --- a/app/src/main/res/layout/activity_accelerometer.xml +++ b/app/src/main/res/layout/activity_accelerometer.xml @@ -1,7 +1,8 @@ - - + + diff --git a/app/src/main/res/layout/activity_accelerometer_main.xml b/app/src/main/res/layout/activity_accelerometer_main.xml new file mode 100644 index 000000000..43f04b357 --- /dev/null +++ b/app/src/main/res/layout/activity_accelerometer_main.xml @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/data_log_menu.xml b/app/src/main/res/menu/data_log_menu.xml index bd6a4078f..f2e9a6bfb 100644 --- a/app/src/main/res/menu/data_log_menu.xml +++ b/app/src/main/res/menu/data_log_menu.xml @@ -2,15 +2,25 @@ + + + app:showAsAction="never" /> + app:showAsAction="never" /> ms<sup><small>-2</small></sup> ms-2 Time (s) + Accelerometer is used to measure acceleration of a body along the X, Y and Z axis.\n + \n\nThe figure above shows the direction of all the three axis when the mobile is held straight.\n\nSteps to measure acceleration in PSLab app:\n\n\u2022 Hold the device as shown in the above figure.\n\n\u2022 Accelerate the device along any one or multiple axis.\n\n\u2022 Observe the values in the cards or the plotted graph of any particular axis.\n\nThe Accelerometer instrument can also be used to measure the acceleration of a moving body by placing the device on/inside the body and then accelerating the body.\n\nNOTE: Don\'t accelerate the body if the device isn\'t properly attached else the device could be damaged. Set Triggers Remove @@ -894,7 +896,7 @@ Measures the pressure of the atmosphere Barometer - Data + Data Plot Configure High Limit Update Period @@ -919,9 +921,16 @@ None - Save CSV Data + Export Data + Delete CSV Data + Record Data + Pause Recording View Map Data Recording: Started + Data Recording: Paused + Recorded data deleted successfully + Nothing to delete + Please record some data CSV file stored at Are you sure you want to delete this file?