add Success Screen
This commit is contained in:
parent
2b57d35553
commit
8ac97437a2
@ -13,6 +13,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.view.animation.OvershootInterpolator;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -79,6 +80,11 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
private String emvTlvData;
|
private String emvTlvData;
|
||||||
private String referenceId;
|
private String referenceId;
|
||||||
|
|
||||||
|
// deklarasi variabel success screen
|
||||||
|
private LinearLayout successScreen;
|
||||||
|
private ImageView successIcon;
|
||||||
|
private TextView successMessage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -117,6 +123,10 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
btn0 = findViewById(R.id.btn_0);
|
btn0 = findViewById(R.id.btn_0);
|
||||||
btn00 = findViewById(R.id.btn_00);
|
btn00 = findViewById(R.id.btn_00);
|
||||||
btnClear = findViewById(R.id.btn_clear);
|
btnClear = findViewById(R.id.btn_clear);
|
||||||
|
|
||||||
|
successScreen = findViewById(R.id.success_screen);
|
||||||
|
successIcon = findViewById(R.id.success_icon);
|
||||||
|
successMessage = findViewById(R.id.success_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initManagers() {
|
private void initManagers() {
|
||||||
@ -234,6 +244,7 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
// Show modal and start card scanning
|
// Show modal and start card scanning
|
||||||
showModalAndStartScanning();
|
showModalAndStartScanning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showModalAndStartScanning() {
|
private void showModalAndStartScanning() {
|
||||||
Log.d(TAG, "Starting card scanning with modal...");
|
Log.d(TAG, "Starting card scanning with modal...");
|
||||||
@ -366,7 +377,6 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public void onTransactionSuccess(int code, String desc) {
|
public void onTransactionSuccess(int code, String desc) {
|
||||||
Log.d(TAG, "EMV Transaction successful");
|
Log.d(TAG, "EMV Transaction successful");
|
||||||
modalManager.hideModal();
|
|
||||||
|
|
||||||
// ✅ NEW: Process Midtrans payment after successful EMV
|
// ✅ NEW: Process Midtrans payment after successful EMV
|
||||||
if (useDirectMidtransPayment && emvCardNumber != null) {
|
if (useDirectMidtransPayment && emvCardNumber != null) {
|
||||||
@ -395,6 +405,34 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showSuccessScreen(Runnable onAnimationComplete) {
|
||||||
|
// Hide modal first
|
||||||
|
modalManager.hideModal();
|
||||||
|
|
||||||
|
// Show success screen
|
||||||
|
successScreen.setVisibility(View.VISIBLE);
|
||||||
|
successScreen.setAlpha(0f);
|
||||||
|
|
||||||
|
// Fade in animation
|
||||||
|
successScreen.animate()
|
||||||
|
.alpha(1f)
|
||||||
|
.setDuration(500)
|
||||||
|
.withStartAction(() -> {
|
||||||
|
// Scale and bounce animation for icon
|
||||||
|
successIcon.setScaleX(0f);
|
||||||
|
successIcon.setScaleY(0f);
|
||||||
|
successIcon.animate()
|
||||||
|
.scaleX(1f).scaleY(1f)
|
||||||
|
.setDuration(800)
|
||||||
|
.setInterpolator(new OvershootInterpolator(1.2f))
|
||||||
|
.start();
|
||||||
|
})
|
||||||
|
.withEndAction(() -> {
|
||||||
|
// Wait for 1.5 seconds then execute next action
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(onAnimationComplete, 1500);
|
||||||
|
})
|
||||||
|
.start();
|
||||||
|
}
|
||||||
// ====== PIN PAD CALLBACK METHODS ======
|
// ====== PIN PAD CALLBACK METHODS ======
|
||||||
@Override
|
@Override
|
||||||
public void onPinInputLength(int length) {
|
public void onPinInputLength(int length) {
|
||||||
@ -448,7 +486,6 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public void onChargeSuccess(JSONObject chargeResponse) {
|
public void onChargeSuccess(JSONObject chargeResponse) {
|
||||||
Log.d(TAG, "✅ Midtrans charge successful!");
|
Log.d(TAG, "✅ Midtrans charge successful!");
|
||||||
modalManager.hideModal();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String transactionId = chargeResponse.getString("transaction_id");
|
String transactionId = chargeResponse.getString("transaction_id");
|
||||||
@ -565,40 +602,44 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void navigateToResults(String cardType, Bundle cardData, String cardNo) {
|
private void navigateToResults(String cardType, Bundle cardData, String cardNo) {
|
||||||
modalManager.hideModal();
|
// modalManager.hideModal();
|
||||||
|
|
||||||
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
showSuccessScreen(() -> {
|
||||||
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
||||||
intent.putExtra("CARD_TYPE", cardType);
|
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
||||||
intent.putExtra("EMV_MODE", isEMVMode);
|
intent.putExtra("CARD_TYPE", cardType);
|
||||||
intent.putExtra("REFERENCE_ID", referenceId);
|
intent.putExtra("EMV_MODE", isEMVMode);
|
||||||
|
intent.putExtra("REFERENCE_ID", referenceId);
|
||||||
if (cardData != null) {
|
|
||||||
intent.putExtra("CARD_DATA", cardData);
|
if (cardData != null) {
|
||||||
}
|
intent.putExtra("CARD_DATA", cardData);
|
||||||
if (cardNo != null) {
|
}
|
||||||
intent.putExtra("CARD_NO", cardNo);
|
if (cardNo != null) {
|
||||||
}
|
intent.putExtra("CARD_NO", cardNo);
|
||||||
|
}
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ NEW: Navigate to results with Midtrans payment data
|
// ✅ NEW: Navigate to results with Midtrans payment data
|
||||||
private void navigateToMidtransResults(JSONObject midtransResponse) {
|
private void navigateToMidtransResults(JSONObject midtransResponse) {
|
||||||
modalManager.hideModal();
|
// modalManager.hideModal();
|
||||||
|
|
||||||
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
showSuccessScreen(() -> {
|
||||||
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
||||||
intent.putExtra("CARD_TYPE", "EMV_MIDTRANS");
|
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
||||||
intent.putExtra("EMV_MODE", true);
|
intent.putExtra("CARD_TYPE", "EMV_MIDTRANS");
|
||||||
intent.putExtra("REFERENCE_ID", referenceId);
|
intent.putExtra("EMV_MODE", true);
|
||||||
intent.putExtra("CARD_NO", emvCardNumber);
|
intent.putExtra("REFERENCE_ID", referenceId);
|
||||||
intent.putExtra("MIDTRANS_RESPONSE", midtransResponse.toString());
|
intent.putExtra("CARD_NO", emvCardNumber);
|
||||||
intent.putExtra("PAYMENT_SUCCESS", true);
|
intent.putExtra("MIDTRANS_RESPONSE", midtransResponse.toString());
|
||||||
|
intent.putExtra("PAYMENT_SUCCESS", true);
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restartScanningAfterDelay() {
|
private void restartScanningAfterDelay() {
|
||||||
@ -694,6 +735,11 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
|||||||
modalManager.hideModal();
|
modalManager.hideModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide success screen if showing
|
||||||
|
if (successScreen != null && successScreen.getVisibility() == View.VISIBLE) {
|
||||||
|
successScreen.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error during cleanup: " + e.getMessage());
|
Log.e(TAG, "Error during cleanup: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -292,4 +292,37 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/success_screen"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="#E31937"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:elevation="100dp">
|
||||||
|
|
||||||
|
<!-- Success Icon -->
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/success_icon"
|
||||||
|
android:layout_width="120dp"
|
||||||
|
android:layout_height="120dp"
|
||||||
|
android:src="@drawable/ic_success_payment"
|
||||||
|
android:layout_marginBottom="32dp"
|
||||||
|
android:scaleType="centerInside"/>
|
||||||
|
|
||||||
|
<!-- Success Message -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/success_message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Pembayaran Berhasil"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="@font/inter"
|
||||||
|
android:gravity="center"
|
||||||
|
android:letterSpacing="0.02"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Loading…
x
Reference in New Issue
Block a user