mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-01 10:20:33 +00:00
Android: Minor cleanup
This commit is contained in:
parent
e0b64e0ef8
commit
30ea98177a
@ -67,7 +67,6 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private MotionListener mMotionListener;
|
private MotionListener mMotionListener;
|
||||||
private ControllerMappingHelper mControllerMappingHelper;
|
|
||||||
|
|
||||||
private Settings mSettings;
|
private Settings mSettings;
|
||||||
|
|
||||||
@ -317,7 +316,6 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
sIsGameCubeGame = Platform.fromNativeInt(mPlatform) == Platform.GAMECUBE;
|
sIsGameCubeGame = Platform.fromNativeInt(mPlatform) == Platform.GAMECUBE;
|
||||||
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
|
mDeviceHasTouchScreen = getPackageManager().hasSystemFeature("android.hardware.touchscreen");
|
||||||
mMotionListener = new MotionListener(this);
|
mMotionListener = new MotionListener(this);
|
||||||
mControllerMappingHelper = new ControllerMappingHelper();
|
|
||||||
|
|
||||||
int themeId;
|
int themeId;
|
||||||
if (mDeviceHasTouchScreen)
|
if (mDeviceHasTouchScreen)
|
||||||
@ -445,19 +443,17 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
||||||
{
|
{
|
||||||
super.onActivityResult(requestCode, resultCode, result);
|
super.onActivityResult(requestCode, resultCode, result);
|
||||||
switch (requestCode)
|
if (requestCode == REQUEST_CHANGE_DISC)
|
||||||
{
|
{
|
||||||
case REQUEST_CHANGE_DISC:
|
// If the user picked a file, as opposed to just backing out.
|
||||||
// If the user picked a file, as opposed to just backing out.
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
{
|
||||||
|
String newDiscPath = FileBrowserHelper.getSelectedPath(result);
|
||||||
|
if (!TextUtils.isEmpty(newDiscPath))
|
||||||
{
|
{
|
||||||
String newDiscPath = FileBrowserHelper.getSelectedPath(result);
|
NativeLibrary.ChangeDisc(newDiscPath);
|
||||||
if (!TextUtils.isEmpty(newDiscPath))
|
|
||||||
{
|
|
||||||
NativeLibrary.ChangeDisc(newDiscPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1041,7 +1037,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private void setIRSensitivity()
|
private void setIRSensitivity()
|
||||||
{
|
{
|
||||||
int ir_pitch = Integer.valueOf(
|
int ir_pitch = Integer.parseInt(
|
||||||
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15"));
|
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15"));
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(this);
|
LayoutInflater inflater = LayoutInflater.from(this);
|
||||||
@ -1074,7 +1070,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int ir_yaw = Integer.valueOf(
|
int ir_yaw = Integer.parseInt(
|
||||||
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));
|
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));
|
||||||
|
|
||||||
TextView text_slider_value_yaw = (TextView) view.findViewById(R.id.text_ir_yaw);
|
TextView text_slider_value_yaw = (TextView) view.findViewById(R.id.text_ir_yaw);
|
||||||
@ -1105,7 +1101,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
int ir_vertical_offset = Integer.valueOf(
|
int ir_vertical_offset = Integer.parseInt(
|
||||||
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
|
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
|
||||||
"10"));
|
"10"));
|
||||||
|
|
||||||
@ -1176,9 +1172,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
|
new AlertDialog.Builder(this, R.style.DolphinDialogBase)
|
||||||
.setTitle(getString(R.string.emulation_touch_overlay_reset))
|
.setTitle(getString(R.string.emulation_touch_overlay_reset))
|
||||||
.setPositiveButton(R.string.yes, (dialogInterface, i) ->
|
.setPositiveButton(R.string.yes, (dialogInterface, i) ->
|
||||||
{
|
mEmulationFragment.resetInputOverlay())
|
||||||
mEmulationFragment.resetInputOverlay();
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
|
||||||
{
|
{
|
||||||
})
|
})
|
||||||
@ -1210,7 +1204,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
{
|
{
|
||||||
int axis = range.getAxis();
|
int axis = range.getAxis();
|
||||||
float origValue = event.getAxisValue(axis);
|
float origValue = event.getAxisValue(axis);
|
||||||
float value = mControllerMappingHelper.scaleAxis(input, axis, origValue);
|
float value = ControllerMappingHelper.scaleAxis(input, axis, origValue);
|
||||||
// If the input is still in the "flat" area, that means it's really zero.
|
// If the input is still in the "flat" area, that means it's really zero.
|
||||||
// This is used to compensate for imprecision in joysticks.
|
// This is used to compensate for imprecision in joysticks.
|
||||||
if (Math.abs(value) > range.getFlat())
|
if (Math.abs(value) > range.getFlat())
|
||||||
|
@ -44,20 +44,17 @@ public final class MotionAlertDialog extends AlertDialog
|
|||||||
public boolean onKeyEvent(int keyCode, KeyEvent event)
|
public boolean onKeyEvent(int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
Log.debug("[MotionAlertDialog] Received key event: " + event.getAction());
|
Log.debug("[MotionAlertDialog] Received key event: " + event.getAction());
|
||||||
switch (event.getAction())
|
if (event.getAction() == KeyEvent.ACTION_UP)
|
||||||
{
|
{
|
||||||
case KeyEvent.ACTION_UP:
|
if (!ControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode))
|
||||||
if (!ControllerMappingHelper.shouldKeyBeIgnored(event.getDevice(), keyCode))
|
{
|
||||||
{
|
setting.onKeyInput(event);
|
||||||
setting.onKeyInput(event);
|
dismiss();
|
||||||
dismiss();
|
}
|
||||||
}
|
// Even if we ignore the key, we still consume it. Thus return true regardless.
|
||||||
// Even if we ignore the key, we still consume it. Thus return true regardless.
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -143,11 +143,10 @@ public final class SettingsActivityPresenter
|
|||||||
|
|
||||||
public boolean handleOptionsItem(int itemId)
|
public boolean handleOptionsItem(int itemId)
|
||||||
{
|
{
|
||||||
switch (itemId)
|
if (itemId == R.id.menu_save_exit)
|
||||||
{
|
{
|
||||||
case R.id.menu_save_exit:
|
mView.finish();
|
||||||
mView.finish();
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -8,7 +8,6 @@ import org.dolphinemu.dolphinemu.R;
|
|||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker;
|
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.features.settings.utils.SettingsFile;
|
|
||||||
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||||
|
|
||||||
public final class FilePickerViewHolder extends SettingViewHolder
|
public final class FilePickerViewHolder extends SettingViewHolder
|
||||||
|
@ -432,10 +432,8 @@ public final class SettingsFile
|
|||||||
{
|
{
|
||||||
File ini = getSettingsFile(fileName);
|
File ini = getSettingsFile(fileName);
|
||||||
|
|
||||||
PrintWriter writer = null;
|
try (PrintWriter writer = new PrintWriter(ini, "UTF-8"))
|
||||||
try
|
|
||||||
{
|
{
|
||||||
writer = new PrintWriter(ini, "UTF-8");
|
|
||||||
|
|
||||||
Set<String> keySet = sections.keySet();
|
Set<String> keySet = sections.keySet();
|
||||||
Set<String> sortedKeySet = new TreeSet<>(keySet);
|
Set<String> sortedKeySet = new TreeSet<>(keySet);
|
||||||
@ -459,13 +457,6 @@ public final class SettingsFile
|
|||||||
if (view != null)
|
if (view != null)
|
||||||
view.showToastMessage("Error saving " + fileName + ".ini: " + e.getMessage());
|
view.showToastMessage("Error saving " + fileName + ".ini: " + e.getMessage());
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (writer != null)
|
|
||||||
{
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveCustomGameSettings(final String gameId,
|
public static void saveCustomGameSettings(final String gameId,
|
||||||
@ -534,14 +525,14 @@ public final class SettingsFile
|
|||||||
DirectoryInitialization.copyFile(defautlWiiProfilePath, wiiConfigPath);
|
DirectoryInitialization.copyFile(defautlWiiProfilePath, wiiConfigPath);
|
||||||
|
|
||||||
NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, "Device",
|
NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, "Device",
|
||||||
"Android/" + (Integer.valueOf(padId) + 4) + "/Touchscreen");
|
"Android/" + (Integer.parseInt(padId) + 4) + "/Touchscreen");
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, key, value);
|
NativeLibrary.SetProfileSetting(profile, Settings.SECTION_PROFILE, key, value);
|
||||||
|
|
||||||
// Enable the profile
|
// Enable the profile
|
||||||
NativeLibrary.SetUserSetting(gameId, Settings.SECTION_CONTROLS,
|
NativeLibrary.SetUserSetting(gameId, Settings.SECTION_CONTROLS,
|
||||||
KEY_WIIMOTE_PROFILE + (Integer.valueOf(padId) + 1), profile);
|
KEY_WIIMOTE_PROFILE + (Integer.parseInt(padId) + 1), profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String mapSectionNameFromIni(String generalSectionName)
|
private static String mapSectionNameFromIni(String generalSectionName)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2013 Dolphin Emulator Project
|
* Copyright 2013 Dolphin Emulator Project
|
||||||
* Licensed under GPLv2+
|
* Licensed under GPLv2+
|
||||||
* Refer to the license.txt file included.
|
* Refer to the license.txt file included.
|
||||||
@ -1075,14 +1075,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
|||||||
// Decide inner scale based on joystick ID
|
// Decide inner scale based on joystick ID
|
||||||
float innerScale;
|
float innerScale;
|
||||||
|
|
||||||
switch (joystick)
|
if (joystick == ButtonType.STICK_C)
|
||||||
{
|
{
|
||||||
case ButtonType.STICK_C:
|
innerScale = 1.833f;
|
||||||
innerScale = 1.833f;
|
}
|
||||||
break;
|
else
|
||||||
default:
|
{
|
||||||
innerScale = 1.375f;
|
innerScale = 1.375f;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now set the bounds for the InputOverlayDrawableJoystick.
|
// Now set the bounds for the InputOverlayDrawableJoystick.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2013 Dolphin Emulator Project
|
* Copyright 2013 Dolphin Emulator Project
|
||||||
* Licensed under GPLv2+
|
* Licensed under GPLv2+
|
||||||
* Refer to the license.txt file included.
|
* Refer to the license.txt file included.
|
||||||
@ -70,7 +70,7 @@ public final class InputOverlayDrawableButton
|
|||||||
return mTrackId;
|
return mTrackId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onConfigureTouch(MotionEvent event)
|
public void onConfigureTouch(MotionEvent event)
|
||||||
{
|
{
|
||||||
int pointerIndex = event.getActionIndex();
|
int pointerIndex = event.getActionIndex();
|
||||||
int fingerPositionX = (int) event.getX(pointerIndex);
|
int fingerPositionX = (int) event.getX(pointerIndex);
|
||||||
@ -89,9 +89,7 @@ public final class InputOverlayDrawableButton
|
|||||||
mPreviousTouchX = fingerPositionX;
|
mPreviousTouchX = fingerPositionX;
|
||||||
mPreviousTouchY = fingerPositionY;
|
mPreviousTouchY = fingerPositionY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(int x, int y)
|
public void setPosition(int x, int y)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2016 Dolphin Emulator Project
|
* Copyright 2016 Dolphin Emulator Project
|
||||||
* Licensed under GPLv2+
|
* Licensed under GPLv2+
|
||||||
* Refer to the license.txt file included.
|
* Refer to the license.txt file included.
|
||||||
@ -148,7 +148,7 @@ public final class InputOverlayDrawableDpad
|
|||||||
return mTrackId;
|
return mTrackId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onConfigureTouch(MotionEvent event)
|
public void onConfigureTouch(MotionEvent event)
|
||||||
{
|
{
|
||||||
int pointerIndex = event.getActionIndex();
|
int pointerIndex = event.getActionIndex();
|
||||||
int fingerPositionX = (int) event.getX(pointerIndex);
|
int fingerPositionX = (int) event.getX(pointerIndex);
|
||||||
@ -167,9 +167,7 @@ public final class InputOverlayDrawableDpad
|
|||||||
mPreviousTouchX = fingerPositionX;
|
mPreviousTouchX = fingerPositionX;
|
||||||
mPreviousTouchY = fingerPositionY;
|
mPreviousTouchY = fingerPositionY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(int x, int y)
|
public void setPosition(int x, int y)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2013 Dolphin Emulator Project
|
* Copyright 2013 Dolphin Emulator Project
|
||||||
* Licensed under GPLv2+
|
* Licensed under GPLv2+
|
||||||
* Refer to the license.txt file included.
|
* Refer to the license.txt file included.
|
||||||
@ -165,7 +165,7 @@ public final class InputOverlayDrawableJoystick
|
|||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onConfigureTouch(MotionEvent event)
|
public void onConfigureTouch(MotionEvent event)
|
||||||
{
|
{
|
||||||
int pointerIndex = event.getActionIndex();
|
int pointerIndex = event.getActionIndex();
|
||||||
int fingerPositionX = (int) event.getX(pointerIndex);
|
int fingerPositionX = (int) event.getX(pointerIndex);
|
||||||
@ -195,7 +195,6 @@ public final class InputOverlayDrawableJoystick
|
|||||||
mPreviousTouchY = fingerPositionY;
|
mPreviousTouchY = fingerPositionY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2013 Dolphin Emulator Project
|
* Copyright 2013 Dolphin Emulator Project
|
||||||
* Licensed under GPLv2+
|
* Licensed under GPLv2+
|
||||||
* Refer to the license.txt file included.
|
* Refer to the license.txt file included.
|
||||||
|
@ -109,6 +109,10 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
|||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
if (isChangingConfigurations())
|
||||||
|
{
|
||||||
|
skipRescanningLibrary();
|
||||||
|
}
|
||||||
StartupHandler.setSessionTime(this);
|
StartupHandler.setSessionTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,36 +178,34 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
||||||
{
|
{
|
||||||
super.onActivityResult(requestCode, resultCode, result);
|
super.onActivityResult(requestCode, resultCode, result);
|
||||||
switch (requestCode)
|
|
||||||
|
// If the user picked a file, as opposed to just backing out.
|
||||||
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
{
|
{
|
||||||
case MainPresenter.REQUEST_DIRECTORY:
|
switch (requestCode)
|
||||||
// If the user picked a file, as opposed to just backing out.
|
{
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
case MainPresenter.REQUEST_DIRECTORY:
|
||||||
{
|
|
||||||
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
|
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case MainPresenter.REQUEST_GAME_FILE:
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
|
||||||
{
|
|
||||||
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case MainPresenter.REQUEST_WAD_FILE:
|
case MainPresenter.REQUEST_WAD_FILE:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
|
||||||
{
|
|
||||||
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skipRescanningLibrary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults)
|
||||||
{
|
{
|
||||||
if (requestCode == PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION)
|
if (requestCode == PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION)
|
||||||
{
|
{
|
||||||
|
@ -43,8 +43,6 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
|
|
||||||
private BrowseSupportFragment mBrowseFragment;
|
private BrowseSupportFragment mBrowseFragment;
|
||||||
|
|
||||||
private ArrayObjectAdapter mRowsAdapter;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
@ -95,6 +93,10 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
if (isChangingConfigurations())
|
||||||
|
{
|
||||||
|
skipRescanningLibrary();
|
||||||
|
}
|
||||||
StartupHandler.setSessionTime(this);
|
StartupHandler.setSessionTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,31 +189,28 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
||||||
{
|
{
|
||||||
super.onActivityResult(requestCode, resultCode, result);
|
super.onActivityResult(requestCode, resultCode, result);
|
||||||
switch (requestCode)
|
|
||||||
|
// If the user picked a file, as opposed to just backing out.
|
||||||
|
if (resultCode == MainActivity.RESULT_OK)
|
||||||
{
|
{
|
||||||
case MainPresenter.REQUEST_DIRECTORY:
|
switch (requestCode)
|
||||||
// If the user picked a file, as opposed to just backing out.
|
{
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
case MainPresenter.REQUEST_DIRECTORY:
|
||||||
{
|
|
||||||
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
|
mPresenter.onDirectorySelected(FileBrowserHelper.getSelectedPath(result));
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case MainPresenter.REQUEST_GAME_FILE:
|
case MainPresenter.REQUEST_GAME_FILE:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
|
||||||
{
|
|
||||||
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case MainPresenter.REQUEST_WAD_FILE:
|
case MainPresenter.REQUEST_WAD_FILE:
|
||||||
// If the user picked a file, as opposed to just backing out.
|
|
||||||
if (resultCode == MainActivity.RESULT_OK)
|
|
||||||
{
|
|
||||||
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skipRescanningLibrary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,29 +218,28 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||||
@NonNull int[] grantResults)
|
@NonNull int[] grantResults)
|
||||||
{
|
{
|
||||||
switch (requestCode)
|
if (requestCode == PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION)
|
||||||
{
|
{
|
||||||
case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION:
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
||||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
{
|
||||||
{
|
DirectoryInitialization.start(this);
|
||||||
DirectoryInitialization.start(this);
|
GameFileCacheService.startLoad(this);
|
||||||
GameFileCacheService.startLoad(this);
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT)
|
||||||
Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT)
|
.show();
|
||||||
.show();
|
}
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
default:
|
{
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildRowsAdapter()
|
private void buildRowsAdapter()
|
||||||
{
|
{
|
||||||
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
|
ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
|
||||||
|
|
||||||
if (PermissionsHandler.hasWriteAccess(this))
|
if (PermissionsHandler.hasWriteAccess(this))
|
||||||
{
|
{
|
||||||
@ -255,13 +253,13 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
// Add row to the adapter only if it is not empty.
|
// Add row to the adapter only if it is not empty.
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
mRowsAdapter.add(row);
|
rowsAdapter.add(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mRowsAdapter.add(buildSettingsRow());
|
rowsAdapter.add(buildSettingsRow());
|
||||||
|
|
||||||
mBrowseFragment.setAdapter(mRowsAdapter);
|
mBrowseFragment.setAdapter(rowsAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListRow buildGamesRow(Platform platform, Collection<GameFile> gameFiles)
|
private ListRow buildGamesRow(Platform platform, Collection<GameFile> gameFiles)
|
||||||
|
@ -80,7 +80,7 @@ public class AppLinkHelper
|
|||||||
|
|
||||||
private static long extractLong(Uri uri, int index)
|
private static long extractLong(Uri uri, int index)
|
||||||
{
|
{
|
||||||
return Long.valueOf(extract(uri, index));
|
return Long.parseLong(extract(uri, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String extract(Uri uri, int index)
|
private static String extract(Uri uri, int index)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2014 Dolphin Emulator Project
|
* Copyright 2014 Dolphin Emulator Project
|
||||||
* Licensed under GPLv2+
|
* Licensed under GPLv2+
|
||||||
* Refer to the license.txt file included.
|
* Refer to the license.txt file included.
|
||||||
@ -267,12 +267,23 @@ public final class DirectoryInitialization
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
String[] assetList = context.getAssets().list(assetFolder);
|
||||||
|
|
||||||
|
if (assetList == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean createdFolder = false;
|
boolean createdFolder = false;
|
||||||
for (String file : context.getAssets().list(assetFolder))
|
for (String file : assetList)
|
||||||
{
|
{
|
||||||
if (!createdFolder)
|
if (!createdFolder)
|
||||||
{
|
{
|
||||||
outputFolder.mkdir();
|
if (!outputFolder.mkdir())
|
||||||
|
{
|
||||||
|
Log.error("[DirectoryInitialization] Failed to create folder " +
|
||||||
|
outputFolder.getAbsolutePath());
|
||||||
|
}
|
||||||
createdFolder = true;
|
createdFolder = true;
|
||||||
}
|
}
|
||||||
copyAssetFolder(assetFolder + File.separator + file, new File(outputFolder, file),
|
copyAssetFolder(assetFolder + File.separator + file, new File(outputFolder, file),
|
||||||
@ -317,7 +328,10 @@ public final class DirectoryInitialization
|
|||||||
File wiiPath = new File(directory);
|
File wiiPath = new File(directory);
|
||||||
if (!wiiPath.isDirectory())
|
if (!wiiPath.isDirectory())
|
||||||
{
|
{
|
||||||
wiiPath.mkdirs();
|
if (!wiiPath.mkdirs())
|
||||||
|
{
|
||||||
|
Log.error("[DirectoryInitialization] Failed to create folder " + wiiPath.getAbsolutePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2013 Dolphin Emulator Project
|
* Copyright 2013 Dolphin Emulator Project
|
||||||
* Licensed under GPLv2+
|
* Licensed under GPLv2+
|
||||||
* Refer to the license.txt file included.
|
* Refer to the license.txt file included.
|
||||||
@ -223,14 +223,14 @@ public final class EGLHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detects the specific kind of GL modes that are supported
|
// Detects the specific kind of GL modes that are supported
|
||||||
private boolean detect()
|
private void detect()
|
||||||
{
|
{
|
||||||
// Get total number of configs available.
|
// Get total number of configs available.
|
||||||
int[] numConfigs = new int[1];
|
int[] numConfigs = new int[1];
|
||||||
if (!mEGL.eglGetConfigs(mDisplay, null, 0, numConfigs))
|
if (!mEGL.eglGetConfigs(mDisplay, null, 0, numConfigs))
|
||||||
{
|
{
|
||||||
Log.error("[EGLHelper] Error retrieving number of EGL configs available.");
|
Log.error("[EGLHelper] Error retrieving number of EGL configs available.");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now get all the configurations
|
// Now get all the configurations
|
||||||
@ -238,7 +238,7 @@ public final class EGLHelper
|
|||||||
if (!mEGL.eglGetConfigs(mDisplay, mEGLConfigs, mEGLConfigs.length, numConfigs))
|
if (!mEGL.eglGetConfigs(mDisplay, mEGLConfigs, mEGLConfigs.length, numConfigs))
|
||||||
{
|
{
|
||||||
Log.error("[EGLHelper] Error retrieving all EGL configs.");
|
Log.error("[EGLHelper] Error retrieving all EGL configs.");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EGLConfig mEGLConfig : mEGLConfigs)
|
for (EGLConfig mEGLConfig : mEGLConfigs)
|
||||||
@ -258,8 +258,6 @@ public final class EGLHelper
|
|||||||
supportGLES3 = true;
|
supportGLES3 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the context and surface.
|
// Creates the context and surface.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user