Skip to content

Commit

Permalink
Merge pull request #1442 from fossasia/development
Browse files Browse the repository at this point in the history
chore: merge dev into master
  • Loading branch information
CloudyPadmal authored Nov 16, 2018
2 parents f3529fb + e1e6f10 commit 446a3e5
Show file tree
Hide file tree
Showing 46 changed files with 2,088 additions and 1,315 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Please join us on the following channels:
- [PSLab Android App Overview](https://www.youtube.com/watch?v=JJfsF0b8M8k)
- [Observing Sound Waveforms Using PSLab Device](https://www.youtube.com/watch?v=5bxDd1PiOMQ)
- [Real-time Sensor Data Logging Using Pocket Science Lab](https://www.youtube.com/watch?v=_A8h6o-UcNo)
- [Generating and Observing Waveforms Using Pocket Science Lab](https://www.youtube.com/watch?v=Ua9_OCR4p8Y)
- [Generating and Observing Waveforms Using Pocket Science Lab](https://www.youtube.com/watch?v=Ua9_OCR4p8Y)

## Features
| **Feature** | **Description** | **Status** |
Expand All @@ -72,6 +72,10 @@ Please join us on the following channels:

## How to set up the Android app in your development environment

Minimum Android version 4.1 (API Level 16)

Maximum Android version 8.1 (API Level 27)

### Development Setup

Before you begin, you should already have the Android Studio SDK downloaded and set up correctly. You can find a guide on how to do this here: [Setting up Android Studio](http://developer.android.com/sdk/installing/index.html?pkg=studio)
Expand All @@ -93,24 +97,24 @@ Before you begin, you should already have the Android Studio SDK downloaded and
6. To Build the app, go to _Build>Make Project_ (or alternatively press the Make Project icon in the toolbar).

7. If the app was built successfully, you can test it by running it on either a real device or an emulated one by going to _Run>Run 'app'_ or pressing the Run icon in the toolbar.

If you want build apk only, go to Build>Build apk and apk would be build and directory where apk is generated would be prompted by Android Studio.

You can't debug the usual way as PSLab device is connected to micro-USB port through OTG cable. So Android Device is not connected to PC through USB cable.
You can't debug the usual way as PSLab device is connected to micro-USB port through OTG cable. So Android Device is not connected to PC through USB cable.

To debug over Wi-Fi: http://blog.fossasia.org/android-app-debugging-over-wifi-for-pslab/
Note :
1. If you built your own hardware, change VendorID and/or ProductID in [CommunicationHandler.java](https://github.com/fossasia/pslab-android/blob/master/app/src/main/java/org/fossasia/pslab/communication/CommunicationHandler.java)

Note :
1. If you built your own hardware, change VendorID and/or ProductID in [CommunicationHandler.java](https://github.com/fossasia/pslab-android/blob/master/app/src/main/java/org/fossasia/pslab/communication/CommunicationHandler.java)

## Setup to use PSLab with Android App
To use PSLab device with Android, you simply need an OTG cable, an Android Device with USB Host feature enabled ( most modern phones have OTG support ) and PSLab Android App. Connect PSLab device to Android Phone via OTG cable. Rest is handled by App itself.

## Contributions Best Practices

### Code practices

Please help us follow the best practice to make it easy for the reviewer as well as the contributor. We want to focus on the code quality more than on managing pull request ethics.
Please help us follow the best practice to make it easy for the reviewer as well as the contributor. We want to focus on the code quality more than on managing pull request ethics.

* Single commit per pull request
* Reference the issue numbers in the commit message. Follow the pattern ``` Fixes #<issue number> <commit message>```
Expand Down
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 "io.pslab"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 6
versionName "2.0.5"
versionCode 7
versionName "2.0.6"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<application
android:name=".PSLabApplication"
android:allowBackup="true"
android:icon="@drawable/logo"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:roundIcon="@drawable/logo"
android:roundIcon="@drawable/app_icon_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
Expand Down Expand Up @@ -68,12 +68,11 @@
android:name=".activity.PowerSourceActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity android:name=".activity.LuxMeterActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.WaveGeneratorActivity"
android:screenOrientation="userLandscape" />
<activity
android:name=".activity.LuxMeterActivity"
android:configChanges="orientation|screenSize|keyboardHidden" />
<activity android:name=".activity.AccelerometerActivity" />
<activity android:name=".activity.DataLoggerActivity" />
<activity
Expand All @@ -94,7 +93,7 @@
<activity android:name=".sensors.SensorSHT21" />
<activity android:name=".sensors.SensorMPU6050" />
<activity android:name=".sensors.SensorTSL2561" />
<activity android:name=".activity.SensorGraphViewActivity"></activity>
<activity android:name=".activity.SensorGraphViewActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
} else {
checkGpsOnResume = true;
}
gpsLogger.startFetchingLocation();
gpsLogger.startCaptureLocation();
} else {
recordData = true;
CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_disabled), null, null);
Expand All @@ -173,7 +173,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
if (locationPref && gpsLogger != null) {
String data;
Location location = gpsLogger.getBestLocation();
Location location = gpsLogger.getDeviceLocation();
if (location != null) {
data = "\nLocation" + "," + String.valueOf(location.getLatitude()) + "," + String.valueOf(location.getLongitude() + "\n");
} else {
Expand Down Expand Up @@ -233,7 +233,9 @@ public void onClick(DialogInterface dialogInterface, int i) {
startActivity(MAP);
break;
case R.id.settings:
startActivity(new Intent(this, SettingsActivity.class));
Intent settingIntent = new Intent(this, SettingsActivity.class);
settingIntent.putExtra("title", getResources().getString(R.string.accelerometer_configurations));
startActivity(settingIntent);
break;
default:
break;
Expand Down
43 changes: 20 additions & 23 deletions app/src/main/java/io/pslab/activity/DataLoggerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
import butterknife.ButterKnife;
import io.pslab.R;
import io.pslab.adapters.SensorLoggerListAdapter;
import io.pslab.models.SensorLogged;
import io.realm.Realm;
import io.pslab.models.SensorDataBlock;
import io.pslab.others.LocalDataLog;
import io.realm.RealmResults;
import io.realm.Sort;

/**
* Created by Avjeet on 05/08/18.
*/

public class DataLoggerActivity extends AppCompatActivity {

public static final String CALLER_ACTIVITY = "Caller";

@BindView(R.id.recycler_view)
RecyclerView recyclerView;

Expand All @@ -35,33 +36,29 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_data_logger);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
Realm realm = Realm.getDefaultInstance();
String caller = getIntent().getStringExtra(CALLER_ACTIVITY);
if (caller == null)
caller = "";
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
if (caller == null) caller = "";

RealmResults<SensorDataBlock> categoryData;

RealmResults<SensorLogged> results;
String title;
switch (caller) {
case "Lux Meter":
results = realm.where(SensorLogged.class).equalTo("sensor", caller)
.findAll()
.sort("dateTimeStart", Sort.DESCENDING);
title = caller + " Data";
getSupportActionBar().setTitle(caller);
categoryData = LocalDataLog.with().getTypeOfSensorBlocks("Lux Meter");
break;
default:
results = realm.where(SensorLogged.class)
.findAll()
.sort("dateTimeStart", Sort.DESCENDING);
title = getString(R.string.logged_data);
}
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(title);
// TODO: Fetch all
categoryData = LocalDataLog.with().getTypeOfSensorBlocks("Lux Meter");
getSupportActionBar().setTitle(getString(R.string.logged_data));
}
SensorLoggerListAdapter adapter = new SensorLoggerListAdapter(results, this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);

SensorLoggerListAdapter adapter = new SensorLoggerListAdapter(categoryData, this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(
this, LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(linearLayoutManager);

DividerItemDecoration itemDecor = new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL);
Expand Down
Loading

0 comments on commit 446a3e5

Please sign in to comment.