diff --git a/app/src/main/java/ru/myitschool/work/data/CallToConsumer.java b/app/src/main/java/ru/myitschool/work/data/CallToConsumer.java new file mode 100644 index 0000000..fb6942a --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/CallToConsumer.java @@ -0,0 +1,53 @@ +package ru.myitschool.work.data; + +import androidx.annotation.NonNull; + +import java.util.function.Consumer; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import ru.myitschool.work.domain.entities.Status; + +public class CallToConsumer implements Callback { + @NonNull + private final Consumer> callback; + + @NonNull + private final Mapper mapper; + + public CallToConsumer( + @NonNull Consumer> callback, + @NonNull Mapper mapper + ) { + this.callback = callback; + this.mapper = mapper; + } + + + @Override + public void onResponse(@NonNull Call call, @NonNull Response response) { + callback.accept( + new Status<>( + response.code(), + mapper.map(response.body()), + null + ) + ); + } + + @Override + public void onFailure(@NonNull Call call, @NonNull Throwable throwable) { + callback.accept( + new Status<>( + -1, + null, + throwable + ) + ); + } + + public interface Mapper { + DEST map(SOURCE source); + } +} diff --git a/app/src/main/java/ru/myitschool/work/data/UserResponseImpl.java b/app/src/main/java/ru/myitschool/work/data/UserResponseImpl.java new file mode 100644 index 0000000..785d6fb --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/UserResponseImpl.java @@ -0,0 +1,90 @@ +package ru.myitschool.work.data; + +import androidx.annotation.NonNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +import ru.myitschool.work.data.dto.HistoryDto; +import ru.myitschool.work.data.dto.UserDto; +import ru.myitschool.work.data.network.RetrofitFactory; +import ru.myitschool.work.data.source.CredentialsDataSource; +import ru.myitschool.work.data.source.UserApi; +import ru.myitschool.work.domain.entities.HistoryEntity; +import ru.myitschool.work.domain.entities.Status; +import ru.myitschool.work.domain.entities.UserEntity; + +public class UserResponseImpl { + + private static UserResponseImpl INSTANCE; + private UserApi userApi = RetrofitFactory.getInstance().getUserApi(); + private final CredentialsDataSource credentialsDataSource = CredentialsDataSource.getInstance(); + + private UserResponseImpl() {} + + public static synchronized UserResponseImpl getInstance() { + if (INSTANCE == null) { + INSTANCE = new UserResponseImpl(); + } + return INSTANCE; + } + + + public void getAllUsers(@NonNull Consumer>> callback) { + userApi.getAllUsers().enqueue(new CallToConsumer<>( + callback, + usersDto -> { + ArrayList result = new ArrayList<>(usersDto.size()); + for (UserDto user : usersDto) { + final String username = user.username; + final String photo = user.photo; + final Long lastVisit = user.lastVisit; + final Integer idUser = user.idUser; + final String position = user.position; + if (idUser != null && username != null) { + result.add(new UserEntity(username, photo, lastVisit, idUser, position)); + } + } + return result; + } + )); + + } + + public void getAllUserHistory(@NonNull Integer id, @NonNull Consumer>> callback) { + userApi.getAllUserHistory(id).enqueue(new CallToConsumer<>( + callback, + historiesDto -> { + ArrayList result = new ArrayList<>(historiesDto.size()); + for (HistoryDto history : historiesDto) { + final Integer id1 = history.id; + final Integer idUser = history.idUser; + final Long time = history.time; + final String nameReader = history.nameReader; + final String type = history.type; + if (idUser != null && id1 != null){ + result.add(new HistoryEntity(id1, idUser, time, nameReader, type)); + } + } + return result; + } + )); + } + + public void login(@NonNull String username, @NonNull String password, Consumer> callback) { + credentialsDataSource.updateLogin(username, password); + userApi = RetrofitFactory.getInstance().getUserApi(); + userApi.login().enqueue(new CallToConsumer<>( + callback, + dto -> null + )); + } + + + + public void logout() { + credentialsDataSource.logout(); + } + +} diff --git a/app/src/main/java/ru/myitschool/work/data/dto/HistoryDto.java b/app/src/main/java/ru/myitschool/work/data/dto/HistoryDto.java new file mode 100644 index 0000000..88c7179 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/dto/HistoryDto.java @@ -0,0 +1,30 @@ +package ru.myitschool.work.data.dto; + +import androidx.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class HistoryDto { + @Nullable + @SerializedName("id") + public Integer id; + + @Nullable + @SerializedName("idUser") + public Integer idUser; + + @Nullable + @SerializedName("time") + public Long time; + + @Nullable + @SerializedName("nameReader") + public String nameReader; + + @Nullable + @SerializedName("type") + public String type; + + + +} diff --git a/app/src/main/java/ru/myitschool/work/data/dto/ReaderDto.java b/app/src/main/java/ru/myitschool/work/data/dto/ReaderDto.java new file mode 100644 index 0000000..dd6ba99 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/dto/ReaderDto.java @@ -0,0 +1,17 @@ +package ru.myitschool.work.data.dto; + +import androidx.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class ReaderDto { + @Nullable + @SerializedName("idReader") + public Integer idReader; + + @Nullable + @SerializedName("typeReader") + public Integer typeReader; + + +} diff --git a/app/src/main/java/ru/myitschool/work/data/dto/RoleDto.java b/app/src/main/java/ru/myitschool/work/data/dto/RoleDto.java new file mode 100644 index 0000000..3f1f8b7 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/dto/RoleDto.java @@ -0,0 +1,18 @@ +package ru.myitschool.work.data.dto; + +import androidx.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class RoleDto { + @Nullable + @SerializedName("idUser") + public Integer idUser; + + @Nullable + @SerializedName("status") + public int status; + + + +} diff --git a/app/src/main/java/ru/myitschool/work/data/dto/UserDto.java b/app/src/main/java/ru/myitschool/work/data/dto/UserDto.java new file mode 100644 index 0000000..019ffce --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/dto/UserDto.java @@ -0,0 +1,116 @@ +package ru.myitschool.work.data.dto; + +import androidx.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class UserDto { + @Nullable + @SerializedName("username") + public String username; + + @Nullable + @SerializedName("password") + public String password; + + @Nullable + @SerializedName("photo") + public String photo; + + @Nullable + @SerializedName("lastVisit") + public Long lastVisit; + + @Nullable + @SerializedName("idUser") + public Integer idUser; + + @Nullable + @SerializedName("status") + public int status; + + @Nullable + @SerializedName("position") + public String position; + + public UserDto(@Nullable String username, @Nullable String password, @Nullable String photo, @Nullable Long lastVisit, @Nullable Integer idUser, int status, @Nullable String position) { + this.username = username; + this.password = password; + this.photo = photo; + this.lastVisit = lastVisit; + this.idUser = idUser; + this.status = status; + this.position = position; + } + + @Nullable + public String getPosition() { + return position; + } + + public void setPosition(@Nullable String position) { + this.position = position; + } + + @Nullable + public String getUsername() { + return username; + } + + public void setUsername(@Nullable String username) { + this.username = username; + } + + @Nullable + public String getPassword() { + return password; + } + + public void setPassword(@Nullable String password) { + this.password = password; + } + + + @Nullable + public String getPhoto() { + return photo; + } + + public void setPhoto(@Nullable String photo) { + this.photo = photo; + } + + @Nullable + public Long getLastVisit() { + return lastVisit; + } + + public void setLastVisit(@Nullable Long lastVisit) { + this.lastVisit = lastVisit; + } + + @Nullable + public Integer getIdUser() { + return idUser; + } + + public void setIdUser(@Nullable Integer idUser) { + this.idUser = idUser; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + + + + + + + +} diff --git a/app/src/main/java/ru/myitschool/work/data/network/RetrofitFactory.java b/app/src/main/java/ru/myitschool/work/data/network/RetrofitFactory.java new file mode 100644 index 0000000..6e428fe --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/network/RetrofitFactory.java @@ -0,0 +1,49 @@ +package ru.myitschool.work.data.network; + +import okhttp3.OkHttpClient; +import okhttp3.Request; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; +import ru.myitschool.work.data.source.CredentialsDataSource; +import ru.myitschool.work.data.source.UserApi; + +public class RetrofitFactory { + private static RetrofitFactory INSTANCE; + + private RetrofitFactory() {} + + public static synchronized RetrofitFactory getInstance() { + if (INSTANCE == null) { + INSTANCE = new RetrofitFactory(); + } + return INSTANCE; + } + + private final OkHttpClient.Builder client = new OkHttpClient.Builder() + .addInterceptor(chain -> { + String authData = CredentialsDataSource.getInstance().getAuthData(); + if (authData == null) { + return chain.proceed(chain.request()); + } else { + Request request = chain.request() + .newBuilder() + .addHeader("Authorization", authData) + .build(); + return chain.proceed(request); + } + + } + ); + + + private final Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://10.0.2.2:8080/") + .client(client.build()) + .addConverterFactory(GsonConverterFactory.create()) + .build(); + + public UserApi getUserApi() { + return retrofit.create(UserApi.class); + } + } + diff --git a/app/src/main/java/ru/myitschool/work/data/source/CredentialsDataSource.java b/app/src/main/java/ru/myitschool/work/data/source/CredentialsDataSource.java new file mode 100644 index 0000000..b383a29 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/source/CredentialsDataSource.java @@ -0,0 +1,36 @@ +package ru.myitschool.work.data.source; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import okhttp3.Credentials; + +public class CredentialsDataSource { + private static CredentialsDataSource INSTANCE; + + private CredentialsDataSource() {} + + public static synchronized CredentialsDataSource getInstance() { + if (INSTANCE == null) { + INSTANCE = new CredentialsDataSource(); + } + return INSTANCE; + } + + @Nullable + private String authData = null; + + @Nullable + public String getAuthData() { + return authData; + } + + public void updateLogin(@NonNull String username, @NonNull String password) { + authData = Credentials.basic(username, password); + } + + public void logout() { + authData = null; + } +} + diff --git a/app/src/main/java/ru/myitschool/work/data/source/UserApi.java b/app/src/main/java/ru/myitschool/work/data/source/UserApi.java new file mode 100644 index 0000000..61f40c4 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/data/source/UserApi.java @@ -0,0 +1,29 @@ +package ru.myitschool.work.data.source; + +import java.util.List; + +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.Path; +import ru.myitschool.work.data.dto.HistoryDto; +import ru.myitschool.work.data.dto.UserDto; +import ru.myitschool.work.ui.History; + + +public interface UserApi { + @GET("api/user") + Call> getAllUsers(); + @GET("api/user/{id}") + Call getUserById(@Path("id") Integer id); + @GET("api/user/username/{username}") + Call isUserExist(@Path("username") String username); + @GET("api/user/login") + Call login(); + @GET("api/history/user/{id}") + Call> getAllUserHistory(@Path("id") Integer id); + @GET("api/history/{id}") + Call getHistoryById(@Path("id") Integer id); + +} diff --git a/app/src/main/java/ru/myitschool/work/domain/entities/HistoryEntity.java b/app/src/main/java/ru/myitschool/work/domain/entities/HistoryEntity.java new file mode 100644 index 0000000..638f72b --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/domain/entities/HistoryEntity.java @@ -0,0 +1,81 @@ +package ru.myitschool.work.domain.entities; + +import androidx.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class HistoryEntity { + @Nullable + @SerializedName("id") + public Integer id; + + @Nullable + public Integer getId() { + return id; + } + + public void setId(@Nullable Integer id) { + this.id = id; + } + + @Nullable + public Integer getIdUser() { + return idUser; + } + + public void setIdUser(@Nullable Integer idUser) { + this.idUser = idUser; + } + + @Nullable + public Long getTime() { + return time; + } + + public void setTime(@Nullable Long time) { + this.time = time; + } + + @Nullable + public String getNameReader() { + return nameReader; + } + + public void setNameReader(@Nullable String nameReader) { + this.nameReader = nameReader; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + public HistoryEntity(@Nullable Integer id, @Nullable Integer idUser, @Nullable Long time, @Nullable String nameReader, @Nullable String type) { + this.id = id; + this.idUser = idUser; + this.time = time; + this.nameReader = nameReader; + this.type = type; + } + + @Nullable + @SerializedName("idUser") + public Integer idUser; + + @Nullable + @SerializedName("time") + public Long time; + + @Nullable + @SerializedName("nameReader") + public String nameReader; + + @Nullable + @SerializedName("type") + public String type; + +} diff --git a/app/src/main/java/ru/myitschool/work/domain/entities/RoleEntity.java b/app/src/main/java/ru/myitschool/work/domain/entities/RoleEntity.java new file mode 100644 index 0000000..0d7163e --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/domain/entities/RoleEntity.java @@ -0,0 +1,39 @@ +package ru.myitschool.work.domain.entities; + +import androidx.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class RoleEntity { + @Nullable + @SerializedName("idUser") + public Integer idUser; + + @Nullable + @SerializedName("status") + public int status; + + public RoleEntity(@Nullable Integer idUser, int status) { + this.idUser = idUser; + this.status = status; + } + + @Nullable + public Integer getIdUser() { + return idUser; + } + + public void setIdUser(@Nullable Integer idUser) { + this.idUser = idUser; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + +} diff --git a/app/src/main/java/ru/myitschool/work/domain/entities/Status.java b/app/src/main/java/ru/myitschool/work/domain/entities/Status.java new file mode 100644 index 0000000..10fcb7b --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/domain/entities/Status.java @@ -0,0 +1,35 @@ +package ru.myitschool.work.domain.entities; + +import androidx.annotation.Nullable; + +public class Status{ + private final int statusCode; + + @Nullable + private final T value; + + @Nullable + private final Throwable errors; + + public Status(int statusCode, @Nullable T value, @Nullable Throwable errors) { + this.statusCode = statusCode; + this.value = value; + this.errors = errors; + } + + public int getStatusCode() { + return statusCode; + } + + @Nullable + public T getValue() { + return value; + } + + @Nullable + public Throwable getErrors() { + return errors; + } + +} + diff --git a/app/src/main/java/ru/myitschool/work/domain/entities/UserEntity.java b/app/src/main/java/ru/myitschool/work/domain/entities/UserEntity.java new file mode 100644 index 0000000..6d70fd7 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/domain/entities/UserEntity.java @@ -0,0 +1,85 @@ +package ru.myitschool.work.domain.entities; + +import androidx.annotation.Nullable; + +import com.google.gson.annotations.SerializedName; + +public class UserEntity { + @Nullable + @SerializedName("username") + public String username; + + + @Nullable + @SerializedName("photo") + public String photo; + + @Nullable + @SerializedName("lastVisit") + public Long lastVisit; + + @Nullable + @SerializedName("idUser") + public Integer idUser; + + + @Nullable + @SerializedName("position") + public String position; + + public UserEntity(@Nullable String username, @Nullable String photo, @Nullable Long lastVisit, @Nullable Integer idUser, @Nullable String position) { + this.username = username; + this.photo = photo; + this.lastVisit = lastVisit; + this.idUser = idUser; + this.position = position; + } + + @Nullable + public String getPosition() { + return position; + } + + public void setPosition(@Nullable String position) { + this.position = position; + } + + @Nullable + public String getUsername() { + return username; + } + + public void setUsername(@Nullable String username) { + this.username = username; + } + + @Nullable + public String getPhoto() { + return photo; + } + + public void setPhoto(@Nullable String photo) { + this.photo = photo; + } + + @Nullable + public Long getLastVisit() { + return lastVisit; + } + + public void setLastVisit(@Nullable Long lastVisit) { + this.lastVisit = lastVisit; + } + + @Nullable + public Integer getIdUser() { + return idUser; + } + + public void setIdUser(@Nullable Integer idUser) { + this.idUser = idUser; + } + + + +} diff --git a/app/src/main/java/ru/myitschool/work/ui/History.java b/app/src/main/java/ru/myitschool/work/ui/History.java new file mode 100644 index 0000000..cd03692 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/ui/History.java @@ -0,0 +1,41 @@ +package ru.myitschool.work.ui; + +public class History { + private Long time; + private String nameReader; + private int type; //1 - qr 2 - карта + + + public History(Long time, String nameReader, int passageType) { + this.time = time; + this.nameReader = nameReader; + this.type = passageType; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } + + public String getNameReader() { + return nameReader; + } + + public void setNameReader(String nameReader) { + this.nameReader = nameReader; + } + + public int getPassageType() { + return type; + } + + public void setPassageType(int passageType) { + this.type = passageType; + } + + + +} diff --git a/app/src/main/java/ru/myitschool/work/ui/HistoryAdapter.java b/app/src/main/java/ru/myitschool/work/ui/HistoryAdapter.java new file mode 100644 index 0000000..bf38fc2 --- /dev/null +++ b/app/src/main/java/ru/myitschool/work/ui/HistoryAdapter.java @@ -0,0 +1,69 @@ +package ru.myitschool.work.ui; + +import android.annotation.SuppressLint; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; +import java.util.List; + +import ru.myitschool.work.databinding.ItemHistoryBinding; + +public class HistoryAdapter extends RecyclerView.Adapter { + + private final List data = new ArrayList<>(); + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ViewHolder( + ItemHistoryBinding.inflate( + LayoutInflater.from(parent.getContext()), + parent, + false + ).getRoot() + ); + + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + holder.bind(data.get(position)); + } + + @Override + public int getItemCount() { + return data.size(); + } + + public void updateData(List newData) { + data.clear(); + data.addAll(newData); + notifyDataSetChanged(); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + private final ItemHistoryBinding binding; + + public ViewHolder(@NonNull View itemView) { + super(itemView); + binding = ItemHistoryBinding.bind(itemView); + } + + public void bind(History item) { + binding.time.setText(item.getTime().toString().substring(0, 10) + " " + + item.getTime().toString().substring(11, 16)); + binding.nameReader.setText(item.getNameReader()); + if (item.getPassageType() == 1){ + binding.type.setText("QR-code"); + } + else{ + binding.type.setText("Карта"); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/myitschool/work/ui/InformationFragment.java b/app/src/main/java/ru/myitschool/work/ui/InformationFragment.java index f7ad481..1e96c75 100644 --- a/app/src/main/java/ru/myitschool/work/ui/InformationFragment.java +++ b/app/src/main/java/ru/myitschool/work/ui/InformationFragment.java @@ -13,10 +13,11 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentResultListener; import androidx.navigation.Navigation; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.squareup.picasso.Picasso; +import java.util.ArrayList; + import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -30,6 +31,7 @@ import ru.myitschool.work.ui.qr.scan.QrScanFragment; public class InformationFragment extends Fragment { FragmentInformationBinding binding; SharedPreferences sharedPreferences; + ArrayList history = new ArrayList<>(); @Nullable @Override @@ -47,16 +49,20 @@ public class InformationFragment extends Fragment { getInformation(); binding.scan.setOnClickListener(view1 -> { - onClickScan(view); + onClickScan(); }); binding.logout.setOnClickListener(view2 -> { - onClickLogout(view); + onClickLogout(); }); binding.refreshLayout.setOnRefreshListener(() -> { onClickRefresh(); }); + //TODO: SERVER ZAGRUZKA LISTAAAAAAAAAAAAAAA + HistoryAdapter adapter = new HistoryAdapter(); + binding.historylist.setAdapter(adapter); + adapter.updateData(history); //getParentFragmentManager() requireActivity().getSupportFragmentManager().setFragmentResultListener(QrScanDestination.REQUEST_KEY, getViewLifecycleOwner(), (requestKey, result) -> { diff --git a/app/src/main/java/ru/myitschool/work/ui/User.java b/app/src/main/java/ru/myitschool/work/ui/User.java index aec09dc..92c8f5b 100644 --- a/app/src/main/java/ru/myitschool/work/ui/User.java +++ b/app/src/main/java/ru/myitschool/work/ui/User.java @@ -1,6 +1,7 @@ package ru.myitschool.work.ui; -public class User { +public class +User { private int id; private String login; @@ -8,14 +9,16 @@ public class User { private String photo; private String position; private String lastVisit; + private int role; // 1 - сотрудник 2 - админ - public User(int id, String login, String name, String photo, String position, String lastVisit) { + public User(int id, String login, String name, String photo, String position, String lastVisit, int role) { this.id = id; this.login = login; this.name = name; this.photo = photo; this.position = position; this.lastVisit = lastVisit; + this.role = role; } public int getId() { @@ -65,4 +68,8 @@ public class User { public void setLastVisit(String lastVisit) { this.lastVisit = lastVisit; } + public int getRole(int role){return role;} + public void setRole(int role){this.role = role;} + + } diff --git a/app/src/main/java/ru/myitschool/work/ui/login/LoginFragment.java b/app/src/main/java/ru/myitschool/work/ui/login/LoginFragment.java index 3730d44..33ab45d 100644 --- a/app/src/main/java/ru/myitschool/work/ui/login/LoginFragment.java +++ b/app/src/main/java/ru/myitschool/work/ui/login/LoginFragment.java @@ -1,10 +1,11 @@ -package ru.myitschool.work.ui.login; +package ru.myitschool.work.ui; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -66,13 +67,6 @@ public class LoginFragment extends Fragment { } } }); - binding.password.addTextChangedListener(new OnChangeText() { - @Override - public void afterTextChanged(Editable s) { - super.afterTextChanged(s); - viewModel.changePassword(s.toString()); - } - }); binding.username.addTextChangedListener(new TextWatcher() { @Override @@ -100,6 +94,30 @@ public class LoginFragment extends Fragment { } }); + binding.password.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + viewModel.changePassword(s.toString()); + if (binding.password.getText().length() >= 5) { + binding.login.setEnabled(true); + } else { + binding.login.setEnabled(false); + } + if (binding.error.getVisibility() == View.VISIBLE) { + binding.error.setVisibility(View.GONE); + } + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); binding.login.setOnClickListener(view1 -> { viewModel.confirm(); diff --git a/app/src/main/res/layout/fragment_information.xml b/app/src/main/res/layout/fragment_information.xml index 8e16bf4..b4f8704 100644 --- a/app/src/main/res/layout/fragment_information.xml +++ b/app/src/main/res/layout/fragment_information.xml @@ -79,6 +79,13 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/> + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_history.xml b/app/src/main/res/layout/item_history.xml new file mode 100644 index 0000000..be3b98d --- /dev/null +++ b/app/src/main/res/layout/item_history.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + \ No newline at end of file