mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Implement proper edge-to-edge with insets and use checkmark for main transport
- Remove fitsSystemWindows hack, use proper window insets handling - Apply system bar insets to RecyclerView top/bottom padding - Apply bottom inset to FAB margin for proper positioning - Replace "Main" text label with checkmark icon (ic_check_white_24dp) - Checkmark appears to the left of transport email for main transport - Properly handle edge-to-edge so toolbar color goes to status bar Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
This commit is contained in:
@@ -3,9 +3,14 @@ package org.thoughtcrime.securesms;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@@ -46,6 +51,7 @@ public class TransportListActivity extends BaseActionBarActivity
|
||||
getSupportActionBar().setElevation(0);
|
||||
}
|
||||
|
||||
CoordinatorLayout coordinatorLayout = findViewById(R.id.coordinator_layout);
|
||||
recyclerView = findViewById(R.id.transport_list);
|
||||
fabAdd = findViewById(R.id.fab_add_transport);
|
||||
|
||||
@@ -55,6 +61,29 @@ public class TransportListActivity extends BaseActionBarActivity
|
||||
|
||||
fabAdd.setOnClickListener(v -> openAddTransport());
|
||||
|
||||
// Handle window insets for edge-to-edge
|
||||
ViewCompat.setOnApplyWindowInsetsListener(coordinatorLayout, (v, windowInsets) -> {
|
||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
|
||||
// Apply top inset to RecyclerView as padding
|
||||
recyclerView.setPadding(
|
||||
recyclerView.getPaddingLeft(),
|
||||
insets.top,
|
||||
recyclerView.getPaddingRight(),
|
||||
insets.bottom
|
||||
);
|
||||
recyclerView.setClipToPadding(false);
|
||||
|
||||
// Apply bottom inset to FAB as margin
|
||||
CoordinatorLayout.LayoutParams fabParams = (CoordinatorLayout.LayoutParams) fabAdd.getLayoutParams();
|
||||
int fabMargin = (int) (16 * getResources().getDisplayMetrics().density);
|
||||
fabParams.bottomMargin = insets.bottom + fabMargin;
|
||||
fabParams.rightMargin = fabMargin;
|
||||
fabAdd.setLayoutParams(fabParams);
|
||||
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
});
|
||||
|
||||
loadTransports();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TransportListAdapter extends RecyclerView.Adapter<TransportListAdap
|
||||
static class TransportViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView emailText;
|
||||
private final TextView serverText;
|
||||
private final TextView mainIndicator;
|
||||
private final ImageView mainIndicator;
|
||||
private final ImageView editButton;
|
||||
private final ImageView deleteButton;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:background="?android:attr/windowBackground">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
@@ -12,8 +12,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:scrollbars="vertical"
|
||||
tools:listitem="@layout/transport_list_item" />
|
||||
|
||||
|
||||
@@ -9,41 +9,32 @@
|
||||
android:minHeight="72dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/main_transport_indicator"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:src="@drawable/ic_check_white_24dp"
|
||||
android:tint="?attr/colorPrimary"
|
||||
android:contentDescription="@string/main"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/transport_email"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/transport_email"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="16sp"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
tools:text="user@example.com" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/main_transport_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:text="@string/main"
|
||||
android:textSize="12sp"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="16sp"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
tools:text="user@example.com" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/transport_server"
|
||||
|
||||
Reference in New Issue
Block a user