Mejora de xml para que se vea mucho mas formal!
This commit is contained in:
parent
4b08948750
commit
f46ae8f521
Binary file not shown.
|
|
@ -3,14 +3,18 @@ package com.santiparra.yomitrack.ui;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.ImageView;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowCompat;
|
import androidx.core.view.WindowCompat;
|
||||||
|
|
@ -18,6 +22,8 @@ import androidx.core.view.WindowInsetsCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
import com.santiparra.yomitrack.R;
|
import com.santiparra.yomitrack.R;
|
||||||
import com.santiparra.yomitrack.databinding.ActivityMainBinding;
|
import com.santiparra.yomitrack.databinding.ActivityMainBinding;
|
||||||
import com.santiparra.yomitrack.ui.fragments.anime_list.FragmentAnime;
|
import com.santiparra.yomitrack.ui.fragments.anime_list.FragmentAnime;
|
||||||
|
|
@ -35,29 +41,37 @@ public class MainActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||||
|
|
||||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
|
// Ajustar colores de barra de estado y navegación
|
||||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||||
EdgeToEdge.enable(this);
|
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.primary));
|
||||||
|
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.primary));
|
||||||
|
|
||||||
|
// Para que íconos de status bar se vean bien con fondo oscuro
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
getWindow().getInsetsController().setSystemBarsAppearance(0,
|
||||||
|
android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS |
|
||||||
|
android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alinear padding según barra superior e inferior
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(binding.getRoot(), (view, insets) -> {
|
ViewCompat.setOnApplyWindowInsetsListener(binding.getRoot(), (view, insets) -> {
|
||||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
view.setPadding(0, systemBars.top, 0, systemBars.bottom);
|
view.setPadding(0, systemBars.top, 0, 0); // solo top, bottom lo controla el menú
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(binding.bottomNavigationView, (view, insets) -> {
|
ViewCompat.setOnApplyWindowInsetsListener(binding.bottomNavigationView, (view, insets) -> {
|
||||||
int bottomInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
|
int bottomInset = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
|
||||||
view.setPadding(0, 0, 0, bottomInset);
|
view.setPadding(0, 0, 0, bottomInset);
|
||||||
|
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
((ViewGroup.MarginLayoutParams) params).bottomMargin = -bottomInset;
|
((ViewGroup.MarginLayoutParams) params).bottomMargin = -bottomInset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -94,8 +108,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
.setMessage("¿Deseas cerrar sesión?")
|
.setMessage("¿Deseas cerrar sesión?")
|
||||||
.setPositiveButton("Sí", (dialog, which) -> {
|
.setPositiveButton("Sí", (dialog, which) -> {
|
||||||
SharedPreferences prefs = getSharedPreferences("user_session", MODE_PRIVATE);
|
SharedPreferences prefs = getSharedPreferences("user_session", MODE_PRIVATE);
|
||||||
prefs.edit().clear().apply(); // ← ¡esto borra la sesión real!
|
prefs.edit().clear().apply();
|
||||||
|
|
||||||
startActivity(new Intent(MainActivity.this, LoginActivity.class)
|
startActivity(new Intent(MainActivity.this, LoginActivity.class)
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
|
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -139,14 +139,20 @@ public class AddAnimeFragment extends Fragment {
|
||||||
AnimeEntity anime = new AnimeEntity();
|
AnimeEntity anime = new AnimeEntity();
|
||||||
anime.setUserId(userId);
|
anime.setUserId(userId);
|
||||||
anime.setTitle(selected.getTitle());
|
anime.setTitle(selected.getTitle());
|
||||||
anime.setImageUrl(selected.getImageUrl());
|
|
||||||
|
// ✅ Si no hay imagen, se usa una predeterminada
|
||||||
|
if (selected.getImageUrl() == null || selected.getImageUrl().isEmpty()) {
|
||||||
|
selectedImageUrl = "android.resource://" + requireContext().getPackageName() + "/" + R.drawable.sample_cover;
|
||||||
|
} else {
|
||||||
|
selectedImageUrl = selected.getImageUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
anime.setImageUrl(selectedImageUrl);
|
||||||
anime.setStatus(status);
|
anime.setStatus(status);
|
||||||
anime.setType(type);
|
anime.setType(type);
|
||||||
anime.setScore(score);
|
anime.setScore(score);
|
||||||
anime.setProgress(progress);
|
anime.setProgress(progress);
|
||||||
|
|
||||||
selectedImageUrl = selected.getImageUrl();
|
|
||||||
|
|
||||||
api.insertAnime(anime).enqueue(new Callback<ApiResponse>() {
|
api.insertAnime(anime).enqueue(new Callback<ApiResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<ApiResponse> call, Response<ApiResponse> response) {
|
public void onResponse(Call<ApiResponse> call, Response<ApiResponse> response) {
|
||||||
|
|
|
||||||
|
|
@ -139,14 +139,19 @@ public class AddMangaFragment extends Fragment {
|
||||||
MangaEntity manga = new MangaEntity();
|
MangaEntity manga = new MangaEntity();
|
||||||
manga.setUserId(userId);
|
manga.setUserId(userId);
|
||||||
manga.setTitle(selected.getTitle());
|
manga.setTitle(selected.getTitle());
|
||||||
manga.setImageUrl(selected.getImageUrl());
|
|
||||||
|
if (selected.getImageUrl() == null || selected.getImageUrl().isEmpty()) {
|
||||||
|
selectedImageUrl = "android.resource://" + requireContext().getPackageName() + "/" + R.drawable.sample_cover;
|
||||||
|
} else {
|
||||||
|
selectedImageUrl = selected.getImageUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
manga.setImageUrl(selectedImageUrl);
|
||||||
manga.setStatus(status);
|
manga.setStatus(status);
|
||||||
manga.setType(type);
|
manga.setType(type);
|
||||||
manga.setScore(score);
|
manga.setScore(score);
|
||||||
manga.setProgress(progress);
|
manga.setProgress(progress);
|
||||||
|
|
||||||
selectedImageUrl = selected.getImageUrl();
|
|
||||||
|
|
||||||
api.insertManga(manga).enqueue(new Callback<ApiResponse>() {
|
api.insertManga(manga).enqueue(new Callback<ApiResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<ApiResponse> call, Response<ApiResponse> response) {
|
public void onResponse(Call<ApiResponse> call, Response<ApiResponse> response) {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -64,5 +64,4 @@
|
||||||
app:itemTextColor="@color/textPrimary"
|
app:itemTextColor="@color/textPrimary"
|
||||||
app:labelVisibilityMode="selected"
|
app:labelVisibilityMode="selected"
|
||||||
app:menu="@menu/bottom_menu" />
|
app:menu="@menu/bottom_menu" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
android:layout_height="90dp"
|
android:layout_height="90dp"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:src="@drawable/placeholder_image"
|
android:src="@drawable/sample_cover"
|
||||||
android:layout_marginEnd="12dp" />
|
android:layout_marginEnd="12dp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue