mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-17 03:15:39 +00:00
Android: Add hotkey categories/grouping
This commit is contained in:
parent
d2cef2e3b5
commit
686fc4cc2a
|
@ -30,6 +30,7 @@ import com.google.android.material.tabs.TabLayout;
|
|||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ControllerSettingsActivity extends AppCompatActivity {
|
||||
|
||||
|
@ -328,10 +329,22 @@ public class ControllerSettingsActivity extends AppCompatActivity {
|
|||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
final PreferenceScreen ps = getPreferenceManager().createPreferenceScreen(getContext());
|
||||
if (mHotkeyInfo != null) {
|
||||
final HashMap<String, PreferenceCategory> categoryMap = new HashMap<>();
|
||||
|
||||
for (HotkeyInfo hotkeyInfo : mHotkeyInfo) {
|
||||
PreferenceCategory category = categoryMap.containsKey(hotkeyInfo.getCategory()) ?
|
||||
categoryMap.get(hotkeyInfo.getCategory()) : null;
|
||||
if (category == null) {
|
||||
category = new PreferenceCategory(getContext());
|
||||
category.setTitle(hotkeyInfo.getCategory());
|
||||
category.setIconSpaceReserved(false);
|
||||
categoryMap.put(hotkeyInfo.getCategory(), category);
|
||||
ps.addPreference(category);
|
||||
}
|
||||
|
||||
final ControllerBindingPreference cbp = new ControllerBindingPreference(getContext(), null);
|
||||
cbp.initHotkey(hotkeyInfo);
|
||||
ps.addPreference(cbp);
|
||||
category.addPreference(cbp);
|
||||
activity.mPreferences.add(cbp);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue