Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oshadha #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@
</activity>
<activity android:name=".MapActivity" />
<activity android:name=".PassengerMap" />
<activity android:name=".PassengerInterface"/>
<activity android:name=".PassengerInterface" />
<activity android:name=".SignUpActivity" />
<activity android:name=".SignInActivity" />
<activity android:name=".BusInterface" />
<activity android:name=".BusMap"></activity>
<activity android:name=".BusMap" />
<activity
android:name=".availablebuses"
android:label="@string/title_activity_availablebuses"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -39,6 +41,8 @@ public class PassengerInterface extends AppCompatActivity {

private String[] bus_id;

Button newbtn;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -47,8 +51,11 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

Button btn_route_search = (Button) findViewById(R.id.btn_search_route);
Button btn_sign_out = (Button) findViewById(R.id.btn_sign_out);

final TextInputEditText txt_route = (TextInputEditText)findViewById(R.id.txt_route_no);
final Button btn_map = (Button) findViewById(R.id.btn_passenger_Map);


btn_map.setVisibility(View.INVISIBLE);

btn_route_search.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -88,7 +95,8 @@ public void onComplete(@NonNull Task<QuerySnapshot> task) {
TextView textView = new TextView(PassengerInterface.this);
textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
textView.setText(group.get(i));
//textView.setText(group.get(i));
addButton(group.get(i));
textView.setPadding(30, 20, 20, 20);// in pixels (left, top, right, bottom)
routeLayout.addView(textView);

Expand All @@ -97,6 +105,7 @@ public void onComplete(@NonNull Task<QuerySnapshot> task) {

btn_map.setVisibility(View.VISIBLE);


}else{
Toast.makeText(PassengerInterface.this, "Coudn't find a Route No", Toast.LENGTH_SHORT).show();
}
Expand Down Expand Up @@ -129,8 +138,24 @@ public void onClick(View v) {
}
});



}

public void addButton(final String name){
LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout_bus);
newbtn = new Button(this);
newbtn.setText(name);
layout.addView(newbtn);
newbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent bookintent = new Intent(PassengerInterface.this,availablebuses.class);
bookintent.putExtra("parameter", name);
startActivity(bookintent);
}
});
}
private void init(){

if(isServicesOK()){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
package com.example.dilansachintha.googlemaps;

import android.app.Dialog;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.design.widget.TextInputEditText;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Toolbar;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.EventListener;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;

import java.util.List;
import java.util.Map;


public class availablebuses extends AppCompatActivity {

private static final String TAG = "PassengerMap";

private static final int ERROR_DIALOG_REQUEST = 9001;

private static FirebaseFirestore db = FirebaseFirestore.getInstance();

private String[] bus_id;
//private Button reservebtn;
private TextView txtseat;
//Button newbtn;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_availablebuses);

//Button btn_route_search = (Button) findViewById(R.id.search);
//Button btn_sign_out = (Button) findViewById(R.id.btn_sign_out);
//reservebtn = (Button) findViewById(R.id.btnbook);
txtseat = (TextView) findViewById(R.id.seats);
//final TextInputEditText txt_route = (TextInputEditText)findViewById(R.id.txt_route_no);
//final Button btn_map = (Button) findViewById(R.id.btn_passenger_Map);
// reservebtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// db.collection("users").document("")
// }
// });

Intent intent = getIntent();
final String str = intent.getStringExtra("parameter");

//final String route = txt_route.getText().toString();

db.collection("driver").get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
Log.d(TAG, document.getId() + " => " + document.getData());

//Toast.makeText(PassengerMap.this, document.getId(), Toast.LENGTH_SHORT).show();

Map<String,Object> data = document.getData();
//System.out.println(data.containsKey("Bus")+"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

List<String> group = (List<String>) data.get(str);
Toast.makeText(availablebuses.this, "Found the Route No", Toast.LENGTH_SHORT).show();

Toast.makeText(availablebuses.this, group.get(0), Toast.LENGTH_SHORT).show();

LinearLayout routeLayout = (LinearLayout) findViewById(R.id.linear_layout_bus);

bus_id = new String[group.size()];
int j = 0;
for(int i=0; i< group.size()-1;i++){
TextView textView = new TextView(availablebuses.this);
textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
textView.setText(group.get(i));
//addButton(group.get(i));
textView.setPadding(30, 20, 20, 20);// in pixels (left, top, right, bottom)
routeLayout.addView(textView);
j=i;
bus_id[i] =(String) group.get(i);
}

txtseat.setText("Remaining Seats : " + group.get(j+1));
// if(document.getId().equals(route)){
//
// //btn_map.setVisibility(View.VISIBLE);
//
//
// }else{
// Toast.makeText(availablebuses.this, "Coudn't find a Route No", Toast.LENGTH_SHORT).show();
// }

}
} else {
Log.w(TAG, "Error getting documents.", task.getException());
}
}
});
//btn_map.setVisibility(View.INVISIBLE);
// reservebtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
//
// txtseat.setText("Remaining Seats : ");
// }
// });
// btn_route_search.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
//
//
//// if(route == ""){
//// Toast.makeText(availablebuses.this, "Enter a Route No", Toast.LENGTH_SHORT).show();
//// }else {
////
//// }
//
//
// }
// });

