This commit is contained in:
agata 2023-01-08 15:09:44 +01:00
parent 4821b01a71
commit 028848e1dc
27 changed files with 243 additions and 0 deletions

View File

@ -0,0 +1,67 @@
package com.example.wrsd;
import static com.example.wrsd.RoomActivity_1.setWindowFlag;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.FieldValue;
import com.google.firebase.firestore.FirebaseFirestore;
public class DeviceSettings extends AppCompatActivity {
private Button deleteButton;
private String device, userEmail, room;
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= 19) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
//make fully Android Transparent Status bar
if (Build.VERSION.SDK_INT >= 21) {
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device_settings);
Bundle extras = getIntent().getExtras();
if (extras != null) {
device = extras.getString("device");
userEmail = extras.getString("email");
room = extras.getString("room");
//The key argument here must match that used in the other activity
}
deleteButton = (Button) findViewById(R.id.deleteButton);
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
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));
finish();
}
});
}
}

View File

@ -0,0 +1,28 @@
package com.example.wrsd;
public class Room {
String id;
String name;
public Room(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,62 @@
package com.example.wrsd;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import com.example.wrsd.Room;
import java.util.List;
public class SingleRoomAdapter extends RecyclerView.Adapter<SingleRoomAdapter.MyViewHolder> {
Context context;
private List<Device> roomList;
public SingleRoomAdapter(List<Device> roomList, Context context) {
this.roomList = roomList;
this.context = context;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.single_room_row, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Device d1 = roomList.get(position);
holder.title.setText(d1.getName());
}
@Override
public int getItemCount() {
return roomList.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
public TextView title;
public CardView cardView;
public MyViewHolder(View view) {
super(view);
title = view.findViewById(R.id.title);
cardView = view.findViewById(R.id.card_view);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:background="@drawable/back"
tools:context=".DeviceSettings">
<Button
android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Usuń urządzenie"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.136" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?><!--Smart Home
https://github.com/quintuslabs/SmartHome
Created on 27-OCT-2019.
Created by : Santosh Kumar Dash:- http://santoshdash.epizy.com-->
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:cardElevation="6dp"
app:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp"
android:weightSum="10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/settings" />
<TextView
android:id="@+id/title"
android:layout_width="168dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:clickable="true"
android:onClick="settings"
android:text="text"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold" />
<Switch
android:id="@+id/switch1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:minHeight="48dp"
android:shadowColor="@color/light_blue_600" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>