Commit 91042840 authored by Amin's avatar Amin

fix and add in history

parent b4ee0f71
package com.example.qms; package com.example.qms;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ImageButton;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets; import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
...@@ -10,15 +19,84 @@ import androidx.core.view.WindowInsetsCompat; ...@@ -10,15 +19,84 @@ import androidx.core.view.WindowInsetsCompat;
public class AddInfo extends AppCompatActivity { public class AddInfo extends AppCompatActivity {
private LinearLayout uploadLayout;
private ImageView cameraIcon;
private TextView uploadText;
// Launcher for picking image
private final ActivityResultLauncher<Intent> pickImageLauncher =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
Uri imageUri = result.getData().getData();
if (imageUri != null) {
getContentResolver().takePersistableUriPermission(
imageUri,
Intent.FLAG_GRANT_READ_URI_PERMISSION
);
// Set the background of the layout to the chosen image
uploadLayout.setBackground(null); // remove the border first
uploadLayout.setBackgroundResource(R.drawable.upload_border); // keep border look
uploadLayout.setClipToOutline(true); // follow rounded shape if any
uploadLayout.setBackground(null);
uploadLayout.setBackgroundResource(0);
uploadLayout.setBackgroundResource(R.drawable.upload_border);
uploadLayout.setClipToOutline(true);
// Create an ImageView to preview inside the layout
ImageView preview = new ImageView(this);
preview.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
));
preview.setScaleType(ImageView.ScaleType.CENTER_CROP);
preview.setImageURI(imageUri);
// Clear previous views (icon + text)
uploadLayout.removeAllViews();
uploadLayout.addView(preview);
}
}
});
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
EdgeToEdge.enable(this); EdgeToEdge.enable(this);
setContentView(R.layout.activity_add_info); setContentView(R.layout.activity_add_info);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets; return insets;
}); });
uploadLayout = findViewById(R.id.comment_section).findViewById(R.id.uploadLayout);
// If uploadLayout doesn’t have id, just find it directly:
uploadLayout = findViewById(R.id.comment_section).findViewById(R.id.comment_section);
// Or simply:
uploadLayout = findViewById(R.id.comment_section).findViewById(R.id.comment_section);
// If your inner layout has no id, give it one in XML:
// android:id="@+id/uploadLayout"
uploadLayout = findViewById(R.id.uploadLayout);
// Reference icon and text
cameraIcon = uploadLayout.findViewById(R.id.camera_icon);
uploadText = uploadLayout.findViewById(R.id.upload_text);
uploadLayout.setOnClickListener(v -> openGallery());
ImageButton backButton = findViewById(R.id.back_button);
if (backButton != null) backButton.setOnClickListener(v -> onBackPressed());
}
private void openGallery() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
pickImageLauncher.launch(intent);
} }
} }
\ No newline at end of file
...@@ -24,6 +24,12 @@ public class History extends AppCompatActivity { ...@@ -24,6 +24,12 @@ public class History extends AppCompatActivity {
}); });
ImageButton addInfo = findViewById(R.id.add_info_icon); ImageButton addInfo = findViewById(R.id.add_info_icon);
ImageButton backButton = findViewById(R.id.backButton);
backButton.setOnClickListener(v -> {
onBackPressed();
});
addInfo.setOnClickListener(v -> { addInfo.setOnClickListener(v -> {
Intent intent = new Intent(History.this, AddInfo.class); Intent intent = new Intent(History.this, AddInfo.class);
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/card_border"
android:dashGap="4dp"
android:dashWidth="4dp"/>
<corners android:radius="21dp" />
</shape>
\ No newline at end of file
...@@ -7,4 +7,150 @@ ...@@ -7,4 +7,150 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".AddInfo"> tools:context=".AddInfo">
<LinearLayout
android:id="@+id/top_nav"
android:layout_width="match_parent"
android:layout_height="117dp"
android:background="@color/primary"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:layout_width="match_parent"
android:layout_height="59dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="59dp">
<ImageButton
android:id="@+id/back_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="16dp"
android:background="@null"
android:src="@drawable/arrow_left"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Info"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<TextView
android:id="@+id/issue_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingHorizontal="21dp"
android:text="ASH1-L011-N826"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_nav" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="21dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/issue_name">
<LinearLayout
android:id="@+id/remarks_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/issue_name">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="* Comment"
android:textSize="19sp"
android:textStyle="bold" />
<EditText
android:id="@+id/remarks_input"
android:layout_width="match_parent"
android:layout_height="115dp"
android:layout_marginTop="10dp"
android:background="@drawable/background_border"
android:gravity="top|start"
android:hint="Enter remarks here..."
android:inputType="textMultiLine"
android:padding="15dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/comment_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/issue_name">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Image Upload"
android:textSize="19sp"
android:textStyle="bold"
android:layout_marginBottom="10dp" />
<LinearLayout
android:id="@+id/uploadLayout"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@drawable/upload_border"
android:gravity="center"
android:orientation="vertical"
android:clipToOutline="true">
<ImageView
android:id="@+id/camera_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/camera_add" />
<TextView
android:id="@+id/upload_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Upload Image"
android:textColor="@color/primary"
android:textSize="17dp" />
</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