Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
5
5711403296
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paded
5711403296
Commits
3b02697b
Commit
3b02697b
authored
May 29, 2018
by
Paded
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit register
parent
76c859c0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
35 deletions
+120
-35
build_file_checksums.ser
.idea/caches/build_file_checksums.ser
+0
-0
CreateAccountActivity.java
...er/paded/com/ubontransitdriver/CreateAccountActivity.java
+23
-18
MainActivity.java
...ansitdriver/paded/com/ubontransitdriver/MainActivity.java
+88
-17
main_layout.xml
app/src/main/res/layout/main_layout.xml
+2
-0
colors.xml
app/src/main/res/values/colors.xml
+7
-0
No files found.
.idea/caches/build_file_checksums.ser
View file @
3b02697b
No preview for this file type
app/src/main/java/ubontransitdriver/paded/com/ubontransitdriver/CreateAccountActivity.java
View file @
3b02697b
...
@@ -296,28 +296,33 @@ public class CreateAccountActivity extends AppCompatActivity implements ItemAdap
...
@@ -296,28 +296,33 @@ public class CreateAccountActivity extends AppCompatActivity implements ItemAdap
busid
=
"B012"
;
busid
=
"B012"
;
}
}
DatabaseReference
keyReference
=
FirebaseDatabase
.
getInstance
().
getReference
().
child
(
"allbus/"
+
busid
);
DatabaseReference
keyReference
=
FirebaseDatabase
.
getInstance
().
getReference
().
child
(
"allbus/"
+
busid
+
"/direction"
);
final
String
finalBusid
=
busid
;
final
String
finalBusid
=
busid
;
keyReference
.
addValueEventListener
(
new
ValueEventListener
()
{
keyReference
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
@Override
public
void
onDataChange
(
DataSnapshot
dataSnapshot
)
{
public
void
onDataChange
(
DataSnapshot
dataSnapshot
)
{
String
x
=
dataSnapshot
.
child
(
"bus_stop"
).
getValue
(
String
.
class
);
// String string = dataSnapshot.getValue(String.class);
if
(
dataSnapshot
.
getValue
().
toString
()!=
null
){
String
[]
bus_stop
=
x
.
split
(
","
);
String
x
=
dataSnapshot
.
getValue
().
toString
();
int
bus_stop_size
=
bus_stop
.
length
;
Log
.
d
(
TAG
,
"insertData: "
+
x
);
// String start_stop_busstop[] = new String[2];
//
// start_stop_busstop[0] = bus_stop[0];
String
[]
x2
=
x
.
split
(
" "
);
// start_stop_busstop[1] = bus_stop[bus_stop_size - 1];
String
[]
x3
=
x2
[
0
].
split
(
"="
);
start_busstop_id
=
bus_stop
[
0
];
String
[]
bus_stop
=
x3
[
1
].
split
(
","
);
stop_busstop_id
=
bus_stop
[
bus_stop_size
-
1
];
int
bus_stop_size
=
bus_stop
.
length
;
start_busstop_id
=
bus_stop
[
0
];
FirebaseDatabase
database
=
FirebaseDatabase
.
getInstance
();
stop_busstop_id
=
bus_stop
[
bus_stop_size
-
1
];
DatabaseReference
myRef
=
database
.
getReference
(
"users/"
+
uid
);
myRef
.
child
(
"name"
).
setValue
(
name
);
FirebaseDatabase
database
=
FirebaseDatabase
.
getInstance
();
myRef
.
child
(
"bus_id"
).
setValue
(
finalBusid
);
DatabaseReference
myRef
=
database
.
getReference
(
"users/"
+
uid
);
myRef
.
child
(
"status"
).
setValue
(
"off"
);
myRef
.
child
(
"name"
).
setValue
(
name
);
myRef
.
child
(
"start_busstop"
).
setValue
(
start_busstop_id
);
myRef
.
child
(
"bus_id"
).
setValue
(
finalBusid
);
myRef
.
child
(
"stop_busstop"
).
setValue
(
stop_busstop_id
);
myRef
.
child
(
"status"
).
setValue
(
"off"
);
myRef
.
child
(
"start_busstop"
).
setValue
(
start_busstop_id
);
myRef
.
child
(
"stop_busstop"
).
setValue
(
stop_busstop_id
);
}
}
}
@Override
@Override
...
...
app/src/main/java/ubontransitdriver/paded/com/ubontransitdriver/MainActivity.java
View file @
3b02697b
...
@@ -11,6 +11,7 @@ import android.content.Intent;
...
@@ -11,6 +11,7 @@ import android.content.Intent;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
import
android.content.IntentSender
;
import
android.content.IntentSender
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.graphics.drawable.GradientDrawable
;
import
android.location.Location
;
import
android.location.Location
;
import
android.location.LocationListener
;
import
android.location.LocationListener
;
import
android.location.LocationManager
;
import
android.location.LocationManager
;
...
@@ -28,7 +29,9 @@ import android.view.View;
...
@@ -28,7 +29,9 @@ import android.view.View;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.FrameLayout
;
import
android.widget.FrameLayout
;
import
android.widget.ImageButton
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.ProgressBar
;
import
android.widget.ProgressBar
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -61,7 +64,7 @@ public class MainActivity extends AppCompatActivity implements LocationListener
...
@@ -61,7 +64,7 @@ public class MainActivity extends AppCompatActivity implements LocationListener
private
ProgressBar
progressBar
;
private
ProgressBar
progressBar
;
private
Button
btn_endtrip
,
btn_endtrip_cancel
,
btn_active_bus
,
btn_return
,
btn_endtrip_yes
;
private
Button
btn_endtrip
,
btn_endtrip_cancel
,
btn_active_bus
,
btn_return
,
btn_endtrip_yes
;
// private Boolean user_status = true;
// private Boolean user_status = true;
private
TextView
txt_user_status_on
,
txt_user_status_off
,
txt_stop
,
txt_start
;
private
TextView
txt_user_status_on
,
txt_user_status_off
,
txt_stop
,
txt_start
,
bus_name_txt
;
BottomSheetDialog
bottomSheetDialog
;
BottomSheetDialog
bottomSheetDialog
;
BottomSheetBehavior
bottomSheetBehavior
;
BottomSheetBehavior
bottomSheetBehavior
;
private
FrameLayout
view_cover
;
private
FrameLayout
view_cover
;
...
@@ -72,6 +75,13 @@ public class MainActivity extends AppCompatActivity implements LocationListener
...
@@ -72,6 +75,13 @@ public class MainActivity extends AppCompatActivity implements LocationListener
static
AlertDialog
alert
;
static
AlertDialog
alert
;
LocationManager
lm
;
LocationManager
lm
;
private
static
final
String
FINE_LOCATION
=
Manifest
.
permission
.
ACCESS_FINE_LOCATION
;
private
static
final
String
COURSE_LOCATION
=
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
;
private
static
final
int
LOCATION_PERMISSION_REQUEST_CODE
=
1234
;
RelativeLayout
bus_icon_layout
;
GradientDrawable
drawable
;
String
bus_id
;
String
bus_id
;
String
user_status
;
String
user_status
;
String
user_id
;
String
user_id
;
...
@@ -98,15 +108,38 @@ public class MainActivity extends AppCompatActivity implements LocationListener
...
@@ -98,15 +108,38 @@ public class MainActivity extends AppCompatActivity implements LocationListener
setContentView
(
R
.
layout
.
main_layout
);
setContentView
(
R
.
layout
.
main_layout
);
MainActivity
.
currentContext
=
this
;
MainActivity
.
currentContext
=
this
;
Log
.
d
(
TAG
,
"onCreate: "
);
database
=
FirebaseDatabase
.
getInstance
().
getReference
();
database
=
FirebaseDatabase
.
getInstance
().
getReference
();
lm
=
(
LocationManager
)
getSystemService
(
Context
.
LOCATION_SERVICE
);
lm
=
(
LocationManager
)
getSystemService
(
Context
.
LOCATION_SERVICE
);
if
(
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
!=
PackageManager
.
PERMISSION_GRANTED
&&
ActivityCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
// if (ActivityCompat.checkSelfPermission(this,
return
;
// Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
}
// ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
lm
.
requestLocationUpdates
(
LocationManager
.
GPS_PROVIDER
,
1000
,
10
,
this
);
// != PackageManager.PERMISSION_GRANTED) {
// if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER) && hasGPSDevice(MainActivity.this)) {
//
// Toast.makeText(MainActivity.this,"Gps already enabled",Toast.LENGTH_SHORT).show();
// Log.d(TAG, "onCreate: per");
// return;
// }
// }
String
[]
permission
=
{
Manifest
.
permission
.
ACCESS_FINE_LOCATION
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
};
if
(
ContextCompat
.
checkSelfPermission
(
this
.
getApplicationContext
(),
FINE_LOCATION
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
ContextCompat
.
checkSelfPermission
(
this
.
getApplicationContext
(),
COURSE_LOCATION
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
// mLocationPermissionGranted = true;
// initMap();
lm
.
requestLocationUpdates
(
LocationManager
.
GPS_PROVIDER
,
1000
,
10
,
this
);
}
else
{
ActivityCompat
.
requestPermissions
(
this
,
permission
,
LOCATION_PERMISSION_REQUEST_CODE
);
}
}
else
{
ActivityCompat
.
requestPermissions
(
this
,
permission
,
LOCATION_PERMISSION_REQUEST_CODE
);
}
// lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 10, this);
if
(
lm
.
isProviderEnabled
(
LocationManager
.
GPS_PROVIDER
)
&&
hasGPSDevice
(
MainActivity
.
this
))
{
Toast
.
makeText
(
MainActivity
.
this
,
"Gps already enabled"
,
Toast
.
LENGTH_SHORT
).
show
();
}
if
(!
hasGPSDevice
(
MainActivity
.
this
))
{
if
(!
hasGPSDevice
(
MainActivity
.
this
))
{
Toast
.
makeText
(
MainActivity
.
this
,
"Gps not Supported"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
MainActivity
.
this
,
"Gps not Supported"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
...
@@ -136,6 +169,9 @@ public class MainActivity extends AppCompatActivity implements LocationListener
...
@@ -136,6 +169,9 @@ public class MainActivity extends AppCompatActivity implements LocationListener
txt_start
=
(
TextView
)
findViewById
(
R
.
id
.
txt_start
);
txt_start
=
(
TextView
)
findViewById
(
R
.
id
.
txt_start
);
txt_stop
=
(
TextView
)
findViewById
(
R
.
id
.
txt_stop
);
txt_stop
=
(
TextView
)
findViewById
(
R
.
id
.
txt_stop
);
bus_name_txt
=
(
TextView
)
findViewById
(
R
.
id
.
bus_name_txt
);
bus_icon_layout
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
bus_icon_layout
);
drawable
=
(
GradientDrawable
)
bus_icon_layout
.
getBackground
();
// view_cover = (FrameLayout) findViewById(R.id.view_cover);
// view_cover = (FrameLayout) findViewById(R.id.view_cover);
progressBar
.
setVisibility
(
View
.
VISIBLE
);
progressBar
.
setVisibility
(
View
.
VISIBLE
);
...
@@ -163,6 +199,8 @@ public class MainActivity extends AppCompatActivity implements LocationListener
...
@@ -163,6 +199,8 @@ public class MainActivity extends AppCompatActivity implements LocationListener
bus_id
=
dataSnapshot
.
child
(
"bus_id"
).
getValue
(
String
.
class
);
bus_id
=
dataSnapshot
.
child
(
"bus_id"
).
getValue
(
String
.
class
);
user_id
=
user
.
getUid
();
user_id
=
user
.
getUid
();
Log
.
d
(
TAG
,
"onDataChange: "
+
user_status
);
start_busstop_id
=
dataSnapshot
.
child
(
"start_busstop"
).
getValue
(
String
.
class
);
start_busstop_id
=
dataSnapshot
.
child
(
"start_busstop"
).
getValue
(
String
.
class
);
stop_busstop_id
=
dataSnapshot
.
child
(
"stop_busstop"
).
getValue
(
String
.
class
);
stop_busstop_id
=
dataSnapshot
.
child
(
"stop_busstop"
).
getValue
(
String
.
class
);
...
@@ -181,6 +219,39 @@ public class MainActivity extends AppCompatActivity implements LocationListener
...
@@ -181,6 +219,39 @@ public class MainActivity extends AppCompatActivity implements LocationListener
}
}
});
});
//set Infomation to Display
DatabaseReference
keyReference11
=
FirebaseDatabase
.
getInstance
().
getReference
().
child
(
"allbus/"
+
bus_id
);
keyReference11
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
public
void
onDataChange
(
DataSnapshot
dataSnapshot
)
{
bus_name_txt
.
setText
(
dataSnapshot
.
child
(
"name"
).
getValue
(
String
.
class
));
if
(
bus_id
.
equalsIgnoreCase
(
"B00"
)){
drawable
.
setColor
(
getResources
().
getColor
(
R
.
color
.
red3
));
}
else
if
(
bus_id
.
equalsIgnoreCase
(
"B01"
)){
drawable
.
setColor
(
getResources
().
getColor
(
R
.
color
.
purple
));
}
else
if
(
bus_id
.
equalsIgnoreCase
(
"B02"
)){
drawable
.
setColor
(
getResources
().
getColor
(
R
.
color
.
gray_300
));
}
else
if
(
bus_id
.
equalsIgnoreCase
(
"B03"
)){
drawable
.
setColor
(
getResources
().
getColor
(
R
.
color
.
pink
));
}
else
if
(
bus_id
.
equalsIgnoreCase
(
"B07"
)
||
bus_id
.
equalsIgnoreCase
(
"B08"
)
||
bus_id
.
equalsIgnoreCase
(
"B09"
)
||
bus_id
.
equalsIgnoreCase
(
"B10"
)
||
bus_id
.
equalsIgnoreCase
(
"B11"
)
||
bus_id
.
equalsIgnoreCase
(
"B12"
)){
drawable
.
setColor
(
getResources
().
getColor
(
R
.
color
.
sky_blue
));
}
}
@Override
public
void
onCancelled
(
DatabaseError
databaseError
)
{
Log
.
d
(
TAG
,
"Read failed"
);
}
});
DatabaseReference
keyReference1
=
FirebaseDatabase
.
getInstance
().
getReference
().
child
(
"allbus/"
+
bus_id
+
"/direction/"
+
start_busstop_id
);
DatabaseReference
keyReference1
=
FirebaseDatabase
.
getInstance
().
getReference
().
child
(
"allbus/"
+
bus_id
+
"/direction/"
+
start_busstop_id
);
keyReference1
.
addValueEventListener
(
new
ValueEventListener
()
{
keyReference1
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
@Override
...
@@ -503,16 +574,16 @@ public class MainActivity extends AppCompatActivity implements LocationListener
...
@@ -503,16 +574,16 @@ public class MainActivity extends AppCompatActivity implements LocationListener
}
}
@Override
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
grantResults
)
{
Log
.
d
(
TAG
,
"onRequestPermissionsResult: "
);
if
(
requestCode
==
PERMISSIONS_REQUEST
&&
grantResults
.
length
==
1
//
if (requestCode == PERMISSIONS_REQUEST && grantResults.length == 1
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
//
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Start the service when the permission is granted
//
// Start the service when the permission is granted
startTrackerService
(
user_id
,
bus_id
);
//
startTrackerService(user_id, bus_id);
Log
.
d
(
TAG
,
"onRequestPermissionsResult: Start"
);
//
Log.d(TAG, "onRequestPermissionsResult: Start");
}
else
{
//
} else {
finish
();
//
finish();
}
//
}
}
}
private
void
buildNotification
()
{
private
void
buildNotification
()
{
...
...
app/src/main/res/layout/main_layout.xml
View file @
3b02697b
...
@@ -205,6 +205,7 @@
...
@@ -205,6 +205,7 @@
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<RelativeLayout
<RelativeLayout
android:id=
"@+id/bus_icon_layout"
android:layout_width=
"25dp"
android:layout_width=
"25dp"
android:layout_height=
"25dp"
android:layout_height=
"25dp"
android:layout_marginRight=
"6dp"
android:layout_marginRight=
"6dp"
...
@@ -224,6 +225,7 @@
...
@@ -224,6 +225,7 @@
<TextView
<TextView
android:id=
"@+id/bus_name_txt"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"สาย ม."
android:text=
"สาย ม."
...
...
app/src/main/res/values/colors.xml
View file @
3b02697b
...
@@ -27,6 +27,13 @@
...
@@ -27,6 +27,13 @@
<color
name=
"gray_800"
>
#424242
</color>
<color
name=
"gray_800"
>
#424242
</color>
<color
name=
"gray_900"
>
#212121
</color>
<color
name=
"gray_900"
>
#212121
</color>
<color
name=
"purple"
>
#3f51b5
</color>
<color
name=
"sky_blue"
>
#5ac8fa
</color>
<color
name=
"pink"
>
#fe5273
</color>
<color
name=
"gray_300"
>
#E0E0E0
</color>
<color
name=
"red3"
>
#f23333
</color>
...
...
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