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
b91edee2
Commit
b91edee2
authored
Nov 04, 2023
by
DESKTOP-ERETTBS\Chathuka Heshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
positioning features added
parent
5f2dc35f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
345 additions
and
0 deletions
+345
-0
Mobile App/app/src/main/java/com/sliit/blindvision/PositionData.java
...app/src/main/java/com/sliit/blindvision/PositionData.java
+74
-0
Mobile App/app/src/main/java/com/sliit/blindvision/Positions.java
...pp/app/src/main/java/com/sliit/blindvision/Positions.java
+181
-0
Mobile App/app/src/main/res/layout/activity_rout.xml
Mobile App/app/src/main/res/layout/activity_rout.xml
+52
-0
Mobile App/app/src/main/res/layout/activity_splash.xml
Mobile App/app/src/main/res/layout/activity_splash.xml
+38
-0
No files found.
Mobile App/app/src/main/java/com/sliit/blindvision/PositionData.java
0 → 100644
View file @
b91edee2
package
com.sliit.blindvision
;
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
;
}
}
Mobile App/app/src/main/java/com/sliit/blindvision/Positions.java
0 → 100644
View file @
b91edee2
package
com.sliit.blindvision
;
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
();
}
}
Mobile App/app/src/main/res/layout/activity_rout.xml
0 → 100644
View file @
b91edee2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
".Route"
>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
tools:context=
".Route"
>
<EditText
android:id=
"@+id/ipEditText"
android:layout_width=
"50dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:hint=
"Enter IP Address"
android:inputType=
"text"
android:padding=
"10dp"
/>
<Button
android:id=
"@+id/setIpButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Set IP"
android:padding=
"10dp"
/>
</LinearLayout>
<WebView
android:id=
"@+id/webView"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
/>
<TextView
android:id=
"@+id/directionTextView"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:text=
"Direction"
android:textSize=
"28sp"
android:gravity=
"center"
/>
</LinearLayout>
Mobile App/app/src/main/res/layout/activity_splash.xml
0 → 100644
View file @
b91edee2
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/linearLayout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
android:gravity=
"center"
android:orientation=
"vertical"
>
<ImageView
android:id=
"@+id/splashGif"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
tools:ignore=
"MissingConstraints"
/>
<TextView
style=
"@style/Widget.AppCompat.TextView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Blind Assistive"
android:textColor=
"@color/colorPrimary"
android:textSize=
"48sp"
app:fontFamily=
"sans-serif-black"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.5"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.848"
tools:layout_conversion_absoluteHeight=
"64dp"
tools:layout_conversion_absoluteWidth=
"411dp"
/>
<!-- Add any other logo or design elements you want here -->
</androidx.constraintlayout.widget.ConstraintLayout>
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