Android: Display default path when no path is set

This commit is contained in:
JosJuice 2020-08-07 13:12:40 +02:00
parent 003696fd78
commit 744c0b13cf
3 changed files with 32 additions and 8 deletions

View File

@ -4,16 +4,21 @@ import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import androidx.annotation.Nullable;
public final class FilePicker extends SettingsItem public final class FilePicker extends SettingsItem
{ {
private AbstractStringSetting mSetting; private AbstractStringSetting mSetting;
private int mRequestType; private int mRequestType;
private String mDefaultPathRelativeToUserDirectory;
public FilePicker(AbstractStringSetting setting, int titleId, int descriptionId, int requestType) public FilePicker(AbstractStringSetting setting, int titleId, int descriptionId, int requestType,
@Nullable String defaultPathRelativeToUserDirectory)
{ {
super(titleId, descriptionId); super(titleId, descriptionId);
mSetting = setting; mSetting = setting;
mRequestType = requestType; mRequestType = requestType;
mDefaultPathRelativeToUserDirectory = defaultPathRelativeToUserDirectory;
} }
public String getSelectedValue(Settings settings) public String getSelectedValue(Settings settings)
@ -31,6 +36,12 @@ public final class FilePicker extends SettingsItem
return mRequestType; return mRequestType;
} }
@Nullable
public String getDefaultPathRelativeToUserDirectory()
{
return mDefaultPathRelativeToUserDirectory;
}
@Override @Override
public int getType() public int getType()
{ {

View File

@ -342,17 +342,17 @@ public final class SettingsFragmentPresenter
sl.add(new CheckBoxSetting(BooleanSetting.MAIN_RECURSIVE_ISO_PATHS, R.string.search_subfolders, sl.add(new CheckBoxSetting(BooleanSetting.MAIN_RECURSIVE_ISO_PATHS, R.string.search_subfolders,
0)); 0));
sl.add(new FilePicker(StringSetting.MAIN_DEFAULT_ISO, R.string.default_ISO, 0, sl.add(new FilePicker(StringSetting.MAIN_DEFAULT_ISO, R.string.default_ISO, 0,
MainPresenter.REQUEST_GAME_FILE)); MainPresenter.REQUEST_GAME_FILE, null));
sl.add(new FilePicker(StringSetting.MAIN_FS_PATH, R.string.wii_NAND_root, 0, sl.add(new FilePicker(StringSetting.MAIN_FS_PATH, R.string.wii_NAND_root, 0,
MainPresenter.REQUEST_DIRECTORY)); MainPresenter.REQUEST_DIRECTORY, "/Wii"));
sl.add(new FilePicker(StringSetting.MAIN_DUMP_PATH, R.string.dump_path, 0, sl.add(new FilePicker(StringSetting.MAIN_DUMP_PATH, R.string.dump_path, 0,
MainPresenter.REQUEST_DIRECTORY)); MainPresenter.REQUEST_DIRECTORY, "/Dump"));
sl.add(new FilePicker(StringSetting.MAIN_LOAD_PATH, R.string.load_path, 0, sl.add(new FilePicker(StringSetting.MAIN_LOAD_PATH, R.string.load_path, 0,
MainPresenter.REQUEST_DIRECTORY)); MainPresenter.REQUEST_DIRECTORY, "/Load"));
sl.add(new FilePicker(StringSetting.MAIN_RESOURCEPACK_PATH, R.string.resource_pack_path, 0, sl.add(new FilePicker(StringSetting.MAIN_RESOURCEPACK_PATH, R.string.resource_pack_path, 0,
MainPresenter.REQUEST_DIRECTORY)); MainPresenter.REQUEST_DIRECTORY, "/ResourcePacks"));
sl.add(new FilePicker(StringSetting.MAIN_SD_PATH, R.string.SD_card_path, 0, sl.add(new FilePicker(StringSetting.MAIN_SD_PATH, R.string.SD_card_path, 0,
MainPresenter.REQUEST_SD_FILE)); MainPresenter.REQUEST_SD_FILE, "/Wii/sd.raw"));
sl.add(new ConfirmRunnable(R.string.reset_paths, 0, R.string.reset_paths_confirmation, 0, sl.add(new ConfirmRunnable(R.string.reset_paths, 0, R.string.reset_paths_confirmation, 0,
mView.getAdapter()::resetPaths)); mView.getAdapter()::resetPaths));
} }

View File

@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -8,6 +9,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker;
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
public final class FilePickerViewHolder extends SettingViewHolder public final class FilePickerViewHolder extends SettingViewHolder
{ {
@ -43,7 +45,18 @@ public final class FilePickerViewHolder extends SettingViewHolder
} }
else else
{ {
mTextSettingDescription.setText(mFilePicker.getSelectedValue(getAdapter().getSettings())); String path = mFilePicker.getSelectedValue(getAdapter().getSettings());
if (TextUtils.isEmpty(path))
{
String defaultPathRelative = mFilePicker.getDefaultPathRelativeToUserDirectory();
if (defaultPathRelative != null)
{
path = DirectoryInitialization.getUserDirectory() + defaultPathRelative;
}
}
mTextSettingDescription.setText(path);
} }
setStyle(mTextSettingName, mItem); setStyle(mTextSettingName, mItem);