Skip to content

Commit

Permalink
Android: Display default path when no path is set
Browse files Browse the repository at this point in the history
  • Loading branch information
JosJuice committed Sep 1, 2020
1 parent d8f9918 commit 024c37f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting;

import androidx.annotation.Nullable;

public final class FilePicker extends SettingsItem
{
private AbstractStringSetting mSetting;
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);
mSetting = setting;
mRequestType = requestType;
mDefaultPathRelativeToUserDirectory = defaultPathRelativeToUserDirectory;
}

public String getSelectedValue(Settings settings)
Expand All @@ -31,6 +36,12 @@ public int getRequestType()
return mRequestType;
}

@Nullable
public String getDefaultPathRelativeToUserDirectory()
{
return mDefaultPathRelativeToUserDirectory;
}

@Override
public int getType()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,17 @@ private void addPathsSettings(ArrayList<SettingsItem> sl)
sl.add(new CheckBoxSetting(BooleanSetting.MAIN_RECURSIVE_ISO_PATHS, R.string.search_subfolders,
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,
MainPresenter.REQUEST_DIRECTORY));
MainPresenter.REQUEST_DIRECTORY, "/Wii"));
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,
MainPresenter.REQUEST_DIRECTORY));
MainPresenter.REQUEST_DIRECTORY, "/Load"));
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,
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,
mView.getAdapter()::resetPaths));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

Expand All @@ -8,6 +9,7 @@
import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;

public final class FilePickerViewHolder extends SettingViewHolder
{
Expand Down Expand Up @@ -43,7 +45,18 @@ public void bind(SettingsItem item)
}
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);
Expand Down

0 comments on commit 024c37f

Please sign in to comment.