mirror of
https://git.wmi.amu.edu.pl/s470664/WRSDv2.git
synced 2024-12-29 11:00:28 +01:00
.
This commit is contained in:
parent
4821b01a71
commit
028848e1dc
67
WRSD2/app/src/main/java/com/example/wrsd/DeviceSettings.java
Normal file
67
WRSD2/app/src/main/java/com/example/wrsd/DeviceSettings.java
Normal 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();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
28
WRSD2/app/src/main/java/com/example/wrsd/Room.java
Normal file
28
WRSD2/app/src/main/java/com/example/wrsd/Room.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
BIN
WRSD2/app/src/main/res/drawable/add.png
Normal file
BIN
WRSD2/app/src/main/res/drawable/add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
WRSD2/app/src/main/res/drawable/kitchentransparent.png
Normal file
BIN
WRSD2/app/src/main/res/drawable/kitchentransparent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
BIN
WRSD2/app/src/main/res/drawable/livngroomtransparent.png
Normal file
BIN
WRSD2/app/src/main/res/drawable/livngroomtransparent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
BIN
WRSD2/app/src/main/res/drawable/settings.png
Normal file
BIN
WRSD2/app/src/main/res/drawable/settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
BIN
WRSD2/app/src/main/res/drawable/toilettransparent.png
Normal file
BIN
WRSD2/app/src/main/res/drawable/toilettransparent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 164 KiB |
BIN
WRSD2/app/src/main/res/font/poppinsblack.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsblack.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/poppinsblackitalian.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsblackitalian.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/poppinsbold.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsbold.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/poppinsbolditalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsbolditalic.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/poppinsextrabold.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsextrabold.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/poppinsextrabolditalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsextrabolditalic.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/poppinsthin.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsthin.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppextralight.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppextralight.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppextralightitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppextralightitalic.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppitalic.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/pplight.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/pplight.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/pplightitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/pplightitalic.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppmedium.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppmedium.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppmediumitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppmediumitalic.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppregular.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppregular.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppsemibold.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppsemibold.ttf
Normal file
Binary file not shown.
BIN
WRSD2/app/src/main/res/font/ppsemibolditalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppsemibolditalic.ttf
Normal file
Binary file not shown.
21
WRSD2/app/src/main/res/layout/activity_device_settings.xml
Normal file
21
WRSD2/app/src/main/res/layout/activity_device_settings.xml
Normal 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>
|
65
WRSD2/app/src/main/res/layout/single_room_row.xml
Normal file
65
WRSD2/app/src/main/res/layout/single_room_row.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user