Compare commits
3 Commits
master
...
featureLog
Author | SHA1 | Date | |
---|---|---|---|
|
028848e1dc | ||
|
4821b01a71 | ||
|
8e55375c32 |
@ -1 +0,0 @@
|
||||
Print("Hello World")
|
15
WRSD2/.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
3
WRSD2/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
1
WRSD2/.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
WRSD
|
6
WRSD2/.idea/compiler.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
16
WRSD2/.idea/deploymentTargetDropDown.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetsSelectedWithDialog>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\Acer\.android\avd\Pixel_3a_API_33_x86_64.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetsSelectedWithDialog>
|
||||
</component>
|
||||
</project>
|
19
WRSD2/.idea/gradle.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
10
WRSD2/.idea/misc.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
6
WRSD2/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
1
WRSD2/app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
59
WRSD2/app/build.gradle
Normal file
@ -0,0 +1,59 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'com.google.gms.google-services'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.example.wrsd'
|
||||
compileSdk 32
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.wrsd"
|
||||
minSdk 21
|
||||
targetSdk 32
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-ui:2.4.1'
|
||||
implementation 'com.google.firebase:firebase-database:20.1.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
implementation platform('com.google.firebase:firebase-bom:31.1.0')
|
||||
implementation 'com.google.firebase:firebase-analytics'
|
||||
implementation 'com.google.firebase:firebase-auth'
|
||||
implementation 'com.google.firebase:firebase-firestore'
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation 'de.hdodenhof:circleimageview:3.1.0'
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
40
WRSD2/app/google-services.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "364206717870",
|
||||
"firebase_url": "https://wrsd-fabbb-default-rtdb.firebaseio.com",
|
||||
"project_id": "wrsd-fabbb",
|
||||
"storage_bucket": "wrsd-fabbb.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:364206717870:android:0f08fe100fcadbc1f9e63f",
|
||||
"android_client_info": {
|
||||
"package_name": "com.example.wrsd"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "364206717870-61ec89v3jg1aro8k8j2ihk99ep1gkkan.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyA9wUpzMLm7YGR_eyfwe3PRc4kC1n2DQM8"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "364206717870-61ec89v3jg1aro8k8j2ihk99ep1gkkan.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
21
WRSD2/app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,26 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.example.wrsd", appContext.getPackageName());
|
||||
}
|
||||
}
|
77
WRSD2/app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@drawable/wrsdlogo"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.WRSD"
|
||||
tools:targetApi="31" >
|
||||
<activity
|
||||
android:name=".DeviceSettings"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.WRSD.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".RoomActivity_1"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.WRSD.NoActionBar" >
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".AddDeviceActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.WRSD.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity2"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.WRSD.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".RegisterUser"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.WRSD.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/Theme.WRSD.NoActionBar" >
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.login.LoginActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.WRSD.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,38 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class AddDeviceActivity extends AppCompatActivity {
|
||||
|
||||
EditText editTextTextName;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add_device);
|
||||
|
||||
editTextTextName = (EditText) findViewById(R.id.editTextTextName);
|
||||
}
|
||||
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 1) {
|
||||
if(resultCode == RESULT_OK) {
|
||||
String strEditText = data.getStringExtra("editTextValue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DeviceName(View view){
|
||||
String editTextName = editTextTextName.getText().toString().trim();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("name", editTextName);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
28
WRSD2/app/src/main/java/com/example/wrsd/Device.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
public class Device {
|
||||
|
||||
String id;
|
||||
String name;
|
||||
|
||||
public Device(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;
|
||||
}
|
||||
}
|
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();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
44
WRSD2/app/src/main/java/com/example/wrsd/MainActivity.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
import com.example.wrsd.databinding.ActivityMainBinding;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private AppBarConfiguration appBarConfiguration;
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
|
||||
appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
|
||||
return NavigationUI.navigateUp(navController, appBarConfiguration)
|
||||
|| super.onSupportNavigateUp();
|
||||
}
|
||||
}
|
164
WRSD2/app/src/main/java/com/example/wrsd/MainActivity2.java
Normal file
@ -0,0 +1,164 @@
|
||||
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.media.Image;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.wrsd.ui.login.LoginActivity;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
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.auth.FirebaseAuth;
|
||||
import com.google.firebase.firestore.CollectionReference;
|
||||
import com.google.firebase.firestore.DocumentReference;
|
||||
import com.google.firebase.firestore.DocumentSnapshot;
|
||||
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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MainActivity2 extends AppCompatActivity {
|
||||
|
||||
FirebaseAuth mAuth;
|
||||
FirebaseFirestore firestore;
|
||||
public String userEmail;
|
||||
@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_main2);
|
||||
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
|
||||
userEmail = extras.getString("key");
|
||||
Toast.makeText(getApplicationContext(), "Cześć " + userEmail, Toast.LENGTH_LONG).show();
|
||||
//The key argument here must match that used in the other activity
|
||||
}
|
||||
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
firestore = FirebaseFirestore.getInstance();
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
|
||||
// DocumentReference docIdRef = rootRef.collection("users").document("FJQULeLWxEMLsAleYBkl");
|
||||
// docIdRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
|
||||
// @Override
|
||||
// public void onComplete(@NonNull Task<DocumentSnapshot> task) {
|
||||
// if (task.isSuccessful()) {
|
||||
// DocumentSnapshot document = task.getResult();
|
||||
// if (document.exists()) {
|
||||
// Toast.makeText(getApplicationContext(), "exist", Toast.LENGTH_LONG).show();
|
||||
// } else {
|
||||
// Toast.makeText(getApplicationContext(), "not", Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
// } else {
|
||||
// Toast.makeText(getApplicationContext(), "failure", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
// FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
|
||||
// CollectionReference yourCollRef = rootRef.collection("users");
|
||||
// Query query = yourCollRef.whereEqualTo("email", userEmail);
|
||||
//
|
||||
// yourCollRef.document(userEmail).collection("rooms")
|
||||
// .document().set(rooms)
|
||||
// .addOnSuccessListener(new OnSuccessListener<Void>() {
|
||||
// @Override
|
||||
// public void onSuccess(Void aVoid) {
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// firestore.collection("users").add(users).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
|
||||
// @Override
|
||||
// public void onSuccess(DocumentReference documentReference) {
|
||||
// Toast.makeText(getApplicationContext(), "success firestore", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// }
|
||||
// }).addOnFailureListener(new OnFailureListener() {
|
||||
// @Override
|
||||
// public void onFailure(@NonNull Exception e) {
|
||||
// Toast.makeText(getApplicationContext(), "Błąd zapisu danych! Spróbuj ponownie", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// query.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
|
||||
// @Override
|
||||
// public void onComplete(@NonNull Task<QuerySnapshot> task) {
|
||||
// if (task.isSuccessful()) {
|
||||
// if (task.getResult().isEmpty()) {
|
||||
// Toast.makeText(getApplicationContext(), "not exist", Toast.LENGTH_LONG).show();
|
||||
// firestore.collection("users").add(users).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
|
||||
// @Override
|
||||
// public void onSuccess(DocumentReference documentReference) {
|
||||
// Toast.makeText(getApplicationContext(), "succes firestore", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// }
|
||||
// }).addOnFailureListener(new OnFailureListener() {
|
||||
// @Override
|
||||
// public void onFailure(@NonNull Exception e) {
|
||||
// Toast.makeText(getApplicationContext(), "Błąd zapisu danych! Spróbuj ponownie", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// else {
|
||||
// Toast.makeText(getApplicationContext(), "exist", Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
// } else {
|
||||
// Toast.makeText(getApplicationContext(), "Błąd pobrania danych! Spróbuj ponownie", Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
public void RoomActivity(View v){
|
||||
|
||||
// ImageView b = (ImageView) v;
|
||||
// String imageText = b.getContentDescription().toString();
|
||||
CharSequence description = v.getContentDescription();
|
||||
String roomText = String.valueOf(description);
|
||||
Intent intent = new Intent(this, RoomActivity_1.class);
|
||||
intent.putExtra("room", roomText);
|
||||
intent.putExtra("email", userEmail);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
138
WRSD2/app/src/main/java/com/example/wrsd/RegisterUser.java
Normal file
@ -0,0 +1,138 @@
|
||||
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.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.wrsd.ui.login.LoginActivity;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
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.FirebaseOptions;
|
||||
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 java.io.FileInputStream;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import kotlin.text.Typography;
|
||||
|
||||
public class RegisterUser extends AppCompatActivity{
|
||||
|
||||
private FirebaseAuth mAuth;
|
||||
private EditText editTextFirstName, editTextLastName, editTextEmail, editTextPassword;
|
||||
private ProgressBar progressBar;
|
||||
private Button registerUser;
|
||||
|
||||
@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_register_user);
|
||||
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
|
||||
editTextFirstName = (EditText) findViewById(R.id.firstName);
|
||||
editTextLastName = (EditText) findViewById(R.id.lastname);
|
||||
editTextEmail = (EditText) findViewById(R.id.email);
|
||||
editTextPassword = (EditText) findViewById(R.id.newpassword);
|
||||
progressBar = (ProgressBar) findViewById(R.id.loadingReg);
|
||||
registerUser = (Button) findViewById(R.id.registerbutton);
|
||||
|
||||
registerUser.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
registerUser();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void nameValidation() {
|
||||
|
||||
}
|
||||
|
||||
private void registerUser() {
|
||||
String email = editTextEmail.getText().toString().trim();
|
||||
String firstname = editTextFirstName.getText().toString().trim();
|
||||
String lastname = editTextLastName.getText().toString().trim();
|
||||
String password = editTextPassword.getText().toString().trim();
|
||||
|
||||
if (firstname.isEmpty()) {
|
||||
editTextFirstName.setError("Podaj swoje imię!");
|
||||
editTextFirstName.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (lastname.isEmpty()) {
|
||||
editTextLastName.setError("Podaj swoje nazwisko!");
|
||||
editTextLastName.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (email.isEmpty()) {
|
||||
editTextEmail.setError("Podaj swój email!");
|
||||
editTextEmail.requestFocus();
|
||||
return;
|
||||
} else if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
|
||||
editTextEmail.setError("Podaj prawidłowy email!");
|
||||
editTextEmail.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (password.isEmpty()) {
|
||||
editTextPassword.setError("Podaj swoje hasło!");
|
||||
editTextPassword.requestFocus();
|
||||
return;
|
||||
} else if (password.length() <= 5) {
|
||||
editTextPassword.setError("Hasło musi mieć więcej niż 5 znaków!");
|
||||
editTextPassword.requestFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
mAuth.createUserWithEmailAndPassword(email, password).addOnSuccessListener(new OnSuccessListener<AuthResult>() {
|
||||
@Override
|
||||
public void onSuccess(AuthResult authResult) {
|
||||
Toast.makeText(getApplicationContext(), "Użytkownik zarejestrowany", Toast.LENGTH_LONG).show();
|
||||
Login();
|
||||
|
||||
}
|
||||
}).addOnFailureListener(new OnFailureListener() {
|
||||
@Override
|
||||
public void onFailure(@NonNull Exception e) {
|
||||
Toast.makeText(getApplicationContext(), "Rejestracja nie powiodła się. Spróbuj ponownie", Toast.LENGTH_LONG).show();
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void Login() {
|
||||
Intent intent = new Intent(this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
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;
|
||||
}
|
||||
}
|
257
WRSD2/app/src/main/java/com/example/wrsd/RoomActivity_1.java
Normal file
@ -0,0 +1,257 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.app.Activity;
|
||||
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.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
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;
|
||||
|
||||
public class RoomActivity_1 extends AppCompatActivity {
|
||||
|
||||
public List<Device> deviceList = new ArrayList<>();
|
||||
public List<String> deviceFromBase = new ArrayList<>();
|
||||
public List<String> temp = new ArrayList<>();
|
||||
private RecyclerView recyclerView;
|
||||
private SingleRoomAdapter mAdapter;
|
||||
private String userEmail;
|
||||
Integer roomIndex;
|
||||
public String roomvalue;
|
||||
private TextView roomName1;
|
||||
TextView myTextView;
|
||||
private TextView deviceName;
|
||||
|
||||
|
||||
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
|
||||
|
||||
Window win = activity.getWindow();
|
||||
WindowManager.LayoutParams winParams = win.getAttributes();
|
||||
if (on) {
|
||||
winParams.flags |= bits;
|
||||
} else {
|
||||
winParams.flags &= ~bits;
|
||||
}
|
||||
win.setAttributes(winParams);
|
||||
}
|
||||
|
||||
@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_room1);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
|
||||
roomName1 = (TextView) findViewById(R.id.textView);
|
||||
roomvalue = extras.getString("room");
|
||||
userEmail = extras.getString("email");
|
||||
//The key argument here must match that used in the other activity
|
||||
}
|
||||
|
||||
|
||||
recyclerView = findViewById(R.id.recycler_view);
|
||||
|
||||
mAdapter = new SingleRoomAdapter(deviceList, getApplicationContext());
|
||||
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
recyclerView.setLayoutManager(mLayoutManager);
|
||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
roomName1 = (TextView) findViewById(R.id.textView);
|
||||
roomName1.setText(roomvalue);
|
||||
|
||||
myTextView =findViewById(R.id.textView);
|
||||
|
||||
getData();
|
||||
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
deviceFromBase.clear();
|
||||
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
|
||||
|
||||
rootRef.collection("users").document(userEmail).collection("rooms").document(roomvalue)
|
||||
.get()
|
||||
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
|
||||
@Override
|
||||
public void onSuccess(DocumentSnapshot documentSnapshot) {
|
||||
if (documentSnapshot!=null) {
|
||||
temp.add(documentSnapshot.getData().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);
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}).addOnFailureListener(new OnFailureListener() {
|
||||
@Override
|
||||
public void onFailure(@NonNull Exception e) {
|
||||
// Toast.makeText(, "", Toast.LENGTH_SHORT).show();
|
||||
// Log.d("Tag",e.toString());
|
||||
// data="Failed";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// CollectionReference usersCol = rootRef.collection("users");
|
||||
// Query query = usersCol.whereEqualTo("email", userEmail).whereEqualTo("rooms", roomvalue);
|
||||
// DocumentReference document = usersCol.document(userEmail).collection("rooms").document(roomvalue);
|
||||
//
|
||||
// Map<String, Object> docData = new HashMap<>();
|
||||
//
|
||||
// query.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());
|
||||
// deviceFromBase.add(document.getData().toString());
|
||||
// Toast.makeText(getApplicationContext(), "dobrze", Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
// } else {
|
||||
// Toast.makeText(getApplicationContext(), "Błąd pobrania danych! Spróbuj ponownie", Toast.LENGTH_LONG).show(); }
|
||||
// }
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 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);
|
||||
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
DocumentReference docRef = rootRef.collection("users").document(userEmail).collection("rooms").document(roomvalue);
|
||||
docRef.update("Urzadzenia", FieldValue.arrayUnion(strEditText));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void settings(View view){
|
||||
|
||||
TextView b = (TextView) view;
|
||||
String dn = b.getText().toString();
|
||||
Intent intent = new Intent(this, DeviceSettings.class);
|
||||
intent.putExtra("device", dn);
|
||||
intent.putExtra("email", userEmail);
|
||||
intent.putExtra("room", roomvalue);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.example.wrsd.databinding.FragmentSecond2Binding;
|
||||
|
||||
public class Second2Fragment extends Fragment {
|
||||
|
||||
private FragmentSecond2Binding binding;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
|
||||
binding = FragmentSecond2Binding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
binding.buttonSecond.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(Second2Fragment.this)
|
||||
.navigate(R.id.action_Second2Fragment_to_First2Fragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
}
|
47
WRSD2/app/src/main/java/com/example/wrsd/SecondFragment.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import com.example.wrsd.databinding.FragmentSecondBinding;
|
||||
|
||||
public class SecondFragment extends Fragment {
|
||||
|
||||
private FragmentSecondBinding binding;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
|
||||
binding = FragmentSecondBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
binding.buttonSecond.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(SecondFragment.this)
|
||||
.navigate(R.id.action_SecondFragment_to_FirstFragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
16
WRSD2/app/src/main/java/com/example/wrsd/User.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.example.wrsd;
|
||||
|
||||
public class User {
|
||||
public String firstName, lastName, email;
|
||||
|
||||
public User(){
|
||||
|
||||
}
|
||||
|
||||
public User(String firstName, String lastName, String email){
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.example.wrsd.data;
|
||||
|
||||
import com.example.wrsd.data.model.LoggedInUser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Class that handles authentication w/ login credentials and retrieves user information.
|
||||
*/
|
||||
public class LoginDataSource {
|
||||
|
||||
public Result<LoggedInUser> login(String username, String password) {
|
||||
|
||||
try {
|
||||
// TODO: handle loggedInUser authentication
|
||||
LoggedInUser fakeUser =
|
||||
new LoggedInUser(
|
||||
java.util.UUID.randomUUID().toString(),
|
||||
username);
|
||||
return new Result.Success<>(fakeUser);
|
||||
} catch (Exception e) {
|
||||
return new Result.Error(new IOException("Error logging in", e));
|
||||
}
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
// TODO: revoke authentication
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.example.wrsd.data;
|
||||
|
||||
import com.example.wrsd.data.model.LoggedInUser;
|
||||
|
||||
/**
|
||||
* Class that requests authentication and user information from the remote data source and
|
||||
* maintains an in-memory cache of login status and user credentials information.
|
||||
*/
|
||||
public class LoginRepository {
|
||||
|
||||
private static volatile LoginRepository instance;
|
||||
|
||||
private LoginDataSource dataSource;
|
||||
|
||||
// If user credentials will be cached in local storage, it is recommended it be encrypted
|
||||
// @see https://developer.android.com/training/articles/keystore
|
||||
private LoggedInUser user = null;
|
||||
|
||||
// private constructor : singleton access
|
||||
private LoginRepository(LoginDataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
public static LoginRepository getInstance(LoginDataSource dataSource) {
|
||||
if (instance == null) {
|
||||
instance = new LoginRepository(dataSource);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return user != null;
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
user = null;
|
||||
dataSource.logout();
|
||||
}
|
||||
|
||||
private void setLoggedInUser(LoggedInUser user) {
|
||||
this.user = user;
|
||||
// If user credentials will be cached in local storage, it is recommended it be encrypted
|
||||
// @see https://developer.android.com/training/articles/keystore
|
||||
}
|
||||
|
||||
public Result<LoggedInUser> login(String username, String password) {
|
||||
// handle login
|
||||
Result<LoggedInUser> result = dataSource.login(username, password);
|
||||
if (result instanceof Result.Success) {
|
||||
setLoggedInUser(((Result.Success<LoggedInUser>) result).getData());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
55
WRSD2/app/src/main/java/com/example/wrsd/data/Result.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.example.wrsd.data;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.example.wrsd.MainActivity;
|
||||
|
||||
/**
|
||||
* A generic class that holds a result success w/ data or an error exception.
|
||||
*/
|
||||
public class Result<T> {
|
||||
// hide the private constructor to limit subclass types (Success, Error)
|
||||
private Result() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this instanceof Result.Success) {
|
||||
Result.Success success = (Result.Success) this;
|
||||
return "Success[data=" + success.getData().toString() + "]";
|
||||
} else if (this instanceof Result.Error) {
|
||||
Result.Error error = (Result.Error) this;
|
||||
return "Error[exception=" + error.getError().toString() + "]";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Success sub-class
|
||||
public final static class Success<T> extends Result {
|
||||
private T data;
|
||||
|
||||
public Success(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Error sub-class
|
||||
public final static class Error extends Result {
|
||||
private Exception error;
|
||||
|
||||
public Error(Exception error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public Exception getError() {
|
||||
return this.error;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.example.wrsd.data.model;
|
||||
|
||||
/**
|
||||
* Data class that captures user information for logged in users retrieved from LoginRepository
|
||||
*/
|
||||
public class LoggedInUser {
|
||||
|
||||
private String userId;
|
||||
private String displayName;
|
||||
|
||||
public LoggedInUser(String userId, String displayName) {
|
||||
this.userId = userId;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.example.wrsd.ui.login;
|
||||
|
||||
/**
|
||||
* Class exposing authenticated user details to the UI.
|
||||
*/
|
||||
class LoggedInUserView {
|
||||
private String displayName;
|
||||
//... other data fields that may be accessible to the UI
|
||||
|
||||
LoggedInUserView(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
@ -0,0 +1,237 @@
|
||||
package com.example.wrsd.ui.login;
|
||||
|
||||
import static com.example.wrsd.RoomActivity_1.setWindowFlag;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.util.Patterns;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.wrsd.MainActivity2;
|
||||
import com.example.wrsd.R;
|
||||
import com.example.wrsd.RegisterUser;
|
||||
import com.example.wrsd.databinding.ActivityLoginBinding;
|
||||
import com.google.android.gms.tasks.OnFailureListener;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.firebase.auth.AuthResult;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private LoginViewModel loginViewModel;
|
||||
private ActivityLoginBinding binding;
|
||||
|
||||
private Button login_button;
|
||||
private TextView register;
|
||||
FirebaseAuth mAuth;
|
||||
FirebaseUser mUser;
|
||||
private EditText usernameEditText2;
|
||||
private EditText passwordEditText2;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
|
||||
@Override
|
||||
public 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);
|
||||
|
||||
binding = ActivityLoginBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
loginViewModel = new ViewModelProvider(this, new LoginViewModelFactory())
|
||||
.get(LoginViewModel.class);
|
||||
|
||||
|
||||
final Button loginButton = binding.login;
|
||||
final EditText usernameEditText = binding.username;
|
||||
final EditText passwordEditText = binding.password;
|
||||
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
mUser = mAuth.getCurrentUser();
|
||||
|
||||
usernameEditText2 = (EditText) findViewById(R.id.username);
|
||||
passwordEditText2 = (EditText) findViewById(R.id.password);
|
||||
progressBar = (ProgressBar) findViewById(R.id.loading);
|
||||
login_button = (Button) findViewById(R.id.login);
|
||||
|
||||
// loginViewModel.getLoginFormState().observe(this, new Observer<LoginFormState>() {
|
||||
// @Override
|
||||
// public void onChanged(@Nullable LoginFormState loginFormState) {
|
||||
// if (loginFormState == null) {
|
||||
// return;
|
||||
// }
|
||||
// loginButton.setEnabled(loginFormState.isDataValid());
|
||||
// if (loginFormState.getUsernameError() != null) {
|
||||
// usernameEditText.setError(getString(loginFormState.getUsernameError()));
|
||||
// }
|
||||
// if (loginFormState.getPasswordError() != null) {
|
||||
// passwordEditText.setError(getString(loginFormState.getPasswordError()));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
// loginViewModel.getLoginResult().observe(this, new Observer<LoginResult>() {
|
||||
// @Override
|
||||
// public void onChanged(@Nullable LoginResult loginResult) {
|
||||
// if (loginResult == null) {
|
||||
// return;
|
||||
// }
|
||||
// progressBar.setVisibility(View.GONE);
|
||||
// if (loginResult.getError() != null) {
|
||||
// showLoginFailed(loginResult.getError());
|
||||
// }
|
||||
// if (loginResult.getSuccess() != null) {
|
||||
// updateUiWithUser(loginResult.getSuccess());
|
||||
// }
|
||||
// setResult(Activity.RESULT_OK);
|
||||
//
|
||||
// //Complete and destroy login activity once successful
|
||||
// finish();
|
||||
// }
|
||||
//// });
|
||||
//
|
||||
// TextWatcher afterTextChangedListener = new TextWatcher() {
|
||||
// @Override
|
||||
// public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
// // ignore
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// // ignore
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void afterTextChanged(Editable s) {
|
||||
// loginViewModel.loginDataChanged(usernameEditText.getText().toString(),
|
||||
// passwordEditText.getText().toString());
|
||||
// }
|
||||
// };
|
||||
// usernameEditText.addTextChangedListener(afterTextChangedListener);
|
||||
// passwordEditText.addTextChangedListener(afterTextChangedListener);
|
||||
// passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
|
||||
// @Override
|
||||
// public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
// if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
// loginViewModel.login(usernameEditText.getText().toString(),
|
||||
// passwordEditText.getText().toString());
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
|
||||
// loginButton.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// progressBar.setVisibility(View.VISIBLE);
|
||||
// loginViewModel.login(usernameEditText.getText().toString(),
|
||||
// passwordEditText.getText().toString());
|
||||
// }
|
||||
// });
|
||||
|
||||
login_button.setEnabled(true);
|
||||
login_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
LoginUser();
|
||||
}
|
||||
});
|
||||
|
||||
register = (TextView) findViewById(R.id.register);
|
||||
register.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
openRegisterUserActivity();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void LoginUser(){
|
||||
String email = usernameEditText2.getText().toString().trim();
|
||||
String password = passwordEditText2.getText().toString().trim();
|
||||
|
||||
if (email.isEmpty()) {
|
||||
usernameEditText2.setError("Podaj swój email");
|
||||
usernameEditText2.requestFocus();
|
||||
return;
|
||||
} else if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
|
||||
usernameEditText2.setError("Podaj prawidłowy email!");
|
||||
usernameEditText2.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (password.isEmpty()) {
|
||||
passwordEditText2.setError("Podaj swoje hasło!");
|
||||
passwordEditText2.requestFocus();
|
||||
return;
|
||||
} else if (password.length() <= 5) {
|
||||
passwordEditText2.setError("Hasło musi mieć więcej niż 5 znaków");
|
||||
passwordEditText2.requestFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
mAuth.signInWithEmailAndPassword(email, password).addOnSuccessListener(new OnSuccessListener<AuthResult>() {
|
||||
@Override
|
||||
public void onSuccess(AuthResult authResult) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
openMainActivity();
|
||||
|
||||
}
|
||||
}).addOnFailureListener(new OnFailureListener() {
|
||||
@Override
|
||||
public void onFailure(@NonNull Exception e) {
|
||||
Toast.makeText(getApplicationContext(), "Logowanie nie powiodła się. Spróbuj ponownie", Toast.LENGTH_LONG).show();
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void openMainActivity(){
|
||||
|
||||
String email = usernameEditText2.getText().toString().trim();
|
||||
Intent intent = new Intent(this, MainActivity2.class);
|
||||
intent.putExtra("key", email);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void openRegisterUserActivity(){
|
||||
Intent intent = new Intent(this, RegisterUser.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
// private void updateUiWithUser(LoggedInUserView model) {
|
||||
// String welcome = getString(R.string.welcome) + model.getDisplayName();
|
||||
// // TODO : initiate successful logged in experience
|
||||
// Toast.makeText(getApplicationContext(), welcome, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
//
|
||||
// private void showLoginFailed(@StringRes Integer errorString) {
|
||||
// Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.example.wrsd.ui.login;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Data validation state of the login form.
|
||||
*/
|
||||
class LoginFormState {
|
||||
@Nullable
|
||||
private Integer usernameError;
|
||||
@Nullable
|
||||
private Integer passwordError;
|
||||
private boolean isDataValid;
|
||||
|
||||
LoginFormState(@Nullable Integer usernameError, @Nullable Integer passwordError) {
|
||||
this.usernameError = usernameError;
|
||||
this.passwordError = passwordError;
|
||||
this.isDataValid = false;
|
||||
}
|
||||
|
||||
LoginFormState(boolean isDataValid) {
|
||||
this.usernameError = null;
|
||||
this.passwordError = null;
|
||||
this.isDataValid = isDataValid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getUsernameError() {
|
||||
return usernameError;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getPasswordError() {
|
||||
return passwordError;
|
||||
}
|
||||
|
||||
boolean isDataValid() {
|
||||
return isDataValid;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.example.wrsd.ui.login;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Authentication result : success (user details) or error message.
|
||||
*/
|
||||
class LoginResult {
|
||||
@Nullable
|
||||
private LoggedInUserView success;
|
||||
@Nullable
|
||||
private Integer error;
|
||||
|
||||
LoginResult(@Nullable Integer error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
LoginResult(@Nullable LoggedInUserView success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
LoggedInUserView getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getError() {
|
||||
return error;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.example.wrsd.ui.login;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import android.util.Patterns;
|
||||
|
||||
import com.example.wrsd.data.LoginRepository;
|
||||
import com.example.wrsd.data.Result;
|
||||
import com.example.wrsd.data.model.LoggedInUser;
|
||||
import com.example.wrsd.R;
|
||||
|
||||
public class LoginViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<LoginFormState> loginFormState = new MutableLiveData<>();
|
||||
private MutableLiveData<LoginResult> loginResult = new MutableLiveData<>();
|
||||
private LoginRepository loginRepository;
|
||||
|
||||
LoginViewModel(LoginRepository loginRepository) {
|
||||
this.loginRepository = loginRepository;
|
||||
}
|
||||
|
||||
LiveData<LoginFormState> getLoginFormState() {
|
||||
return loginFormState;
|
||||
}
|
||||
|
||||
LiveData<LoginResult> getLoginResult() {
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
public void login(String username, String password) {
|
||||
// can be launched in a separate asynchronous job
|
||||
Result<LoggedInUser> result = loginRepository.login(username, password);
|
||||
|
||||
if (result instanceof Result.Success) {
|
||||
LoggedInUser data = ((Result.Success<LoggedInUser>) result).getData();
|
||||
loginResult.setValue(new LoginResult(new LoggedInUserView(data.getDisplayName())));
|
||||
} else {
|
||||
loginResult.setValue(new LoginResult(R.string.login_failed));
|
||||
}
|
||||
}
|
||||
|
||||
public void loginDataChanged(String username, String password) {
|
||||
if (!isUserNameValid(username)) {
|
||||
loginFormState.setValue(new LoginFormState(R.string.invalid_username, null));
|
||||
} else if (!isPasswordValid(password)) {
|
||||
loginFormState.setValue(new LoginFormState(null, R.string.invalid_password));
|
||||
} else {
|
||||
loginFormState.setValue(new LoginFormState(true));
|
||||
}
|
||||
}
|
||||
|
||||
// A placeholder username validation check
|
||||
private boolean isUserNameValid(String username) {
|
||||
if (username == null) {
|
||||
return false;
|
||||
}
|
||||
if (username.contains("@")) {
|
||||
return Patterns.EMAIL_ADDRESS.matcher(username).matches();
|
||||
} else {
|
||||
return !username.trim().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
// A placeholder password validation check
|
||||
private boolean isPasswordValid(String password) {
|
||||
return password != null && password.trim().length() > 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.example.wrsd.ui.login;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.example.wrsd.data.LoginDataSource;
|
||||
import com.example.wrsd.data.LoginRepository;
|
||||
|
||||
/**
|
||||
* ViewModel provider factory to instantiate LoginViewModel.
|
||||
* Required given LoginViewModel has a non-empty constructor
|
||||
*/
|
||||
public class LoginViewModelFactory implements ViewModelProvider.Factory {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||
if (modelClass.isAssignableFrom(LoginViewModel.class)) {
|
||||
return (T) new LoginViewModel(LoginRepository.getInstance(new LoginDataSource()));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown ViewModel class");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
BIN
WRSD2/app/src/main/res/drawable/add.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
WRSD2/app/src/main/res/drawable/back.png
Normal file
After Width: | Height: | Size: 831 KiB |
BIN
WRSD2/app/src/main/res/drawable/bathroom.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
WRSD2/app/src/main/res/drawable/bedroom.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
WRSD2/app/src/main/res/drawable/glosnik.png
Normal file
After Width: | Height: | Size: 24 KiB |
170
WRSD2/app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
BIN
WRSD2/app/src/main/res/drawable/kibelek.png
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
WRSD2/app/src/main/res/drawable/kitchen.png
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
WRSD2/app/src/main/res/drawable/kitchentransparent.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
WRSD2/app/src/main/res/drawable/led.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
WRSD2/app/src/main/res/drawable/light.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
WRSD2/app/src/main/res/drawable/livingroom.png
Normal file
After Width: | Height: | Size: 226 KiB |
BIN
WRSD2/app/src/main/res/drawable/livngroomtransparent.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
WRSD2/app/src/main/res/drawable/rolety.png
Normal file
After Width: | Height: | Size: 235 KiB |
BIN
WRSD2/app/src/main/res/drawable/salon.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
WRSD2/app/src/main/res/drawable/settings.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
WRSD2/app/src/main/res/drawable/toilettransparent.png
Normal file
After Width: | Height: | Size: 164 KiB |
BIN
WRSD2/app/src/main/res/drawable/tv.png
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
WRSD2/app/src/main/res/drawable/wrsdlogo.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
WRSD2/app/src/main/res/font/poppinsblack.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsblackitalian.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsbold.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsbolditalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsextrabold.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsextrabolditalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/poppinsthin.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppextralight.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppextralightitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/pplight.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/pplightitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppmedium.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppmediumitalic.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppregular.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppsemibold.ttf
Normal file
BIN
WRSD2/app/src/main/res/font/ppsemibolditalic.ttf
Normal file
69
WRSD2/app/src/main/res/layout-w1240dp/activity_login.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<?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:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".ui.login.LoginActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="96dp"
|
||||
android:hint="@string/prompt_email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="@string/prompt_password"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/username" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:enabled="false"
|
||||
android:text="@string/action_sign_in"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||
app:layout_constraintVertical_bias="0.2" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||
app:layout_constraintStart_toStartOf="@+id/password"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.3" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
76
WRSD2/app/src/main/res/layout-w936dp/activity_login.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?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:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".ui.login.LoginActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="840dp"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="96dp"
|
||||
android:hint="@string/prompt_email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="@string/prompt_password"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/username" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:enabled="false"
|
||||
android:text="@string/action_sign_in"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||
app:layout_constraintVertical_bias="0.2" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||
app:layout_constraintStart_toStartOf="@+id/password"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.3" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
56
WRSD2/app/src/main/res/layout/activity_add_device.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?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=".AddDeviceActivity">
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="Nazwa urządzenia"
|
||||
android:inputType="textPersonName"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.129"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.311" />
|
||||
|
||||
<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: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_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.775" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Dodaj"
|
||||
android:clickable="true"
|
||||
android:onClick="DeviceName"
|
||||
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" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
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>
|
96
WRSD2/app/src/main/res/layout/activity_login.xml
Normal file
@ -0,0 +1,96 @@
|
||||
<?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:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#007FFD"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".ui.login.LoginActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="328dp"
|
||||
android:hint="@string/prompt_login"
|
||||
android:inputType="textEmailAddress"
|
||||
android:minHeight="48dp"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:hint="@string/prompt_haslo"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:inputType="textPassword"
|
||||
android:minHeight="48dp"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/username" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:enabled="false"
|
||||
android:text="Zaloguj się"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||
app:layout_constraintVertical_bias="0.811" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="89dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@+id/login"
|
||||
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||
app:layout_constraintHorizontal_bias="0.483"
|
||||
app:layout_constraintStart_toStartOf="@+id/password"
|
||||
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||
app:layout_constraintVertical_bias="1.0"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="209dp"
|
||||
android:layout_height="392dp"
|
||||
android:layout_marginTop="-60dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/login"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.239"
|
||||
app:srcCompat="@drawable/wrsdlogo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/register"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Nie masz konta? Zarejestruj się"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.469"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/login"
|
||||
app:layout_constraintVertical_bias="0.534" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
33
WRSD2/app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout 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=".MainActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Theme.WRSD.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main" />
|
||||
|
||||
<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_marginBottom="676dp"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
234
WRSD2/app/src/main/res/layout/activity_main2.xml
Normal file
@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity2">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="130dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
app:srcCompat="@drawable/wrsdlogo" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="100dp"
|
||||
android:background="@drawable/back">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_margin="20dp"
|
||||
android:backgroundTint="#F3F0D8"
|
||||
app:cardCornerRadius="30dp"
|
||||
app:cardElevation="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:clickable="true"
|
||||
android:contentDescription="Salon"
|
||||
android:gravity="center"
|
||||
android:onClick="RoomActivity"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:contentDescription="salon"
|
||||
android:src="@drawable/livngroomtransparent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:fontFamily="@font/ppmedium"
|
||||
android:text="Salon"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_margin="20dp"
|
||||
android:backgroundTint="#F3F0D8"
|
||||
app:cardCornerRadius="30dp"
|
||||
app:cardElevation="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:clickable="true"
|
||||
android:contentDescription="Kuchnia"
|
||||
android:gravity="center"
|
||||
android:onClick="RoomActivity"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/kitchentransparent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:fontFamily="@font/ppmedium"
|
||||
android:text="Kuchnia"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_margin="20dp"
|
||||
android:backgroundTint="#F3F0D8"
|
||||
app:cardCornerRadius="30dp"
|
||||
app:cardElevation="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:clickable="true"
|
||||
android:contentDescription="Sypialnia"
|
||||
android:gravity="center"
|
||||
android:onClick="RoomActivity"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/bedroom" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:fontFamily="@font/ppmedium"
|
||||
android:text="Sypialnia"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_margin="20dp"
|
||||
android:backgroundTint="#F3F0D8"
|
||||
app:cardCornerRadius="30dp"
|
||||
app:cardElevation="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:clickable="true"
|
||||
android:contentDescription="Lazienka"
|
||||
android:gravity="center"
|
||||
android:onClick="RoomActivity"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/bathroom" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:fontFamily="@font/ppmedium"
|
||||
android:text="Łazienka"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_margin="20dp"
|
||||
android:backgroundTint="#F3F0D8"
|
||||
app:cardCornerRadius="30dp"
|
||||
app:cardElevation="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:clickable="true"
|
||||
android:contentDescription="Toaleta"
|
||||
android:onClick="RoomActivity"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/kibelek"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:fontFamily="@font/ppmedium"
|
||||
android:text="Toaleta"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</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" />
|
||||
|
||||
|
||||
</LinearLayout>
|
109
WRSD2/app/src/main/res/layout/activity_register_user.xml
Normal file
@ -0,0 +1,109 @@
|
||||
<?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="#0380FE"
|
||||
tools:context=".RegisterUser">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loadingReg"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="89dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.484"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.876"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/firstName"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="156dp"
|
||||
android:ems="10"
|
||||
android:hint="Imię"
|
||||
android:inputType="textPersonName"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/lastname"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.496"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.716" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/lastname"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="60dp"
|
||||
android:hint="Nazwisko"
|
||||
android:inputType="textPersonName"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/email"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.496"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.92" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/email"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="60dp"
|
||||
android:hint="Email"
|
||||
android:inputType="textPersonName"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/newpassword"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.496"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.938" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/newpassword"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="60dp"
|
||||
android:hint="Hasło"
|
||||
android:minHeight="48dp"
|
||||
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.742" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/registerbutton"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:backgroundTint="#09B6A6"
|
||||
android:text="Dołącz"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/newpassword"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="183dp"
|
||||
android:layout_height="168dp"
|
||||
android:background="#0280FE"
|
||||
app:layout_constraintBottom_toTopOf="@+id/firstName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/wrsdlogo" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
197
WRSD2/app/src/main/res/layout/activity_room1.xml
Normal file
@ -0,0 +1,197 @@
|
||||
<?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"
|
||||
tools:context=".RoomActivity_1">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/back">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<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:clickable="true"
|
||||
android:onClick="addDevice"
|
||||
app:srcCompat="@drawable/add" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="10">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="
|
||||
9"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:weightSum="2">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_centerInParent="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="20\u2103"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TEMP"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_centerInParent="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="50%"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:clipToPadding="true" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
19
WRSD2/app/src/main/res/layout/content_main.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment_content_main"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/nav_graph" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
19
WRSD2/app/src/main/res/layout/content_register_user.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment_content_register_user"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/nav_graph2" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
187
WRSD2/app/src/main/res/layout/fragment_first2.xml
Normal file
@ -0,0 +1,187 @@
|
||||
<?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"
|
||||
tools:context=".First2Fragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="409dp"
|
||||
android:layout_height="729dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_margin="20dp"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/salon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Salon"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_margin="20dp"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/salon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Kuchnia"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_margin="20dp"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/salon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Sypialnia"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_margin="20dp"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/salon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Łazienka"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" />
|
||||
</HorizontalScrollView>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="181dp"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
27
WRSD2/app/src/main/res/layout/fragment_second.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?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"
|
||||
tools:context=".SecondFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textview_second"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@id/button_second"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_second"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/textview_second" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
27
WRSD2/app/src/main/res/layout/fragment_second2.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?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"
|
||||
tools:context=".Second2Fragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textview_second"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@id/button_second"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_second"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/textview_second" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
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>
|
5
WRSD2/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
BIN
WRSD2/app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
WRSD2/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
WRSD2/app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 982 B |
BIN
WRSD2/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
WRSD2/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
WRSD2/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
After Width: | Height: | Size: 3.8 KiB |