Commit 2c5c9df7 authored by Amin's avatar Amin

add back function

parent 943b715b
......@@ -12,6 +12,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.Qms">
<activity
android:name=".TransactionDetails"
android:exported="false" />
<activity
android:name=".AccessItem"
android:exported="false" />
<activity
......
package com.example.qms;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
......@@ -10,6 +13,10 @@ import androidx.core.view.WindowInsetsCompat;
public class AccessItem extends AppCompatActivity {
private LinearLayout transactionDetail;
private ImageButton back_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -20,5 +27,17 @@ public class AccessItem extends AppCompatActivity {
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
transactionDetail = findViewById(R.id.transactionDetails);
back_button = findViewById(R.id.backButton);
transactionDetail.setOnClickListener(v -> {
Intent intent = new Intent(AccessItem.this, TransactionDetails.class);
startActivity(intent);
});
back_button.setOnClickListener(v -> {
onBackPressed();
});
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
......@@ -17,6 +18,8 @@ public class SyncActivity extends AppCompatActivity {
private Button syncButton;
private ImageButton back_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -29,6 +32,7 @@ public class SyncActivity extends AppCompatActivity {
});
syncButton = findViewById(R.id.sync_button);
back_button = findViewById(R.id.backButton);
syncButton.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -36,35 +40,43 @@ public class SyncActivity extends AppCompatActivity {
showAlertDialog();
}
});
back_button.setOnClickListener(v -> {
onBackPressed();
});
}
private void showAlertDialog() {
// Inflate your custom layout
View alertView = getLayoutInflater().inflate(R.layout.sync_alert, null);
// Create the AlertDialog builder
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Alert Title");
builder.setMessage("This is a simple alert message.");
builder.setCancelable(false); // User must click a button to dismiss
builder.setView(alertView);
// Add a positive button
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(SyncActivity.this, "OK clicked!", Toast.LENGTH_SHORT).show();
dialog.dismiss(); // Dismiss the dialog
}
});
// Create and show the dialog
AlertDialog dialog = builder.create();
dialog.show();
// Add a negative button (optional)
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(SyncActivity.this, "Cancel clicked!", Toast.LENGTH_SHORT).show();
dialog.dismiss(); // Dismiss the dialog
}
});
// Optional: make dialog background rounded if your layout has rounded corners
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
// Create and show the AlertDialog
AlertDialog alertDialog = builder.create();
alertDialog.show();
// Now find the buttons from your custom layout
Button noButton = alertView.findViewById(R.id.no_button);
Button yesButton = alertView.findViewById(R.id.yes_button);
// Handle clicks
noButton.setOnClickListener(v -> dialog.dismiss());
yesButton.setOnClickListener(v -> {
Toast.makeText(this, "Sync started!", Toast.LENGTH_SHORT).show();
dialog.dismiss();
});
}
}
package com.example.qms;
import android.os.Bundle;
import android.widget.ImageButton;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class TransactionDetails extends AppCompatActivity {
private ImageButton back_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_transaction_details);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
back_button = findViewById(R.id.backButton);
back_button.setOnClickListener(v -> {
onBackPressed();
});
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- This is the stroke you want to define -->
<stroke android:width="1dp"
android:color="@color/card_border"/>
<!-- Optional, round your corners -->
<corners android:bottomLeftRadius="21dp"
android:topLeftRadius="21dp"
android:bottomRightRadius="21dp"
android:topRightRadius="21dp" />
<!-- Optional, fill the rest of your background with a color or gradient, use transparent if you only want the border to be displayed-->
<gradient android:startColor="@android:color/white"
android:endColor="@android:color/white"
android:angle="90"/>
</shape>
\ No newline at end of file
......@@ -139,6 +139,7 @@
android:textStyle="bold" />
<LinearLayout
android:id="@+id/transactionDetails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_border"
......
This diff is collapsed.
......@@ -4,8 +4,9 @@
android:id="@+id/syncAlert"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintHeight="wrap_content"
app:layout_constraintWidth="300dp">
app:layout_constraintHeight="match_parent"
app:layout_constraintWidth="match_parent"
android:background="@drawable/alert_border">
<LinearLayout
android:layout_width="match_parent"
......@@ -13,7 +14,8 @@
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingHorizontal="30dp"
android:paddingVertical="30dp">
android:paddingVertical="30dp"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="56dp"
......@@ -200,42 +202,43 @@
app:useMaterialThemeColors="true" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:layout_marginVertical="20dp"
android:layout_marginBottom="20dp">
<Button
android:id="@+id/no_button"
android:layout_width="165dp"
android:layout_height="64dp"
android:layout_marginEnd="10dp"
android:backgroundTint="@color/white"
android:clickable="true"
android:focusable="true"
android:text="No"
android:textColor="@color/primary"
android:textSize="19sp"
app:cornerRadius="27dp"
app:strokeColor="@color/primary"
app:strokeWidth="1dp"/>
<Button
android:id="@+id/yes_button"
android:layout_width="165dp"
android:layout_height="64dp"
android:backgroundTint="@color/primary"
android:clickable="true"
android:focusable="true"
android:text="Yes"
android:textColor="@color/white"
android:textSize="19sp"
app:cornerRadius="27dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="20dp">
<Button
android:layout_width="165dp"
android:layout_height="64dp"
android:layout_marginEnd="10dp"
android:backgroundTint="@color/white"
android:clickable="true"
android:focusable="true"
android:text="No"
android:textColor="@color/primary"
android:textSize="19sp"
app:cornerRadius="27dp"
app:strokeColor="@color/primary"
app:strokeWidth="1dp"/>
<Button
android:layout_width="165dp"
android:layout_height="64dp"
android:backgroundTint="@color/primary"
android:clickable="true"
android:focusable="true"
android:text="Yes"
android:textColor="@color/white"
android:textSize="19sp"
app:cornerRadius="27dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment