Commit 985d60f6 authored by Amin's avatar Amin

fix scroll bar issue

parent 58a4a997
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
......
...@@ -4,58 +4,44 @@ import android.app.Activity; ...@@ -4,58 +4,44 @@ import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.ImageButton;
import androidx.activity.EdgeToEdge; import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts; import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets; import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class AddInfo extends AppCompatActivity { public class AddInfo extends AppCompatActivity {
private LinearLayout uploadLayout; private LinearLayout uploadLayout; // For image upload
private LinearLayout uploadMedia; // For media upload
private ImageView cameraIcon; private ImageView cameraIcon;
private TextView uploadText; private TextView uploadText;
private ImageView mediaIcon;
private TextView mediaText;
// Launcher for picking image // --- Image picker launcher ---
private final ActivityResultLauncher<Intent> pickImageLauncher = private final ActivityResultLauncher<Intent> pickImageLauncher =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) { if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
Uri imageUri = result.getData().getData(); Uri imageUri = result.getData().getData();
if (imageUri != null) { if (imageUri != null) {
getContentResolver().takePersistableUriPermission( displayImagePreview(imageUri);
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) // --- Media picker launcher (for PDF, videos, etc.) ---
uploadLayout.removeAllViews(); private final ActivityResultLauncher<Intent> pickMediaLauncher =
uploadLayout.addView(preview); registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
Uri mediaUri = result.getData().getData();
if (mediaUri != null) {
displayMediaPreview(mediaUri);
} }
} }
}); });
...@@ -63,39 +49,103 @@ public class AddInfo extends AppCompatActivity { ...@@ -63,39 +49,103 @@ public class AddInfo extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_add_info); setContentView(R.layout.activity_add_info);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { // Find views
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
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); uploadLayout = findViewById(R.id.uploadLayout);
uploadMedia = findViewById(R.id.uploadMedia);
cameraIcon = findViewById(R.id.camera_icon);
uploadText = findViewById(R.id.upload_text);
mediaIcon = findViewById(R.id.media_icon);
mediaText = findViewById(R.id.media_text);
// Reference icon and text // Handle image upload
cameraIcon = uploadLayout.findViewById(R.id.camera_icon); uploadLayout.setOnClickListener(v -> openGalleryForImages());
uploadText = uploadLayout.findViewById(R.id.upload_text);
uploadLayout.setOnClickListener(v -> openGallery()); // Handle media upload
uploadMedia.setOnClickListener(v -> openGalleryForMedia());
// Back button using modern dispatcher
ImageButton backButton = findViewById(R.id.back_button); ImageButton backButton = findViewById(R.id.back_button);
if (backButton != null) backButton.setOnClickListener(v -> onBackPressed()); if (backButton != null) {
backButton.setOnClickListener(v -> finish());
} }
private void openGallery() { // Handle physical back safely (modern way)
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
finish();
}
});
}
// ==================== IMAGE PICKER ====================
private void openGalleryForImages() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE); intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*"); intent.setType("image/*");
pickImageLauncher.launch(intent); pickImageLauncher.launch(intent);
} }
private void displayImagePreview(Uri uri) {
// Clear old views
uploadLayout.removeAllViews();
// Add new preview image
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(uri);
uploadLayout.addView(preview);
}
// ==================== MEDIA PICKER ====================
private void openGalleryForMedia() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
// Only allow PDFs and videos
String[] mimeTypes = {"application/pdf", "video/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
pickMediaLauncher.launch(intent);
}
private void displayMediaPreview(Uri uri) {
// Clear old views
uploadMedia.removeAllViews();
// Show an icon + filename instead of image preview
LinearLayout container = new LinearLayout(this);
container.setOrientation(LinearLayout.HORIZONTAL);
container.setGravity(1);
container.setPadding(20, 20, 20, 20);
container.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
));
ImageView fileIcon = new ImageView(this);
fileIcon.setLayoutParams(new LinearLayout.LayoutParams(64, 64));
fileIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.media_upload)); // your icon
container.addView(fileIcon);
TextView fileName = new TextView(this);
fileName.setText(getFileNameFromUri(uri));
fileName.setTextSize(16);
fileName.setPadding(20, 0, 0, 0);
container.addView(fileName);
uploadMedia.addView(container);
}
private String getFileNameFromUri(Uri uri) {
String path = uri.getLastPathSegment();
if (path == null) return "Unknown File";
int index = path.lastIndexOf('/');
return (index != -1) ? path.substring(index + 1) : path;
}
} }
...@@ -2,22 +2,21 @@ package com.example.qms; ...@@ -2,22 +2,21 @@ package com.example.qms;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.Toast;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets; import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
public class WithdrawIssueSummary extends AppCompatActivity { public class WithdrawIssueSummary extends AppCompatActivity {
private ImageButton back_button;
private Button confirmButton, back_button_bot;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -28,15 +27,16 @@ public class WithdrawIssueSummary extends AppCompatActivity { ...@@ -28,15 +27,16 @@ public class WithdrawIssueSummary extends AppCompatActivity {
return insets; return insets;
}); });
back_button = findViewById(R.id.backButton); ImageButton backButton = findViewById(R.id.back_button);
confirmButton = findViewById(R.id.confirm_button); Button confirmButton = findViewById(R.id.confirm_button);
back_button_bot = findViewById(R.id.backButtonBot); Button backButtonBot = findViewById(R.id.back_button_bot);
EditText inputRemarks = findViewById(R.id.input_remarks);
back_button.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
onBackPressed(); onBackPressed();
}); });
back_button_bot.setOnClickListener(v -> { backButtonBot.setOnClickListener(v -> {
onBackPressed(); onBackPressed();
}); });
...@@ -60,8 +60,34 @@ public class WithdrawIssueSummary extends AppCompatActivity { ...@@ -60,8 +60,34 @@ public class WithdrawIssueSummary extends AppCompatActivity {
.show(); .show();
}); });
confirmButton.setBackgroundTintList(
ContextCompat.getColorStateList(this, R.color.sync_button)
);
confirmButton.setEnabled(false);
inputRemarks.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.toString().trim().length() > 0) {
confirmButton.setEnabled(true);
confirmButton.setBackgroundTintList(
ContextCompat.getColorStateList(WithdrawIssueSummary.this, R.color.primary)
);
} else {
confirmButton.setEnabled(false);
confirmButton.setBackgroundTintList(
ContextCompat.getColorStateList(WithdrawIssueSummary.this, R.color.sync_button)
);
}
}
@Override
public void afterTextChanged(Editable s) { }
});
} }
} }
\ No newline at end of file
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<stroke <stroke
android:width="1dp" android:width="1dp"
android:color="@color/card_border" android:color="@color/card_border"
android:dashGap="4dp" android:dashGap="10dp"
android:dashWidth="4dp"/> android:dashWidth="6dp"/>
<corners android:radius="21dp" /> <corners android:radius="21dp" />
</shape> </shape>
\ No newline at end of file
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/top_nav" app:layout_constraintTop_toBottomOf="@+id/top_nav"
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/top_nav" app:layout_constraintTop_toBottomOf="@+id/top_nav"
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main" android:id="@+id/activity_add_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".AddInfo"> tools:context=".AddInfo">
......
...@@ -70,7 +70,8 @@ ...@@ -70,7 +70,8 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_nav"> app:layout_constraintTop_toBottomOf="@+id/top_nav"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -68,7 +68,8 @@ ...@@ -68,7 +68,8 @@
app:layout_constraintBottom_toTopOf="@id/bottom_bar" app:layout_constraintBottom_toTopOf="@id/bottom_bar"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_nav"> app:layout_constraintTop_toBottomOf="@id/top_nav"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -178,7 +178,8 @@ ...@@ -178,7 +178,8 @@
android:background="@color/light_grey" android:background="@color/light_grey"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mid_bar"> app:layout_constraintTop_toBottomOf="@+id/mid_bar"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -72,7 +72,6 @@ ...@@ -72,7 +72,6 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"> app:layout_constraintStart_toStartOf="parent">
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -94,7 +93,6 @@ ...@@ -94,7 +93,6 @@
android:textSize="16sp" /> android:textSize="16sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/add_issue_bottom_nav" android:id="@+id/add_issue_bottom_nav"
android:layout_width="0dp" android:layout_width="0dp"
...@@ -113,7 +111,7 @@ ...@@ -113,7 +111,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Add Issue" android:text="Add Issue"
android:textColor="@color/white" android:textColor="?android:attr/colorBackground"
android:textSize="16sp" /> android:textSize="16sp" />
</LinearLayout> </LinearLayout>
......
...@@ -59,7 +59,8 @@ ...@@ -59,7 +59,8 @@
android:background="@color/light_grey" android:background="@color/light_grey"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_nav"> app:layout_constraintTop_toBottomOf="@+id/top_nav"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -66,7 +66,8 @@ ...@@ -66,7 +66,8 @@
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_nav"> app:layout_constraintTop_toBottomOf="@+id/top_nav"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -81,7 +81,8 @@ ...@@ -81,7 +81,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/status"> app:layout_constraintTop_toBottomOf="@+id/status"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/top_nav" app:layout_constraintTop_toBottomOf="@+id/top_nav"
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent"
android:scrollbars="none">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -172,7 +172,8 @@ ...@@ -172,7 +172,8 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/bottom_bar" app:layout_constraintBottom_toTopOf="@+id/bottom_bar"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mid_bar"> app:layout_constraintTop_toBottomOf="@+id/mid_bar"
android:scrollbars="none">
<LinearLayout <LinearLayout
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
android:layout_height="59dp"> android:layout_height="59dp">
<ImageButton <ImageButton
android:id="@+id/backButton" android:id="@+id/back_button"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
android:textStyle="bold" /> android:textStyle="bold" />
<EditText <EditText
android:id="@+id/remarks" android:id="@+id/input_remarks"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="115dp" android:layout_height="115dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
app:layout_constraintStart_toStartOf="parent"> app:layout_constraintStart_toStartOf="parent">
<Button <Button
android:id="@+id/backButtonBot" android:id="@+id/back_button_bot"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="64dp" android:layout_height="64dp"
android:layout_weight="1" android:layout_weight="1"
......
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