Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-235 Vehicle parking system
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
3
Merge Requests
3
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
2022-235
2022-235 Vehicle parking system
Commits
09a5ed21
Commit
09a5ed21
authored
Nov 02, 2022
by
@Thilakasiri_M.D.T.S
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dashboard initial change
parent
16e98c19
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
410 additions
and
1 deletion
+410
-1
README.md
README.md
+3
-1
app/src/main/java/com/example/vehicleparkingsystem/Dashboard.java
...main/java/com/example/vehicleparkingsystem/Dashboard.java
+407
-0
No files found.
README.md
View file @
09a5ed21
...
@@ -79,3 +79,5 @@ Vehicle Parking System(2022-235)
...
@@ -79,3 +79,5 @@ Vehicle Parking System(2022-235)
Ensure the safety of the vehicle while parked in the vehicle-park using image processing and Machine Learning.
Ensure the safety of the vehicle while parked in the vehicle-park using image processing and Machine Learning.
Also display of unsecured status by notification.
Also display of unsecured status by notification.
test
\ No newline at end of file
app/src/main/java/com/example/vehicleparkingsystem/Dashboard.java
0 → 100644
View file @
09a5ed21
package
com.example.vehicleparkingsystem
;
import
androidx.annotation.RequiresApi
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.core.app.NotificationCompat
;
import
androidx.core.content.ContextCompat
;
import
android.app.AlertDialog
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.media.RingtoneManager
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.MediaController
;
import
android.widget.TextView
;
import
android.widget.VideoView
;
import
com.example.vehicleparkingsystem.Models.BaseURL
;
import
com.example.vehicleparkingsystem.SQLite.Sqlitedb
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.util.Objects
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
okhttp3.ResponseBody
;
public
class
Dashboard
extends
AppCompatActivity
{
Button
button1
;
Button
button2
;
Button
button3
;
Button
button4
;
Button
button5
;
String
type
;
String
number
;
int
threatStatus
;
int
parkingStatus
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_dashboard
);
button1
=
findViewById
(
R
.
id
.
parking
);
button2
=
findViewById
(
R
.
id
.
logout
);
button3
=
findViewById
(
R
.
id
.
entrance
);
button4
=
findViewById
(
R
.
id
.
violation
);
button5
=
findViewById
(
R
.
id
.
threat
);
new
entranceDetection
().
execute
();
new
ParkingViolation
().
execute
();
new
threatDetection
().
execute
();
button1
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
mainIntent
=
new
Intent
(
Dashboard
.
this
,
ParkingSlots
.
class
);
Dashboard
.
this
.
startActivity
(
mainIntent
);
Dashboard
.
this
.
finish
();
}
});
button2
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
mainIntent
=
new
Intent
(
Dashboard
.
this
,
Login
.
class
);
Dashboard
.
this
.
startActivity
(
mainIntent
);
Dashboard
.
this
.
finish
();
}
});
button3
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
new
entranceDetection
().
execute
();
}
});
button4
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
new
ParkingViolation
().
execute
();
}
});
button5
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
new
threatDetection
().
execute
();
}
});
}
private
class
entranceDetection
extends
AsyncTask
<
String
,
String
,
String
>
{
@Override
protected
void
onPreExecute
()
{
}
@Override
protected
void
onPostExecute
(
String
s
)
{
// AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(Dashboard.this);
// LayoutInflater inflater = LayoutInflater.from(Dashboard.this);
// View view1 = inflater.inflate(R.layout.custom_entrance_details, null);
// dialogBuilder.setView(view1);
//
// final TextView textView1 = (TextView) view1.findViewById(R.id.num);
// final TextView textView2 = (TextView) view1.findViewById(R.id.ty);
//
// textView1.setText(number);
// textView2.setText(type);
//
// final AlertDialog alertDialog = dialogBuilder.create();
// alertDialog.show();
String
message
=
"vehicle type is "
+
type
+
" and vehicle number "
+
number
+
""
;
int
reqCode
=
1
;
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
showNotification
(
Dashboard
.
this
,
"Entrance Detection"
,
message
,
intent
,
reqCode
);
}
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
KITKAT
)
@Override
protected
String
doInBackground
(
String
...
strings
)
{
try
{
String
Url
=
BaseURL
.
get_url
()
+
"enternce"
;
OkHttpClient
client
=
new
OkHttpClient
();
Request
request
=
new
Request
.
Builder
()
.
url
(
Url
)
.
get
()
.
build
();
try
(
Response
response
=
client
.
newCall
(
request
).
execute
())
{
ResponseBody
body
=
response
.
body
();
JSONArray
json
=
new
JSONArray
(
body
.
string
());
System
.
out
.
println
(
json
);
for
(
int
i
=
0
;
i
<
json
.
length
();
i
++)
{
JSONObject
joo
=
json
.
getJSONObject
(
i
);
type
=
joo
.
getString
(
"type"
);
number
=
joo
.
getString
(
"number_plate"
);
}
}
catch
(
IOException
|
JSONException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
finally
{
}
}
}
private
class
threatDetection
extends
AsyncTask
<
String
,
String
,
String
>
{
@Override
protected
void
onPreExecute
()
{
}
@Override
protected
void
onPostExecute
(
String
s
)
{
if
(
threatStatus
==
1
){
// AlertDialog.Builder builder1 = new AlertDialog.Builder(Dashboard.this);
// builder1.setMessage("You have a threat. Be careful!!!");
// builder1.setCancelable(true);
//
// builder1.setPositiveButton(
// "OK",
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
//
//
// AlertDialog alert11 = builder1.create();
// alert11.show();
String
message
=
"You have a threat. Be careful!!!"
;
int
reqCode
=
1
;
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
showNotification
(
Dashboard
.
this
,
"Threat Detection"
,
message
,
intent
,
reqCode
);
}
else
{
// AlertDialog.Builder builder1 = new AlertDialog.Builder(Dashboard.this);
// builder1.setMessage("You have no threats. You are safe!");
// builder1.setCancelable(true);
//
// builder1.setPositiveButton(
// "OK",
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
//
//
// AlertDialog alert11 = builder1.create();
// alert11.show();
String
message
=
"You have no threats. You are safe!"
;
int
reqCode
=
1
;
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
showNotification
(
Dashboard
.
this
,
"Threat Detection"
,
message
,
intent
,
reqCode
);
}
}
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
KITKAT
)
@Override
protected
String
doInBackground
(
String
...
strings
)
{
try
{
String
Url
=
BaseURL
.
get_url
()
+
"threat"
;
OkHttpClient
client
=
new
OkHttpClient
();
Request
request
=
new
Request
.
Builder
()
.
url
(
Url
)
.
get
()
.
build
();
try
(
Response
response
=
client
.
newCall
(
request
).
execute
())
{
ResponseBody
body
=
response
.
body
();
JSONArray
json
=
new
JSONArray
(
body
.
string
());
System
.
out
.
println
(
json
);
for
(
int
i
=
0
;
i
<
json
.
length
();
i
++)
{
JSONObject
joo
=
json
.
getJSONObject
(
i
);
threatStatus
=
joo
.
getInt
(
"status"
);
}
}
catch
(
IOException
|
JSONException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
finally
{
}
}
}
private
class
ParkingViolation
extends
AsyncTask
<
String
,
String
,
String
>
{
@Override
protected
void
onPreExecute
()
{
}
@Override
protected
void
onPostExecute
(
String
s
)
{
if
(
parkingStatus
==
1
){
// AlertDialog.Builder builder1 = new AlertDialog.Builder(Dashboard.this);
// builder1.setMessage("You Parked very well!!");
// builder1.setCancelable(true);
//
// builder1.setPositiveButton(
// "OK",
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
//
//
// AlertDialog alert11 = builder1.create();
// alert11.show();
String
message
=
"You Parked very well!!"
;
int
reqCode
=
1
;
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
showNotification
(
Dashboard
.
this
,
"Parking Violation Detection"
,
message
,
intent
,
reqCode
);
}
else
{
AlertDialog
.
Builder
builder1
=
new
AlertDialog
.
Builder
(
Dashboard
.
this
);
builder1
.
setMessage
(
"You are not parked well!!!"
);
builder1
.
setCancelable
(
true
);
builder1
.
setPositiveButton
(
"OK"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
AlertDialog
.
Builder
dialogBuilder
=
new
AlertDialog
.
Builder
(
Dashboard
.
this
);
LayoutInflater
inflater
=
LayoutInflater
.
from
(
Dashboard
.
this
);
View
view1
=
inflater
.
inflate
(
R
.
layout
.
custom_parking_violation
,
null
);
dialogBuilder
.
setView
(
view1
);
final
VideoView
videoView
=
(
VideoView
)
view1
.
findViewById
(
R
.
id
.
videoView
);
MediaController
mediaController
;
mediaController
=
new
MediaController
(
Dashboard
.
this
);
mediaController
.
setAnchorView
(
videoView
);
Uri
localUri
=
Uri
.
parse
(
"android.resource://"
+
getPackageName
()
+
"/"
+
R
.
raw
.
parking
);
videoView
.
setVideoURI
(
localUri
);
videoView
.
setMediaController
(
mediaController
);
videoView
.
start
();
final
AlertDialog
alertDialog
=
dialogBuilder
.
create
();
alertDialog
.
show
();
}
});
AlertDialog
alert11
=
builder1
.
create
();
alert11
.
show
();
}
}
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
KITKAT
)
@Override
protected
String
doInBackground
(
String
...
strings
)
{
try
{
String
Url
=
BaseURL
.
get_url
()
+
"parking_violation"
;
OkHttpClient
client
=
new
OkHttpClient
();
Request
request
=
new
Request
.
Builder
()
.
url
(
Url
)
.
get
()
.
build
();
try
(
Response
response
=
client
.
newCall
(
request
).
execute
())
{
ResponseBody
body
=
response
.
body
();
JSONArray
json
=
new
JSONArray
(
body
.
string
());
System
.
out
.
println
(
json
);
for
(
int
i
=
0
;
i
<
json
.
length
();
i
++)
{
JSONObject
joo
=
json
.
getJSONObject
(
i
);
parkingStatus
=
joo
.
getInt
(
"status"
);
}
}
catch
(
IOException
|
JSONException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
finally
{
}
}
}
public
void
showNotification
(
Context
context
,
String
title
,
String
message
,
Intent
intent
,
int
reqCode
)
{
// SharedPreferenceManager sharedPreferenceManager = SharedPreferenceManager.getInstance(context);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
reqCode
,
intent
,
PendingIntent
.
FLAG_ONE_SHOT
);
String
CHANNEL_ID
=
"channel_name"
;
// The id of the channel.
NotificationCompat
.
Builder
notificationBuilder
=
new
NotificationCompat
.
Builder
(
context
,
CHANNEL_ID
)
.
setSmallIcon
(
R
.
drawable
.
car
)
.
setContentTitle
(
title
)
.
setContentText
(
message
)
.
setAutoCancel
(
true
)
.
setSound
(
RingtoneManager
.
getDefaultUri
(
RingtoneManager
.
TYPE_NOTIFICATION
))
.
setContentIntent
(
pendingIntent
);
NotificationManager
notificationManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
CharSequence
name
=
"Channel Name"
;
// The user-visible name of the channel.
int
importance
=
NotificationManager
.
IMPORTANCE_HIGH
;
NotificationChannel
mChannel
=
new
NotificationChannel
(
CHANNEL_ID
,
name
,
importance
);
notificationManager
.
createNotificationChannel
(
mChannel
);
}
notificationManager
.
notify
(
reqCode
,
notificationBuilder
.
build
());
// 0 is the request code, it should be unique id
Log
.
d
(
"showNotification"
,
"showNotification: "
+
reqCode
);
}
}
\ 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