FeatureDevicesTypes #2

Open
s470659 wants to merge 3 commits from FeatureDevicesTypes into featureLoger
21 changed files with 615 additions and 115 deletions

View File

@ -2,13 +2,21 @@ package com.example.wrsd;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import java.util.List;
public class AddDeviceActivity extends AppCompatActivity {
static String[] deviceTypes = new String[]{"Rolety", "Oświetlenie", "Ogrzewanie"};
Spinner deviceTypeDropdown;
EditText editTextTextName;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -16,6 +24,12 @@ public class AddDeviceActivity extends AppCompatActivity {
setContentView(R.layout.activity_add_device);
editTextTextName = (EditText) findViewById(R.id.editTextTextName);
deviceTypeDropdown = (Spinner) findViewById(R.id.deviceTypeDropdown);
ArrayAdapter<String> adapter = new ArrayAdapter<>(AddDeviceActivity.this, android.R.layout.simple_spinner_item, deviceTypes);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
deviceTypeDropdown.setAdapter(adapter);
}
@ -30,8 +44,22 @@ public class AddDeviceActivity extends AppCompatActivity {
public void DeviceName(View view){
String editTextName = editTextTextName.getText().toString().trim();
if (editTextName.isEmpty()) {
editTextTextName.setError("Podaj nazwę");
editTextTextName.requestFocus();
return;
}
if (editTextTextName.getText().toString().contains(" ")){
editTextTextName.setError("Nazwa nie może zawierać spacji");
editTextTextName.requestFocus();
return;
}
String deviceType = deviceTypeDropdown.getSelectedItem().toString();
Intent intent = new Intent();
intent.putExtra("name", editTextName);
intent.putExtra("type", deviceType);
setResult(RESULT_OK, intent);
finish();
}

View File

@ -0,0 +1,25 @@
package com.example.wrsd;
public class BlindsDevice extends Device{
public boolean state;
public BlindsDevice(String id, String name) {
super(id, name, DeviceType.BLINDS);
state = false;
}
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
@Override
public String toString() {
String stateString = state? "1" : "0";
return deviceType.toString() + name + "?" + stateString;
}
}

View File

@ -0,0 +1,37 @@
package com.example.wrsd;
public class BulbDevice extends Device{
public boolean state;
public int brightness;
public BulbDevice(String id, String name) {
super(id, name, DeviceType.BULB);
this.state = false;
this.brightness = 000;
}
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
public int getBrightness() {
return brightness;
}
public void setBrightness(int brightness) {
this.brightness = brightness;
}
@Override
public String toString() {
String stateString = state? "1" : "0";
String brightnessString = Integer.toString(brightness);
return deviceType.toString() + name + "?" + stateString + "?" + brightnessString;
}
}

View File

@ -4,10 +4,12 @@ public class Device {
String id;
String name;
DeviceType deviceType;
public Device(String id, String name) {
public Device(String id, String name, DeviceType deviceType) {
this.id = id;
this.name = name;
this.deviceType = deviceType;
}
public String getId() {
@ -25,4 +27,9 @@ public class Device {
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return deviceType.toString() + id;
}
}

View File

@ -4,7 +4,11 @@ import static com.example.wrsd.RoomActivity_1.setWindowFlag;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
@ -12,6 +16,9 @@ import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
@ -24,7 +31,12 @@ import com.google.firebase.firestore.FirebaseFirestore;
public class DeviceSettings extends AppCompatActivity {
private Button deleteButton;
private String device, userEmail, room;
private TextView progressLabel, roomText;
private Switch stateSwitch;
private SeekBar progressBar;
private String device, userEmail, type, room, code, state;
private Integer techNotification = 0;
private String onOff, tempTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -39,29 +51,223 @@ public class DeviceSettings extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device_settings);
progressLabel = (TextView) findViewById(R.id.progressLabel);
stateSwitch = (Switch) findViewById(R.id.state);
progressBar = (SeekBar) findViewById(R.id.progress);
roomText = (TextView) findViewById(R.id.textView4);
stateSwitch.setChecked(true);
progressLabel.setVisibility(View.INVISIBLE);
stateSwitch.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.INVISIBLE);
Bundle extras = getIntent().getExtras();
if (extras != null) {
device = extras.getString("device");
userEmail = extras.getString("email");
room = extras.getString("room");
type = extras.getString("type");
code = extras.getString("code");
// state = extras.getString("state");
roomText.setText(room);
//The key argument here must match that used in the other activity
}
// if(state.equals("1")){
// stateSwitch.setChecked(true);
// }else{
// stateSwitch.setChecked(false);
// }
deleteButton = (Button) findViewById(R.id.deleteButton);
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
stateSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked==true){
onOff = "włączone";
}else{
onOff = "wyłączone";
}
}
});
if (type.equals("Blinds")) {
if(onOff == "włączone"){
stateSwitch.setText("Opuść rolety");
}else{
stateSwitch.setText("Podnieś rolety");
}
stateSwitch.setVisibility(View.VISIBLE);
} else if (type.equals("Bulb")) {
if(onOff == "włączone"){
stateSwitch.setText("Wyłącz oświetlenie");
}else{
stateSwitch.setText("Włącz oświetlenie");
}
progressLabel.setText("Jasność");
tempTextView = "Jasność";
stateSwitch.setVisibility(View.VISIBLE);
progressLabel.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
} else if (type.equals("Heater")) {
if(onOff == "włączone"){
stateSwitch.setText("Wyłącz ogrzewanie");
}else{
stateSwitch.setText("Włącz ogrzewanie");
}
tempTextView = "Temperatura";
progressLabel.setText("Temperatura");
stateSwitch.setVisibility(View.VISIBLE);
progressLabel.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
}
deleteButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
DocumentReference docRef = rootRef.collection("users").document(userEmail).collection("rooms").document(room);
docRef.update("Urzadzenia", FieldValue.arrayRemove(device));
docRef.update("Urzadzenia", FieldValue.arrayRemove(code));
Toast.makeText(getApplicationContext(), "Usunięto " + device, Toast.LENGTH_LONG).show();
Intent intent = new Intent();
intent.putExtra("name", "!");
intent.putExtra("type", "!");
setResult(RESULT_OK, intent);
finish();
}
});
progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
int progress = progressBar.getProgress();
boolean started = false; //use this variable to see whether the user clicked the right place
@Override
public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
if(!started){ //check to see if user clicks the right place
//if the user clicks within a specific threshold
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel("Moje powiadomienie", "Moje powiadomienie", NotificationManager.IMPORTANCE_DEFAULT );
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), "Moje powiadomienie");
builder.setContentTitle("WRSD Home");
builder.setContentText(tempTextView + " w urządzeniu " + device + " w pokoju " + room + " została zmieniona.");
builder.setStyle( new
NotificationCompat.BigTextStyle().bigText(tempTextView + " w urządzeniu " + device + " w pokoju: " + room + " została zmieniona."));
builder.setSmallIcon(R.drawable.wrsdlogo);
builder.setAutoCancel(false);
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(getApplicationContext());
managerCompat.notify(techNotification,builder.build());
techNotification++;
}
if(started) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel("Moje powiadomienie", "Moje powiadomienie", NotificationManager.IMPORTANCE_DEFAULT );
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), "Moje powiadomienie");
builder.setContentTitle("WRSD Home");
builder.setContentText(tempTextView + " w urządzeniu " + device + " w pokoju: " + room + " została zmieniona.");
builder.setStyle( new
NotificationCompat.BigTextStyle().bigText(tempTextView + " w urządzeniu " + device + " w pokoju: " + room + " została zmieniona."));
builder.setSmallIcon(R.drawable.wrsdlogo);
builder.setAutoCancel(false);
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(getApplicationContext());
managerCompat.notify(techNotification,builder.build());
techNotification++;
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
System.out.println("onStartTracking:" + progress + "/" + seekBar.getMax());
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
System.out.println("onStopTracking:" + progress + "/" + seekBar.getMax());
//DO WHATEVER YOU NEED TO DO WHEN PROGRESS IS DONE CHANGING
started = false; //remember to set variable to false
}
});
}
public void Notification(View view){
if (type.equals("Bulb")) {
if (onOff == "włączone") {
stateSwitch.setText("Wyłącz oświetlenie");
} else {
stateSwitch.setText("Włącz oświetlenie");
}
}else if (type.equals("Heater")) {
if (onOff == "włączone") {
stateSwitch.setText("Wyłącz ogrzewanie");
} else {
stateSwitch.setText("Włącz ogrzewanie");
}
}else if (type.equals("Blinds")) {
if (onOff == "włączone") {
stateSwitch.setText("Opuść rolety");
} else {
stateSwitch.setText("Podnieś rolety");
}
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel("Moje powiadomienie", "Moje powiadomienie", NotificationManager.IMPORTANCE_DEFAULT );
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), "Moje powiadomienie");
builder.setContentTitle("WRSD Home");
builder.setContentText("Urządzenie: " + device + " w pokoju: " + room + " zostało " + onOff);
builder.setStyle( new
NotificationCompat.BigTextStyle().bigText("Urządzenie: " + device + " w pokoju: " + room + " zostało " + onOff));
builder.setSmallIcon(R.drawable.wrsdlogo);
builder.setAutoCancel(false);
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(getApplicationContext());
managerCompat.notify(techNotification,builder.build());
techNotification++;
}
public void GetSeekBarValue(){
}
}

