Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-232
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
T.H.C. Heshan
2023-232
Commits
0a871921
Commit
0a871921
authored
Nov 04, 2023
by
DESKTOP-ERETTBS\Chathuka Heshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wifi positioning changes
parent
ebaa71f2
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
303 additions
and
0 deletions
+303
-0
Mobile App/app/src/main/java/com/sliit/blindvision/Landing.java
... App/app/src/main/java/com/sliit/blindvision/Landing.java
+34
-0
Mobile App/app/src/main/java/com/sliit/blindvision/Route.java
...le App/app/src/main/java/com/sliit/blindvision/Route.java
+107
-0
Mobile App/app/src/main/java/com/sliit/blindvision/Router.java
...e App/app/src/main/java/com/sliit/blindvision/Router.java
+37
-0
Mobile App/app/src/main/res/layout/positions.xml
Mobile App/app/src/main/res/layout/positions.xml
+54
-0
Mobile App/app/src/main/res/layout/scan.xml
Mobile App/app/src/main/res/layout/scan.xml
+41
-0
Mobile App/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
...le App/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+5
-0
Mobile App/app/src/main/res/xml/network_security_config.xml
Mobile App/app/src/main/res/xml/network_security_config.xml
+8
-0
Mobile App/app/src/test/java/com/sliit/blindvision/ExampleUnitTest.java
.../src/test/java/com/sliit/blindvision/ExampleUnitTest.java
+17
-0
No files found.
Mobile App/app/src/main/java/com/sliit/blindvision/Landing.java
0 → 100644
View file @
0a871921
package
com.sliit.blindvision
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Button
;
public
class
Landing
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_landing
);
Button
btnWifiCalibration
=
findViewById
(
R
.
id
.
btn_wifi_calibration
);
Button
btnRouteFinder
=
findViewById
(
R
.
id
.
btn_route_finder
);
btnWifiCalibration
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
// For this example, let's open WiFi settings as calibration. Adjust this as needed.
startActivity
(
new
Intent
(
Landing
.
this
,
StartingScreen
.
class
));
}
});
btnRouteFinder
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
startActivity
(
new
Intent
(
Landing
.
this
,
Route
.
class
));
}
});
}
}
\ No newline at end of file
Mobile App/app/src/main/java/com/sliit/blindvision/Route.java
0 → 100644
View file @
0a871921
package
com.sliit.blindvision
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.speech.tts.TextToSpeech
;
import
java.util.Locale
;
import
org.json.JSONObject
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
android.util.Log
;
public
class
Route
extends
AppCompatActivity
{
private
WebView
webView
;
private
TextView
directionTextView
;
private
EditText
ipEditText
;
private
Button
setIpButton
;
private
static
final
String
PREFS_NAME
=
"IP_PREFS"
;
private
static
final
String
IP_KEY
=
"IP_KEY"
;
private
TextToSpeech
tts
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_rout
);
ipEditText
=
findViewById
(
R
.
id
.
ipEditText
);
setIpButton
=
findViewById
(
R
.
id
.
setIpButton
);
webView
=
findViewById
(
R
.
id
.
webView
);
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
String
savedIp
=
settings
.
getString
(
IP_KEY
,
"192.168.1.2"
);
ipEditText
.
setText
(
savedIp
);
tts
=
new
TextToSpeech
(
this
,
status
->
{
if
(
status
!=
TextToSpeech
.
ERROR
)
{
tts
.
setLanguage
(
Locale
.
US
);
}
});
setIpButton
.
setOnClickListener
(
v
->
{
String
newIp
=
ipEditText
.
getText
().
toString
();
if
(!
newIp
.
isEmpty
())
{
// Save the new IP
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
IP_KEY
,
newIp
);
editor
.
apply
();
// Update the WebView and direction fetcher with the new IP
Intent
intent
=
getIntent
();
finish
();
startActivity
(
intent
);
}
});
WebSettings
webSettings
=
webView
.
getSettings
();
webSettings
.
setUseWideViewPort
(
true
);
webSettings
.
setLoadWithOverviewMode
(
true
);
directionTextView
=
findViewById
(
R
.
id
.
directionTextView
);
// Load the video feed
webView
.
loadUrl
(
"http://"
+
savedIp
+
":5005/video_feed"
);
// Fetch the direction results periodically
new
Thread
(()
->
{
Log
.
d
(
"direction"
,
"starting"
);
while
(
true
)
{
try
{
URL
url
=
new
URL
(
"http://"
+
savedIp
+
":5005/direction"
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
String
result
=
Utils
.
streamToString
(
connection
.
getInputStream
());
JSONObject
jsonObject
=
new
JSONObject
(
result
);
Log
.
d
(
"direction"
,
jsonObject
.
toString
());
// String direction = jsonObject.getString("direction");
//
// runOnUiThread(() -> directionTextView.setText(direction));
String
direction
=
jsonObject
.
getString
(
"direction"
);
runOnUiThread
(()
->
{
directionTextView
.
setText
(
direction
);
tts
.
speak
(
direction
,
TextToSpeech
.
QUEUE_FLUSH
,
null
,
null
);
// Speak the direction
});
Thread
.
sleep
(
4000
);
// Fetch every 5 seconds
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}).
start
();
}
}
\ No newline at end of file
Mobile App/app/src/main/java/com/sliit/blindvision/Router.java
0 → 100644
View file @
0a871921
package
com.sliit.blindvision
;
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
Mobile App/app/src/main/res/layout/positions.xml
0 → 100644
View file @
0a871921
<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
Mobile App/app/src/main/res/layout/scan.xml
0 → 100644
View file @
0a871921
<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
Mobile App/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
0 → 100644
View file @
0a871921
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<background
android:drawable=
"@drawable/ic_launcher_background"
/>
<foreground
android:drawable=
"@drawable/ic_launcher_foreground"
/>
</adaptive-icon>
\ No newline at end of file
Mobile App/app/src/main/res/xml/network_security_config.xml
0 → 100644
View file @
0a871921
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config
cleartextTrafficPermitted=
"true"
>
<trust-anchors>
<certificates
src=
"system"
/>
</trust-anchors>
</base-config>
</network-security-config>
\ No newline at end of file
Mobile App/app/src/test/java/com/sliit/blindvision/ExampleUnitTest.java
0 → 100644
View file @
0a871921
package
com.sliit.blindvision
;
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment