diff --git a/app/src/main/java/com/example/bdkipoc/LoginActivity.java b/app/src/main/java/com/example/bdkipoc/LoginActivity.java
index 19bc1dd..471b647 100644
--- a/app/src/main/java/com/example/bdkipoc/LoginActivity.java
+++ b/app/src/main/java/com/example/bdkipoc/LoginActivity.java
@@ -39,6 +39,8 @@ public class LoginActivity extends AppCompatActivity {
private ProgressBar progressBar;
private ExecutorService executor;
+ private String currentPassword;
+
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
@@ -119,6 +121,8 @@ public class LoginActivity extends AppCompatActivity {
private void performLogin(String identifier, String password) {
setLoadingState(true);
+ currentPassword = password;
+
executor.execute(() -> {
try {
// Create JSON payload
@@ -193,7 +197,14 @@ public class LoginActivity extends AppCompatActivity {
JSONObject userData = result.getJSONObject("user");
// Save login data
- saveLoginData(token, userData.toString());
+ // saveLoginData(token, userData.toString());
+ SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putString(KEY_TOKEN, token);
+ editor.putString(KEY_USER_DATA, userData.toString());
+ editor.putBoolean(KEY_IS_LOGGED_IN, true);
+ editor.putString("current_password", currentPassword);
+ editor.apply();
Toast.makeText(this, "Login berhasil! " + message, Toast.LENGTH_SHORT).show();
diff --git a/app/src/main/java/com/example/bdkipoc/infotoko/InfoTokoActivity.java b/app/src/main/java/com/example/bdkipoc/infotoko/InfoTokoActivity.java
index dec501d..804580f 100644
--- a/app/src/main/java/com/example/bdkipoc/infotoko/InfoTokoActivity.java
+++ b/app/src/main/java/com/example/bdkipoc/infotoko/InfoTokoActivity.java
@@ -1,10 +1,13 @@
package com.example.bdkipoc.infotoko;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.text.InputType;
import android.view.View;
import android.view.ViewParent;
import android.widget.EditText;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.util.Log;
@@ -18,6 +21,8 @@ import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
+import android.text.method.PasswordTransformationMethod;
+
import org.json.JSONException;
import org.json.JSONObject;
@@ -40,11 +45,12 @@ public class InfoTokoActivity extends AppCompatActivity {
private TextInputEditText etAddress;
private MaterialButton btnUpdate;
- private ImageView btnBack;
+ private LinearLayout backNavigation; // Changed from ImageView to LinearLayout
// Data
private String authToken;
private JSONObject userData;
+ private String userPassword; // Add password storage
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -75,7 +81,15 @@ public class InfoTokoActivity extends AppCompatActivity {
tvStoreName = findViewById(R.id.tv_store_name);
tvMerchantId = findViewById(R.id.tv_merchant_id);
tvTerminalId = findViewById(R.id.tv_terminal_id);
- btnBack = findViewById(R.id.btn_back);
+
+ // Find the back navigation from the included layout
+ backNavigation = findViewById(R.id.back_navigation);
+
+ // Optionally, you can also update the title in the appbar
+ TextView appbarTitle = findViewById(R.id.appbarTitle);
+ if (appbarTitle != null) {
+ appbarTitle.setText("Kembali");
+ }
// Account Information
etEmail = findViewById(R.id.et_email);
@@ -114,20 +128,59 @@ public class InfoTokoActivity extends AppCompatActivity {
userData = LoginActivity.getUserDataAsJson(this);
}
+ // Get saved password from SharedPreferences
+ SharedPreferences prefs = getSharedPreferences("LoginPrefs", MODE_PRIVATE);
+ userPassword = prefs.getString("current_password", ""); // Fix: use correct key
+
Log.d(TAG, "Loaded auth token: " + (authToken != null ? "✓" : "✗"));
Log.d(TAG, "Loaded user data: " + (userData != null ? "✓" : "✗"));
+ Log.d(TAG, "Loaded password: " + (!userPassword.isEmpty() ? "✓" : "✗"));
}
private void setupListeners() {
- // Back button
- if (btnBack != null) {
- btnBack.setOnClickListener(v -> finish());
+ // Back button - now using the LinearLayout
+ if (backNavigation != null) {
+ backNavigation.setOnClickListener(v -> {
+ Log.d(TAG, "Back button clicked");
+ finish();
+ });
+ } else {
+ Log.e(TAG, "Back navigation not found!");
}
// Update button
if (btnUpdate != null) {
btnUpdate.setOnClickListener(v -> updateStoreInfo());
}
+
+ // Password toggle listener
+ setupPasswordToggle();
+ }
+
+ private void setupPasswordToggle() {
+ ViewParent passwordParentView = etPassword.getParent().getParent();
+ if (passwordParentView instanceof TextInputLayout) {
+ TextInputLayout passwordLayout = (TextInputLayout) passwordParentView;
+
+ // Set initial state to visible
+ etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
+
+ passwordLayout.setEndIconOnClickListener(v -> {
+ // Toggle password visibility
+ if (etPassword.getTransformationMethod() == null) {
+ // Hide password
+ etPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
+ passwordLayout.setEndIconDrawable(R.drawable.ic_visibility_off); // Set your eye-off icon
+ } else {
+ // Show password
+ etPassword.setTransformationMethod(null);
+ passwordLayout.setEndIconDrawable(R.drawable.ic_visibility); // Set your eye icon
+ }
+
+ // Move cursor to end
+ etPassword.setSelection(etPassword.getText().length());
+ });
+ }
}
private void displayStoreInfo() {
@@ -150,9 +203,33 @@ public class InfoTokoActivity extends AppCompatActivity {
etEmail.setText("Email tidak tersedia");
}
- // Password - show masked placeholder (we don't store actual password)
- etPassword.setText("••••••••");
- etPassword.setEnabled(false); // Disable editing for security
+ // Password - show actual password from SharedPreferences (VISIBLE by default)
+ if (!userPassword.isEmpty()) {
+ etPassword.setText(userPassword);
+ // Start with password visible
+ etPassword.setTransformationMethod(null);
+ // Refresh the eye icon state
+ ViewParent passwordParentView = etPassword.getParent().getParent();
+ if (passwordParentView instanceof TextInputLayout) {
+ ((TextInputLayout) passwordParentView).setEndIconDrawable(R.drawable.ic_visibility);
+ }
+ } else {
+ etPassword.setText("");
+ }
+ etPassword.setEnabled(true); // Enable for display with toggle
+
+ // Update the eye icon to show "hide" state initially
+ ViewParent passwordParentView = etPassword.getParent().getParent();
+ if (passwordParentView instanceof TextInputLayout) {
+ TextInputLayout passwordLayout = (TextInputLayout) passwordParentView;
+ passwordLayout.setPasswordVisibilityToggleEnabled(true);
+ // Force refresh the toggle icon
+ passwordLayout.refreshDrawableState();
+ }
+
+ // Debug log
+ Log.d(TAG, "Password field text: " + etPassword.getText().toString());
+ Log.d(TAG, "Password field length: " + etPassword.getText().length());
// Nama Pemilik - from API response
String ownerName = userData.optString("name", "");
@@ -210,7 +287,10 @@ public class InfoTokoActivity extends AppCompatActivity {
ViewParent addressContainer = etAddress.getParent();
if (addressContainer != null && addressContainer instanceof View) {
((View) addressContainer).setVisibility(View.GONE);
- }
+ }
+
+ // Update the section title to be more accurate
+ // Note: You'll need to add an ID to the section title TextView in the XML
}
private void updateStoreInfo() {
@@ -233,6 +313,13 @@ public class InfoTokoActivity extends AppCompatActivity {
// Show success message
Toast.makeText(this, "Informasi akun berhasil diperbarui", Toast.LENGTH_SHORT).show();
+ // If password was changed, inform user
+ String currentPasswordText = etPassword.getText().toString();
+ if (!currentPasswordText.isEmpty() && !currentPasswordText.equals(userPassword)) {
+ Toast.makeText(this, "Password berhasil diperbarui", Toast.LENGTH_SHORT).show();
+ userPassword = currentPasswordText; // Update local variable
+ }
+
// Reset button state
btnUpdate.setEnabled(true);
btnUpdate.setText("Perbarui Informasi Toko");
@@ -280,11 +367,20 @@ public class InfoTokoActivity extends AppCompatActivity {
return false;
}
+ // Check password if changed
+ String password = etPassword.getText().toString();
+ if (!password.isEmpty() && password.length() < 6) {
+ etPassword.setError("Password minimal 6 karakter");
+ etPassword.requestFocus();
+ return false;
+ }
+
return true;
}
private void saveUpdatedData() {
-
+ // In a real app, this would update the user data in SharedPreferences
+ // and call an API to update the server
try {
JSONObject updatedData = new JSONObject();
updatedData.put("email", etEmail.getText().toString().trim());
@@ -299,8 +395,22 @@ public class InfoTokoActivity extends AppCompatActivity {
// Add other fields as needed
}
+ // Save updated password to SharedPreferences
+ String newPassword = etPassword.getText().toString();
+ if (!newPassword.isEmpty() && !newPassword.equals(userPassword)) {
+ SharedPreferences prefs = getSharedPreferences("LoginPrefs", MODE_PRIVATE);
+ prefs.edit().putString("current_password", newPassword).apply(); // Fix: use correct key
+ Log.d(TAG, "Password updated in SharedPreferences");
+ }
+
Log.d(TAG, "Updated data: " + updatedData.toString());
-
+
+ // In real app, you would:
+ // 1. Call API to update user data
+ // 2. On success, update SharedPreferences:
+ // SharedPreferences prefs = getSharedPreferences("LoginPrefs", MODE_PRIVATE);
+ // prefs.edit().putString("user_data", updatedData.toString()).apply();
+
} catch (JSONException e) {
Log.e(TAG, "Error creating updated data: " + e.getMessage());
}
diff --git a/app/src/main/res/drawable/ic_logo_toko.png b/app/src/main/res/drawable/ic_logo_toko.png
new file mode 100644
index 0000000..d11533f
Binary files /dev/null and b/app/src/main/res/drawable/ic_logo_toko.png differ
diff --git a/app/src/main/res/drawable/ic_visibility.xml b/app/src/main/res/drawable/ic_visibility.xml
new file mode 100644
index 0000000..7e9f684
--- /dev/null
+++ b/app/src/main/res/drawable/ic_visibility.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_visibility_off.xml b/app/src/main/res/drawable/ic_visibility_off.xml
new file mode 100644
index 0000000..ee0514f
--- /dev/null
+++ b/app/src/main/res/drawable/ic_visibility_off.xml
@@ -0,0 +1,10 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/oval_blur_decoration.xml b/app/src/main/res/drawable/oval_blur_decoration.xml
new file mode 100644
index 0000000..902d4a9
--- /dev/null
+++ b/app/src/main/res/drawable/oval_blur_decoration.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/rounded_bottom_background.xml b/app/src/main/res/drawable/rounded_bottom_background.xml
new file mode 100644
index 0000000..0b9c2cd
--- /dev/null
+++ b/app/src/main/res/drawable/rounded_bottom_background.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_info_toko.xml b/app/src/main/res/layout/activity_info_toko.xml
index cbdfed3..0ff08be 100644
--- a/app/src/main/res/layout/activity_info_toko.xml
+++ b/app/src/main/res/layout/activity_info_toko.xml
@@ -5,37 +5,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:background="#E53935"
+ android:background="#FFFFFF"
tools:context=".InfoTokoActivity">
-
-
-
-
-
-
-
-
+
+
-
+ android:layout_height="wrap_content">
-
-
+
+
+
+
+
+ android:layout_marginStart="-40dp"
+ android:layout_marginTop="-30dp"
+ android:background="@drawable/oval_blur_decoration"
+ android:rotation="15" />
-
+
+
-
+
+
-
-
+
+
-
+
+
+
+
+ android:orientation="vertical"
+ android:gravity="center_horizontal"
+ android:paddingTop="16dp"
+ android:paddingBottom="40dp">
+
+
+
+
+
+
+
+
+ android:textSize="18sp"
+ android:textStyle="bold" />
-
+
+ android:orientation="horizontal"
+ android:layout_marginTop="8dp">
-
+
+
+
+
+
+
+
-
+
@@ -168,13 +200,14 @@
android:layout_marginTop="12dp"
android:hint="Kata Sandi"
app:passwordToggleEnabled="true"
+ app:endIconMode="password_toggle"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
@@ -308,9 +341,13 @@
android:text="Perbarui Informasi Toko"
android:textAllCaps="false"
android:textSize="16sp"
- android:textColor="@android:color/black"
- app:cornerRadius="28dp"
- android:backgroundTint="@android:color/white" />
+ android:textStyle="bold"
+ android:textColor="#DE0701"
+ android:backgroundTint="@android:color/white"
+ app:cornerRadius="8dp"
+ app:strokeColor="#DE0701"
+ app:strokeWidth="2dp" />
+