View File

@ -0,0 +1,18 @@
package com.example.wrsd;
public enum DeviceType {
BLINDS("b"),
BULB("l"),
HEATER("h");
private String shortCut;
DeviceType(String shortcut) {
this.shortCut = shortcut;
}
@Override
public String toString() {
return this.shortCut;
}
}

View File

@ -0,0 +1,37 @@
package com.example.wrsd;
public class HeaterDevice extends Device {
public boolean state;
public int temperature;
public HeaterDevice(String id, String name) {
super(id, name, DeviceType.HEATER);
this.state = false;
this.temperature = 000;
}
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
public int getTemperature() {
return temperature;
}
public void setTemperature(int temperature) {
this.temperature = temperature;
}
@Override
public String toString() {
String stateString = state? "1" : "0";
String temperatureString = Integer.toString(temperature);
return deviceType.toString() + name + "?" + stateString + "?" + temperatureString;
}
}

View File

@ -28,8 +28,14 @@ import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.firestore.FirebaseFirestore;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import kotlin.text.Typography;
@ -116,6 +122,7 @@ public class RegisterUser extends AppCompatActivity{
mAuth.createUserWithEmailAndPassword(email, password).addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
Rooms();
Toast.makeText(getApplicationContext(), "Użytkownik zarejestrowany", Toast.LENGTH_LONG).show();
Login();
@ -128,7 +135,25 @@ public class RegisterUser extends AppCompatActivity{
}
});
}
public void Rooms() {
String email = editTextEmail.getText().toString().trim();
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
Map<String, Object> room = new HashMap<>();
List<String> rooms = new ArrayList<>();
rooms.add("Salon");
rooms.add("Sypialnia");
rooms.add("Kuchnia");
rooms.add("Lazienka");
rooms.add("Toaleta");
Map<String, Object> docData = new HashMap<>();
docData.put("Urzadzenia", Arrays.asList());
for (String r1 : rooms) {
rootRef.collection("users").document(email).collection("rooms").document(r1).set(docData);
}
}
public void Login() {
Intent intent = new Intent(this, LoginActivity.class);

View File

@ -11,34 +11,23 @@ import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Adapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.example.wrsd.databinding.ActivityDeviceSettingsBinding;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FieldValue;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@ -50,12 +39,12 @@ public class RoomActivity_1 extends AppCompatActivity {
public List<String> temp = new ArrayList<>();
private RecyclerView recyclerView;
private SingleRoomAdapter mAdapter;
private String userEmail;
Integer roomIndex;
public String roomvalue;
private String userEmail, code;
public String roomvalue, deviceState;
private TextView roomName1;
public Integer la;
TextView myTextView;
private TextView deviceName;
ImageView ivDevice;
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
@ -102,6 +91,7 @@ public class RoomActivity_1 extends AppCompatActivity {
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(mAdapter);
roomName1 = (TextView) findViewById(R.id.textView);
roomName1.setText(roomvalue);
@ -113,6 +103,7 @@ public class RoomActivity_1 extends AppCompatActivity {
private void getData() {
deviceFromBase.clear();
deviceList.clear();
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
rootRef.collection("users").document(userEmail).collection("rooms").document(roomvalue)
@ -121,30 +112,21 @@ public class RoomActivity_1 extends AppCompatActivity {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (documentSnapshot!=null) {
temp.add(documentSnapshot.getData().toString());
if(!temp.get(0).equals("{Urzadzenia=[]}")) {
Map<String, Object> data = documentSnapshot.getData();
if (data != null) {
temp.add(data.toString());
if (!temp.get(0).equals("{Urzadzenia=[]}")) {
String[] parts = temp.get(0).split(Pattern.quote("["));
String[] p2 = parts[1].split(Pattern.quote("]"));
String[] devices = p2[0].split("(,)|(\\s+)");
for (Integer i = 0; i < devices.length; i = i + 2) {
deviceFromBase.add(devices[i]);
}
Device d1;
Integer j = 0;
for (String d : deviceFromBase) {
String jStr = Integer.toString(j);
d1 = new Device(jStr, d);
deviceList.add(d1);
}
decodeDevices(devices);
mAdapter.notifyDataSetChanged();
}
else{
} else {
Toast.makeText(getApplicationContext(), "Brak urządzeń w pokoju", Toast.LENGTH_LONG).show();
}
}
} else {
Toast.makeText(getApplicationContext(), "Brak urządzeń w pokoju", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Błąd", Toast.LENGTH_LONG).show();
}
}
}).addOnFailureListener(new OnFailureListener() {
@ -157,9 +139,36 @@ public class RoomActivity_1 extends AppCompatActivity {
});
}
private void decodeDevices(String[] devicesNames) {
for (String deviceName : devicesNames) {
decodeDevice(deviceName);
}
}
private void decodeDevice(String encodedDevice) {
if (encodedDevice.equals("")) {
return;
}
String[] parts = encodedDevice.split("\\?");
String deviceType = parts[0].substring(0,1);
String deviceName = parts[0].substring(1);
deviceState = parts[1];
String deviceId = getLastUsedId();
if (deviceType.equals(DeviceType.BLINDS.toString())) {
deviceList.add(new BlindsDevice(deviceId, deviceName));
} else if (deviceType.equals(DeviceType.BULB.toString())) {
deviceList.add(new BulbDevice(deviceId, deviceName));
} else if (deviceType.equals(DeviceType.HEATER.toString())) {
deviceList.add(new HeaterDevice(deviceId, deviceName));
}
}
private String getLastUsedId() {
String lastIdString = deviceList.isEmpty()? "0" : deviceList.get(deviceList.size() - 1).id;
int incrementedId = Integer.parseInt(lastIdString) + 1;
return Integer.toString(incrementedId);
}
// CollectionReference usersCol = rootRef.collection("users");
// Query query = usersCol.whereEqualTo("email", userEmail).whereEqualTo("rooms", roomvalue);
@ -183,59 +192,59 @@ public class RoomActivity_1 extends AppCompatActivity {
// }
// private void prepareRoomData() {
// getData();
//
// Device d1;
// Integer j = 0;
//
// for(String d: deviceFromBase){
// String jStr = Integer.toString(j);
// d1 = new Device(jStr, d);
// deviceList.add(d1);
// }
// d1 = new Device("1", "Oświetlenie");
// deviceList.add(d1);
// d1 = new Device("2", "Głośniki");
// deviceList.add(d1);
// d1 = new Device("3", "Rolety");
// deviceList.add(d1);
// d1 = new Device("4", "Ogrzewanie");
// deviceList.add(d1);
// d1 = new Device("5", "Odkurzacz");
// deviceList.add(d1);
// mAdapter.notifyDataSetChanged();
// public void onBackClicked(View view) {
// startActivity(new Intent(getApplicationContext(), MainActivity.class));
// finish();
// }
public void onBackClicked(View view) {
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
}
public void addDevice(View view){
Intent i = new Intent(this, AddDeviceActivity.class);
startActivityForResult(i, 1);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1) {
if(resultCode == RESULT_OK) {
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
String strEditText = data.getStringExtra("name");
Device d1 = new Device("6", strEditText);
deviceList.add(d1);
String deviceType = data.getStringExtra("type");
if(!deviceType.equals("!")){
Device newDevice;
String deviceId = getLastUsedId();
if (deviceType.equals("Rolety")) {
newDevice = new BlindsDevice(deviceId, strEditText);
} else if (deviceType.equals("Oświetlenie")) {
newDevice = new BulbDevice(deviceId, strEditText);
} else if (deviceType.equals("Ogrzewanie")) {
newDevice = new HeaterDevice(deviceId, strEditText);
} else {
newDevice = new BlindsDevice(deviceId, strEditText);
}
deviceList.add(newDevice);
mAdapter.notifyDataSetChanged();
DocumentReference docRef = rootRef.collection("users").document(userEmail).collection("rooms").document(roomvalue);
docRef.update("Urzadzenia", FieldValue.arrayUnion(newDevice.toString()));
Toast.makeText(getApplicationContext(), "Dodano " + strEditText, Toast.LENGTH_LONG).show();
}else{
for(int j=0; j<deviceList.size();j++) {
if (deviceList.get(j).toString().equals(code)) {
deviceList.remove(j);
mAdapter.notifyDataSetChanged();
break;
}
}
mAdapter.notifyDataSetChanged();
}
mAdapter.notifyDataSetChanged();
DocumentReference docRef = rootRef.collection("users").document(userEmail).collection("rooms").document(roomvalue);
docRef.update("Urzadzenia", FieldValue.arrayUnion(strEditText));
}
}
@ -243,15 +252,31 @@ public class RoomActivity_1 extends AppCompatActivity {
public void settings(View view){
TextView b = (TextView) view;
String dn = b.getText().toString();
String type = "";
code = "";
for (Device device : deviceList) {
if (device.name.equals(dn)) {
code = device.toString();
if (device.deviceType == DeviceType.BLINDS) {
type = "Blinds";
} else if (device.deviceType == DeviceType.BULB) {
type = "Bulb";
} else if (device.deviceType == DeviceType.HEATER) {
type = "Heater";
}
}
}
Intent intent = new Intent(this, DeviceSettings.class);
intent.putExtra("device", dn);
intent.putExtra("email", userEmail);
intent.putExtra("room", roomvalue);
startActivity(intent);
finish();
intent.putExtra("type", type);
intent.putExtra("code", code);
// intent.putExtra("state", deviceState);
startActivityForResult(intent, 1);
}
}

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
@ -26,6 +27,8 @@ public class SingleRoomAdapter extends RecyclerView.Adapter<SingleRoomAdapter.My
this.context = context;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
@ -40,6 +43,18 @@ public class SingleRoomAdapter extends RecyclerView.Adapter<SingleRoomAdapter.My
holder.title.setText(d1.getName());
if (d1.deviceType == DeviceType.BLINDS) {
holder.imageView.setBackgroundResource(R.drawable.rolety);
} else if (d1.deviceType == DeviceType.BULB) {
holder.imageView.setBackgroundResource(R.drawable.light);
} else if (d1.deviceType == DeviceType.HEATER) {
holder.imageView.setBackgroundResource(R.drawable.heater);
}
}
@ -51,11 +66,13 @@ public class SingleRoomAdapter extends RecyclerView.Adapter<SingleRoomAdapter.My
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView title;
public CardView cardView;
public ImageView imageView;
public MyViewHolder(View view) {
super(view);
title = view.findViewById(R.id.title);
cardView = view.findViewById(R.id.card_view);
imageView = view.findViewById(R.id.deviceView);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 KiB

View File

@ -5,6 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back"
android:backgroundTint="#007FFE"
tools:context=".AddDeviceActivity">
@ -18,39 +19,65 @@
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.129"
app:layout_constraintHorizontal_bias="0.233"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.311" />
app:layout_constraintVertical_bias="0.439" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="38dp"
android:layout_marginEnd="210dp"
android:layout_marginBottom="86dp"
android:gravity="center"
android:text="Dodajesz nowe urządzenie"
android:textSize="30dp"
app:layout_constraintBottom_toTopOf="@+id/editTextTextName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.046"
app:layout_constraintHorizontal_bias="0.49"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.775" />
app:layout_constraintVertical_bias="0.176" />
<Spinner
android:id="@+id/deviceTypeDropdown"
android:layout_width="299dp"
android:layout_height="48dp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/editTextTextName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.491"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.725"
tools:ignore="SpeakableTextPresentCheck" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dodaj"
android:clickable="true"
android:onClick="DeviceName"
android:text="Dodaj"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.863"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.919" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="55dp"
android:layout_marginEnd="323dp"
android:layout_marginBottom="31dp"
android:text="Wybierz typ urządzenia"
app:layout_constraintBottom_toTopOf="@+id/deviceTypeDropdown"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.4" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -14,8 +14,61 @@
android:text="Usuń urządzenie"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintHorizontal_bias="0.852"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.136" />
app:layout_constraintTop_toBottomOf="@+id/progress"
app:layout_constraintVertical_bias="0.93" />
<SeekBar
android:id="@+id/progress"
android:layout_width="228dp"
android:layout_height="70dp"
android:layout_marginTop="40dp"
android:clickable="true"
android:onClick="Notification"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressLabel" />
<TextView
android:id="@+id/progressLabel"
android:layout_width="281dp"
android:layout_height="59dp"
android:layout_marginTop="76dp"
android:text="TextView"
android:textSize="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.138"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/state" />
<Switch
android:id="@+id/state"
android:layout_width="254dp"
android:layout_height="71dp"
android:layout_marginTop="152dp"
android:clickable="true"
android:onClick="Notification"
android:text="Switch"
android:textSize="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.273"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView4"
android:layout_width="213dp"
android:layout_height="60dp"
android:layout_marginStart="51dp"
android:layout_marginTop="28dp"
android:layout_marginEnd="147dp"
android:layout_marginBottom="24dp"
android:text="TextView"
android:textSize="30dp"
app:layout_constraintBottom_toTopOf="@+id/state"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -5,7 +5,7 @@
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#007FFD"
android:background="#0581FE"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
@ -16,7 +16,7 @@
android:id="@+id/username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="328dp"
android:layout_marginTop="316dp"
android:hint="@string/prompt_login"
android:inputType="textEmailAddress"
android:minHeight="48dp"
@ -78,7 +78,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.239"
app:layout_constraintVertical_bias="0.187"
app:srcCompat="@drawable/wrsdlogo" />
<TextView

View File

@ -14,7 +14,7 @@
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginTop="40dp"
app:srcCompat="@drawable/wrsdlogo" />
<HorizontalScrollView
@ -221,14 +221,14 @@
</HorizontalScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="10dp"
android:layout_marginTop="130dp"
app:srcCompat="@drawable/add" />
<!-- <com.google.android.material.floatingactionbutton.FloatingActionButton-->
<!-- android:id="@+id/fab"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_gravity="bottom|end"-->
<!-- android:layout_marginEnd="10dp"-->
<!-- android:layout_marginTop="130dp"-->
<!-- app:srcCompat="@drawable/add" />-->
</LinearLayout>

View File

@ -72,6 +72,7 @@
android:layout_width="250dp"
android:layout_height="60dp"
android:hint="Hasło"
android:imeActionLabel="@string/action_sign_in_short"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -32,6 +32,7 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/deviceView"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/settings" />
@ -55,7 +56,7 @@
android:layout_marginRight="10dp"
android:layout_weight="1"
android:minHeight="48dp"
android:shadowColor="@color/light_blue_600" />
android:outlineAmbientShadowColor="@color/light_blue_600"/>
</LinearLayout>
</LinearLayout>

View File

@ -10,7 +10,8 @@
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<item name="android:statusBarColor">@color/background_color</item>
<item name="android:navigationBarColor">@color/background_color</item>
<!-- Customize your theme here. -->
</style>

View File

@ -12,4 +12,5 @@
<color name="light_blue_A200">#FF40C4FF</color>
<color name="light_blue_A400">#FF00B0FF</color>
<color name="black_overlay">#66000000</color>
<color name="background_color">#FF007FFE</color>
</resources>

View File

@ -10,7 +10,8 @@
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<item name="android:statusBarColor">@color/background_color</item>
<item name="android:navigationBarColor">@color/background_color</item>
<!-- Customize your theme here. -->
</style>

View File

@ -1,10 +0,0 @@
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C\:\\Users\\Acer\\AppData\\Local\\Android\\Sdk