Commit 7959a8fa authored by Paded's avatar Paded

add notification

parent b32a2165
......@@ -13,6 +13,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:launchMode="singleTop"
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize" />
<activity
......@@ -34,7 +35,7 @@
<activity android:name=".AddBusActivity" />
<activity android:name=".ProfileSettingActivity"></activity>
<service
android:name=".TrackerService"
android:name=".TrackerService3"
android:enabled="true"
android:exported="true"></service>
</application>
......
package ubontransitdriver.paded.com.ubontransitdriver;
import android.Manifest;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.net.Uri;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
......@@ -33,8 +39,8 @@ public class MainActivity extends AppCompatActivity {
private ImageButton btn_profile;
private String TAG = "mainAC";
private ProgressBar progressBar;
private Button btn_endtrip, btn_endtrip_cancel, btn_active_bus, btn_return,btn_endtrip_yes;
// private Boolean user_status = true;
private Button btn_endtrip, btn_endtrip_cancel, btn_active_bus, btn_return, btn_endtrip_yes;
// private Boolean user_status = true;
private TextView txt_user_status_on, txt_user_status_off;
BottomSheetDialog bottomSheetDialog;
BottomSheetBehavior bottomSheetBehavior;
......@@ -46,6 +52,8 @@ public class MainActivity extends AppCompatActivity {
String user_status;
String user_id;
NotificationManager mNotificationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -56,14 +64,13 @@ public class MainActivity extends AppCompatActivity {
FirebaseUser user = auth.getCurrentUser();
progressBar = (ProgressBar) findViewById(R.id.progressBar);
btn_profile = (ImageButton)findViewById(R.id.btn_profile);
btn_endtrip = (Button)findViewById(R.id.btn_endtrip);
txt_user_status_on = (TextView)findViewById(R.id.txt_user_status_on);
txt_user_status_off = (TextView)findViewById(R.id.txt_user_status_off);
btn_active_bus = (Button)findViewById(R.id.btn_active_bus);
btn_return = (Button)findViewById(R.id.btn_return);
btn_profile = (ImageButton) findViewById(R.id.btn_profile);
btn_endtrip = (Button) findViewById(R.id.btn_endtrip);
txt_user_status_on = (TextView) findViewById(R.id.txt_user_status_on);
txt_user_status_off = (TextView) findViewById(R.id.txt_user_status_off);
btn_active_bus = (Button) findViewById(R.id.btn_active_bus);
btn_return = (Button) findViewById(R.id.btn_return);
// view_cover = (FrameLayout) findViewById(R.id.view_cover);
......@@ -77,25 +84,26 @@ public class MainActivity extends AppCompatActivity {
bottomSheetDialog.setContentView(bottomSheetView);
bottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetView.getParent());
btn_endtrip_cancel = (Button)bottomSheetView.findViewById(R.id.btn_endtrip_cancel);
btn_endtrip_yes = (Button)bottomSheetView.findViewById(R.id.btn_endtrip_yes);
btn_endtrip_cancel = (Button) bottomSheetView.findViewById(R.id.btn_endtrip_cancel);
btn_endtrip_yes = (Button) bottomSheetView.findViewById(R.id.btn_endtrip_yes);
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
// Attach a listener to read the data at our posts reference
database.child("users/"+user.getUid()).addValueEventListener(new ValueEventListener() {
database.child("users/" + user.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
FirebaseUser user = auth.getCurrentUser();
Log.d(TAG, "onDataChange: "+dataSnapshot.child("name").getValue(String.class));
Log.d(TAG, "onDataChange: "+dataSnapshot.child("bus_id").getValue(String.class));
Log.d(TAG, "onDataChange: "+dataSnapshot.child("status").getValue(String.class));
Log.d(TAG, "onDataChange: " + dataSnapshot.child("name").getValue(String.class));
Log.d(TAG, "onDataChange: " + dataSnapshot.child("bus_id").getValue(String.class));
Log.d(TAG, "onDataChange: " + dataSnapshot.child("status").getValue(String.class));
user_status = dataSnapshot.child("status").getValue(String.class);
bus_id = dataSnapshot.child("bus_id").getValue(String.class);
user_id = user.getUid();
updateUI(user_status);
if(user_status.equalsIgnoreCase("on")){
trackBus(user_id,bus_id);
if (user_status.equalsIgnoreCase("on")) {
buildNotification();
trackBus(user_id, bus_id);
}
......@@ -135,18 +143,19 @@ public class MainActivity extends AppCompatActivity {
FirebaseUser user = auth.getCurrentUser();
active_status = false;
if(bus_id!=null){
Intent intent = new Intent(MainActivity.this, TrackerService.class);
if (bus_id != null) {
Intent intent = new Intent(MainActivity.this, TrackerService3.class);
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("active_bus/"+bus_id);
DatabaseReference myRef = database.getReference("active_bus/" + bus_id);
myRef.child(user.getUid()).removeValue();
stopService(intent);
mNotificationManager.cancel(001);
}
// DatabaseReference myRef = database.getReference("active_bus/"+bus_id+"/"+user_id);
// myRef.child("lat").setValue(12);
// myRef.child("lng").setValue(12);
UpdateUserStatus(user.getUid(),active_status);
UpdateUserStatus(user.getUid(), active_status);
bottomSheetDialog.hide();
}
});
......@@ -164,16 +173,11 @@ public class MainActivity extends AppCompatActivity {
progressBar.setVisibility(View.VISIBLE);
FirebaseUser user = auth.getCurrentUser();
active_status = true;
UpdateUserStatus(user.getUid(),active_status);
UpdateUserStatus(user.getUid(), active_status);
}
});
//
// MaterialShadowContainerView shadowView =
// (MaterialShadowContainerView) findViewById(R.id.shadow_item_container);
......@@ -186,27 +190,27 @@ public class MainActivity extends AppCompatActivity {
}
public void UpdateUserStatus(String user_id, boolean active_status){
public void UpdateUserStatus(String user_id, boolean active_status) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("users/"+user_id);
if(!active_status){
DatabaseReference myRef = database.getReference("users/" + user_id);
if (!active_status) {
myRef.child("status").setValue("off");
}else{
} else {
myRef.child("status").setValue("on");
}
progressBar.setVisibility(View.GONE);
}
public void updateUI(String user_status){
if(user_status.equalsIgnoreCase("off")){
public void updateUI(String user_status) {
if (user_status.equalsIgnoreCase("off")) {
btn_active_bus.setVisibility(View.VISIBLE);
txt_user_status_off.setVisibility(View.VISIBLE);
btn_endtrip.setVisibility(View.GONE);
btn_return.setVisibility(View.GONE);
txt_user_status_on.setVisibility(View.GONE);
}else{
} else {
btn_active_bus.setVisibility(View.GONE);
txt_user_status_off.setVisibility(View.GONE);
......@@ -216,22 +220,22 @@ public class MainActivity extends AppCompatActivity {
}
progressBar.setVisibility(View.GONE);
// view_cover.getForeground().setAlpha(0);
Log.d(TAG, "updateUI: "+user_status);
Log.d(TAG, "updateUI: " + user_status);
}
public void trackBus(String user_id,String bus_id){
public void trackBus(String user_id, String bus_id) {
// Check GPS is enabled ****
LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Toast.makeText(this, "Please enable location services", Toast.LENGTH_SHORT).show();
finish();
}
// Check location permission is granted - if it is, start
// the service, otherwise request the permission
int permission = ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION);
if (permission == PackageManager.PERMISSION_GRANTED) {
startTrackerService(user_id,bus_id);
startTrackerService(user_id, bus_id);
Log.d(TAG, "trackBus: ");
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
......@@ -244,13 +248,12 @@ public class MainActivity extends AppCompatActivity {
// myRef.child("lng").setValue(12);
}
private void startTrackerService(String user_id,String bus_id) {
Intent intent = new Intent(this,TrackerService.class);
intent.putExtra("user_id",user_id);
intent.putExtra("bus_id",bus_id);
private void startTrackerService(String user_id, String bus_id) {
Intent intent = new Intent(this, TrackerService3.class);
intent.putExtra("user_id", user_id);
intent.putExtra("bus_id", bus_id);
startService(intent);
}
......@@ -260,10 +263,53 @@ public class MainActivity extends AppCompatActivity {
if (requestCode == PERMISSIONS_REQUEST && grantResults.length == 1
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Start the service when the permission is granted
startTrackerService(user_id,bus_id);
startTrackerService(user_id, bus_id);
Log.d(TAG, "onRequestPermissionsResult: Start");
} else {
finish();
}
}
private void buildNotification() {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_wifi_bus)
.setContentTitle("On Going")
.setContentText("Tracking, tap to open")
.setOngoing(true);
//Create the intent that’ll fire when the user taps the notification//
// Intent intent = new Intent(this, MainActivity.class);
// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
//
// mBuilder.setContentIntent(pendingIntent);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(contentIntent);
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(001, mBuilder.build());
}
@Override
protected void onPause() {
super.onPause();
// if(user_status.equalsIgnoreCase("on")){
// buildNotification();
// }
}
@Override
protected void onDestroy() {
super.onDestroy();
// NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
// notificationManager.cancel(001);
}
}
......@@ -9,13 +9,17 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.widget.Toast;
import android.os.Process;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
......@@ -26,10 +30,18 @@ import com.google.firebase.database.FirebaseDatabase;
public class TrackerService extends Service {
private static final String TAG = "GPS2";
private boolean isRunning = false;
private Looper looper;
private MyServiceHandler myServiceHandler;
@Override
public void onCreate() {
super.onCreate();
HandlerThread handlerthread = new HandlerThread("MyThread", Process.THREAD_PRIORITY_BACKGROUND);
handlerthread.start();
looper = handlerthread.getLooper();
myServiceHandler = new MyServiceHandler(looper);
isRunning = true;
}
......@@ -37,7 +49,7 @@ public class TrackerService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
String user_id = intent.getStringExtra("user_id");
String bus_id = intent.getStringExtra("bus_id");
buildNotification();
// buildNotification();
requestLocationUpdates(user_id,bus_id);
Toast.makeText(this, "MyService Started.", Toast.LENGTH_SHORT).show();
//If service is killed while starting, it restarts.
......@@ -53,6 +65,37 @@ public class TrackerService extends Service {
return null;
}
@Override
public void onDestroy() {
isRunning = false;
Toast.makeText(this, "MyService Completed or Stopped.", Toast.LENGTH_SHORT).show();
}
private final class MyServiceHandler extends Handler {
public MyServiceHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
synchronized (this) {
for (int i = 0; i < 10; i++) {
try {
Log.i(TAG, "MyService running...");
Thread.sleep(1000);
} catch (Exception e) {
Log.i(TAG, e.getMessage());
}
if(!isRunning){
break;
}
}
}
//stops the service for the start id.
stopSelfResult(msg.arg1);
}
}
private void buildNotification() {
String stop = "stop";
registerReceiver(stopReceiver, new IntentFilter(stop));
......@@ -64,7 +107,7 @@ public class TrackerService extends Service {
.setContentText(getString(R.string.notification_text))
.setOngoing(true)
.setContentIntent(broadcastIntent)
.setSmallIcon(R.drawable.ic_bus);
.setSmallIcon(R.drawable.ic_frontal_bus_silhouette);
startForeground(1, builder.build());
}
......
package ubontransitdriver.paded.com.ubontransitdriver;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
public class TrackerService2 extends Service {
private static final String TAG = "MyLocationService";
private LocationManager mLocationManager = null;
private static final int LOCATION_INTERVAL = 50000;
private static final float LOCATION_DISTANCE = 10;
private class LocationListener implements android.location.LocationListener {
Location mLastLocation;
public LocationListener(String provider) {
Log.e(TAG, "LocationListener " + provider);
mLastLocation = new Location(provider);
}
@Override
public void onLocationChanged(Location location) {
Log.e(TAG, "onLocationChanged: " + location);
mLastLocation.set(location);
Log.d(TAG, "onLocationChanged Lat Lng: "+location.getLatitude()+" "+location.getLongitude());
}
@Override
public void onProviderDisabled(String provider) {
Log.e(TAG, "onProviderDisabled: " + provider);
}
@Override
public void onProviderEnabled(String provider) {
Log.e(TAG, "onProviderEnabled: " + provider);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.e(TAG, "onStatusChanged: " + provider);
}
}
LocationListener[] mLocationListeners = new LocationListener[]{
new LocationListener(LocationManager.PASSIVE_PROVIDER)
};
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand");
super.onStartCommand(intent, flags, startId);
return START_STICKY;
}
@Override
public void onCreate() {
Log.e(TAG, "onCreate");
initializeLocationManager();
try {
mLocationManager.requestLocationUpdates(
LocationManager.PASSIVE_PROVIDER,
LOCATION_INTERVAL,
LOCATION_DISTANCE,
mLocationListeners[0]
);
} catch (java.lang.SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "network provider does not exist, " + ex.getMessage());
}
/*try {
mLocationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
LOCATION_INTERVAL,
LOCATION_DISTANCE,
mLocationListeners[1]
);
} catch (java.lang.SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "gps provider does not exist " + ex.getMessage());
}*/
}
@Override
public void onDestroy() {
Log.e(TAG, "onDestroy");
super.onDestroy();
if (mLocationManager != null) {
for (int i = 0; i < mLocationListeners.length; i++) {
try {
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mLocationManager.removeUpdates(mLocationListeners[i]);
} catch (Exception ex) {
Log.i(TAG, "fail to remove location listener, ignore", ex);
}
}
}
}
private void initializeLocationManager() {
Log.e(TAG, "initializeLocationManager - LOCATION_INTERVAL: " + LOCATION_INTERVAL + " LOCATION_DISTANCE: " + LOCATION_DISTANCE);
if (mLocationManager == null) {
mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
}
}
}
package ubontransitdriver.paded.com.ubontransitdriver;
import android.app.Service;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.Manifest;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.util.Calendar;
import java.util.Date;
public class TrackerService3 extends Service implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener{
FusedLocationProviderClient mFusedLocationClient;
GoogleApiClient mGoogleApiClient;
LocationRequest mLocationRequest;
String TAG = "trackService";
private String user_id;
private String bus_id;
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
user_id = intent.getStringExtra("user_id");
bus_id = intent.getStringExtra("bus_id");
Log.d(TAG, "onStartCommand: "+user_id+" "+bus_id);
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
if (mGoogleApiClient != null && mFusedLocationClient != null) {
requestLocationUpdates();
} else {
buildGoogleApiClient();
}
return START_STICKY;
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
}
@Override
public void onDestroy() {
super.onDestroy();
if (mFusedLocationClient != null) {
Log.d(TAG, "Service Stop");
mFusedLocationClient.removeLocationUpdates(mLocationCallback);
}
}
public void requestLocationUpdates() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000); // two minute interval
mLocationRequest.setFastestInterval(5000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
}
}
LocationCallback mLocationCallback = new LocationCallback(){
@Override
public void onLocationResult(LocationResult locationResult) {
final String path ="active_bus/"+bus_id+"/"+user_id;
for (Location location : locationResult.getLocations()) {
DatabaseReference ref = FirebaseDatabase.getInstance().getReference(path);
ref.child("latitude").setValue(location.getLatitude());
ref.child("longitude").setValue(location.getLongitude());
ref.child("time").setValue(location.getTime());
// Date currentTime = Calendar.getInstance().getTime();
// Log.d(TAG, "Location: " + location.getLatitude() + " " + location.getLongitude()+" "+location.getTime()+" "+currentTime);
}
};
};
@Override
public void onConnected(@Nullable Bundle bundle) {
requestLocationUpdates();
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/off_green" />
<solid android:color="@color/green" />
<corners android:radius="8dp" />
<padding
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/green" />
<solid android:color="@color/white" />
<corners android:radius="8dp" />
<stroke
android:width = "1.5dp"
android:color="@color/green"
/>
<padding
android:bottom="7dip"
android:left="7dip"
......
......@@ -16,7 +16,7 @@
</padding>
<corners
android:radius="8dp" >
android:radius="360dp" >
</corners>
</shape>
\ No newline at end of file
<vector android:height="24dp" android:viewportHeight="426.667"
android:viewportWidth="426.667" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/gray_400" android:pathData="M213.333,0C95.467,0 0,95.467 0,213.333s95.467,213.333 213.333,213.333S426.667,331.2 426.667,213.333S331.2,0 213.333,0zM96,149.333l74.667,-74.667l74.667,74.667H192v85.333h-42.667v-85.333H96zM256,352l-74.667,-74.667h53.333V192h42.667v85.333h53.333L256,352z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/green"
android:pathData="M19.07,4.93l-1.41,1.41C19.1,7.79 20,9.79 20,12c0,4.42 -3.58,8 -8,8s-8,-3.58 -8,-8c0,-4.08 3.05,-7.44 7,-7.93v2.02C8.16,6.57 6,9.03 6,12c0,3.31 2.69,6 6,6s6,-2.69 6,-6c0,-1.66 -0.67,-3.16 -1.76,-4.24l-1.41,1.41C15.55,9.9 16,10.9 16,12c0,2.21 -1.79,4 -4,4s-4,-1.79 -4,-4c0,-1.86 1.28,-3.41 3,-3.86v2.14c-0.6,0.35 -1,0.98 -1,1.72 0,1.1 0.9,2 2,2s2,-0.9 2,-2c0,-0.74 -0.4,-1.38 -1,-1.72V2h-1C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10c0,-2.76 -1.12,-5.26 -2.93,-7.07z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/white"
android:pathData="M19.07,4.93l-1.41,1.41C19.1,7.79 20,9.79 20,12c0,4.42 -3.58,8 -8,8s-8,-3.58 -8,-8c0,-4.08 3.05,-7.44 7,-7.93v2.02C8.16,6.57 6,9.03 6,12c0,3.31 2.69,6 6,6s6,-2.69 6,-6c0,-1.66 -0.67,-3.16 -1.76,-4.24l-1.41,1.41C15.55,9.9 16,10.9 16,12c0,2.21 -1.79,4 -4,4s-4,-1.79 -4,-4c0,-1.86 1.28,-3.41 3,-3.86v2.14c-0.6,0.35 -1,0.98 -1,1.72 0,1.1 0.9,2 2,2s2,-0.9 2,-2c0,-0.74 -0.4,-1.38 -1,-1.72V2h-1C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10c0,-2.76 -1.12,-5.26 -2.93,-7.07z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/ic_track_changes_white_24dp" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/ic_track_changes_white_24dp" /> <!-- focused -->
<item android:drawable="@drawable/ic_track_changes_green_24dp" /> <!-- default -->
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/white" />
<item android:color="@color/green"/>
</selector>
\ No newline at end of file
......@@ -45,22 +45,23 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<LinearLayout
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your route"
android:textColor="@color/gray_900"
android:textSize="32dp"
android:layout_gravity="center_vertical"
android:text="Route"
android:textColor="@color/gray_800"
android:textSize="30dp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
......@@ -91,231 +92,374 @@
android:background="@drawable/bg_busstatus_off"
android:padding="8dp"
android:text="On Pause"
android:textColor="@color/gray_500"
android:textColor="@color/gray_400"
android:textStyle="bold"
android:visibility="invisible" />
</RelativeLayout>
</LinearLayout>
<!--<View-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="1dp"-->
<!--android:layout_marginTop="4dp"-->
<!--android:layout_marginBottom="6dp"-->
<!--android:background="@color/gray_100" />-->
<!--<TextView-->
<!--android:text="Your route"-->
<!--android:textColor="@color/gray_800"-->
<!--android:textStyle="bold"-->
<!--android:textSize="16dp"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:background="@drawable/bg_destination_driver"
android:orientation="vertical"
android:padding="0dp">
<!--<LinearLayout-->
<!--android:background="@drawable/bg_ongoing"-->
<!--android:padding="8dp"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content">-->
<!--<TextView-->
<!--android:text="On Going"-->
<!--android:textSize="18dp"-->
<!--android:textStyle="bold"-->
<!--android:textColor="@color/white"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" />-->
<!--</LinearLayout>-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="18dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginRight="25dp">-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="On Going"-->
<!--android:textColor="@color/green"-->
<!--android:textSize="30dp"-->
<!--android:textStyle="bold" />-->
<!--</LinearLayout>-->
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ic_start_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toStartOf="@+id/text_start"
android:src="@drawable/ic_start_black_24dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start Location"
android:textColor="@color/gray_900"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ubon Ratchathani"
android:textColor="@color/gray_600"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ic_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/text_start"
android:src="@drawable/ic_more_vert_black_24dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ic_stop_circle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toStartOf="@+id/text_start"
android:src="@drawable/ic_stop_black_24dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Destination"
android:textColor="@color/gray_900"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Terminal Ubon"
android:textColor="@color/gray_600"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:text="To"
android:textColor="@color/gray_800"
android:textSize="26dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ubon Terminal"
android:textColor="@color/gray_800"
android:textSize="26dp"
android:textStyle="bold" />
<!--<RelativeLayout-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<!--<ImageButton-->
<!--android:layout_alignParentRight="true"-->
<!--android:layout_width="35dp"-->
<!--android:background="@drawable/bg_profile"-->
<!--android:src="@drawable/ic_sort"-->
<!--android:layout_height="35dp" />-->
<!--</RelativeLayout>-->
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:background="@color/gray_100" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:text="From"
android:textColor="@color/gray_600"
android:textSize="17dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ubon Ratchathani"
android:textColor="@color/blue"
android:textSize="17dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="15dp">
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginRight="6dp"
android:background="@drawable/bus_color_icon_red"
android:padding="10dp">
android:padding="6dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_frontal_bus_silhouette_white" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:orientation="vertical">
<LinearLayout
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Bus"
android:textColor="@color/gray_500" />
</LinearLayout>
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="สาย ม."
android:textColor="@color/gray_900"
android:textSize="22dp"
android:textStyle="" />
</LinearLayout>
android:textColor="@color/gray_600"
android:textSize="17dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:background="@drawable/bg_destination_driver"-->
<!--android:orientation="vertical"-->
<!--android:padding="0dp">-->
<!--<LinearLayout-->
<!--android:background="@drawable/bg_ongoing"-->
<!--android:padding="8dp"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content">-->
<!--<TextView-->
<!--android:text="On Going"-->
<!--android:textSize="18dp"-->
<!--android:textStyle="bold"-->
<!--android:textColor="@color/white"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content" />-->
<!--</LinearLayout>-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:padding="15dp">-->
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="horizontal">-->
<!--&lt;!&ndash;<LinearLayout&ndash;&gt;-->
<!--&lt;!&ndash;android:layout_width="wrap_content"&ndash;&gt;-->
<!--&lt;!&ndash;android:layout_height="wrap_content"&ndash;&gt;-->
<!--&lt;!&ndash;android:layout_gravity="center_vertical"&ndash;&gt;-->
<!--&lt;!&ndash;android:layout_marginRight="25dp">&ndash;&gt;-->
<!--&lt;!&ndash;<TextView&ndash;&gt;-->
<!--&lt;!&ndash;android:layout_width="wrap_content"&ndash;&gt;-->
<!--&lt;!&ndash;android:layout_height="wrap_content"&ndash;&gt;-->
<!--&lt;!&ndash;android:text="On Going"&ndash;&gt;-->
<!--&lt;!&ndash;android:textColor="@color/green"&ndash;&gt;-->
<!--&lt;!&ndash;android:textSize="30dp"&ndash;&gt;-->
<!--&lt;!&ndash;android:textStyle="bold" />&ndash;&gt;-->
<!--&lt;!&ndash;</LinearLayout>&ndash;&gt;-->
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="vertical">-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<!--<ImageView-->
<!--android:id="@+id/ic_start_circle"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_toStartOf="@+id/text_start"-->
<!--android:src="@drawable/ic_start_black_24dp" />-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginLeft="15dp"-->
<!--android:orientation="vertical">-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="Start Location"-->
<!--android:textColor="@color/gray_900"-->
<!--android:textStyle="bold" />-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="Ubon Ratchathani"-->
<!--android:textColor="@color/gray_600"-->
<!--android:textSize="20dp"-->
<!--android:textStyle="bold" />-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<!--<ImageView-->
<!--android:id="@+id/ic_line"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_toStartOf="@+id/text_start"-->
<!--android:src="@drawable/ic_more_vert_black_24dp" />-->
<!--</LinearLayout>-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<!--<ImageView-->
<!--android:id="@+id/ic_stop_circle"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_toStartOf="@+id/text_start"-->
<!--android:src="@drawable/ic_stop_black_24dp" />-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginLeft="15dp"-->
<!--android:orientation="vertical">-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="Your Destination"-->
<!--android:textColor="@color/gray_900"-->
<!--android:textStyle="bold" />-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="Terminal Ubon"-->
<!--android:textColor="@color/gray_600"-->
<!--android:textSize="20dp"-->
<!--android:textStyle="bold" />-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<!--<View-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="1dp"-->
<!--android:background="@color/gray_100" />-->
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="horizontal"-->
<!--android:padding="15dp">-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<!--<RelativeLayout-->
<!--android:layout_width="45dp"-->
<!--android:layout_height="45dp"-->
<!--android:background="@drawable/bus_color_icon_red"-->
<!--android:padding="10dp">-->
<!--<ImageView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:src="@drawable/ic_frontal_bus_silhouette_white" />-->
<!--</RelativeLayout>-->
<!--</LinearLayout>-->
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginLeft="16dp"-->
<!--android:orientation="vertical">-->
<!--<LinearLayout-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="Your Bus"-->
<!--android:textColor="@color/gray_500" />-->
<!--</LinearLayout>-->
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content">-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="สาย ม."-->
<!--android:textColor="@color/gray_900"-->
<!--android:textSize="22dp"-->
<!--android:textStyle="" />-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<!--</LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
......@@ -335,10 +479,10 @@
android:gravity="left|center_vertical"
android:padding="15dp"
android:text="Return"
android:visibility="gone"
android:textColor="@color/white"
android:textSize="20dp"
android:textStyle="bold" />
android:textStyle="bold"
android:visibility="gone" />
<Button
android:id="@+id/btn_endtrip"
......@@ -353,24 +497,24 @@
android:text="End Trip"
android:textColor="@color/gray_500"
android:textSize="20dp"
android:visibility="gone"
android:textStyle="bold" />
android:textStyle="bold"
android:visibility="gone" />
<Button
android:visibility="gone"
android:id="@+id/btn_active_bus"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/bg_btn_activebus"
android:padding="15dp"
android:drawableRight="@drawable/ic_wifi_bus"
android:drawableRight="@drawable/icon_active_clicked"
android:gravity="left|center_vertical"
android:padding="15dp"
android:text="Active Bus"
android:textColor="@color/white"
android:textColor="@drawable/text_active_color"
android:textSize="20dp"
android:textStyle="bold" />
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
......@@ -381,10 +525,10 @@
</LinearLayout>
<!--<FrameLayout-->
<!--android:id="@+id/view_cover"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:foreground="@drawable/shape_window_dim">-->
<!--android:id="@+id/view_cover"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:foreground="@drawable/shape_window_dim">-->
<!--</FrameLayout>-->
......
......@@ -23,6 +23,7 @@
<color name="gray_500">#9E9E9E</color>
<color name="gray_400">#BDBDBD</color>
<color name="gray_600"> #757575</color>
<color name="gray_800">#424242</color>
<color name="gray_900">#212121</color>
......
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