Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/documenteinaer/ad-app into …
Browse files Browse the repository at this point in the history
…ar-activity
  • Loading branch information
Vlad Catanoiu committed Jun 6, 2023
2 parents 357dd3b + 9873548 commit 427b33c
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 22 deletions.
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
<meta-data android:name="com.google.ar.core" android:value="required" />
<meta-data
android:name="com.google.android.ar.API_KEY"
android:value="AIzaSyDCxq2tBwTi60y7ZhXZTkijHW127g6ji4c"/>
android:value="TODO"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyDCxq2tBwTi60y7ZhXZTkijHW127g6ji4c" />
android:value="TODO" />

<meta-data
android:name="com.indooratlas.android.sdk.API_KEY"
android:value="60bd1f86-9c8a-44e8-bec8-20ecf75688de" />
android:value="TODO" />
<meta-data
android:name="com.indooratlas.android.sdk.API_SECRET"
android:value="szaN1IuMnaJr4CfryXScrCI1lvYSrUPpexKhFc9CnN4J+/0PwbvN8NLnu7QO552OJ1PWiIjQ/X8kPumaf/Zsb9pHB8Jyom87BMNbnjp/EjGDRhGR3yeCBq+4qvvB8w==" />
android:value="TODO" />

<activity
android:name=".TestingActivity"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/upb/airdocs/BLEFingerprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public JSONObject toJSON(){
try {
if (name != null) jsonObject.put("name", name);
for (int i = 0; i < rssiArray.size(); i++) {
jsonArray.put(rssiArray.get(i).toString());
jsonArray.put(rssiArray.get(i));
}
jsonObject.put("rssi", jsonArray);
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/upb/airdocs/BLEScan.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import android.bluetooth.le.ScanResult;
import android.content.Context;
import android.os.Handler;
import android.os.ParcelUuid;
import android.util.Log;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Map;

public class BLEScan {
Context mContext;
Expand Down Expand Up @@ -69,6 +72,16 @@ public void stopScan(){
public void onScanResult(int callbackType, ScanResult result) {
super.onScanResult(callbackType, result);
BluetoothDevice device = result.getDevice();
if (device.getName()!= null && device.getName().equals("Kontakt")) {
//Log.d(LOG_TAG, "BLE info: " + result.getScanRecord().getServiceData());
Map<ParcelUuid, byte[]> serviceData = result.getScanRecord().getServiceData();
Map.Entry<ParcelUuid, byte[]> entry = serviceData.entrySet().iterator().next();
byte[] value = entry.getValue();
byte[] ID = {value[0], value[1], value[2], value[3]};
String sID = new String(ID);
Log.d(LOG_TAG, sID + " " + device.getAddress());
}

//Log.d(LOG_TAG, "Timestamp: "+result.getTimestampNanos()+" Name: "+device.getName()+
// " MAC: "+device.getAddress()+ " RSSI: "+result.getRssi());

Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/upb/airdocs/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public class Document {
public Double latitude = 0.0;
public Double longitude = 0.0;
public Double altitude = 0.0;
private String similarity = null;

public Document(String name, String description, String fileType, String id) {
public Document(String name, String description, String fileType, String id, String similarity) {
this.itemName = name;
this.itemDescription = description;
this.fileType = fileType;
this.id = id;
this.similarity = similarity;
}

public Document(String name, String description, String fileType, String id, Double latitude, Double longitude, Double altitude) {
Expand All @@ -27,12 +29,13 @@ public Document(String name, String description, String fileType, String id, Dou
this.altitude = altitude;
}

public Document(String name, String description, String fileString, String fileType, String id) {
public Document(String name, String description, String fileString, String fileType, String id, String similarity) {
this.itemName = name;
this.itemDescription = description;
this.fileString = fileString;
this.fileType = fileType;
this.id = id;
this.similarity = similarity;
}

public Document(String name, String description, String fileString, String fileType, String id, Double latitude, Double longitude, Double altitude) {
Expand Down Expand Up @@ -64,4 +67,8 @@ public String getFileType() {
}

public String getId(){ return id;}

public String getSimilarity() {
return similarity;
}
}
3 changes: 2 additions & 1 deletion app/src/main/java/upb/airdocs/DocumentsListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ public View getView(int position, View convertView, ViewGroup parent) {
final Document currentItem = (Document) getItem(position);
String docName = currentItem.getItemName();
final String docDescription = currentItem.getItemDescription();
final String docSimilarity = currentItem.getSimilarity();
if (!docName.equals("-")) {
viewHolder.itemName.setText(docName);
}else{
viewHolder.itemName.setVisibility(View.GONE);
}
viewHolder.itemDescription.setText(docDescription);
viewHolder.itemDescription.setText(docDescription + " -> " + docSimilarity);
String fileString = currentItem.getFileString();
String fileType = currentItem.getFileType();
if (fileString != null){
Expand Down
32 changes: 30 additions & 2 deletions app/src/main/java/upb/airdocs/ScanService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package upb.airdocs;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
Expand All @@ -8,6 +9,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Build;
Expand Down Expand Up @@ -126,6 +129,7 @@ public class ScanService extends Service implements IALocationListener, IARegio
String file;
String fileType;
String delId;
String activity;


IALocationManager mManager;
Expand Down Expand Up @@ -448,7 +452,17 @@ public void sendJSONtoServer(JSONObject jsonObject, int type){
numberOfTotalScans = 0;
sent = 1;
Log.d(LOG_TAG, "Success (send doc)");
announceSendDone(null);
restoreActivityName();
Log.d(LOG_TAG, "Activity name: "+activity);
if (activity != null && activity.equals("Testing")){
displayNumberOfScans();
displaySendStatus();
}
else {
announceSendDone(null);
}
saveActivityName(null);

} else if (type == TYPE_SEARCH_DOC) {
collectionsList = new ArrayList<FingerprintCollection>();
numberOfCollections = 0;
Expand Down Expand Up @@ -497,7 +511,6 @@ public void handleMessage(Message msg) {
case MSG_SEND:
Log.d(LOG_TAG, "Send test fingerprints");
Log.d(LOG_TAG, "address=" + address + " port=" + port);
sendFingerprintsToServer(TYPE_TESTING);
break;
case MSG_START_SCAN:
restoreFieldsTesting();
Expand Down Expand Up @@ -701,4 +714,19 @@ public void onExitRegion(IARegion iaRegion) {
mCurrentFloorPlan = iaRegion;
}
}
private void restoreActivityName() {
Context context = getApplicationContext();
SharedPreferences sharedPref = context.getSharedPreferences(getString(R.string.preference_file), Context.MODE_PRIVATE);
activity = sharedPref.getString("activity", null);
}
private void saveActivityName(String name){

Context context = getApplicationContext();
SharedPreferences sharedPref = context.getSharedPreferences(getString(R.string.preference_file), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();

editor.putString("activity", name);
editor.apply();
}

}
6 changes: 3 additions & 3 deletions app/src/main/java/upb/airdocs/SearchDocumentActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,13 @@ private ArrayList<Document> generateItemsList(String jsonString) {

System.out.println("latitude" + latitude);
System.out.println("longitude" + longitude);
String similarity = docInfo.get("similarity").toString();
if (docInfo.has("file")){
String fileString = (String)docInfo.get("file");
// TODO HERE
list.add(new Document(docName, docDescription, fileString, fileType, id));
list.add(new Document(docName, docDescription, fileString, fileType, id, similarity));
}
else {
list.add(new Document(docName, docDescription, fileType, id));
list.add(new Document(docName, docDescription, fileType, id, similarity));
}

}
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/java/upb/airdocs/TestingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ private void getDevIDAndStartService(){
public void onSendButton() {
if (mBound) {
// Create and send a message to the service, using a supported 'what' value
Message msg = Message.obtain(null, ScanService.MSG_SEND, 0, 0);
saveActivityName("Testing");
Message msg = Message.obtain(null, ScanService.MSG_ACTUAL_SEND_DOC, 0, 0);
try {
mMessenger.send(msg);
} catch (RemoteException e) {
Expand All @@ -195,7 +196,7 @@ public void onStartScan() {
if (mBound) {
Message msg;
// Create and send a message to the service, using a supported 'what' value
msg = Message.obtain(null, ScanService.MSG_START_SCAN, 0, 0);
msg = Message.obtain(null, ScanService.MSG_SCAN_TO_POST_DOC, 0, 0);

try {
mMessenger.send(msg);
Expand Down Expand Up @@ -635,4 +636,14 @@ private void restoreFields(){
devIDTextView.setText(devID);
}

private void saveActivityName(String name){

Context context = getApplicationContext();
SharedPreferences sharedPref = context.getSharedPreferences(getString(R.string.preference_file), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();

editor.putString("activity", name);
editor.apply();
}

}
11 changes: 4 additions & 7 deletions app/src/main/java/upb/airdocs/WiFiScan.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.media.AudioManager;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.media.ToneGenerator;
import android.net.Uri;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
Expand Down Expand Up @@ -147,13 +149,8 @@ private void scanSuccess() {
}

private void beep(){
try {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(mContext, notification);
r.play();
} catch (Exception e) {
e.printStackTrace();
}
ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 200);
toneGen1.startTone(ToneGenerator.TONE_CDMA_PIP,150);
}

public void unregisterReceiver(){
Expand Down

0 comments on commit 427b33c

Please sign in to comment.