Commit f9219bf4 authored by Yuvindu Caldera's avatar Yuvindu Caldera

YC-wi-fi-positioning initial commit

parent 29551612
Pipeline #6622 canceled with stages
#Wed May 17 15:34:56 IST 2023
gradle.version=7.5
# Default ignored files
/shelf/
/workspace.xml
Local Wifi Positioning
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>2023-232</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
/build
\ No newline at end of file
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.localwifipositioning'
compileSdk 33
defaultConfig {
applicationId "com.example.localwifipositioning"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.code.gson:gson:2.8.9'
implementation'org.apache.httpcomponents:httpclient:4.5.13'
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package com.example.localwifipositioning;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.localwifipositioning", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.localwifipositioning"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".Scan"
android:label="Scan">
</activity>
<activity
android:name=".Positions"
android:label="Calibrate">
</activity>
<activity
android:name=".Buildings"
android:label="Buildings">
</activity>
<activity
android:name=".StartingScreen"
android:exported="true"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Locate"
android:label="Locate">
</activity>
<activity android:name=".FriendlyWifis"
android:label="Choose Friendly Wifis">
</activity>
</application>
</manifest>
\ No newline at end of file
package com.example.localwifipositioning;
import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemLongClickListener;
public class Buildings extends Activity {
ArrayList<String> buildings;
DatabaseHelper db;
ListView buildingsList;
Button add;
EditText buildingName;
ArrayAdapter<String> arrayAdapter;
Context context = this;
private void switchToPositionsActivity(String data) {
Intent intent = new Intent(context, Positions.class);
intent.putExtra("BUILDING_NAME", data);
startActivity(intent);
}
public void onCreate(Bundle saveInstanceState) {
super.onCreate(saveInstanceState);
setContentView(R.layout.buildings);
db = new DatabaseHelper(this);
add = (Button) findViewById(R.id.add);
buildingName = (EditText) findViewById(R.id.name);
buildingName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
if (charSequence.toString().equals("")) {
add.setEnabled(false);
} else {
boolean exists = false;
for (String buildingName : buildings) {
if (charSequence.toString().equals(buildingName)) {
add.setEnabled(false);
exists = true;
break;
}
}
if (!exists) {
add.setEnabled(true);
}
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
buildingName.setText("");
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
final String input = buildingName.getText().toString();
if (input.length() < 4) {
new AlertDialog.Builder(context)
.setTitle(getString(R.string.warning))
.setMessage(getString(R.string.dialog_message))
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
switchToPositionsActivity(input);
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
} else {
switchToPositionsActivity(input);
}
}
});
buildings = db.getBuildings();
buildingsList = (ListView) findViewById(R.id.buildingslist);
arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, buildings);
buildingsList.setAdapter(arrayAdapter);
buildingsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
String selectedBuilding = (String) parent.getItemAtPosition(position);
Intent intent = new Intent(getApplicationContext(), Positions.class);
intent.putExtra("BUILDING_NAME", selectedBuilding);
startActivityForResult(intent, 0);
}
});
SwipeDismissListViewTouchListener touchListener =
new SwipeDismissListViewTouchListener(
buildingsList,
new SwipeDismissListViewTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
return true;
}
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
db.deleteBuilding(buildings.get(position));
buildings.remove(position);
arrayAdapter.notifyDataSetChanged();
}
}
});
buildingsList.setOnTouchListener(touchListener);
}
@Override
protected void onResume() {
buildings = db.getBuildings();
arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, buildings);
buildingsList.setAdapter(arrayAdapter);
buildingName.setText("");
add.setEnabled(false);
super.onResume();
}
}
package com.example.localwifipositioning;
/**
* Created by ajnas on 1/11/17.
*/
public class Config {
public static final String BASE_URL = "http://your-server.url.com";
}
package com.example.localwifipositioning;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "wifips.db";
public static final String AP_TABLE = "access_points";
public static final String READINGS_TABLE = "readings";
public static final String AP_CREATE = "CREATE TABLE 'access_points' "
+ "('building_id' TEXT NOT NULL ,'ssid' TEXT NOT NULL,'mac_id' TEXT NOT NULL )";
public static final String READINGS_CREATE = "CREATE TABLE 'readings' ('building_id' TEXT NOT NULL , "
+ "'position_id' TEXT NOT NULL ,"
+ " 'ssid' TEXT NOT NULL , 'mac_id' TEXT NOT NULL , 'rssi' INTEGER NOT NULL )";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(AP_CREATE);
db.execSQL(READINGS_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + AP_CREATE);
db.execSQL("DROP TABLE IF EXISTS " + READINGS_CREATE);
onCreate(db);
}
public int deleteReading(String building_id, String position_id) {
SQLiteDatabase db = getWritableDatabase();
String[] args = new String[] { building_id, position_id };
return db.delete(READINGS_TABLE, "building_id=? and position_id=?", args);
}
public boolean deleteBuilding(String building_id) {
SQLiteDatabase db = getWritableDatabase();
String[] args = new String[] { building_id };
db.delete(AP_TABLE,"building_id=?",args);
db.delete(READINGS_TABLE, "building_id=?", args);
return true;
}
public ArrayList<String> getBuildings() {
SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.rawQuery("select distinct building_id from " + READINGS_TABLE, null);
ArrayList<String> result = new ArrayList<String>();
cursor.moveToFirst();
while (cursor.isAfterLast() == false) {
result.add(cursor.getString(0));
cursor.moveToNext();
}
return result;
}
public ArrayList<Router> getFriendlyWifis(String building_id) {
ArrayList<Router> result = new ArrayList<Router>();
SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.rawQuery("select ssid, mac_id from " + AP_TABLE
+ " where building_id=?", new String[] { building_id });
cursor.moveToFirst();
while (cursor.isAfterLast() == false) {
result.add(new Router(cursor.getString(0), cursor.getString(1)));
cursor.moveToNext();
}
return result;
}
public int deleteFriendlyWifis(String building_id) {
SQLiteDatabase db = getWritableDatabase();
String[] args = new String[] { building_id };
return db.delete(AP_TABLE, "building_id=?", args);
}
public boolean addFriendlyWifis(String building_id, ArrayList<Router> wifis) {
deleteFriendlyWifis(building_id);
SQLiteDatabase db = getWritableDatabase();
for (int i = 0; i < wifis.size(); i++) {
ContentValues cv = new ContentValues();
cv.put("building_id", building_id);
cv.put("ssid", wifis.get(i).getSSID());
cv.put("mac_id", wifis.get(i).getBSSID());
db.insert(AP_TABLE, null, cv);
}
return true;
}
public ArrayList<String> getPositions(String building_id) {
SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.rawQuery("select distinct position_id from " + READINGS_TABLE
+ " where building_id=?", new String[] { building_id });
ArrayList<String> result = new ArrayList<String>();
cursor.moveToFirst();
while (cursor.isAfterLast() == false) {
result.add(cursor.getString(0));
cursor.moveToNext();
}
return result;
}
public boolean addReadings(String building_id, PositionData positionData) {
deleteReading(building_id, positionData.getName());
SQLiteDatabase db = getWritableDatabase();
for (Map.Entry<String, Integer> e : positionData.getValues().entrySet()) {
ContentValues cv = new ContentValues();
cv.put("building_id", building_id);
cv.put("position_id", positionData.getName());
cv.put("ssid",positionData.routers.get(e.getKey()));
cv.put("mac_id",e.getKey());
cv.put("rssi", e.getValue());
db.insert(READINGS_TABLE, null, cv);
}
return true;
}
public ArrayList<PositionData> getReadings(String building_id) {
HashMap<String, PositionData> positions = new HashMap<String, PositionData>();
SQLiteDatabase db = getReadableDatabase();
Cursor cursor = db.rawQuery("select distinct * from " + READINGS_TABLE
+ " where building_id='" + building_id + "'", null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
String position_id = cursor.getString(1);
Router router = new Router(cursor.getString(2), cursor.getString(3));
if (positions.containsKey(position_id)) {
positions.get(position_id).addValue(router, cursor.getInt(4));
} else {
PositionData positionData = new PositionData(cursor.getString(1));
positionData.addValue(router, cursor.getInt(4));
positions.put(position_id, positionData);
}
cursor.moveToNext();
}
ArrayList<PositionData> result = new ArrayList<PositionData>();
for (Map.Entry<String, PositionData> e : positions.entrySet())
result.add(e.getValue());
return result;
}
}
package com.example.localwifipositioning;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import java.util.ArrayList;
import java.util.List;
public class FriendlyWifis extends Activity {
private static final int PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION = 1;
private Button addWifi;
WifiManager wifi;
List<ScanResult> results;
ListView wifisList;
protected CharSequence[] options;
protected boolean[] selections;
ArrayAdapter<Router> arrayAdapter;
ArrayList<Router> wifis;
String building;
Button save;
DatabaseHelper db;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
db = new DatabaseHelper(this);
addWifi = findViewById(R.id.button_add);
wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
addWifi.setOnClickListener(new ButtonClickHandler());
save = findViewById(R.id.save);
wifisList = findViewById(R.id.friendly_wifis);
Intent intent = getIntent();
building = intent.getStringExtra("BUILDING_NAME");
wifis = db.getFriendlyWifis(building);
arrayAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_list_item_1, wifis);
// Set The Adapter
wifisList.setAdapter(arrayAdapter);
save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (db.addFriendlyWifis(building, wifis)) {
Toast toast = Toast.makeText(getApplicationContext(), "Saved Wi-Fi Network", Toast.LENGTH_SHORT);
toast.show();
}
}
});
wifisList.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int arg2, long arg3) {
wifis.remove(arg2);
arrayAdapter.notifyDataSetChanged();
return false;
}
});
}
public void updateOptions() {
options = new CharSequence[results.size()];
for (int i = 0; i < results.size(); i++)
options[i] = results.get(i).SSID;
selections = new boolean[options.length];
}
public class ButtonClickHandler implements View.OnClickListener {
public void onClick(View view) {
if (ActivityCompat.checkSelfPermission(FriendlyWifis.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(FriendlyWifis.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
// After this point, you wait for the callback in onRequestPermissionsResult(int, String[], int[]) overridden method
} else {
getAndShowScanResults();
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
getAndShowScanResults();
}
}
private void getAndShowScanResults() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION);
return;
}
results = wifi.getScanResults();
updateOptions();
onCreateDialog(0).show();
}
@Override
protected Dialog onCreateDialog(int id) {
return new AlertDialog.Builder(this)
.setTitle("Choose Friendly Wifis")
.setMultiChoiceItems(options, selections, new DialogSelectionClickHandler())
.setPositiveButton("OK", new DialogButtonClickHandler())
.create();
}
public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener {
public void onClick(DialogInterface dialog, int clicked, boolean selected) {
Log.i("ME", options[clicked] + " selected: " + selected);
}
}
public class DialogButtonClickHandler implements DialogInterface.OnClickListener {
public void onClick(DialogInterface dialog, int clicked) {
switch (clicked) {
case DialogInterface.BUTTON_POSITIVE:
updateFriendlyWifis();
break;
}
}
}
protected void updateFriendlyWifis() {
for (int i = 0; i < options.length; i++) {
if (selections[i]) {
Router router = new Router(results.get(i).SSID, results.get(i).BSSID);
if (!wifis.contains(router)) {
wifis.add(router);
Toast.makeText(getApplicationContext(), "Wi-Fi network added: " + router.getSSID(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "Wi-Fi network already added: " + router.getSSID(), Toast.LENGTH_SHORT).show();
}
}
arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, wifis);
// Set The Adapter
wifisList.setAdapter(arrayAdapter);
Log.i("ME", options[i] + " selected: " + selections[i]);
}
}
}
package com.example.localwifipositioning;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class Locate extends Activity {
ArrayList<String> buildings;
DatabaseHelper db;
ArrayAdapter<String> arrayAdapter;
ArrayList<PositionData> positionsData;
String building;
TextView result;
Button locate;
public void onCreate(Bundle saveInstanceState) {
super.onCreate(saveInstanceState);
setContentView(R.layout.locate);
db = new DatabaseHelper(this);
buildings = db.getBuildings();
locate = (Button) findViewById(R.id.locate);
result = (TextView) findViewById(R.id.result);
arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, buildings);
locate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(getApplicationContext(), Scan.class);
intent.putExtra("isLearning", false);
startActivityForResult(intent,0);
}
});
arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, buildings);
// Set The Adapter
if (buildings.size()==0) {
Toast.makeText(this, "No building data available.", Toast.LENGTH_LONG).show();
locate.setEnabled(false);
}
else{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setTitle("Choose building");
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// the user clicked on colors[which]
building = buildings.get(which);
}
});
builder.show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
// TODO Auto-generated method stub
if(resultCode==RESULT_OK){
PositionData positionData = (PositionData) intent
.getSerializableExtra("PositionData");
positionsData=db.getReadings(building);
String closestPosition = null;
ArrayList<Router> wifis = db.getFriendlyWifis(building);
int min_distance = positionData.uDistance(positionsData.get(0), wifis);
int j=0;
closestPosition = positionsData.get(0).getName();
String res = "";
res += closestPosition + "\n" + min_distance;
res += "\n" + positionsData.get(0).toString();
for (int i = 1; i < positionsData.size(); i++) {
int distance = positionData.uDistance(positionsData.get(i), wifis);
res += "\n" + positionsData.get(i).getName() + "\n" + distance;
res += "\n" + positionsData.get(i).toString();
if (distance < min_distance) {
min_distance = distance;
j=i;
closestPosition = positionsData.get(i).getName();
}
}
if (min_distance == PositionData.MAX_DISTANCE){
closestPosition="OUT OF RANGE";
Toast.makeText(this,"You are out of range of the selected building",Toast.LENGTH_LONG).show();
}
result.setText("Nearest point : "+ closestPosition);
//////////////////////////////////////////////////
min_distance = positionData.uDistance(positionsData.get(0), wifis);
String closestPosition2 = null;
closestPosition2 = positionsData.get(0).getName();
res = "";
res += closestPosition2 + "\n" + min_distance;
res += "\n" + positionsData.get(0).toString();
for (int i = 1; i < positionsData.size(); i++) {
if(i!=j) {
int distance = positionData.uDistance(positionsData.get(i), wifis);
res += "\n" + positionsData.get(i).getName() + "\n" + distance;
res += "\n" + positionsData.get(i).toString();
closestPosition2 = positionsData.get(i).getName();//////////////////////////
if(closestPosition2.equals(closestPosition))
continue;
if (distance < min_distance) {
min_distance = distance;
closestPosition2 = positionsData.get(i).getName();
}
}
}
if (min_distance == PositionData.MAX_DISTANCE){
closestPosition2="OUT OF RANGE";
Toast.makeText(this,"You are out of range of the selected building",Toast.LENGTH_LONG).show();
}
res += "\nCurrent:\n" + positionData.toString();
Log.v("Result",res);
super.onActivityResult(requestCode, resultCode, intent);
}
}
public class CustomOnItemSelectedListener implements
AdapterView.OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos,
long id) {
building = parent.getItemAtPosition(pos).toString();
locate.setEnabled(true);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
locate.setEnabled(false);
}
}
}
package com.example.localwifipositioning;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
\ No newline at end of file
package com.example.localwifipositioning;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class PositionData implements Serializable {
public static final int MAX_DISTANCE=99999999;
private String name;
public static final int MINIMUM_COMMON_ROUTERS=1;
public HashMap<String, Integer> values;
public HashMap<String,String> routers;
public PositionData(String name) {
// TODO Auto-generated constructor stub
this.name=name;
values = new HashMap<String, Integer>();
routers = new HashMap<String, String>();
}
public void addValue(Router router,int strength){
values.put(router.getBSSID(), strength);
routers.put(router.getBSSID(),router.getSSID());
}
public String getName() {
return name;
}
public String toString() {
String result="";
result+=name+"\n";
for(Map.Entry<String, Integer> e: this.values.entrySet())
result+=routers.get(e.getKey())+" : "+e.getValue().toString()+"\n";
return result;
}
public HashMap<String, Integer> getValues() {
return values;
}
public int uDistance(PositionData positionData,ArrayList<Router> friendlyWifis){
int sum=0;
int count=0;
for(Map.Entry<String, Integer> e: this.values.entrySet()){
int v;
//Log.v("Key : ",positionData.values.get(e.getKey()).toString());
if(isFriendlyWifi(friendlyWifis,e.getKey()) && positionData.values.containsKey(e.getKey()))
{
v=positionData.values.get(e.getKey());
sum+=Math.pow((v-e.getValue()),2);
count++;
}
}
if(count<MINIMUM_COMMON_ROUTERS){
sum=MAX_DISTANCE;
}
return sum;
}
private boolean isFriendlyWifi(ArrayList<Router> wifis,String bssid){
for(int i=0;i<wifis.size();i++){
if(wifis.get(i).getBSSID().equals(bssid))
return true;
}
return false;
}
}
package com.example.localwifipositioning;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
public class Positions extends Activity {
private TextView textHeading;
private Button calibrate;
private Button finish;
private EditText positionName;
private int readingCount = 30;
private TextView results;
private String resultsText;
private ListView positionsList;
ArrayList<String> positions;
ArrayAdapter arrayAdapter;
Timer timer;
TimerTask myTimerTask;
int positionCount;
DatabaseHelper db;
private Boolean isLearning = true;
static final int SCAN_REQUEST = 0;
Button friendlyWifisButton;
private List<PositionData> positionsData;
private PositionData positionData;
private String building;
Gson gson;
@SuppressWarnings("null")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.positions);
friendlyWifisButton = (Button) findViewById(R.id.friendly_wifis_button);
friendlyWifisButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), FriendlyWifis.class);
intent.putExtra("BUILDING_NAME", building);
startActivity(intent);
}
});
textHeading = (TextView) findViewById(R.id.textHeading);
positionName = (EditText) findViewById(R.id.position_name);
calibrate = (Button) findViewById(R.id.calibratebutton);
finish = (Button) findViewById(R.id.finish);
positionsList = (ListView) findViewById(R.id.positionslist);
gson = new Gson();
resultsText = "";
positionCount = 0;
positionsData = new ArrayList<PositionData>();
Intent intent = getIntent();
// readingCount = Integer.parseInt(intent
// .getStringExtra("NUMBER_OF_SECONDS"));
building = intent.getStringExtra("BUILDING_NAME");
db = new DatabaseHelper(this);
positions = db.getPositions(building);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, positions);
positionsList.setAdapter(arrayAdapter);
positionName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
if (charSequence.equals("")) {
calibrate.setEnabled(false);
} else
calibrate.setEnabled(true);
}
@Override
public void afterTextChanged(Editable editable) {
}
});
positionName.setText("");
calibrate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (db.getFriendlyWifis(building).isEmpty()) {
Context context = getApplicationContext();
CharSequence text = "Select one or more Friendly WiFi";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
} else {
Intent intent = new Intent(getApplicationContext(), Scan.class);
intent.putExtra("POSITION_NAME", positionName.getText().toString());
intent.putExtra("isLearning", isLearning);
intent.putExtra("NUMBER_OF_SECONDS", readingCount);
startActivityForResult(intent, SCAN_REQUEST);
}
}
});
finish.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Buildings.class);
setResult(2, intent);
finish();
}
});
positionsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
Intent intent = new Intent(getApplicationContext(), Scan.class);
String selectedPosition = (String) parent.getItemAtPosition(position);
intent.putExtra("isLearning", isLearning);
intent.putExtra("POSITION_NAME", selectedPosition);
intent.putExtra("NUMBER_OF_SECONDS", readingCount);
startActivityForResult(intent, SCAN_REQUEST);
}
});
SwipeDismissListViewTouchListener touchListener = new SwipeDismissListViewTouchListener(
positionsList,
new SwipeDismissListViewTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
return true;
}
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
db.deleteReading(building, positions.get(position));
positions.remove(position);
arrayAdapter.notifyDataSetChanged();
}
}
});
positionsList.setOnTouchListener(touchListener);
}
@Override
protected void onActivityResult(int request, int result, Intent intent) {
if (result == RESULT_OK) {
positionData = (PositionData) intent.getSerializableExtra("PositionData");
Log.v("Before db : ", positionData.toString());
db.addReadings(building, positionData);
positions = db.getPositions(building);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, positions);
positionsList.setAdapter(arrayAdapter);
super.onActivityResult(request, result, intent);
}
}
@Override
protected void onResume() {
positions = db.getPositions(building);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, positions);
positionsList.setAdapter(arrayAdapter);
positionName.setText("");
calibrate.setEnabled(false);
super.onResume();
}
}
package com.example.localwifipositioning;
import java.io.Serializable;
public class Router implements Serializable{
private String SSID;
private String BSSID;
public Router(String SSID, String BSSID) {
this.SSID = SSID;
this.BSSID = BSSID;
}
public String getSSID() {
return SSID;
}
public String getBSSID() {
return BSSID;
}
@Override
public String toString(){
return SSID;
}
@Override
public boolean equals(Object arg){
return ((Router) arg).getBSSID().equals(this.getBSSID());
}
@Override
public int hashCode(){
return this.BSSID.hashCode();
}
}
\ No newline at end of file
package com.example.localwifipositioning;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import androidx.core.app.ActivityCompat;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
public class Scan extends Activity {
private TextView warning;
private TextView timeRemaining;
private Button calibrate;
private int readingCount = 10;
private int currentCount;
String currentPositionName;
WifiManager wifi;
Timer timer;
TimerTask myTimerTask;
public class ResultData {
private Router router;
public Router getRouter() {
return this.router;
}
public List<Integer> values;
public ResultData(Router router) {
// TODO Auto-generated constructor stub
this.router = router;
values = new ArrayList<Integer>();
}
}
private List<ResultData> resultsData;
private List<PositionData> positionsData;
private PositionData positionData;
@SuppressWarnings("null")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scan);
warning = findViewById(R.id.TextView1);
timeRemaining = findViewById(R.id.TextView2);
calibrate = findViewById(R.id.start);
wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
// Check if Wi-Fi is enabled
if (!wifi.isWifiEnabled()) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("Confirm...");
alertDialog.setMessage("Scanning requires WiFi.");
alertDialog.setPositiveButton("Turn on WiFi", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Activity transfer to Wi-Fi settings
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
}
});
alertDialog.setCancelable(false);
alertDialog.show();
}
Intent intent = getIntent();
currentPositionName = null;
if (intent.getBooleanExtra("isLearning", true))
currentPositionName = intent.getStringExtra("POSITION_NAME");
calibrate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
calibrate.setEnabled(false);
warning.setText("DO NOT MOVE FOR");
resultsData = new ArrayList<ResultData>();
currentCount = 0;
timer = new Timer();
myTimerTask = new TimerTask() {
@Override
public void run() {
refresh();
}
};
timer.schedule(myTimerTask, 0, 1000);
}
});
}
private void refresh() {
// TODO Auto-generated method stub
if (currentCount >= readingCount) {
if (myTimerTask != null)
myTimerTask.cancel();
}
currentCount++;
wifi.startScan();
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
List<ScanResult> results = wifi.getScanResults();
for (int i = 0; i < results.size(); i++) {
// System.out.println("test2");
String ssid0 = results.get(i).SSID;
String bssid = results.get(i).BSSID;
int rssi0 = results.get(i).level;
boolean found = false;
for (int pos = 0; pos < resultsData.size(); pos++) {
if (resultsData.get(pos).getRouter().getBSSID().equals(bssid)) {
found = true;
resultsData.get(pos).values.add(rssi0);
break;
}
}
if (!found) {
ResultData data = new ResultData(new Router(ssid0, bssid));
data.values.add(rssi0);
resultsData.add(data);
}
// String rssiString0 = String.valueOf(rssi0);
// textStatus = textStatus.concat("\n" + ssid0 + " " +
// rssiString0);
// System.out.println("ajsdhks"+textStatus);
}
// Log.v("textStatus", textStatus);
// System.out.println(""+textStatus);
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
// result.setText("here"+currentCount);
timeRemaining
.setText(" " + (readingCount - currentCount) + "s");
if (currentCount >= readingCount) {
returnResults();
}
}
});
}
private void returnResults() {
// TODO Auto-generated method stub
positionData = new PositionData(currentPositionName);
for (int length = 0; length < resultsData.size(); length++) {
int sum = 0;
for (int l = 0; l < resultsData.get(length).values.size(); l++) {
sum += resultsData.get(length).values.get(l);
}
int average = sum / resultsData.get(length).values.size();
positionData.addValue(resultsData.get(length).getRouter(), average);
}
Intent intent = new Intent(getApplicationContext(), Positions.class);
intent.putExtra("PositionData", (Serializable) positionData);
setResult(RESULT_OK,intent);
finish();
}
}
package com.example.localwifipositioning;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class StartingScreen extends Activity {
private Button learnButton;
private Button locateButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.starting_screen);
learnButton = findViewById(R.id.learn_button);
locateButton = findViewById(R.id.locate_button);
learnButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(StartingScreen.this, Buildings.class);
startActivity(intent);
}
});
locateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(StartingScreen.this, Locate.class);
startActivity(intent);
}
});
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<TextView
android:id="@+id/textHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/placename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Calibrate" />
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/TextView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="#ff0000"
android:textSize="30dp" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/TextView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</ScrollView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter a new building name"
android:ems="10" >
</EditText>
<Button
android:id="@+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:enabled="false"
android:text="Add" />
<requestFocus />
</LinearLayout>
<ListView
android:id="@+id/buildingslist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#0000CC"
android:dividerHeight="0.1dp" >
</ListView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/locate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20px"
android:text="Locate"
android:layout_marginBottom="100dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/result"
android:textSize="30dp"
android:text=""
android:textColor="#ff0000"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your position"
android:textSize="30dp"
android:paddingBottom="30dp"
android:layout_above="@+id/result"
android:layout_centerHorizontal="true" />
<!--<LinearLayout-->
<!--android:id="@+id/everythingelse"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="vertical" >-->
<!---->
<!--<ScrollView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" >-->
<!--<TextView-->
<!--android:id="@+id/result"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" />-->
<!--</ScrollView>-->
<!--</LinearLayout>-->
</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<Button
android:id="@+id/friendly_wifis_button"
android:enabled="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Choose Friendly Wifis" />
<EditText
android:id="@+id/position_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter a new position name and calibrate"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/calibratebutton"
android:enabled="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Calibrate" />
<Button
android:id="@+id/finish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Update" />
<ListView
android:id="@+id/positionslist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#0000CC"
android:dividerHeight="0.1dp" >
</ListView>
</LinearLayout>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<TextView
android:id="@+id/heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Start" />
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/TextView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="#ff0000"
android:textSize="30dp" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<Button
android:id="@+id/button_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add more wifis" />
<Button
android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save" />
<ListView
android:id="@+id/friendly_wifis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#0000CC"
android:dividerHeight="0.1dp" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@id/learn_button"
android:text="Main Menu"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/learn_button"
android:layout_width="@dimen/button_width"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_alignStart="@id/locate_button"
android:layout_alignLeft="@id/locate_button"
android:layout_above="@id/locate_button"
android:text="Learn"
android:onClick="onClick" />
<Button
android:id="@+id/locate_button"
android:layout_width="@dimen/button_width"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Locate"
android:onClick="onClick" />
</RelativeLayout>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/friendly_wifis"
android:orderInCategory="100"
android:title="Choose Friendly WiFis"
app:showAsAction="never"/>
</menu>
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
<resources>
<!--
Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
-->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="button_width">300dp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">IndoorPositioning</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="spinner_prompt">Select Building</string>
<string name="warning">Warning</string>
<string name="dialog_message">Building name has less than 4 characters. Proceed?</string>
</resources>
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
package com.example.localwifipositioning;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
}
\ No newline at end of file
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
\ No newline at end of file
#Wed May 17 15:34:51 IST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C\:\\Users\\User\\AppData\\Local\\Android\\Sdk
\ No newline at end of file
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Local Wifi Positioning"
include ':app'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment