Skip to content

Commit

Permalink
Fix[gamepad_remapper]: use setBackgroundColor instead of creating Col…
Browse files Browse the repository at this point in the history
…orDrawable, add settings entry
  • Loading branch information
artdeell committed Aug 25, 2024
1 parent 012e71e commit 04c0937
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -156,7 +155,6 @@ protected void onDownStateChanged(boolean isDown) {
public class ViewHolder extends RecyclerView.ViewHolder implements AdapterView.OnItemSelectedListener, View.OnClickListener {
private static final int COLOR_ACTIVE_BUTTON = 0x2000FF00;
private final Context mContext;
private final ColorDrawable mBackgroundDrawable;
private final ImageView mButtonIcon;
private final ImageView mExpansionIndicator;
private final Spinner[] mKeySpinners;
Expand All @@ -167,8 +165,6 @@ public class ViewHolder extends RecyclerView.ViewHolder implements AdapterView.O

public ViewHolder(@NonNull View itemView) {
super(itemView);
mBackgroundDrawable = new ColorDrawable(Color.TRANSPARENT);
itemView.setBackground(mBackgroundDrawable);
mContext = itemView.getContext();
mButtonIcon = itemView.findViewById(R.id.controller_mapper_button);
mExpandedView = itemView.findViewById(R.id.controller_mapper_expanded_view);
Expand Down Expand Up @@ -223,7 +219,7 @@ private void detach() {
mAttachedPosition = -1;
}
private void setPressed(boolean pressed) {
mBackgroundDrawable.setColor(pressed ? COLOR_ACTIVE_BUTTON : Color.TRANSPARENT);
itemView.setBackgroundColor(pressed ? COLOR_ACTIVE_BUTTON : Color.TRANSPARENT);
}

private void updateKeycodeLabel() {
Expand Down
2 changes: 2 additions & 0 deletions app_pojavlauncher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,6 @@
<string name="customctrl_visibility_ingame">In-game</string>
<string name="customctrl_visibility_in_menus">In menus</string>
<string name="controller_remapper_expand_entry">Expand to change keycodes</string>
<string name="preference_remap_controller_title">Change controller key bindings</string>
<string name="preference_remap_controller_description">Allows you to modify the keyboard keys bound to each controller button</string>
</resources>
5 changes: 5 additions & 0 deletions app_pojavlauncher/src/main/res/xml/pref_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@
<PreferenceCategory
android:title="@string/preference_category_controller_settings"
>
<Preference
android:title="@string/preference_remap_controller_title"
android:summary="@string/preference_remap_controller_description"
android:fragment="net.kdt.pojavlaunch.fragments.GamepadMapperFragment"/>
<net.kdt.pojavlaunch.prefs.GamepadRemapPreference
android:title="@string/preference_wipe_controller_title"
android:summary="@string/preference_wipe_controller_description"
Expand All @@ -143,6 +147,7 @@
app2:showSeekBarValue="true"
app2:seekBarIncrement="5"
/>

</PreferenceCategory>


Expand Down

0 comments on commit 04c0937

Please sign in to comment.