-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67730f5
commit 788df1c
Showing
77 changed files
with
627 additions
and
1,267 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="io.mgba"> | ||
|
||
<uses-feature | ||
android:name="android.hardware.touchscreen" | ||
android:required="false" /> | ||
<uses-feature | ||
android:name="android.hardware.gamepad" | ||
android:required="false" /> | ||
<uses-feature android:name="android.hardware.touchscreen" | ||
android:required="true" /> | ||
<uses-feature android:name="android.hardware.gamepad" | ||
android:required="false" /> | ||
<uses-feature android:glEsVersion="0x00020000" /> | ||
|
||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".mgba" | ||
android:allowBackup="true" | ||
android:allowBackup="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".main.MainActivity" | ||
android:theme="@style/AppTheme" /> | ||
|
||
<activity | ||
android:name="com.nononsenseapps.filepicker.Views.Activities.FilePickerActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/FilePickerTheme"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.GET_CONTENT" /> | ||
android:roundIcon="@mipmap/ic_launcher" | ||
tools:ignore="AllowBackup,GoogleAppIndexingWarning" | ||
android:theme="@style/MainTheme"> | ||
|
||
<category android:name="android.intent.category.DEFAULT" /> | ||
<activity android:name=".splash.SplashActivity" | ||
android:screenOrientation="portrait" | ||
android:theme="@style/SplashStyle"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name=".settings.sections.SettingsPanelActivity" | ||
android:label="@string/title_activity_settings" | ||
android:theme="@style/SettingsTheme" /> | ||
<activity android:name=".setup.SetupActivity" /> | ||
<activity android:name=".main.MainActivity" | ||
android:theme="@style/MainTheme" /> | ||
|
||
<activity | ||
android:name=".splash.SplashActivity" | ||
android:screenOrientation="portrait" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name="com.nononsenseapps.filepicker.Views.Activities.FilePickerActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/FilePickerTheme"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<action android:name="android.intent.action.GET_CONTENT" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".emulation.EmulationActivity" /> | ||
|
||
<activity android:name=".settings.sections.SettingsPanelActivity" | ||
android:label="@string/title_activity_settings" | ||
android:theme="@style/MainTheme" /> | ||
|
||
<activity android:name=".setup.SetupActivity" | ||
android:theme="@style/SetupTheme"/> | ||
|
||
<activity android:name=".emulation.EmulationActivity" | ||
android:theme="@style/MainTheme"/> | ||
|
||
<activity android:name=".settings.categories.SettingsCategoriesActivity" | ||
android:label="@string/title_activity_settings" | ||
android:theme="@style/SettingsTheme"/> | ||
</application> | ||
android:label="@string/title_activity_settings" | ||
android:theme="@style/MainTheme"/> | ||
|
||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.mgba.data | ||
|
||
import java.io.File | ||
import io.mgba.utilities.device.PreferencesManager.GAMES_DIRECTORY | ||
import io.mgba.utilities.device.PreferencesManager.get | ||
|
||
/** | ||
* Handles the fetching/filtering of the supported files for the selected dir. | ||
*/ | ||
object FilesManager { | ||
|
||
private val TAG = "FileService" | ||
|
||
private val GBC_FILES_SUPPORTED: List<String> = listOf("gba", "gb") | ||
private val GBA_FILES_SUPPORTED: List<String> = listOf("gbc") | ||
private var directory: File = File(get(GAMES_DIRECTORY, "")) | ||
|
||
val gameList: List<File> = if (!directory.exists()) emptyList() else fetchGames() | ||
var path: String | ||
get() = directory.absolutePath | ||
set(directory) { FilesManager.directory = File(directory) } | ||
|
||
/** | ||
* Based on the files of the directory, discard the ones we dont need. | ||
* If the file is a directory or the extension isnt in the FILES_SUPPORTED list, that file | ||
* isnt valid. | ||
* @param files the files of the directory | ||
* @return files that contain gba, gb, gbc extension and arent folders | ||
*/ | ||
private fun filter(files: Array<File>): List<File> { | ||
return files.toList() | ||
.filter { f -> !f.isDirectory && (GBA_FILES_SUPPORTED.contains(getFileExtension(f)) || GBC_FILES_SUPPORTED.contains(getFileExtension(f))) } | ||
.toList() | ||
} | ||
|
||
private fun fetchGames(): List<File> = filter(directory.listFiles()) | ||
|
||
/** | ||
* Gets the file extension. | ||
* For example. For the file 'a.bc' this method will return 'bc' | ||
* @param file The file to extract a extension | ||
* @return the file's extension | ||
*/ | ||
fun getFileExtension(file: File): String { | ||
val name = file.name | ||
|
||
return if (!name.contains(".")) name.substring(name.length - 3) else name | ||
.substring(file.name.lastIndexOf(".")) | ||
.substring(1) | ||
.toLowerCase() | ||
|
||
} | ||
|
||
/** | ||
* Gets the filename without the extension | ||
* @param file | ||
* @return | ||
*/ | ||
fun getFileWithoutExtension(file: File): String { | ||
val tmp = file.path.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() | ||
|
||
return tmp[tmp.size - 1].substring(0, tmp[tmp.size - 1].lastIndexOf(".")) | ||
} | ||
} |
Oops, something went wrong.