From 508e56e2bfde9d83c028a61323db01101ee0a0ee Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Wed, 15 Mar 2023 03:30:37 -0400 Subject: [PATCH] Android: Convert SettingsFragmentView to Kotlin --- .../settings/ui/SettingsFragmentView.java | 123 ------------------ .../settings/ui/SettingsFragmentView.kt | 114 ++++++++++++++++ 2 files changed, 114 insertions(+), 123 deletions(-) delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.kt diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java deleted file mode 100644 index 809f26f7cc..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.java +++ /dev/null @@ -1,123 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.settings.ui; - -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.FragmentActivity; - -import org.dolphinemu.dolphinemu.features.settings.model.Settings; -import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; - -import java.util.ArrayList; - -/** - * Abstraction for a screen showing a list of settings. Instances of - * this type of view will each display a layer of the setting hierarchy. - */ -public interface SettingsFragmentView -{ - /** - * Called by the containing Activity to notify the Fragment that an - * asynchronous load operation completed. - * - * @param settings The (possibly null) result of the ini load operation. - */ - void onSettingsFileLoaded(Settings settings); - - /** - * Pass an ArrayList of settings to the View so that it can be displayed on screen. - * - * @param settingsList The settings to display - */ - void showSettingsList(ArrayList settingsList); - - /** - * Called by the containing Activity when an asynchronous load operation fails. - * Instructs the Fragment to load the settings screen with defaults selected. - */ - void loadDefaultSettings(); - - /** - * @return The Fragment's containing activity. - */ - FragmentActivity getActivity(); - - /** - * @return The Fragment's SettingsAdapter. - */ - SettingsAdapter getAdapter(); - - /** - * Tell the Fragment to tell the containing Activity to show a new - * Fragment containing a submenu of settings. - * - * @param menuKey Identifier for the settings group that should be shown. - */ - void loadSubMenu(MenuTag menuKey); - - void showDialogFragment(DialogFragment fragment); - - /** - * Tell the Fragment to tell the containing activity to display a toast message. - * - * @param message Text to be shown in the Toast - */ - void showToastMessage(String message); - - /** - * @return The backing settings store. - */ - Settings getSettings(); - - /** - * Have the fragment tell the containing Activity that a setting was modified. - */ - void onSettingChanged(); - - /** - * Refetches the values of all controller settings. - * - * To be used when loading an input profile or performing some other action that changes all - * controller settings at once. - */ - void onControllerSettingsChanged(); - - /** - * Have the fragment tell the containing Activity that the user wants to open the MenuTag - * associated with a setting. - * - * @param menuTag The MenuTag of the setting. - * @param value The current value of the setting. - */ - void onMenuTagAction(@NonNull MenuTag menuTag, int value); - - /** - * Returns whether anything will happen when the user wants to open the MenuTag associated with a - * setting, given the current value of the setting. - * - * @param menuTag The MenuTag of the setting. - * @param value The current value of the setting. - */ - boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value); - - /** - * Sets whether the input mapping dialog should detect inputs from all devices, - * not just the device configured for the controller. - */ - void setMappingAllDevices(boolean allDevices); - - /** - * Returns whether the input mapping dialog should detect inputs from all devices, - * not just the device configured for the controller. - */ - boolean isMappingAllDevices(); - - /** - * Shows or hides a warning telling the user that they're using incompatible controller settings. - * The warning is hidden by default. - * - * @param visible Whether the warning should be visible. - */ - void setOldControllerSettingsWarningVisibility(boolean visible); -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.kt new file mode 100644 index 0000000000..fa861153dd --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentView.kt @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.settings.ui + +import androidx.fragment.app.DialogFragment +import androidx.fragment.app.FragmentActivity +import org.dolphinemu.dolphinemu.features.settings.model.Settings +import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem + +/** + * Abstraction for a screen showing a list of settings. Instances of + * this type of view will each display a layer of the Setting hierarchy. + */ +interface SettingsFragmentView { + /** + * Called by the containing Activity to notify the Fragment that an + * asynchronous load operation completed. + * + * @param settings The (possibly null) result of the ini load operation. + */ + fun onSettingsFileLoaded(settings: Settings) + + /** + * Pass an ArrayList of settings to the View so that it can be displayed on screen. + * + * @param settingsList The settings to display + */ + fun showSettingsList(settingsList: ArrayList) + + /** + * Called by the containing Activity when an asynchronous load operation fails. + * Instructs the Fragment to load the settings screen with defaults selected. + */ + fun loadDefaultSettings() + + /** + * @return The Fragment's containing activity. + */ + val fragmentActivity: FragmentActivity + + /** + * @return The Fragment's SettingsAdapter. + */ + val adapter: SettingsAdapter? + + /** + * Tell the Fragment to tell the containing Activity to show a new + * Fragment containing a submenu of settings. + * + * @param menuKey Identifier for the settings group that should be shown. + */ + fun loadSubMenu(menuKey: MenuTag) + fun showDialogFragment(fragment: DialogFragment) + + /** + * Tell the Fragment to tell the containing activity to display a toast message. + * + * @param message Text to be shown in the Toast + */ + fun showToastMessage(message: String) + + /** + * @return The backing settings store. + */ + val settings: Settings? + + /** + * Have the fragment tell the containing Activity that a Setting was modified. + */ + fun onSettingChanged() + + /** + * Refetches the values of all controller settings. + * + * To be used when loading an input profile or performing some other action that changes all + * controller settings at once. + */ + fun onControllerSettingsChanged() + + /** + * Have the fragment tell the containing Activity that the user wants to open the MenuTag + * associated with a Setting. + * + * @param menuTag The MenuTag of the Setting. + * @param value The current value of the Setting. + */ + fun onMenuTagAction(menuTag: MenuTag, value: Int) + + /** + * Returns whether anything will happen when the user wants to open the MenuTag associated with a + * stringSetting, given the current value of the Setting. + * + * @param menuTag The MenuTag of the Setting. + * @param value The current value of the Setting. + */ + fun hasMenuTagActionForValue(menuTag: MenuTag, value: Int): Boolean + /** + * Returns whether the input mapping dialog should detect inputs from all devices, + * not just the device configured for the controller. + */ + /** + * Sets whether the input mapping dialog should detect inputs from all devices, + * not just the device configured for the controller. + */ + var isMappingAllDevices: Boolean + + /** + * Shows or hides a warning telling the user that they're using incompatible controller settings. + * The warning is hidden by default. + * + * @param visible Whether the warning should be visible. + */ + fun setOldControllerSettingsWarningVisibility(visible: Boolean) +}