Android: Convert SettingsFragmentView to Kotlin

This commit is contained in:
Charles Lombardo 2023-03-15 03:30:37 -04:00
parent 656d91cd18
commit 508e56e2bf
2 changed files with 114 additions and 123 deletions

View File

@ -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<SettingsItem> 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);
}

View File

@ -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<SettingsItem>)
/**
* 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)
}