Skip to content

Commit

Permalink
feat: Redesign Local Libraries UI
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Dec 29, 2024
1 parent 3b551f5 commit fa0d2ee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.divider.MaterialDividerItemDecoration;
import com.google.gson.Gson;

import java.io.File;
Expand All @@ -39,7 +38,6 @@
import pro.sketchware.databinding.ViewItemLocalLibSearchBinding;
import pro.sketchware.utility.FileUtil;
import pro.sketchware.utility.SketchwareUtil;
import pro.sketchware.utility.ThemeUtils;

public class ManageLocalLibraryActivity extends AppCompatActivity {

Expand Down Expand Up @@ -75,14 +73,16 @@ protected void onCreate(Bundle savedInstanceState) {
localLibFile = FileUtil.getExternalStorageDir().concat("/.sketchware/data/").concat(scId.concat("/local_library"));
}

var decoration = new MaterialDividerItemDecoration(this, MaterialDividerItemDecoration.VERTICAL);
decoration.setDividerColor(ThemeUtils.getColor(binding.searchList, R.attr.colorOutline));

binding.librariesList.setAdapter(adapter);
binding.searchList.setAdapter(searchAdapter);
binding.searchList.addItemDecoration(decoration);

loadLibraries();
binding.searchBar.setNavigationOnClickListener(v -> {
if (!binding.searchView.isShowing()) {
binding.searchView.hide();
} else {
finish();
}
});

binding.downloadLibraryButton.setOnClickListener(v -> {
if (getSupportFragmentManager().findFragmentByTag("library_downloader_dialog") != null) {
Expand Down Expand Up @@ -118,6 +118,8 @@ public void onTextChanged(CharSequence newText, int start, int before, int count
}
}
});

loadLibraries();
}

private void loadLibraries() {
Expand Down Expand Up @@ -204,7 +206,7 @@ public void onBindViewHolder(ViewHolder holder, final int position) {
binding.libraryName.setText(libraryFile.getName());
binding.librarySize.setText(librarySize);

binding.card.setOnClickListener(v -> onItemClicked(binding));
binding.card.setOnClickListener(v -> binding.checkbox.performClick());
binding.checkbox.setOnClickListener(v -> onItemClicked(binding));

binding.checkbox.setChecked(false);
Expand Down Expand Up @@ -309,7 +311,7 @@ public void onBindViewHolder(ViewHolder holder, final int position) {
binding.libraryName.setText(libraryFile.getName());
binding.librarySize.setText(librarySize);

binding.getRoot().setOnClickListener(v -> onItemClicked(binding));
binding.getRoot().setOnClickListener(v -> binding.checkbox.performClick());
binding.checkbox.setOnClickListener(v -> onItemClicked(binding));

binding.checkbox.setChecked(false);
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/res/layout/view_item_local_lib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
style="?attr/materialCardViewFilledStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginVertical="8dp"
android:layout_margin="4dp"
android:clickable="true"
android:focusable="true"
app:cardBackgroundColor="@android:color/transparent">
app:cardBackgroundColor="@android:color/transparent"
app:cardCornerRadius="24dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="8dp"
android:paddingStart="16dp"
android:paddingVertical="8dp">
android:paddingEnd="12dp"
android:paddingStart="20dp"
android:paddingVertical="12dp">

<TextView
android:id="@+id/library_name"
Expand All @@ -30,6 +29,7 @@
android:ellipsize="marquee"
android:textAppearance="?attr/textAppearanceBodyLarge"
android:textColor="?attr/colorOnSurface"
android:textSize="17sp"
app:layout_constraintEnd_toStartOf="@id/checkbox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/library_size"
Expand All @@ -42,6 +42,7 @@
android:layout_marginTop="2dp"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?attr/colorOnSurfaceVariant"
android:textSize="15sp"
app:layout_constraintEnd_toStartOf="@id/checkbox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/library_name"
Expand All @@ -62,8 +63,7 @@
android:background="?attr/selectableItemBackgroundBorderless"
android:focusable="true"
android:clickable="true"
android:padding="4dp"
android:scaleType="fitCenter"
android:scaleType="centerInside"
android:src="@drawable/ic_more_vert_grey600_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/view_item_local_lib_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingEnd="8dp"
android:paddingStart="16dp"
android:paddingVertical="8dp">
android:paddingVertical="12dp">

<TextView
android:id="@+id/library_name"
Expand Down Expand Up @@ -48,8 +51,7 @@
android:background="?attr/selectableItemBackgroundBorderless"
android:focusable="true"
android:clickable="true"
android:padding="4dp"
android:scaleType="fitCenter"
android:scaleType="centerInside"
android:src="@drawable/ic_more_vert_grey600_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down

0 comments on commit fa0d2ee

Please sign in to comment.