Skip to content

Commit 7346284

Browse files
author
Daniil Efremov
committed
code cleaning: - removed unused or commented code
1 parent 03d08fd commit 7346284

File tree

1 file changed

+3
-224
lines changed

1 file changed

+3
-224
lines changed

app/src/main/java/openscience/crowdsource/video/experiments/MainActivity.java

Lines changed: 3 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import android.app.Activity;
2020
import android.app.AlertDialog;
21-
import android.app.ProgressDialog;
2221
import android.content.DialogInterface;
2322
import android.content.Intent;
2423
import android.content.pm.ActivityInfo;
@@ -41,7 +40,6 @@
4140
import android.text.SpannableString;
4241
import android.text.style.UnderlineSpan;
4342
import android.util.Base64;
44-
import android.util.Log;
4543
import android.view.SurfaceHolder;
4644
import android.view.SurfaceView;
4745
import android.view.View;
@@ -80,9 +78,7 @@
8078
import java.net.URL;
8179
import java.net.URLConnection;
8280
import java.security.MessageDigest;
83-
import java.text.SimpleDateFormat;
8481
import java.util.ArrayList;
85-
import java.util.Date;
8682
import java.util.LinkedList;
8783
import java.util.List;
8884

@@ -93,7 +89,6 @@ public class MainActivity extends Activity implements GLSurfaceView.Renderer {
9389

9490
private static final int REQUEST_IMAGE_CAPTURE = 100;
9591
private static final int REQUEST_IMAGE_SELECT = 200;
96-
public static final int MEDIA_TYPE_IMAGE = 1;
9792
public static final String ACKNOWLEDGE_YOUR_CONTRIBUTIONS = "acknowledge your contributions!";
9893

9994

@@ -121,26 +116,18 @@ public class MainActivity extends Activity implements GLSurfaceView.Renderer {
121116
String repo_uoa = "upload";
122117

123118
String BUTTON_NAME_UPDATE = "Update";
124-
String BUTTON_NAME_EXIT = "Exit";
125119

126120
String s_thanks = "Thank you for participation!\n";
127121

128-
int iterations = 1;
129122
static String email = "";
130123

131124
EditText log = null;
132125
Button buttonUpdateExit = null;
133126

134127
private ImageButton btnSelect;
135128

136-
private ProgressDialog dialog;
137129
private GLSurfaceView glSurfaceView;
138130

139-
private Uri fileUri;
140-
File sdcard = Environment.getExternalStorageDirectory();
141-
142-
private static String[] IMAGENET_CLASSES;
143-
144131
String cemail = "email.txt";
145132
String path1 = "ck-crowd";
146133

@@ -163,11 +150,8 @@ public class MainActivity extends Activity implements GLSurfaceView.Renderer {
163150
TextView t_email;
164151

165152

166-
String fpack = "ck-pack.zip";
167-
168153
String chmod744 = "/system/bin/chmod 744";
169154

170-
boolean skip_freq_check = true;
171155
private GoogleApiClient client;
172156

173157
PFInfo pfInfo;
@@ -302,7 +286,6 @@ private void stopCameraPreview() {
302286
}
303287
camera = null;
304288
isCameraStarted = false;
305-
// captureImageFromCameraPreviewAndPredict(false);
306289
}
307290
}
308291

@@ -354,8 +337,6 @@ public void onClick(View v) {
354337
captureImageFromCameraPreviewAndPredict(true);
355338
return;
356339
}
357-
// if (updateEMail()) return;
358-
359340

360341
// Call prediction
361342
predictImage(actualImageFilePath);
@@ -497,32 +478,6 @@ public void onClick(View v) {
497478

498479
loadCachedEmail();
499480

500-
// TBD: need to be redone!
501-
//Get GPU name via GLES10 **************************************************
502-
/* new Thread(new Runnable() {
503-
504-
@Override
505-
public void run() {
506-
try {
507-
Thread.sleep(800);
508-
MainActivity.this.runOnUiThread(new Runnable() {
509-
510-
@Override
511-
public void run() {
512-
pf_gpu_vendor = String.valueOf(GLES10.glGetString(GL10.GL_VENDOR));
513-
if (pf_gpu_vendor.equals("null")) pf_gpu_vendor = "";
514-
515-
String x = String.valueOf(GLES10.glGetString(GL10.GL_RENDERER));
516-
if (x.equals("null")) pf_gpu = "";
517-
else pf_gpu = pf_gpu_vendor + " " + x;
518-
}
519-
});
520-
} catch (InterruptedException e) {
521-
log.append("\nWarning: "+e.getMessage() + "\n\n");
522-
}
523-
}
524-
}).start();
525-
*/
526481
isUpdateMode = false;
527482
preloadScenarioses(false);
528483
// ATTENTION: This was auto-generated to implement the App Indexing API.
@@ -677,28 +632,6 @@ public void run() {
677632
platformFeatures = null; // force reload features
678633
isUpdateMode = true;
679634
preloadScenarioses(true);
680-
// running = true;
681-
// buttonUpdateExit.setText(BUTTON_NAME_EXIT);
682-
// b_clean.setEnabled(false);
683-
//
684-
// String email1 = t_email.getText().toString().replaceAll("(\\r|\\n)", "");
685-
// if (email1.equals("")) {
686-
// email1 = openme.gen_uid();
687-
// }
688-
// if (!email1.equals(email)) {
689-
// email = email1;
690-
// if (!save_one_string_file(pemail, email)) {
691-
// log.append("ERROR: can't write local configuration (" + pemail + "!");
692-
// return;
693-
// }
694-
// t_email.setText(email.trim());
695-
// }
696-
//
697-
//// CheckBox c_continuous = (CheckBox) findViewById(R.id.c_continuous);
698-
//// if (c_continuous.isChecked()) iterations = -1;
699-
// isPreloadMode = false;
700-
// isUpdateMode = true;
701-
// crowdTask = new RunCodeAsync().execute("");
702635
}
703636
}
704637
});
@@ -1064,10 +997,6 @@ public void onSurfaceCreated(GL10 gl10, EGLConfig eglConfig) {
1064997
runOnUiThread(new Runnable() {
1065998
@Override
1066999
public void run() {
1067-
// log.append(s_line1);
1068-
// log.append(" GPU: " + pf_gpu + "\n");
1069-
// log.append(" GPU Vendor: " + pf_gpu_vendor + "\n");
1070-
// log.append(s_line1);
10711000
glSurfaceView.setVisibility(View.GONE);
10721001
}
10731002
});
@@ -1251,22 +1180,8 @@ protected String doInBackground(String... arg0) {
12511180
JSONObject ft_plat = null;
12521181
JSONObject ftuoa = null;
12531182

1254-
// Example of alert box for errors
1255-
// publishProgress("", "Error", "Internal problem");
1256-
1257-
// request example {"raw_results":"---------- Prediction for \/sdcard\/openscience\/\/tmp\/\/1477424158844.jpg ----------\n0.3990 - \"n04372370 switch, electric switch, electrical switch\"\n0.2136 - \"n04254120 soap dispenser\"\n0.1158 - \"n15075141 toilet tissue, toilet paper, bathroom tissue\"\n0.0343 - \"n04447861 toilet seat\"\n0.0325 - \"n04554684 washer, automatic washer, washing machine\"\n","correct_answer":"socket","file_base64":"","data_uid":"0876cb59d3249129","behavior_uid":"2b451da3d4bc836a","action":"process_unexpected_behavior","crowd_uid":"1046ff8d479dc6af"}
1258-
// sendCorrectAnswer("ok", "not ok ", "/sdcard/openscience/test.jpg", "0876cb59d3249129", "2b451da3d4bc836a", "1046ff8d479dc6af");
1259-
/*********** Printing local tmp directory **************/
1260-
1261-
// used for fast tests
1262-
// runOnUiThread(new Runnable() {
1263-
// @Override
1264-
// public void run() {
1265-
// updateImageView("/sdcard/openscience/test.jpg");
1266-
// }
1267-
// });
1268-
12691183
publishProgress("\n"); //s_line);
1184+
publishProgress(s_line);
12701185
publishProgress("Local tmp directory: " + path + "\n");
12711186
publishProgress("User ID: " + email + "\n");
12721187

@@ -2080,11 +1995,6 @@ protected String doInBackground(String... arg0) {
20801995
return null;
20811996
}
20821997

2083-
// String externalSDCard = System.getenv("SECONDARY_STORAGE"); //this is correct way to detect externalSDCard but there is problem with permissions ls -l
2084-
// String externalSDCard = Environment.getExternalStorageDirectory().getAbsolutePath(); // actually this is internal emulated sdcard storage
2085-
// String externalSDCardOpensciencePath = externalSDCard + File.separator + "openscience" + File.separator;
2086-
// String externalSDCardPath = File.separator + "sdcard";
2087-
// String externalSDCardOpensciencePath = externalSDCardPath + File.separator + "openscience" + File.separator;
20881998
String localAppPath = path + File.separator + "openscience" + File.separator;
20891999

20902000
File externalSDCardFile = new File(externalSDCardOpensciencePath);
@@ -2471,7 +2381,7 @@ public void run() {
24712381
final EditText edittext = new EditText(MainActivity.this);
24722382
AlertDialog.Builder clarifyDialogBuilder = new AlertDialog.Builder(MainActivity.this);
24732383
clarifyDialogBuilder.setTitle("Please, enter correct answer:")
2474-
// .setIcon(R.drawable.) //todo provide some standart icon for synch answer
2384+
//todo provide some standart icon for synch answer for example using clarifyDialogBuilder.setIcon(R.drawable.)
24752385
.setCancelable(false)
24762386
.setPositiveButton("Send",
24772387
new DialogInterface.OnClickListener() {
@@ -2655,93 +2565,6 @@ public void setJ_sys_uid(String j_sys_uid) {
26552565
this.j_sys_uid = j_sys_uid;
26562566
}
26572567
}
2658-
2659-
class RecognitionResult {
2660-
private long processingTime;
2661-
private String crowdUID;
2662-
private String recognitionResultText;
2663-
private String imageFileName;
2664-
private int imageHeight;
2665-
private int imageWidth;
2666-
2667-
public long getProcessingTime() {
2668-
return processingTime;
2669-
}
2670-
2671-
public void setProcessingTime(long processingTime) {
2672-
this.processingTime = processingTime;
2673-
}
2674-
2675-
public String getCrowdUID() {
2676-
return crowdUID;
2677-
}
2678-
2679-
public void setCrowdUID(String crowdUID) {
2680-
this.crowdUID = crowdUID;
2681-
}
2682-
2683-
public String getRecognitionResultText() {
2684-
return recognitionResultText;
2685-
}
2686-
2687-
public void setRecognitionResultText(String recognitionResultText) {
2688-
this.recognitionResultText = recognitionResultText;
2689-
}
2690-
2691-
public String getImageFileName() {
2692-
return imageFileName;
2693-
}
2694-
2695-
public void setImageFileName(String imageFileName) {
2696-
this.imageFileName = imageFileName;
2697-
}
2698-
2699-
public int getImageHeight() {
2700-
return imageHeight;
2701-
}
2702-
2703-
public void setImageHeight(int imageHeight) {
2704-
this.imageHeight = imageHeight;
2705-
}
2706-
2707-
public int getImageWidth() {
2708-
return imageWidth;
2709-
}
2710-
2711-
public void setImageWidth(int imageWidth) {
2712-
this.imageWidth = imageWidth;
2713-
}
2714-
2715-
@Override
2716-
public boolean equals(Object o) {
2717-
if (this == o) return true;
2718-
if (o == null || getClass() != o.getClass()) return false;
2719-
2720-
RecognitionResult that = (RecognitionResult) o;
2721-
2722-
if (processingTime != that.processingTime) return false;
2723-
if (imageHeight != that.imageHeight) return false;
2724-
if (imageWidth != that.imageWidth) return false;
2725-
if (crowdUID != null ? !crowdUID.equals(that.crowdUID) : that.crowdUID != null)
2726-
return false;
2727-
if (recognitionResultText != null ? !recognitionResultText.equals(that.recognitionResultText) : that.recognitionResultText != null)
2728-
return false;
2729-
return imageFileName != null ? imageFileName.equals(that.imageFileName) : that.imageFileName == null;
2730-
2731-
}
2732-
2733-
@Override
2734-
public int hashCode() {
2735-
int result = (int) (processingTime ^ (processingTime >>> 32));
2736-
result = 31 * result + (crowdUID != null ? crowdUID.hashCode() : 0);
2737-
result = 31 * result + (recognitionResultText != null ? recognitionResultText.hashCode() : 0);
2738-
result = 31 * result + (imageFileName != null ? imageFileName.hashCode() : 0);
2739-
result = 31 * result + imageHeight;
2740-
result = 31 * result + imageWidth;
2741-
return result;
2742-
}
2743-
}
2744-
27452568
}
27462569

27472570
// Recognize image ********************************************************************************
@@ -2816,16 +2639,6 @@ public static Bitmap decodeSampledBitmapFromResource(String imagePath,
28162639
return BitmapFactory.decodeFile(imagePath, options);
28172640
}
28182641

2819-
private BitmapFactory.Options prepareBitmapOptions(String imagePath) {
2820-
BitmapFactory.Options options = new BitmapFactory.Options();
2821-
options.inJustDecodeBounds = true;
2822-
BitmapFactory.decodeFile(imagePath, options);
2823-
int imageHeight = options.outHeight;
2824-
int imageWidth = options.outWidth;
2825-
String imageType = options.outMimeType;
2826-
return options;
2827-
}
2828-
28292642
public static int calculateInSampleSize(
28302643
BitmapFactory.Options options, int reqWidth, int reqHeight) {
28312644
// Raw height and width of image
@@ -2865,17 +2678,14 @@ private ImageInfo getImageInfo(String imagePath) {
28652678
@Override
28662679
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
28672680
if ((requestCode == REQUEST_IMAGE_CAPTURE || requestCode == REQUEST_IMAGE_SELECT) && resultCode == RESULT_OK) {
2868-
String imgPath;
2869-
28702681
if (requestCode == REQUEST_IMAGE_CAPTURE) {
2871-
imgPath = fileUri.getPath();
28722682
} else {
28732683
Uri selectedImage = data.getData();
28742684
String[] filePathColumn = {MediaStore.Images.Media.DATA};
28752685
Cursor cursor = MainActivity.this.getContentResolver().query(selectedImage, filePathColumn, null, null, null);
28762686
cursor.moveToFirst();
28772687
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
2878-
imgPath = cursor.getString(columnIndex);
2688+
String imgPath = cursor.getString(columnIndex);
28792689
cursor.close();
28802690
predictImage(imgPath);
28812691
}
@@ -3234,37 +3044,6 @@ public void setPf_os_bits(String pf_os_bits) {
32343044
}
32353045
}
32363046

3237-
private class CachedInfo {
3238-
private PFInfo pfInfo;
3239-
private RunCodeAsync.DeviceInfo deviceInfo;
3240-
private String curl;
3241-
3242-
public PFInfo getPfInfo() {
3243-
return pfInfo;
3244-
}
3245-
3246-
public void setPfInfo(PFInfo pfInfo) {
3247-
this.pfInfo = pfInfo;
3248-
}
3249-
3250-
public RunCodeAsync.DeviceInfo getDeviceInfo() {
3251-
return deviceInfo;
3252-
}
3253-
3254-
public void setDeviceInfo(RunCodeAsync.DeviceInfo deviceInfo) {
3255-
this.deviceInfo = deviceInfo;
3256-
}
3257-
3258-
public String getCurl() {
3259-
return curl;
3260-
}
3261-
3262-
public void setCurl(String curl) {
3263-
this.curl = curl;
3264-
}
3265-
}
3266-
3267-
32683047
class RemoteCallTask extends AsyncTask<JSONObject, String, JSONObject> {
32693048

32703049
private Exception exception;

0 commit comments

Comments
 (0)