// btn_sign_out.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// FirebaseAuth.getInstance().signOut();
// Intent intent = new Intent(availablebuses.this,MainActivity.class);
// startActivity(intent);
// }
// });
//
// btn_map.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// init();
// }
// });



}

// public void addButton(final String name){
// LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout_bus);
// newbtn = new Button(this);
// newbtn.setText(name);
// layout.addView(newbtn);
// newbtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Intent bookintent = new Intent(PassengerInterface.this,availablebuses.class);
// bookintent.putExtra("parameter", name);
// startActivity(bookintent);
// }
// });
// }


private void init(){

if(isServicesOK()){
Intent intent = new Intent(availablebuses.this, PassengerMap.class);
intent.putExtra("bus_id", bus_id);
startActivity(intent);
}else{

}
}

public boolean isServicesOK(){
Log.d(TAG,"isServicesOK: checking google services version");
int availability = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(availablebuses.this);
if(availability == ConnectionResult.SUCCESS){
Log.d(TAG,"isServicesOK: Google Play Services is working");
Toast.makeText(availablebuses.this,"Google Play Services are working",Toast.LENGTH_SHORT).show();
return true;
}else if(GoogleApiAvailability.getInstance().isUserResolvableError(availability)){
Log.d(TAG, "isServicesOK: an error occured but we can fix it");
Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(availablebuses.this,availability,ERROR_DIALOG_REQUEST);
dialog.show();
}else{
Toast.makeText(this, "You can't make map requests", Toast.LENGTH_SHORT).show();
}
return false;
}

}
Binary file added app/src/main/res/drawable/mario.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/soap.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions app/src/main/res/layout/activity_availablebuses.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".availablebuses">


<LinearLayout
android:id="@+id/linear_layout_bus"
android:layout_width="324dp"
android:layout_height="230dp"
android:layout_marginStart="40dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="76dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/btn_passenger_Map"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

</LinearLayout>

<Button
android:id="@+id/btnbook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="125dp"
android:layout_marginLeft="125dp"
android:layout_marginTop="161dp"
android:layout_marginEnd="125dp"
android:layout_marginRight="125dp"
android:layout_marginBottom="52dp"
android:text="Reserve a seat"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear_layout_bus" />

<TextView
android:id="@+id/seats"
android:layout_width="320dp"
android:layout_height="48dp"
android:layout_marginStart="40dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="57dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="56dp"
android:text="TextView"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
app:layout_constraintBottom_toTopOf="@+id/btnbook"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear_layout_bus" />

</android.support.constraint.ConstraintLayout>
Loading