Commit 2c5c9df7 authored by Amin's avatar Amin

add back function

parent 943b715b
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Qms"> android:theme="@style/Theme.Qms">
<activity <activity
android:name=".TransactionDetails"
android:exported="false" />
<activity
android:name=".AccessItem" android:name=".AccessItem"
android:exported="false" /> android:exported="false" />
<activity <activity
......
package com.example.qms; package com.example.qms;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
...@@ -10,6 +13,10 @@ import androidx.core.view.WindowInsetsCompat; ...@@ -10,6 +13,10 @@ import androidx.core.view.WindowInsetsCompat;
public class AccessItem extends AppCompatActivity { public class AccessItem extends AppCompatActivity {
private LinearLayout transactionDetail;
private ImageButton back_button;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -20,5 +27,17 @@ public class AccessItem extends AppCompatActivity { ...@@ -20,5 +27,17 @@ public class AccessItem extends AppCompatActivity {
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets; 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; ...@@ -5,6 +5,7 @@ import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast; import android.widget.Toast;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
...@@ -17,6 +18,8 @@ public class SyncActivity extends AppCompatActivity { ...@@ -17,6 +18,8 @@ public class SyncActivity extends AppCompatActivity {
private Button syncButton; private Button syncButton;
private ImageButton back_button;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -29,6 +32,7 @@ public class SyncActivity extends AppCompatActivity { ...@@ -29,6 +32,7 @@ public class SyncActivity extends AppCompatActivity {
}); });
syncButton = findViewById(R.id.sync_button); syncButton = findViewById(R.id.sync_button);
back_button = findViewById(R.id.backButton);
syncButton.setOnClickListener(new View.OnClickListener() { syncButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -36,35 +40,43 @@ public class SyncActivity extends AppCompatActivity { ...@@ -36,35 +40,43 @@ public class SyncActivity extends AppCompatActivity {
showAlertDialog(); showAlertDialog();
} }
}); });
back_button.setOnClickListener(v -> {
onBackPressed();
});
} }
private void showAlertDialog() { 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); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Alert Title"); builder.setView(alertView);
builder.setMessage("This is a simple alert message.");
builder.setCancelable(false); // User must click a button to dismiss
// Add a positive button // Create and show the dialog
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { AlertDialog dialog = builder.create();
@Override dialog.show();
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(SyncActivity.this, "OK clicked!", Toast.LENGTH_SHORT).show();
dialog.dismiss(); // Dismiss the dialog
}
});
// Add a negative button (optional) // Optional: make dialog background rounded if your layout has rounded corners
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(SyncActivity.this, "Cancel clicked!", Toast.LENGTH_SHORT).show();
dialog.dismiss(); // Dismiss the dialog
}
});
// Create and show the AlertDialog // Now find the buttons from your custom layout
AlertDialog alertDialog = builder.create(); Button noButton = alertView.findViewById(R.id.no_button);
alertDialog.show(); 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 @@ ...@@ -139,6 +139,7 @@
android:textStyle="bold" /> android:textStyle="bold" />
<LinearLayout <LinearLayout
android:id="@+id/transactionDetails"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/background_border" android:background="@drawable/background_border"
......
This diff is collapsed.
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
android:id="@+id/syncAlert" android:id="@+id/syncAlert"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_constraintHeight="wrap_content" app:layout_constraintHeight="match_parent"
app:layout_constraintWidth="300dp"> app:layout_constraintWidth="match_parent"
android:background="@drawable/alert_border">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -13,7 +14,8 @@ ...@@ -13,7 +14,8 @@
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="30dp" android:paddingHorizontal="30dp"
android:paddingVertical="30dp"> android:paddingVertical="30dp"
app:layout_constraintTop_toTopOf="parent">
<ImageView <ImageView
android:layout_width="56dp" android:layout_width="56dp"
...@@ -200,19 +202,17 @@ ...@@ -200,19 +202,17 @@
app:useMaterialThemeColors="true" /> app:useMaterialThemeColors="true" />
</LinearLayout> </LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent" android:layout_marginVertical="20dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="20dp"> android:layout_marginBottom="20dp">
<Button <Button
android:id="@+id/no_button"
android:layout_width="165dp" android:layout_width="165dp"
android:layout_height="64dp" android:layout_height="64dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
...@@ -227,6 +227,7 @@ ...@@ -227,6 +227,7 @@
app:strokeWidth="1dp"/> app:strokeWidth="1dp"/>
<Button <Button
android:id="@+id/yes_button"
android:layout_width="165dp" android:layout_width="165dp"
android:layout_height="64dp" android:layout_height="64dp"
android:backgroundTint="@color/primary" android:backgroundTint="@color/primary"
...@@ -238,4 +239,6 @@ ...@@ -238,4 +239,6 @@
app:cornerRadius="27dp" /> app:cornerRadius="27dp" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </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