Skip to content

Commit 6da9bd7

Browse files
committed
using BuildConfig.DEBUG instead of custom var
1 parent 1f96fea commit 6da9bd7

22 files changed

Lines changed: 130 additions & 111 deletions

fielddb/src/main/java/com/github/fielddb/Config.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public class Config {
2121

2222
public static String CURRENT_USERNAME = "default";
2323

24-
public static boolean D = true;
25-
2624
public static final String DATA_IS_ABOUT_LANGUAGE_ISO = PrivateConstants.DATA_IS_ABOUT_LANGUAGE_ISO;
2725
public static final String DATA_IS_ABOUT_LANGUAGE_NAME_ASCII = PrivateConstants.DATA_IS_ABOUT_LANGUAGE_NAME_ASCII;
2826
public static final String DATA_IS_ABOUT_LANGUAGE_NAME = PrivateConstants.DATA_IS_ABOUT_LANGUAGE_NAME;

fielddb/src/main/java/com/github/fielddb/database/FieldDBUserContentProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.fielddb.database;
22

3+
import com.github.fielddb.BuildConfig;
34
import com.github.fielddb.Config;
45

56
import android.content.UriMatcher;
@@ -10,7 +11,7 @@ public class FieldDBUserContentProvider extends UserContentProvider {
1011
@Override
1112
public boolean onCreate() {
1213
UserTable.ANONYMOUS_PREFIX = Config.ANONYMOUS_USER_PREFIX;
13-
if (Config.D) {
14+
if (BuildConfig.DEBUG) {
1415
UserTable.ANONYMOUS_PREFIX = "testing" + UserTable.ANONYMOUS_PREFIX;
1516
}
1617
AUTHORITY = "com.github.fielddb." + Config.APP_TYPE.toLowerCase() + "."

fielddb/src/main/java/com/github/fielddb/datacollection/DeviceDetails.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.fielddb.datacollection;
22

33
import com.github.fielddb.Config;
4+
import com.github.fielddb.BuildConfig;
45

56
import android.Manifest;
67
import android.annotation.SuppressLint;
@@ -123,24 +124,24 @@ public DeviceDetails(Context mContext) {
123124

124125
String provider = locationManager.getBestProvider(crta, true);
125126
if ("network".equals(provider)) {
126-
if (Config.D)
127+
if (BuildConfig.DEBUG)
127128
Log.d(Config.TAG, "Using network for location provider.");
128129
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
129130
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, this.min_time, this.min_dis, this);
130131
}
131132
} else if ("gps".equals(provider)) {
132-
if (Config.D)
133+
if (BuildConfig.DEBUG)
133134
Log.d(Config.TAG, "Using network for location provider.");
134135
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
135136
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
136137
}
137138
} else {
138-
if (Config.D)
139+
if (BuildConfig.DEBUG)
139140
Log.d(Config.TAG, "Best location provider was not specified, using both network and gps.");
140141

141142
permissionCheck = ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION);
142143
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
143-
if (Config.D) {
144+
if (BuildConfig.DEBUG) {
144145
Log.d(Config.TAG, "Using network for location provider.");
145146
}
146147

@@ -151,7 +152,7 @@ public DeviceDetails(Context mContext) {
151152
}
152153
}
153154
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
154-
if (Config.D)
155+
if (BuildConfig.DEBUG)
155156
Log.d(Config.TAG, "Using gps for location provider.");
156157

157158
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
@@ -173,7 +174,7 @@ public void onLocationChanged(Location location) {
173174
this.longitude = location.getLongitude();
174175
this.latitude = location.getLatitude();
175176
this.locationAccuracy = location.getAccuracy();
176-
if (Config.D)
177+
if (BuildConfig.DEBUG)
177178
Log.d(Config.TAG, "Location changed; " + this.longitude + ":" + this.latitude + " accuracy: "
178179
+ this.locationAccuracy);
179180
}

fielddb/src/main/java/com/github/fielddb/datacollection/NotifyingIntentService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.google.gson.JsonParser;
2929

3030
import com.github.fielddb.R;
31+
import com.github.fielddb.BuildConfig;
32+
3133
import android.annotation.SuppressLint;
3234
import android.app.IntentService;
3335
import android.app.Notification;
@@ -181,7 +183,7 @@ public String processResponse(URL url, HttpURLConnection urlConnection) {
181183
this.userFriendlyErrorMessage = "Problem getting server resonse code.";
182184
return null;
183185
}
184-
if (Config.D) {
186+
if (BuildConfig.DEBUG) {
185187
Log.d(Config.TAG, "Server status code " + status);
186188
}
187189
this.statusMessage = "Downloading.";
@@ -214,7 +216,7 @@ public String processResponse(URL url, HttpURLConnection urlConnection) {
214216
}
215217

216218
public void notifyUser(String message, Notification notification, int id, boolean showTryAgain) {
217-
if (Config.D) {
219+
if (BuildConfig.DEBUG) {
218220
Log.d(Config.TAG, message);
219221
}
220222
notification.tickerText = message;

fielddb/src/main/java/com/github/fielddb/datacollection/VideoRecorder.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.fielddb.datacollection;
22

33
import com.github.fielddb.Config;
4+
import com.github.fielddb.BuildConfig;
45

56
import com.github.fielddb.R;
67
import android.app.Activity;
@@ -69,7 +70,7 @@ public void surfaceCreated(SurfaceHolder holder) {
6970
Log.d(Config.TAG, "Surface was created but we are already running.");
7071
return;
7172
}
72-
if (Config.D)
73+
if (BuildConfig.DEBUG)
7374
Log.d(Config.TAG, "Preparing to record. ");
7475
this.mRecordVideoTask = new VideoRecorderAsyncTask();
7576
this.mRecordVideoTask.setContext(this);
@@ -78,7 +79,7 @@ public void surfaceCreated(SurfaceHolder holder) {
7879

7980
setResult(Activity.RESULT_OK, getIntent());
8081

81-
if (Config.D)
82+
if (BuildConfig.DEBUG)
8283
Log.d(Config.TAG, "Telling recorder asyc to execute. ");
8384
this.mRecordVideoTask.execute();
8485
this.mRecording = true;
@@ -92,7 +93,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {
9293

9394
public boolean finishSubExperiment(boolean fromExternalRequest) {
9495
try {
95-
if (Config.D)
96+
if (BuildConfig.DEBUG)
9697
Log.d(Config.TAG, "Telling recorder async to stop. ");
9798
if (this.mRecordVideoTask != null) {
9899
this.mRecordVideoTask.stopRecording();
@@ -104,7 +105,7 @@ public boolean finishSubExperiment(boolean fromExternalRequest) {
104105
return true;
105106
}
106107
} catch (Exception e) {
107-
if (Config.D)
108+
if (BuildConfig.DEBUG)
108109
Log.d(Config.TAG, "Error Telling recorder async to stop. ");
109110
e.printStackTrace();
110111
}
@@ -152,7 +153,7 @@ public void onReceive(Context context, Intent intent) {
152153
@Override
153154
public void onConfigurationChanged(Configuration newConfig) {
154155
super.onConfigurationChanged(newConfig);
155-
if (Config.D)
156+
if (BuildConfig.DEBUG)
156157
Log.d(Config.TAG, "Configuration has changed (rotation). Not redrawing the screen.");
157158
/*
158159
* Doing nothing makes the current redraw properly
@@ -161,7 +162,7 @@ public void onConfigurationChanged(Configuration newConfig) {
161162

162163
@Override
163164
public void onLowMemory() {
164-
if (Config.D)
165+
if (BuildConfig.DEBUG)
165166
Log.w(Config.TAG, "Low memory...closing");
166167
super.onLowMemory();
167168
}

fielddb/src/main/java/com/github/fielddb/datacollection/VideoRecorderAsyncTask.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.File;
44
import java.io.IOException;
55

6+
import com.github.fielddb.BuildConfig;
67
import com.github.fielddb.Config;
78
import com.github.fielddb.R;
89

@@ -148,10 +149,10 @@ public static Camera getCameraInstance() throws IOException {
148149
@SuppressLint("NewApi")
149150
protected void beginRecording(SurfaceHolder holder) throws IOException {
150151
if (this.mVideoRecorder != null) {
151-
if (Config.D)
152+
if (BuildConfig.DEBUG)
152153
Log.d(Config.TAG, "mVideoRecorder was not null. ");
153154
if (this.mRecording) {
154-
if (Config.D)
155+
if (BuildConfig.DEBUG)
155156
Log.d(Config.TAG, "Telling mVideoRecorder to stop before we start. ");
156157
this.mVideoRecorder.stop();
157158
}
@@ -167,7 +168,7 @@ protected void beginRecording(SurfaceHolder holder) throws IOException {
167168
try {
168169
this.mCamera = getCameraInstance();
169170
if (this.mCamera == null) {
170-
if (Config.D)
171+
if (BuildConfig.DEBUG)
171172
Log.e(Config.TAG, "There was a problem opening the camera. ");
172173
// TODO email devs?
173174
this.beginRecordingAudio();
@@ -185,14 +186,14 @@ protected void beginRecording(SurfaceHolder holder) throws IOException {
185186
int sdk = android.os.Build.VERSION.SDK_INT;
186187
if (sdk > 7) {
187188
if (cameraNumberUsed == -1) {
188-
if (Config.D)
189+
if (BuildConfig.DEBUG)
189190
Log.e(Config.TAG, "This appears to have no camera set, trying another resolution.");
190191
this.mVideoRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
191192
} else {
192193
this.mVideoRecorder.setProfile(CamcorderProfile.get(cameraNumberUsed, CamcorderProfile.QUALITY_HIGH));
193194
}
194195
} else {
195-
if (Config.D)
196+
if (BuildConfig.DEBUG)
196197
Log.e(Config.TAG, "This appears to be android 2.1, trying to set the audio and video manually.");
197198
this.mVideoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
198199
this.mVideoRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
@@ -211,7 +212,7 @@ protected void beginRecording(SurfaceHolder holder) throws IOException {
211212
this.mVideoRecorder.start();
212213
this.mRecording = true;
213214
} catch (Exception e) {
214-
if (Config.D)
215+
if (BuildConfig.DEBUG)
215216
Log.e(Config.TAG, "There was a problem with the camera " + e.toString());
216217
this.mRecording = false;
217218
this.beginRecordingAudio();
@@ -233,12 +234,12 @@ public void beginRecordingAudio() {
233234

234235
@Override
235236
protected String doInBackground(Void... params) {
236-
if (Config.D)
237+
if (BuildConfig.DEBUG)
237238
Log.v(Config.TAG, " doInBackground");
238239
try {
239240
this.beginRecording(this.holder);
240241
} catch (Exception e) {
241-
if (Config.D)
242+
if (BuildConfig.DEBUG)
242243
Log.e(Config.TAG, "Error calling begin recording " + e.toString());
243244
return "error recording video.";
244245
}
@@ -259,7 +260,7 @@ public Activity getParentUI() {
259260

260261
@Override
261262
protected void onPostExecute(String result) {
262-
if (Config.D)
263+
if (BuildConfig.DEBUG)
263264
Log.v(Config.TAG, " onPostExecute " + result);
264265
if (result.startsWith("error")) {
265266
this.beginRecordingAudio();
@@ -268,7 +269,7 @@ protected void onPostExecute(String result) {
268269

269270
@Override
270271
protected void onPreExecute() {
271-
if (Config.D)
272+
if (BuildConfig.DEBUG)
272273
Log.v(Config.TAG, " onPreExecute");
273274

274275
/*
@@ -284,7 +285,7 @@ protected void onPreExecute() {
284285
}
285286
(new File(this.mVideoResultsFile).getParentFile()).mkdirs();
286287

287-
if (Config.D)
288+
if (BuildConfig.DEBUG)
288289
Log.d(Config.TAG, "mVideoResultsFile " + this.mVideoResultsFile);
289290
}
290291

@@ -303,7 +304,7 @@ public void setParentUI(Activity mParentUI) {
303304
public void stopRecording() throws Exception {
304305
if (this.mVideoRecorder != null) {
305306
if (this.mRecording) {
306-
if (Config.D)
307+
if (BuildConfig.DEBUG)
307308
Log.d(Config.TAG, "We are recording. Telling mVideoRecorder to stop. ");
308309
}
309310
this.mVideoRecorder.stop();

fielddb/src/main/java/com/github/fielddb/experimentation/ui/StopWatchSubExperiment.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.util.ArrayList;
2323

24+
import com.github.fielddb.BuildConfig;
2425
import com.github.fielddb.Config;
2526
import com.github.fielddb.datacollection.AudioRecorder;
2627
import com.github.fielddb.datacollection.VideoRecorderAsyncTask;
@@ -103,13 +104,13 @@ public void finishSubExperiment() {
103104
this.setResult(Config.CODE_EXPERIMENT_COMPLETED, intent);
104105

105106
try {
106-
if (Config.D)
107+
if (BuildConfig.DEBUG)
107108
Log.d(Config.TAG, "Telling recorder asyc to stop. ");
108109
if (this.recordVideoTask != null) {
109110
this.recordVideoTask.stopRecording();
110111
}
111112
} catch (Exception e) {
112-
if (Config.D)
113+
if (BuildConfig.DEBUG)
113114
Log.d(Config.TAG, "Error Telling recorder asyc to stop. ");
114115
e.printStackTrace();
115116
}
@@ -123,7 +124,7 @@ public void finishSubExperiment() {
123124
@Override
124125
public void onConfigurationChanged(Configuration newConfig) {
125126
super.onConfigurationChanged(newConfig);
126-
if (Config.D)
127+
if (BuildConfig.DEBUG)
127128
Log.d(Config.TAG, "Configuration has changed (rotation). Not redrawing the screen.");
128129
/*
129130
* Doing nothing makes the current redraw properly
@@ -204,7 +205,7 @@ public void onNextClick(View v) {
204205

205206
@Override
206207
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
207-
if (Config.D)
208+
if (BuildConfig.DEBUG)
208209
Log.v(Config.TAG, "Width x Height = " + width + "x" + height);
209210
}
210211

@@ -213,13 +214,13 @@ public void surfaceCreated(SurfaceHolder holder) {
213214
if (this.mRecording) {
214215
return;
215216
}
216-
if (Config.D)
217+
if (BuildConfig.DEBUG)
217218
Log.d(Config.TAG, "Preparing to record. ");
218219
this.recordVideoTask = new VideoRecorderAsyncTask();
219220
this.recordVideoTask.setContext(this);
220221
this.recordVideoTask.setParentUI(this);
221222
this.recordVideoTask.setHolder(holder);
222-
if (Config.D)
223+
if (BuildConfig.DEBUG)
223224
Log.d(Config.TAG, "Telling recorder asyc to execute. ");
224225
this.recordVideoTask.execute();
225226

0 commit comments

Comments
 (0)