Skip to content

Commit 446a3e5

Browse files
authored
Merge pull request #1442 from fossasia/development
chore: merge dev into master
2 parents f3529fb + e1e6f10 commit 446a3e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2088
-1315
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Please join us on the following channels:
5555
- [PSLab Android App Overview](https://www.youtube.com/watch?v=JJfsF0b8M8k)
5656
- [Observing Sound Waveforms Using PSLab Device](https://www.youtube.com/watch?v=5bxDd1PiOMQ)
5757
- [Real-time Sensor Data Logging Using Pocket Science Lab](https://www.youtube.com/watch?v=_A8h6o-UcNo)
58-
- [Generating and Observing Waveforms Using Pocket Science Lab](https://www.youtube.com/watch?v=Ua9_OCR4p8Y)
58+
- [Generating and Observing Waveforms Using Pocket Science Lab](https://www.youtube.com/watch?v=Ua9_OCR4p8Y)
5959

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

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

75+
Minimum Android version 4.1 (API Level 16)
76+
77+
Maximum Android version 8.1 (API Level 27)
78+
7579
### Development Setup
7680

7781
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)
@@ -93,24 +97,24 @@ Before you begin, you should already have the Android Studio SDK downloaded and
9397
6. To Build the app, go to _Build>Make Project_ (or alternatively press the Make Project icon in the toolbar).
9498

9599
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.
96-
100+
97101
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.
98102

99-
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.
103+
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.
100104

101105
To debug over Wi-Fi: http://blog.fossasia.org/android-app-debugging-over-wifi-for-pslab/
102-
103-
Note :
104-
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)
105-
106+
107+
Note :
108+
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)
109+
106110
## Setup to use PSLab with Android App
107111
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.
108112

109113
## Contributions Best Practices
110114

111115
### Code practices
112116

113-
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.
117+
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.
114118

115119
* Single commit per pull request
116120
* Reference the issue numbers in the commit message. Follow the pattern ``` Fixes #<issue number> <commit message>```

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "io.pslab"
99
minSdkVersion rootProject.ext.minSdkVersion
1010
targetSdkVersion rootProject.ext.targetSdkVersion
11-
versionCode 6
12-
versionName "2.0.5"
11+
versionCode 7
12+
versionName "2.0.6"
1313
multiDexEnabled true
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
}

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<application
1717
android:name=".PSLabApplication"
1818
android:allowBackup="true"
19-
android:icon="@drawable/logo"
19+
android:icon="@drawable/app_icon"
2020
android:label="@string/app_name"
21-
android:roundIcon="@drawable/logo"
21+
android:roundIcon="@drawable/app_icon_round"
2222
android:supportsRtl="true"
2323
android:theme="@style/AppTheme">
2424
<activity
@@ -68,12 +68,11 @@
6868
android:name=".activity.PowerSourceActivity"
6969
android:screenOrientation="portrait"
7070
android:windowSoftInputMode="stateHidden|adjustResize" />
71+
<activity android:name=".activity.LuxMeterActivity"
72+
android:screenOrientation="portrait" />
7173
<activity
7274
android:name=".activity.WaveGeneratorActivity"
7375
android:screenOrientation="userLandscape" />
74-
<activity
75-
android:name=".activity.LuxMeterActivity"
76-
android:configChanges="orientation|screenSize|keyboardHidden" />
7776
<activity android:name=".activity.AccelerometerActivity" />
7877
<activity android:name=".activity.DataLoggerActivity" />
7978
<activity
@@ -94,7 +93,7 @@
9493
<activity android:name=".sensors.SensorSHT21" />
9594
<activity android:name=".sensors.SensorMPU6050" />
9695
<activity android:name=".sensors.SensorTSL2561" />
97-
<activity android:name=".activity.SensorGraphViewActivity"></activity>
96+
<activity android:name=".activity.SensorGraphViewActivity" />
9897
</application>
9998

10099
</manifest>

app/src/main/java/io/pslab/activity/AccelerometerActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
150150
} else {
151151
checkGpsOnResume = true;
152152
}
153-
gpsLogger.startFetchingLocation();
153+
gpsLogger.startCaptureLocation();
154154
} else {
155155
recordData = true;
156156
CustomSnackBar.showSnackBar(coordinatorLayout, getString(R.string.data_recording_start) + "\n" + getString(R.string.location_disabled), null, null);
@@ -173,7 +173,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
173173
}
174174
if (locationPref && gpsLogger != null) {
175175
String data;
176-
Location location = gpsLogger.getBestLocation();
176+
Location location = gpsLogger.getDeviceLocation();
177177
if (location != null) {
178178
data = "\nLocation" + "," + String.valueOf(location.getLatitude()) + "," + String.valueOf(location.getLongitude() + "\n");
179179
} else {
@@ -233,7 +233,9 @@ public void onClick(DialogInterface dialogInterface, int i) {
233233
startActivity(MAP);
234234
break;
235235
case R.id.settings:
236-
startActivity(new Intent(this, SettingsActivity.class));
236+
Intent settingIntent = new Intent(this, SettingsActivity.class);
237+
settingIntent.putExtra("title", getResources().getString(R.string.accelerometer_configurations));
238+
startActivity(settingIntent);
237239
break;
238240
default:
239241
break;

app/src/main/java/io/pslab/activity/DataLoggerActivity.java

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
import butterknife.ButterKnife;
1313
import io.pslab.R;
1414
import io.pslab.adapters.SensorLoggerListAdapter;
15-
import io.pslab.models.SensorLogged;
16-
import io.realm.Realm;
15+
import io.pslab.models.SensorDataBlock;
16+
import io.pslab.others.LocalDataLog;
1717
import io.realm.RealmResults;
18-
import io.realm.Sort;
1918

2019
/**
2120
* Created by Avjeet on 05/08/18.
2221
*/
2322

2423
public class DataLoggerActivity extends AppCompatActivity {
24+
2525
public static final String CALLER_ACTIVITY = "Caller";
26+
2627
@BindView(R.id.recycler_view)
2728
RecyclerView recyclerView;
2829

@@ -35,33 +36,29 @@ protected void onCreate(Bundle savedInstanceState) {
3536
setContentView(R.layout.activity_data_logger);
3637
ButterKnife.bind(this);
3738
setSupportActionBar(toolbar);
38-
Realm realm = Realm.getDefaultInstance();
3939
String caller = getIntent().getStringExtra(CALLER_ACTIVITY);
40-
if (caller == null)
41-
caller = "";
40+
if (getSupportActionBar() != null) {
41+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
42+
getSupportActionBar().setDisplayShowHomeEnabled(true);
43+
}
44+
if (caller == null) caller = "";
45+
46+
RealmResults<SensorDataBlock> categoryData;
4247

43-
RealmResults<SensorLogged> results;
44-
String title;
4548
switch (caller) {
4649
case "Lux Meter":
47-
results = realm.where(SensorLogged.class).equalTo("sensor", caller)
48-
.findAll()
49-
.sort("dateTimeStart", Sort.DESCENDING);
50-
title = caller + " Data";
50+
getSupportActionBar().setTitle(caller);
51+
categoryData = LocalDataLog.with().getTypeOfSensorBlocks("Lux Meter");
5152
break;
5253
default:
53-
results = realm.where(SensorLogged.class)
54-
.findAll()
55-
.sort("dateTimeStart", Sort.DESCENDING);
56-
title = getString(R.string.logged_data);
57-
}
58-
if (getSupportActionBar() != null) {
59-
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
60-
getSupportActionBar().setDisplayShowHomeEnabled(true);
61-
getSupportActionBar().setTitle(title);
54+
// TODO: Fetch all
55+
categoryData = LocalDataLog.with().getTypeOfSensorBlocks("Lux Meter");
56+
getSupportActionBar().setTitle(getString(R.string.logged_data));
6257
}
63-
SensorLoggerListAdapter adapter = new SensorLoggerListAdapter(results, this);
64-
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
58+
59+
SensorLoggerListAdapter adapter = new SensorLoggerListAdapter(categoryData, this);
60+
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(
61+
this, LinearLayoutManager.VERTICAL, false);
6562
recyclerView.setLayoutManager(linearLayoutManager);
6663

6764
DividerItemDecoration itemDecor = new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL);

0 commit comments

Comments
 (0)