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.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -79,6 +80,11 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
||||
private String emvTlvData;
|
||||
private String referenceId;
|
||||
|
||||
// deklarasi variabel success screen
|
||||
private LinearLayout successScreen;
|
||||
private ImageView successIcon;
|
||||
private TextView successMessage;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -117,6 +123,10 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
||||
btn0 = findViewById(R.id.btn_0);
|
||||
btn00 = findViewById(R.id.btn_00);
|
||||
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() {
|
||||
@ -234,6 +244,7 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
||||
// Show modal and start card scanning
|
||||
showModalAndStartScanning();
|
||||
}
|
||||
|
||||
|
||||
private void showModalAndStartScanning() {
|
||||
Log.d(TAG, "Starting card scanning with modal...");
|
||||
@ -366,7 +377,6 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
||||
@Override
|
||||
public void onTransactionSuccess(int code, String desc) {
|
||||
Log.d(TAG, "EMV Transaction successful");
|
||||
modalManager.hideModal();
|
||||
|
||||
// ✅ NEW: Process Midtrans payment after successful EMV
|
||||
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 ======
|
||||
@Override
|
||||
public void onPinInputLength(int length) {
|
||||
@ -448,7 +486,6 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
||||
@Override
|
||||
public void onChargeSuccess(JSONObject chargeResponse) {
|
||||
Log.d(TAG, "✅ Midtrans charge successful!");
|
||||
modalManager.hideModal();
|
||||
|
||||
try {
|
||||
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) {
|
||||
modalManager.hideModal();
|
||||
// modalManager.hideModal();
|
||||
|
||||
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
||||
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
||||
intent.putExtra("CARD_TYPE", cardType);
|
||||
intent.putExtra("EMV_MODE", isEMVMode);
|
||||
intent.putExtra("REFERENCE_ID", referenceId);
|
||||
|
||||
if (cardData != null) {
|
||||
intent.putExtra("CARD_DATA", cardData);
|
||||
}
|
||||
if (cardNo != null) {
|
||||
intent.putExtra("CARD_NO", cardNo);
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
showSuccessScreen(() -> {
|
||||
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
||||
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
||||
intent.putExtra("CARD_TYPE", cardType);
|
||||
intent.putExtra("EMV_MODE", isEMVMode);
|
||||
intent.putExtra("REFERENCE_ID", referenceId);
|
||||
|
||||
if (cardData != null) {
|
||||
intent.putExtra("CARD_DATA", cardData);
|
||||
}
|
||||
if (cardNo != null) {
|
||||
intent.putExtra("CARD_NO", cardNo);
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
// ✅ NEW: Navigate to results with Midtrans payment data
|
||||
private void navigateToMidtransResults(JSONObject midtransResponse) {
|
||||
modalManager.hideModal();
|
||||
// modalManager.hideModal();
|
||||
|
||||
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
||||
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
||||
intent.putExtra("CARD_TYPE", "EMV_MIDTRANS");
|
||||
intent.putExtra("EMV_MODE", true);
|
||||
intent.putExtra("REFERENCE_ID", referenceId);
|
||||
intent.putExtra("CARD_NO", emvCardNumber);
|
||||
intent.putExtra("MIDTRANS_RESPONSE", midtransResponse.toString());
|
||||
intent.putExtra("PAYMENT_SUCCESS", true);
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
showSuccessScreen(() -> {
|
||||
Intent intent = new Intent(this, ResultTransactionActivity.class);
|
||||
intent.putExtra("TRANSACTION_AMOUNT", transactionAmount);
|
||||
intent.putExtra("CARD_TYPE", "EMV_MIDTRANS");
|
||||
intent.putExtra("EMV_MODE", true);
|
||||
intent.putExtra("REFERENCE_ID", referenceId);
|
||||
intent.putExtra("CARD_NO", emvCardNumber);
|
||||
intent.putExtra("MIDTRANS_RESPONSE", midtransResponse.toString());
|
||||
intent.putExtra("PAYMENT_SUCCESS", true);
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
private void restartScanningAfterDelay() {
|
||||
@ -694,6 +735,11 @@ public class CreateTransactionActivity extends AppCompatActivity implements
|
||||
modalManager.hideModal();
|
||||
}
|
||||
|
||||
// Hide success screen if showing
|
||||
if (successScreen != null && successScreen.getVisibility() == View.VISIBLE) {
|
||||
successScreen.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error during cleanup: " + e.getMessage());
|
||||
}
|
||||
|
@ -292,4 +292,37 @@
|
||||
|
||||
</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>
|
Loading…
x
Reference in New Issue
Block a user