Compare commits
2 Commits
main
...
31a7cbb2df
| Author | SHA1 | Date | |
|---|---|---|---|
| 31a7cbb2df | |||
| fe9266263f |
@@ -98,7 +98,7 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
// NovaReservaActivity
|
// NovaReservaActivity
|
||||||
// We pass the filter so it can maybe open directly or we just pass restaurant
|
// We pass the filter so it can maybe open directly or we just pass restaurant
|
||||||
// email
|
// email
|
||||||
intent.putExtra("category_filter", restaurant.getCategory());
|
intent.putExtra("restaurant", restaurant);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
layoutAllRestaurants.setVisibility(View.GONE);
|
layoutAllRestaurants.setVisibility(View.GONE);
|
||||||
|
|
||||||
DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference("Restaurantes");
|
DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference("Restaurantes");
|
||||||
usersRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
usersRef.addValueEventListener(new ValueEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDataChange(@androidx.annotation.NonNull DataSnapshot snapshot) {
|
public void onDataChange(@androidx.annotation.NonNull DataSnapshot snapshot) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
@@ -176,7 +176,8 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
String role = ds.child("role").getValue(String.class);
|
String role = ds.child("role").getValue(String.class);
|
||||||
String accountType = ds.child("accountType").getValue(String.class);
|
String accountType = ds.child("accountType").getValue(String.class);
|
||||||
|
|
||||||
if ("ADMIN".equalsIgnoreCase(role) || "ESTABELECIMENTO".equalsIgnoreCase(accountType)) {
|
// Aceitar todos os registos na coleção Restaurantes
|
||||||
|
if (true) {
|
||||||
String name = ds.child("establishmentName").getValue(String.class);
|
String name = ds.child("establishmentName").getValue(String.class);
|
||||||
if (name == null)
|
if (name == null)
|
||||||
name = ds.child("displayName").getValue(String.class);
|
name = ds.child("displayName").getValue(String.class);
|
||||||
@@ -292,7 +293,7 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
featuredAdapter = new FeaturedRestaurantAdapter(featuredList,
|
featuredAdapter = new FeaturedRestaurantAdapter(featuredList,
|
||||||
mainAdapter instanceof RestaurantAdapter ? restaurant -> {
|
mainAdapter instanceof RestaurantAdapter ? restaurant -> {
|
||||||
Intent intent = new Intent(this, ExplorarRestaurantesActivity.class);
|
Intent intent = new Intent(this, ExplorarRestaurantesActivity.class);
|
||||||
intent.putExtra("category_filter", restaurant.getCategory());
|
intent.putExtra("restaurant", restaurant);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} : null);
|
} : null);
|
||||||
rvFeatured.setAdapter(featuredAdapter);
|
rvFeatured.setAdapter(featuredAdapter);
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ public class ExplorarRestaurantesActivity extends AppCompatActivity {
|
|||||||
back.setOnClickListener(v -> handleBackNavigation());
|
back.setOnClickListener(v -> handleBackNavigation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getIntent().hasExtra("restaurant")) {
|
||||||
|
selectedRestaurant = (com.example.pap_teste.models.Restaurant) getIntent().getSerializableExtra("restaurant");
|
||||||
|
currentState = State.DETAILS;
|
||||||
|
}
|
||||||
|
|
||||||
setupRestaurantList();
|
setupRestaurantList();
|
||||||
updateViewState();
|
updateViewState();
|
||||||
}
|
}
|
||||||
@@ -135,7 +140,7 @@ public class ExplorarRestaurantesActivity extends AppCompatActivity {
|
|||||||
if (progressBar != null)
|
if (progressBar != null)
|
||||||
progressBar.setVisibility(android.view.View.VISIBLE);
|
progressBar.setVisibility(android.view.View.VISIBLE);
|
||||||
|
|
||||||
query.addListenerForSingleValueEvent(new com.google.firebase.database.ValueEventListener() {
|
query.addValueEventListener(new com.google.firebase.database.ValueEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDataChange(@androidx.annotation.NonNull com.google.firebase.database.DataSnapshot snapshot) {
|
public void onDataChange(@androidx.annotation.NonNull com.google.firebase.database.DataSnapshot snapshot) {
|
||||||
if (progressBar != null)
|
if (progressBar != null)
|
||||||
@@ -145,7 +150,8 @@ public class ExplorarRestaurantesActivity extends AppCompatActivity {
|
|||||||
String role = ds.child("role").getValue(String.class);
|
String role = ds.child("role").getValue(String.class);
|
||||||
String accountType = ds.child("accountType").getValue(String.class);
|
String accountType = ds.child("accountType").getValue(String.class);
|
||||||
|
|
||||||
if ("ADMIN".equalsIgnoreCase(role) || "ESTABELECIMENTO".equalsIgnoreCase(accountType)) {
|
// Aceitar todos os registos na coleção Restaurantes
|
||||||
|
if (true) {
|
||||||
String name = ds.child("establishmentName").getValue(String.class);
|
String name = ds.child("establishmentName").getValue(String.class);
|
||||||
if (name == null)
|
if (name == null)
|
||||||
name = ds.child("displayName").getValue(String.class);
|
name = ds.child("displayName").getValue(String.class);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class FavoritosActivity extends AppCompatActivity {
|
|||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
adapter = new RestaurantAdapter(list, restaurant -> {
|
adapter = new RestaurantAdapter(list, restaurant -> {
|
||||||
android.content.Intent intent = new android.content.Intent(this, ExplorarRestaurantesActivity.class);
|
android.content.Intent intent = new android.content.Intent(this, ExplorarRestaurantesActivity.class);
|
||||||
intent.putExtra("category_filter", restaurant.getCategory()); // just as demo
|
intent.putExtra("restaurant", restaurant);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
rv.setAdapter(adapter);
|
rv.setAdapter(adapter);
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private AccountType selectedAccountType = AccountType.CLIENTE;
|
private AccountType selectedAccountType = AccountType.CLIENTE;
|
||||||
private AccountAction selectedAccountAction = AccountAction.ENTRAR;
|
private AccountAction selectedAccountAction = AccountAction.ENTRAR;
|
||||||
|
|
||||||
private Button btnCliente;
|
|
||||||
private Button btnEstabelecimento;
|
|
||||||
private Button btnEntrar;
|
private Button btnEntrar;
|
||||||
private Button btnCriarConta;
|
private Button btnCriarConta;
|
||||||
private Button btnPrimaryAction;
|
private Button btnPrimaryAction;
|
||||||
@@ -101,12 +98,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
selectedAccountType = AccountType.CLIENTE;
|
||||||
|
|
||||||
FirebaseApp.initializeApp(this);
|
FirebaseApp.initializeApp(this);
|
||||||
firebaseAuth = FirebaseAuth.getInstance();
|
firebaseAuth = FirebaseAuth.getInstance();
|
||||||
databaseReference = FirebaseDatabase.getInstance().getReference();
|
databaseReference = FirebaseDatabase.getInstance().getReference();
|
||||||
|
|
||||||
bindViews();
|
bindViews();
|
||||||
setupTypeToggle();
|
|
||||||
setupActionToggle();
|
setupActionToggle();
|
||||||
setupPrimaryAction();
|
setupPrimaryAction();
|
||||||
checkPermissions();
|
checkPermissions();
|
||||||
@@ -177,8 +175,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bindViews() {
|
private void bindViews() {
|
||||||
btnCliente = findViewById(R.id.btnCliente);
|
|
||||||
btnEstabelecimento = findViewById(R.id.btnEstabelecimento);
|
|
||||||
btnEntrar = findViewById(R.id.btnEntrar);
|
btnEntrar = findViewById(R.id.btnEntrar);
|
||||||
btnCriarConta = findViewById(R.id.btnCriarConta);
|
btnCriarConta = findViewById(R.id.btnCriarConta);
|
||||||
btnPrimaryAction = findViewById(R.id.btnFinalCriarConta);
|
btnPrimaryAction = findViewById(R.id.btnFinalCriarConta);
|
||||||
@@ -240,17 +236,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTypeToggle() {
|
|
||||||
btnCliente.setOnClickListener(v -> {
|
|
||||||
selectedAccountType = AccountType.CLIENTE;
|
|
||||||
updateTypeButtons();
|
|
||||||
});
|
|
||||||
btnEstabelecimento.setOnClickListener(v -> {
|
|
||||||
selectedAccountType = AccountType.ESTABELECIMENTO;
|
|
||||||
updateTypeButtons();
|
|
||||||
});
|
|
||||||
updateTypeButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupActionToggle() {
|
private void setupActionToggle() {
|
||||||
btnEntrar.setOnClickListener(v -> {
|
btnEntrar.setOnClickListener(v -> {
|
||||||
@@ -269,11 +254,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
updatePrimaryActionState();
|
updatePrimaryActionState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTypeButtons() {
|
|
||||||
setSelectedState(btnCliente, selectedAccountType == AccountType.CLIENTE);
|
|
||||||
setSelectedState(btnEstabelecimento, selectedAccountType == AccountType.ESTABELECIMENTO);
|
|
||||||
updateInputVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateActionButtons() {
|
private void updateActionButtons() {
|
||||||
setSelectedState(btnEntrar, selectedAccountAction == AccountAction.ENTRAR);
|
setSelectedState(btnEntrar, selectedAccountAction == AccountAction.ENTRAR);
|
||||||
|
|||||||
@@ -119,7 +119,8 @@ public class NovaReservaActivity extends AppCompatActivity {
|
|||||||
String role = ds.child("role").getValue(String.class);
|
String role = ds.child("role").getValue(String.class);
|
||||||
String accountType = ds.child("accountType").getValue(String.class);
|
String accountType = ds.child("accountType").getValue(String.class);
|
||||||
|
|
||||||
if ("ADMIN".equalsIgnoreCase(role) || "ESTABELECIMENTO".equalsIgnoreCase(accountType)) {
|
// Aceitar todos os registos na coleção Restaurantes
|
||||||
|
if (true) {
|
||||||
String name = ds.child("establishmentName").getValue(String.class);
|
String name = ds.child("establishmentName").getValue(String.class);
|
||||||
if (name == null)
|
if (name == null)
|
||||||
name = ds.child("displayName").getValue(String.class);
|
name = ds.child("displayName").getValue(String.class);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.example.pap_teste.models;
|
package com.example.pap_teste.models;
|
||||||
|
|
||||||
public class Restaurant {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Restaurant implements Serializable {
|
||||||
private String name;
|
private String name;
|
||||||
private String category;
|
private String category;
|
||||||
private String email;
|
private String email;
|
||||||
|
|||||||
@@ -36,15 +36,13 @@
|
|||||||
android:id="@+id/txtClientGreeting"
|
android:id="@+id/txtClientGreeting"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
android:text="Olá, convidado!"
|
android:text="Olá, convidado!"
|
||||||
android:textColor="@color/colorTextPrimary"
|
android:textColor="@color/colorTextPrimary"
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:fontFamily="sans-serif"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/imgNotification"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
android:layout_marginEnd="16dp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
@@ -52,21 +50,8 @@
|
|||||||
android:text="Encontre a sua próxima mesa."
|
android:text="Encontre a sua próxima mesa."
|
||||||
android:textColor="@color/colorTextSecondary"
|
android:textColor="@color/colorTextSecondary"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/txtClientGreeting"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/imgNotification" />
|
app:layout_constraintTop_toBottomOf="@id/txtClientGreeting" />
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/imgNotification"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:background="@drawable/bg_circle_white"
|
|
||||||
android:src="@android:drawable/ic_popup_reminder"
|
|
||||||
app:tint="@color/colorTextPrimary"
|
|
||||||
android:layout_marginEnd="12dp"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/cardProfile"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@id/cardProfile"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/cardProfile" />
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/cardProfile"
|
android:id="@+id/cardProfile"
|
||||||
|
|||||||
@@ -19,13 +19,14 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/logoNaMesa"
|
android:id="@+id/logoNaMesa"
|
||||||
android:layout_width="100dp"
|
android:layout_width="160dp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="156dp"
|
||||||
|
android:layout_marginTop="124dp"
|
||||||
android:src="@drawable/na_mesa"
|
android:src="@drawable/na_mesa"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.508"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
android:layout_marginTop="50dp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtTitle"
|
android:id="@+id/txtTitle"
|
||||||
@@ -70,43 +71,13 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="387dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/bg_tabs"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="3dp">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btnCliente"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@drawable/btn_light"
|
|
||||||
android:text="Cliente"
|
|
||||||
android:textAllCaps="false"
|
|
||||||
android:textColor="#231F1F"
|
|
||||||
android:textSize="14sp" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btnEstabelecimento"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:text="Estabelecimento"
|
|
||||||
android:textAllCaps="false"
|
|
||||||
android:textColor="@color/colorTextSecondary"
|
|
||||||
android:textSize="14sp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:background="@drawable/bg_tabs"
|
android:background="@drawable/bg_tabs"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@@ -221,37 +192,37 @@
|
|||||||
android:layout_height="54dp"
|
android:layout_height="54dp"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:padding="12dp"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:src="@drawable/ic_visibility_off"
|
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless" />
|
android:padding="12dp"
|
||||||
|
android:src="@drawable/ic_visibility_off" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtForgotPassword"
|
android:id="@+id/txtForgotPassword"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:text="Esqueceu-se da palavra-passe?"
|
android:text="Esqueceu-se da palavra-passe?"
|
||||||
android:textColor="@color/colorPrimary"
|
android:textColor="@color/colorPrimary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:visibility="visible"
|
android:visibility="visible" />
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"/>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btnFinalCriarConta"
|
android:id="@+id/btnFinalCriarConta"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
app:cornerRadius="14dp"
|
|
||||||
app:backgroundTint="@color/colorPrimary"
|
|
||||||
android:text="Entrar"
|
android:text="Entrar"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
|
android:textColor="@color/white"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@color/white" />
|
app:backgroundTint="@color/colorPrimary"
|
||||||
|
app:cornerRadius="14dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user