mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 00:29:50 -04:00
Feat[UI]: custom filter dialog, reduced overlay size
This commit is contained in:
parent
faa0d6b0a6
commit
37cdc11ed5
@ -1,16 +1,21 @@
|
|||||||
package net.kdt.pojavlaunch.fragments;
|
package net.kdt.pojavlaunch.fragments;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.math.MathUtils;
|
import androidx.core.math.MathUtils;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
@ -36,9 +41,8 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private TextView mSelectedVersion;
|
|
||||||
private Button mSelectVersionButton;
|
|
||||||
private EditText mSearchEditText;
|
private EditText mSearchEditText;
|
||||||
|
private ImageButton mFilterButton;
|
||||||
private RecyclerView mRecyclerview;
|
private RecyclerView mRecyclerview;
|
||||||
private ModItemAdapter mModItemAdapter;
|
private ModItemAdapter mModItemAdapter;
|
||||||
private ProgressBar mSearchProgressBar;
|
private ProgressBar mSearchProgressBar;
|
||||||
@ -65,10 +69,9 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
|||||||
mOverlay = view.findViewById(R.id.search_mod_overlay);
|
mOverlay = view.findViewById(R.id.search_mod_overlay);
|
||||||
mSearchEditText = view.findViewById(R.id.search_mod_edittext);
|
mSearchEditText = view.findViewById(R.id.search_mod_edittext);
|
||||||
mSearchProgressBar = view.findViewById(R.id.search_mod_progressbar);
|
mSearchProgressBar = view.findViewById(R.id.search_mod_progressbar);
|
||||||
mSelectedVersion = view.findViewById(R.id.search_mod_selected_mc_version_textview);
|
|
||||||
mSelectVersionButton = view.findViewById(R.id.search_mod_mc_version_button);
|
|
||||||
mRecyclerview = view.findViewById(R.id.search_mod_list);
|
mRecyclerview = view.findViewById(R.id.search_mod_list);
|
||||||
mStatusTextView = view.findViewById(R.id.search_mod_status_text);
|
mStatusTextView = view.findViewById(R.id.search_mod_status_text);
|
||||||
|
mFilterButton = view.findViewById(R.id.search_mod_filter);
|
||||||
|
|
||||||
mDefaultTextColor = mStatusTextView.getTextColors();
|
mDefaultTextColor = mStatusTextView.getTextColors();
|
||||||
|
|
||||||
@ -77,12 +80,6 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
|||||||
|
|
||||||
mRecyclerview.addOnScrollListener(mOverlayPositionListener);
|
mRecyclerview.addOnScrollListener(mOverlayPositionListener);
|
||||||
|
|
||||||
// Setup the expendable list behavior
|
|
||||||
mSelectVersionButton.setOnClickListener(v -> VersionSelectorDialog.open(v.getContext(), true, (id, snapshot)->{
|
|
||||||
mSelectedVersion.setText(id);
|
|
||||||
mSearchFilters.mcVersion = id;
|
|
||||||
}));
|
|
||||||
|
|
||||||
mSearchEditText.setOnEditorActionListener((v, actionId, event) -> {
|
mSearchEditText.setOnEditorActionListener((v, actionId, event) -> {
|
||||||
mSearchProgressBar.setVisibility(View.VISIBLE);
|
mSearchProgressBar.setVisibility(View.VISIBLE);
|
||||||
mSearchFilters.name = mSearchEditText.getText().toString();
|
mSearchFilters.name = mSearchEditText.getText().toString();
|
||||||
@ -97,6 +94,7 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
|||||||
mRecyclerview.getPaddingRight(),
|
mRecyclerview.getPaddingRight(),
|
||||||
mRecyclerview.getPaddingBottom());
|
mRecyclerview.getPaddingBottom());
|
||||||
});
|
});
|
||||||
|
mFilterButton.setOnClickListener(v -> displayFilterDialog());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,7 +113,7 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
|||||||
public void onSearchError(int error) {
|
public void onSearchError(int error) {
|
||||||
mSearchProgressBar.setVisibility(View.GONE);
|
mSearchProgressBar.setVisibility(View.GONE);
|
||||||
mStatusTextView.setVisibility(View.VISIBLE);
|
mStatusTextView.setVisibility(View.VISIBLE);
|
||||||
switch(error) {
|
switch (error) {
|
||||||
case ERROR_INTERNAL:
|
case ERROR_INTERNAL:
|
||||||
mStatusTextView.setTextColor(Color.RED);
|
mStatusTextView.setTextColor(Color.RED);
|
||||||
mStatusTextView.setText(R.string.search_modpack_error);
|
mStatusTextView.setText(R.string.search_modpack_error);
|
||||||
@ -126,4 +124,32 @@ public class SearchModFragment extends Fragment implements ModItemAdapter.Search
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayFilterDialog() {
|
||||||
|
AlertDialog dialog = new AlertDialog.Builder(requireContext())
|
||||||
|
.setView(R.layout.dialog_mod_filters)
|
||||||
|
.create();
|
||||||
|
|
||||||
|
// setup the view behavior
|
||||||
|
dialog.setOnShowListener(dialogInterface -> {
|
||||||
|
TextView mSelectedVersion = dialog.findViewById(R.id.search_mod_selected_mc_version_textview);
|
||||||
|
Button mSelectVersionButton = dialog.findViewById(R.id.search_mod_mc_version_button);
|
||||||
|
Button mApplyButton = dialog.findViewById(R.id.search_mod_apply_filters);
|
||||||
|
|
||||||
|
// Setup the expendable list behavior
|
||||||
|
mSelectVersionButton.setOnClickListener(v -> VersionSelectorDialog.open(v.getContext(), true, (id, snapshot)-> mSelectedVersion.setText(id)));
|
||||||
|
|
||||||
|
// Apply visually all the current settings
|
||||||
|
mSelectedVersion.setText(mSearchFilters.mcVersion);
|
||||||
|
|
||||||
|
// Apply the new settings
|
||||||
|
mApplyButton.setOnClickListener(v -> {
|
||||||
|
mSearchFilters.mcVersion = mSelectedVersion.getText().toString();
|
||||||
|
dialogInterface.dismiss();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ public class ModItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openDetailedView(){
|
private void openDetailedView() {
|
||||||
mExtendedLayout.setVisibility(View.VISIBLE);
|
mExtendedLayout.setVisibility(View.VISIBLE);
|
||||||
mDescription.setMaxLines(99);
|
mDescription.setMaxLines(99);
|
||||||
|
|
||||||
|
9
app_pojavlauncher/src/main/res/drawable/ic_filter.xml
Normal file
9
app_pojavlauncher/src/main/res/drawable/ic_filter.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="16.03dp"
|
||||||
|
android:height="18.02dp"
|
||||||
|
android:viewportWidth="16.03"
|
||||||
|
android:viewportHeight="18.02">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFF"
|
||||||
|
android:pathData="M10.02,9v7.88c0.04,0.3 -0.06,0.62 -0.29,0.83a1,1 0,0 1,-1.41 0l-2.01,-2.01a0.99,0.99 0,0 1,-0.29 -0.83L6.02,9h-0.03L0.23,1.62a1,1 0,0 1,0.17 -1.4c0.19,-0.14 0.4,-0.22 0.62,-0.22h14c0.22,0 0.43,0.08 0.62,0.22a1,1 0,0 1,0.17 1.4L10.05,9L10.02,9Z"/>
|
||||||
|
</vector>
|
60
app_pojavlauncher/src/main/res/layout/dialog_mod_filters.xml
Normal file
60
app_pojavlauncher/src/main/res/layout/dialog_mod_filters.xml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingHorizontal="@dimen/padding_heavy"
|
||||||
|
android:paddingBottom="@dimen/padding_large"
|
||||||
|
android:paddingTop="@dimen/padding_heavy"
|
||||||
|
>
|
||||||
|
|
||||||
|
<!-- Version filter -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/search_mod_mc_version_textview"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/profiles_profile_version"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/search_mod_selected_mc_version_textview" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/search_mod_selected_mc_version_textview"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
android:layout_marginEnd="@dimen/padding_medium"
|
||||||
|
|
||||||
|
android:background="@drawable/background_line"
|
||||||
|
android:hint="@string/version_select_hint"
|
||||||
|
android:paddingHorizontal="@dimen/padding_heavy"
|
||||||
|
android:textSize="@dimen/_13ssp"
|
||||||
|
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/search_mod_mc_version_button"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/search_mod_mc_version_textview" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/search_mod_mc_version_button"
|
||||||
|
android:layout_width="@dimen/_72sdp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
|
||||||
|
android:text="@string/global_select"
|
||||||
|
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/search_mod_selected_mc_version_textview"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/search_mod_selected_mc_version_textview" />
|
||||||
|
|
||||||
|
<!-- Apply -->
|
||||||
|
<com.kdt.mcgui.MineButton
|
||||||
|
android:id="@+id/search_mod_apply_filters"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/generic_apply"
|
||||||
|
android:layout_marginVertical="@dimen/padding_large"
|
||||||
|
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/search_mod_selected_mc_version_textview"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -31,7 +31,7 @@
|
|||||||
<!-- Search text -->
|
<!-- Search text -->
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/search_mod_edittext"
|
android:id="@+id/search_mod_edittext"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/background_line"
|
android:background="@drawable/background_line"
|
||||||
android:textSize="@dimen/_13ssp"
|
android:textSize="@dimen/_13ssp"
|
||||||
@ -42,6 +42,24 @@
|
|||||||
android:inputType="textPersonName"
|
android:inputType="textPersonName"
|
||||||
android:paddingHorizontal="@dimen/padding_heavy"
|
android:paddingHorizontal="@dimen/padding_heavy"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/search_mod_filter"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/search_mod_filter"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:minWidth="@dimen/_38sdp"
|
||||||
|
android:src="@drawable/ic_filter"
|
||||||
|
|
||||||
|
android:paddingHorizontal="@dimen/padding_medium"
|
||||||
|
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/search_mod_edittext"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/search_mod_edittext"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
@ -54,41 +72,6 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/search_mod_edittext"
|
app:layout_constraintTop_toBottomOf="@+id/search_mod_edittext"
|
||||||
tools:layout_editor_absoluteX="13dp" />
|
tools:layout_editor_absoluteX="13dp" />
|
||||||
|
|
||||||
<!-- Version filter -->
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/search_mod_mc_version_textview"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/profiles_profile_version"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/search_mod_selected_mc_version_textview"
|
|
||||||
app:layout_constraintStart_toStartOf="@+id/search_mod_selected_mc_version_textview" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/search_mod_selected_mc_version_textview"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginVertical="32dp"
|
|
||||||
android:layout_marginEnd="@dimen/padding_medium"
|
|
||||||
|
|
||||||
android:background="@drawable/background_line"
|
|
||||||
android:hint="@string/version_select_hint"
|
|
||||||
android:paddingHorizontal="@dimen/padding_heavy"
|
|
||||||
android:textSize="@dimen/_13ssp"
|
|
||||||
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/search_mod_mc_version_button"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/search_mod_progressbar" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/search_mod_mc_version_button"
|
|
||||||
android:layout_width="@dimen/_72sdp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
|
|
||||||
android:text="@string/global_select"
|
|
||||||
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/search_mod_selected_mc_version_textview"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/search_mod_selected_mc_version_textview" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
@ -409,6 +409,7 @@
|
|||||||
<string name="hint_search_modpack">Search for modpacks</string>
|
<string name="hint_search_modpack">Search for modpacks</string>
|
||||||
|
|
||||||
<string name="generic_install">Install</string>
|
<string name="generic_install">Install</string>
|
||||||
|
<string name="generic_apply">Apply</string>
|
||||||
|
|
||||||
<string name="search_modpack_no_result">No modpacks found</string>
|
<string name="search_modpack_no_result">No modpacks found</string>
|
||||||
<string name="search_modpack_error">Failed to find modpacks</string>
|
<string name="search_modpack_error">Failed to find modpacks</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user