mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Android: Remove CheckBoxSettingViewHolder's log setting name hack
This commit is contained in:
parent
a8f48feddb
commit
c5491e8205
@ -17,6 +17,13 @@ public class CheckBoxSetting extends SettingsItem
|
||||
mSetting = setting;
|
||||
}
|
||||
|
||||
public CheckBoxSetting(AbstractBooleanSetting setting, CharSequence title,
|
||||
CharSequence description)
|
||||
{
|
||||
super(title, description);
|
||||
mSetting = setting;
|
||||
}
|
||||
|
||||
public boolean isChecked(Settings settings)
|
||||
{
|
||||
return mSetting.getBoolean(settings);
|
||||
|
@ -9,11 +9,10 @@ public class LogCheckBoxSetting extends CheckBoxSetting
|
||||
{
|
||||
String mKey;
|
||||
|
||||
public LogCheckBoxSetting(Context context, String key, int titleId, int descriptionId)
|
||||
public LogCheckBoxSetting(String key, CharSequence title, CharSequence description)
|
||||
{
|
||||
super(context,
|
||||
new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false),
|
||||
titleId, descriptionId);
|
||||
super(new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false),
|
||||
title, description);
|
||||
mKey = key;
|
||||
}
|
||||
|
||||
|
@ -176,6 +176,13 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
mView.onSettingChanged();
|
||||
}
|
||||
|
||||
public void notifyAllSettingsChanged()
|
||||
{
|
||||
notifyItemRangeChanged(0, getItemCount());
|
||||
|
||||
mView.onSettingChanged();
|
||||
}
|
||||
|
||||
public void onBooleanClick(CheckBoxSetting item, int position, boolean checked)
|
||||
{
|
||||
item.setChecked(getSettings(), checked);
|
||||
@ -334,20 +341,6 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
mClickedItem = null;
|
||||
}
|
||||
|
||||
public void setAllLogTypes(boolean value)
|
||||
{
|
||||
Settings settings = mView.getSettings();
|
||||
|
||||
for (Map.Entry<String, String> entry : SettingsFragmentPresenter.LOG_TYPE_NAMES.entrySet())
|
||||
{
|
||||
new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, entry.getKey(),
|
||||
false).setBoolean(settings, value);
|
||||
}
|
||||
|
||||
notifyItemRangeChanged(0, getItemCount());
|
||||
mView.onSettingChanged();
|
||||
}
|
||||
|
||||
public static void clearLog()
|
||||
{
|
||||
// Don't delete the log in case it is being monitored by another app.
|
||||
|
@ -10,6 +10,7 @@ import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
|
||||
@ -50,7 +51,7 @@ public final class SettingsFragmentPresenter
|
||||
private final SettingsFragmentView mView;
|
||||
private final Context mContext;
|
||||
|
||||
public static final LinkedHashMap<String, String> LOG_TYPE_NAMES =
|
||||
private static final LinkedHashMap<String, String> LOG_TYPE_NAMES =
|
||||
NativeLibrary.GetLogTypeNames();
|
||||
|
||||
public static final String ARG_CONTROLLER_TYPE = "controller_type";
|
||||
@ -748,19 +749,16 @@ public final class SettingsFragmentPresenter
|
||||
sl.add(new SingleChoiceSetting(mContext, IntSetting.LOGGER_VERBOSITY, R.string.log_verbosity, 0,
|
||||
getLogVerbosityEntries(), getLogVerbosityValues()));
|
||||
sl.add(new RunRunnable(mContext, R.string.log_enable_all, 0,
|
||||
R.string.log_enable_all_confirmation, 0,
|
||||
() -> mView.getAdapter().setAllLogTypes(true)));
|
||||
R.string.log_enable_all_confirmation, 0, () -> setAllLogTypes(true)));
|
||||
sl.add(new RunRunnable(mContext, R.string.log_disable_all, 0,
|
||||
R.string.log_disable_all_confirmation, 0,
|
||||
() -> mView.getAdapter().setAllLogTypes(false)));
|
||||
R.string.log_disable_all_confirmation, 0, () -> setAllLogTypes(false)));
|
||||
sl.add(new RunRunnable(mContext, R.string.log_clear, 0, R.string.log_clear_confirmation, 0,
|
||||
SettingsAdapter::clearLog));
|
||||
|
||||
sl.add(new HeaderSetting(mContext, R.string.log_types, 0));
|
||||
for (Map.Entry<String, String> entry : LOG_TYPE_NAMES.entrySet())
|
||||
{
|
||||
// TitleID is handled by special case in CheckBoxSettingViewHolder.
|
||||
sl.add(new LogCheckBoxSetting(mContext, entry.getKey(), 0, 0));
|
||||
sl.add(new LogCheckBoxSetting(entry.getKey(), entry.getValue(), ""));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1341,4 +1339,17 @@ public final class SettingsFragmentPresenter
|
||||
return R.array.logVerbosityValuesMaxLevelInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllLogTypes(boolean value)
|
||||
{
|
||||
Settings settings = mView.getSettings();
|
||||
|
||||
for (Map.Entry<String, String> entry : LOG_TYPE_NAMES.entrySet())
|
||||
{
|
||||
new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, entry.getKey(),
|
||||
false).setBoolean(settings, value);
|
||||
}
|
||||
|
||||
mView.getAdapter().notifyAllSettingsChanged();
|
||||
}
|
||||
}
|
||||
|
@ -41,17 +41,7 @@ public final class CheckBoxSettingViewHolder extends SettingViewHolder
|
||||
{
|
||||
mItem = (CheckBoxSetting) item;
|
||||
|
||||
// Special case for LogTypes retrieved via JNI since those aren't string references.
|
||||
if (TextUtils.isEmpty(item.getName()) && item instanceof LogCheckBoxSetting)
|
||||
{
|
||||
String key = ((LogCheckBoxSetting) item).getKey();
|
||||
mTextSettingName.setText(SettingsFragmentPresenter.LOG_TYPE_NAMES.get(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextSettingName.setText(item.getName());
|
||||
}
|
||||
|
||||
mTextSettingName.setText(item.getName());
|
||||
mTextSettingDescription.setText(item.getDescription());
|
||||
|
||||
mCheckbox.setChecked(mItem.isChecked(getAdapter().getSettings()));
|
||||
|
Loading…
Reference in New Issue
Block a user