Added the final version of Alex's code.
This commit is contained in:
parent
c57bdef04a
commit
bfcd8177d6
17 changed files with 7 additions and 167 deletions
|
@ -1,36 +0,0 @@
|
|||
package com.example.capstone;
|
||||
|
||||
public class Signal {
|
||||
|
||||
private String power;
|
||||
private String alarm;
|
||||
private String motor;
|
||||
|
||||
public Signal() {
|
||||
}
|
||||
|
||||
public String getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
public void setPower(String power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public String getAlarm() {
|
||||
return alarm;
|
||||
}
|
||||
|
||||
public void setAlarm(String alarm) {
|
||||
this.alarm = alarm;
|
||||
}
|
||||
|
||||
public String getMotor() {
|
||||
return motor;
|
||||
}
|
||||
|
||||
public void setMotor(String motor) {
|
||||
this.motor = motor;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
package com.example.capstone;
|
||||
|
||||
public class User {
|
||||
|
||||
private String Firstname;
|
||||
private String Lastname;
|
||||
private String phone;
|
||||
private String email;
|
||||
|
||||
public User(String fn, String ln, String ph, String em) {
|
||||
Firstname = fn;
|
||||
Lastname = ln;
|
||||
phone = ph;
|
||||
email = em;
|
||||
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return Firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
Firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return Lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
Lastname = lastname;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,7 +31,6 @@ import java.util.ArrayList;
|
|||
|
||||
public class VThiefPictures extends AppCompatActivity {
|
||||
FirebaseAuth fAuth;
|
||||
private ImageView mImageView;
|
||||
private FirebaseStorage storage=FirebaseStorage.getInstance();
|
||||
ImageView img1, img2, img3;
|
||||
DatabaseReference reff;
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package com.example.capstone;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.database.DatabaseReference;
|
||||
|
||||
public class addDriver extends AppCompatDialogFragment {
|
||||
private EditText fn, ln, ph, em;
|
||||
private addDriverListener listener;
|
||||
DatabaseReference reff;
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.add_driver, null);
|
||||
|
||||
builder.setView(view).setTitle("Add Driver").setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
})
|
||||
.setPositiveButton("Add", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String fns = fn.getText().toString();
|
||||
String lns = ln.getText().toString();
|
||||
String phs = ph.getText().toString();
|
||||
String ems = fn.getText().toString();
|
||||
listener.applyTexts(fns, lns, phs, ems);
|
||||
}
|
||||
});
|
||||
|
||||
fn = view.findViewById(R.id.fname);
|
||||
ln = view.findViewById(R.id.lname);
|
||||
ph = view.findViewById(R.id.phone);
|
||||
em = view.findViewById(R.id.email);
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
listener = (addDriverListener) context;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(context.toString()+"must implement addDriverListener");
|
||||
}
|
||||
}
|
||||
|
||||
public interface addDriverListener{
|
||||
void applyTexts(String fn, String ln, String ph, String em);
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,6 @@ public class homepage extends AppCompatActivity {
|
|||
FirebaseAuth fAuth;
|
||||
private Button setting, poweron, alarmoff, apps;
|
||||
DatabaseReference reff;
|
||||
Signal sig;
|
||||
int check = 0;
|
||||
int check2 = 0;
|
||||
private ImageView a, e;
|
||||
|
@ -46,11 +45,9 @@ public class homepage extends AppCompatActivity {
|
|||
e = findViewById(R.id.engine);
|
||||
|
||||
reff = FirebaseDatabase.getInstance().getReference().child("signal");
|
||||
sig = new Signal();
|
||||
sig.setMotor("off");
|
||||
sig.setPower("off");
|
||||
sig.setAlarm("off");
|
||||
reff.child("1").setValue(sig);
|
||||
reff.child("1").child("power").setValue("off");
|
||||
reff.child("1").child("motor").setValue("off");
|
||||
reff.child("1").child("alarm").setValue("off");
|
||||
|
||||
setting.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -71,18 +68,17 @@ public class homepage extends AppCompatActivity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if(check == 0){
|
||||
sig.setPower("on");
|
||||
reff.child("1").child("power").setValue("on");
|
||||
e.setImageResource(R.drawable.ic_power_on);
|
||||
et.setText("ON");
|
||||
check = 1;
|
||||
} else {
|
||||
sig.setPower("off");
|
||||
reff.child("1").child("power").setValue("off");
|
||||
e.setImageResource(R.drawable.ic_power_off);
|
||||
et.setText("OFF");
|
||||
check = 0;
|
||||
|
||||
}
|
||||
reff.child("1").setValue(sig);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -90,18 +86,17 @@ public class homepage extends AppCompatActivity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if(check2 == 0){
|
||||
sig.setAlarm("on");
|
||||
reff.child("1").child("alarm").setValue("on");
|
||||
a.setImageResource(R.drawable.ic_alarm_on);
|
||||
at.setText("ON");
|
||||
check2 = 1;
|
||||
} else {
|
||||
sig.setAlarm("off");
|
||||
reff.child("1").child("alarm").setValue("off");
|
||||
a.setImageResource(R.drawable.ic_alarm_off);
|
||||
at.setText("OFF");
|
||||
check2 = 0;
|
||||
|
||||
}
|
||||
reff.child("1").setValue(sig);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue