Skip to content

Commit

Permalink
* More updates.. Still doesnt build
Browse files Browse the repository at this point in the history
  • Loading branch information
Andr3Carvalh0 committed Oct 7, 2018
1 parent 67730f5 commit 788df1c
Show file tree
Hide file tree
Showing 77 changed files with 627 additions and 1,267 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
32 changes: 21 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {
android.compileOptions.targetCompatibility 1.8
}

dataBinding { enabled = true }

configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
Expand Down Expand Up @@ -62,6 +63,7 @@ android {
}

dependencies {
// Google
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'androidx.appcompat:appcompat:1.0.0'
Expand All @@ -72,30 +74,38 @@ dependencies {
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.room:room-runtime:2.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation "android.arch.work:work-runtime:1.0.0-alpha09"

// Kotlin
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.10'

// Lottie
implementation 'com.airbnb.android:lottie:2.8.0'

// Glide
implementation('com.github.florent37:glidepalette:2.1.1', { exclude group: 'com.android.support', 'module': 'palette-v7' })
implementation 'com.github.bumptech.glide:glide:4.8.0'

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'me.grantland:autofittextview:0.2.1'
implementation 'com.google.guava:guava:24.1-jre'
implementation 'com.github.apl-devs:appintro:v4.2.3'
implementation 'com.annimon:stream:1.2.0'
implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.1'

// Setup
implementation 'com.github.heinrichreimer:material-intro:1.6'

//To remove
implementation('com.mikepenz:aboutlibraries:6.0.6@aar') { transitive = true }
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5"
implementation 'me.grantland:autofittextview:0.2.1'

implementation fileTree(include: ['*.jar'], dir: 'libs')

//Tests
testImplementation 'org.mockito:mockito-core:2.19.0'
androidTestImplementation 'org.mockito:mockito-android:2.10.0'
testImplementation 'androidx.room:room-testing:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' })

//Annotations
kapt "androidx.room:room-compiler:2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion app/src/androidTest/java/io/mgba/DatabaseTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.io.IOException;
import java.util.List;

import io.mgba.data.local.database.Database;
import io.mgba.data.local.Database;
import io.mgba.data.local.database.model.Game;
import io.mgba.data.Platform;
import io.mgba.data.io.Repository;
Expand Down
72 changes: 36 additions & 36 deletions app/src/main/AndroidManifest.xml
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>
12 changes: 12 additions & 0 deletions app/src/main/java/io/mgba/base/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ package io.mgba.base
import android.os.Bundle
import android.view.View
import android.app.Activity
import android.os.Build
import android.os.Build.VERSION_CODES.M
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import com.google.android.material.snackbar.Snackbar
import io.mgba.R
import io.mgba.widgets.MaterialSnackbar

abstract class BaseActivity<T : ViewModel> : AppCompatActivity() {
Expand All @@ -20,9 +25,16 @@ abstract class BaseActivity<T : ViewModel> : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(getLayout())
vm = ViewModelProviders.of(this).get(getViewModel())
colorizeStatusbar()
onCreate()
}

private fun colorizeStatusbar() {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = ContextCompat.getColor(this, R.color.statusbarColor)
}

open fun onCreate(){}

abstract fun getLayout(): Int
Expand Down
64 changes: 64 additions & 0 deletions app/src/main/java/io/mgba/data/FilesManager.kt
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("."))
}
}
Loading

0 comments on commit 788df1c

Please sign in to comment.