Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile app #42

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
618e906
Migrate to AndroidX
codebutler Nov 25, 2018
606673a
First implementation of touch inputs, currently attached to GameActiv…
Swordfish90 Sep 7, 2019
6e7bd1d
Add touch layout for Sega Genesis.
Swordfish90 Sep 7, 2019
4078e5f
Fix layout issue in GameBoyPad.
Swordfish90 Sep 7, 2019
9d860b9
Refactor GamePadView into BaseGamePad.
Swordfish90 Sep 7, 2019
888d361
Fix some klint issues.
Swordfish90 Sep 8, 2019
b041a18
Merge branch 'androidx' into mobile-app
Swordfish90 Sep 8, 2019
64e0fe5
First mobile app implementation. Currently only displays the list of …
Swordfish90 Sep 12, 2019
c3a7f31
Create a copy of GameActivity (TBD if needed) to mobile-app.
Swordfish90 Sep 13, 2019
2e2884c
Replace ram save with retro_serialize. Use gambatte instead of mgba f…
Swordfish90 Sep 13, 2019
1abddca
Fix lint issues.
Swordfish90 Sep 13, 2019
1aad489
Fill home screen with recent and favorite games.
Swordfish90 Sep 13, 2019
16cb4f3
Show library with systems instead of games.
Swordfish90 Sep 14, 2019
ef7bdd8
Add search functionality.
Swordfish90 Sep 15, 2019
e1c595e
Force both navigationbar color to be black.
Swordfish90 Sep 15, 2019
d1a914e
Fix wrong behaviour in activity recreation.
Swordfish90 Sep 15, 2019
9ff457d
Undo Picasso requests on view recycle.
Swordfish90 Sep 15, 2019
5e47f72
Display placeholder when cover art is missing.
Swordfish90 Sep 15, 2019
9be04fb
Completely clear items in viewholder unbind.
Swordfish90 Sep 15, 2019
086bb9b
Fix back button navigation.
Swordfish90 Sep 15, 2019
25f21b1
Avoid GameActivity recreation on rotation. This is temporary till pro…
Swordfish90 Sep 16, 2019
fdda9df
Enable immersive mode in GameActivity.
Swordfish90 Sep 16, 2019
0e45891
Rudimentary permission management in MainActivity.
Swordfish90 Sep 16, 2019
8dda108
LocalStorageProvider now only check in private app directories on mob…
Swordfish90 Sep 17, 2019
7afd3f2
Index games in a background Work. Update WorkManager version.
Swordfish90 Sep 17, 2019
8ab8b5c
Use StorageAccessFramework for roms. The first step towards proper An…
Swordfish90 Sep 18, 2019
0047465
Allow customizable haptic feedback.
Swordfish90 Sep 18, 2019
923f878
Make configuration changes really work.
Swordfish90 Sep 18, 2019
b8741bb
Revert "Allow customizable haptic feedback."
Swordfish90 Sep 20, 2019
10414ed
Enlarge touch controls on bigger devices.
Swordfish90 Sep 21, 2019
29d7c89
Fix code style issues and update kotlint version.
Swordfish90 Sep 21, 2019
bac2f04
Add app name.
Swordfish90 Sep 21, 2019
93bbed8
Add shader effects for lcd and crt.
Swordfish90 Sep 23, 2019
116fbf0
Add SNES gamepad.
Swordfish90 Sep 23, 2019
078a4ae
Some more code style.
Swordfish90 Sep 23, 2019
07f6473
Improve search layout and theming.
Swordfish90 Sep 24, 2019
4321bfe
Display material progressbar on indexing.
Swordfish90 Sep 25, 2019
69d8c8f
Improve lcd shader.
Swordfish90 Sep 25, 2019
6d9499e
Fix some ui issues.
Swordfish90 Sep 26, 2019
e69cc42
Redesign home screen with epoxy.
Swordfish90 Sep 27, 2019
e953d7d
Use lists instead of grids for games and search. Replace heart in gri…
Swordfish90 Sep 30, 2019
809bedd
Properly scale touch control size with display size.
Swordfish90 Oct 2, 2019
1539d64
Move viewmodel initializations in onResume.
Swordfish90 Oct 3, 2019
3d74e9b
Some lint fixes.
Swordfish90 Oct 3, 2019
e07ed85
Handle activity lifecycle persisting emulation state (in memory).
Swordfish90 Oct 4, 2019
6fe59e2
Properly handle touch subscriptions in onCreate.
Swordfish90 Oct 4, 2019
ca8d040
Fix immersive sticky mode behaviour.
Swordfish90 Oct 4, 2019
30340b4
Use thumbnail placeholders in epoxy views.
Swordfish90 Oct 4, 2019
f06ebd6
Take persistent uris when using storage access framework.
Swordfish90 Oct 4, 2019
aebc1b5
Cache storage access framework games for future access.
Swordfish90 Oct 4, 2019
544abe3
Disable translucent bars and use darker color variant.
Swordfish90 Oct 5, 2019
89b4258
Make actionbutton stroke width proportional to their size.
Swordfish90 Oct 5, 2019
6e3077f
Fix tiny behaviour issues in SearchFragment.
Swordfish90 Oct 5, 2019
66e43cf
Fix lint issues.
Swordfish90 Oct 7, 2019
90b763b
Fix work chain dying forever when an error occurs.
Swordfish90 Oct 7, 2019
d628c7e
Add full retropad support (psx like).
Swordfish90 Oct 7, 2019
b0281f0
Arcade simulation was no longer working. Use fbneo since fbalpha is n…
Swordfish90 Oct 7, 2019
5dd12dc
Hash functions in ovgdb are actually nullable.
Swordfish90 Oct 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use lists instead of grids for games and search. Replace heart in gri…
…ds with popup menu.
  • Loading branch information
Swordfish90 committed Sep 30, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit e953d7dfaa1e0b1d63450160f262235e269dea42
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.codebutler.retrograde.R
import com.codebutler.retrograde.app.shared.DynamicGridLayoutManager
@@ -37,7 +38,7 @@ class GamesFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val root = inflater.inflate(R.layout.fragment_games, container, false)

gamesAdapter = GamesAdapter(R.layout.layout_game, gameInteractor)
gamesAdapter = GamesAdapter(R.layout.layout_game_list, gameInteractor)

gamesViewModel = ViewModelProviders.of(this, GamesViewModel.Factory(retrogradeDb))
.get(GamesViewModel::class.java)
@@ -52,7 +53,7 @@ class GamesFragment : Fragment() {

root.findViewById<RecyclerView>(R.id.games_recyclerview).apply {
this.adapter = gamesAdapter
this.layoutManager = DynamicGridLayoutManager(context, 2)
this.layoutManager = LinearLayoutManager(context)
}

return root
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import com.airbnb.epoxy.EpoxyHolder
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import android.widget.ToggleButton
import com.airbnb.epoxy.EpoxyAttribute
import com.codebutler.retrograde.app.shared.GameContextMenuListener
import com.squareup.picasso.Picasso


@@ -17,20 +17,18 @@ abstract class EpoxyGameView : EpoxyModelWithHolder<EpoxyGameView.Holder>() {

@EpoxyAttribute var title: String? = null
@EpoxyAttribute var coverUrl: String? = null
@EpoxyAttribute var toggled: Boolean? = null
@EpoxyAttribute var favorite: Boolean? = null
@EpoxyAttribute var onClick: (() -> Unit)? = null
@EpoxyAttribute var onToggle: ((Boolean) -> Unit)? = null
@EpoxyAttribute var onFavoriteChanged: ((Boolean) -> Unit)? = null

override fun bind(holder: Holder) {
holder.titleView?.text = title
Picasso.get().load(coverUrl).into(holder.coverView)
holder.itemView?.setOnClickListener { onClick?.invoke() }
holder.favoriteToggle?.isChecked = toggled ?: false
holder.favoriteToggle?.setOnCheckedChangeListener { _, isChecked -> onToggle?.invoke(isChecked) }
holder.itemView?.setOnCreateContextMenuListener(GameContextMenuListener(favorite, onClick, onFavoriteChanged))
}

override fun unbind(holder: Holder) {
holder.favoriteToggle?.setOnCheckedChangeListener(null)
holder.itemView?.setOnClickListener(null)
holder.coverView?.apply {
Picasso.get().cancelRequest(this)
@@ -42,13 +40,11 @@ abstract class EpoxyGameView : EpoxyModelWithHolder<EpoxyGameView.Holder>() {
var itemView: View? = null
var titleView: TextView? = null
var coverView: ImageView? = null
var favoriteToggle: ToggleButton? = null

override fun bindView(itemView: View) {
this.itemView = itemView
this.titleView = itemView.findViewById(R.id.text)
this.coverView = itemView.findViewById(R.id.image)
this.favoriteToggle = itemView.findViewById(R.id.favorite_toggle)
}
}
}
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ class EpoxyHomeController(private val gameInteractor: GameInteractor): PagedList
.id(item.id)
.title(item.title)
.coverUrl(item.coverFrontUrl)
.toggled(item.isFavorite)
.onToggle { gameInteractor.onFavoriteToggle(item, it) }
.favorite(item.isFavorite)
.onFavoriteChanged { gameInteractor.onFavoriteToggle(item, it) }
.onClick { gameInteractor.onGameClick(item) }
}
}
@@ -44,8 +44,8 @@ class EpoxyHomeController(private val gameInteractor: GameInteractor): PagedList
.id(item.id)
.title(item.title)
.coverUrl(item.coverFrontUrl)
.toggled(item.isFavorite)
.onToggle { gameInteractor.onFavoriteToggle(item, it) }
.favorite(item.isFavorite)
.onFavoriteChanged { gameInteractor.onFavoriteToggle(item, it) }
.onClick { gameInteractor.onGameClick(item) }
}
}
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import androidx.appcompat.widget.SearchView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.codebutler.retrograde.R
import com.codebutler.retrograde.app.shared.DynamicGridLayoutManager
@@ -81,7 +82,7 @@ class SearchFragment : Fragment() {
override fun onResume() {
super.onResume()

val gamesAdapter = GamesAdapter(R.layout.layout_game, gameInteractor)
val gamesAdapter = GamesAdapter(R.layout.layout_game_list, gameInteractor)
searchViewModel.searchResults.observe(this, Observer {
gamesAdapter.submitList(it)
})
@@ -94,7 +95,7 @@ class SearchFragment : Fragment() {

view?.findViewById<RecyclerView>(R.id.search_recyclerview)?.apply {
this.adapter = gamesAdapter
this.layoutManager = DynamicGridLayoutManager(context, 2)
this.layoutManager = LinearLayoutManager(context)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.codebutler.retrograde.app.shared

import android.view.ContextMenu
import android.view.View
import com.codebutler.retrograde.R

class GameContextMenuListener(
private val isFavorite: Boolean?,
private val onPlaySelected: (() -> Unit)?,
private val onFavoriteChanged: ((Boolean) -> Unit)?
): View.OnCreateContextMenuListener {

override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) {
menu.add(R.string.play).setOnMenuItemClickListener {
onPlaySelected?.invoke()
true
}
when (isFavorite) {
true -> {
menu.add(R.string.remove_from_favorites).setOnMenuItemClickListener {
onFavoriteChanged?.invoke(false)
true
}
}
false -> {
menu.add(R.string.add_to_favorites).setOnMenuItemClickListener {
onFavoriteChanged?.invoke(true)
true
}
}
else -> Unit // Do nothing if is favorite is null
}
}
}
Original file line number Diff line number Diff line change
@@ -10,22 +10,30 @@ import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.codebutler.retrograde.R
import com.codebutler.retrograde.lib.library.GameSystem
import com.codebutler.retrograde.lib.library.db.entity.Game
import com.squareup.picasso.Picasso

class GameViewHolder(parent: View) : RecyclerView.ViewHolder(parent) {
private var titleView: TextView? = null
private var subtitleView: TextView? = null
private var coverView: ImageView? = null
private var favoriteToggle: ToggleButton? = null

init {
titleView = itemView.findViewById(R.id.text)
subtitleView = itemView.findViewById(R.id.subtext)
coverView = itemView.findViewById(R.id.image)
favoriteToggle = itemView.findViewById(R.id.favorite_toggle)
}

fun bind(game: Game, gameInteractor: GameInteractor) {
val systemName = GameSystem.findById(game.systemId)?.shortTitleResId?.let {
itemView.context.getString(it)
} ?: ""

titleView?.text = game.title
subtitleView?.text = "${systemName} - ${game.developer}"
favoriteToggle?.isChecked = game.isFavorite

Picasso.get()
14 changes: 1 addition & 13 deletions retrograde-app-mobile/src/main/res/layout/layout_game.xml
Original file line number Diff line number Diff line change
@@ -34,23 +34,11 @@
android:lines="1"
android:textAppearance="?attr/textAppearanceSubtitle2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/favorite_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/image"
tools:text="Game Name" />

<ToggleButton
android:id="@+id/favorite_toggle"
android:layout_width="@dimen/favorite_toggle_size"
android:layout_height="@dimen/favorite_toggle_size"
android:layout_gravity="center_vertical"
android:layout_marginEnd="8dp"
android:background="@drawable/favorite_button"
android:textOff=""
android:textOn=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</com.codebutler.retrograde.app.shared.SquaredMaterialCardView>
70 changes: 70 additions & 0 deletions retrograde-app-mobile/src/main/res/layout/layout_game_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/size_game_list">

<ImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:textAppearance="?attr/textAppearanceSubtitle1"
app:layout_constraintEnd_toStartOf="@+id/favorite_toggle"
app:layout_constraintStart_toEndOf="@+id/image"
app:layout_constraintTop_toTopOf="parent"
tools:text="Game Name" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/subtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:textAppearance="?attr/textAppearanceCaption"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/favorite_toggle"
app:layout_constraintStart_toEndOf="@+id/image"
tools:text="Game Name" />

<ToggleButton
android:id="@+id/favorite_toggle"
android:layout_width="@dimen/favorite_toggle_size"
android:layout_height="@dimen/favorite_toggle_size"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/favorite_button"
android:textOff=""
android:textOn=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions retrograde-app-mobile/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -2,4 +2,5 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="game_entry_size">160dp</dimen>
<dimen name="favorite_toggle_size">24dp</dimen>
<dimen name="size_game_list">72dp</dimen>
</resources>
4 changes: 4 additions & 0 deletions retrograde-app-mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -14,6 +14,10 @@
<string name="graphics">Graphics</string>
<string name="roms">Roms</string>

<string name="add_to_favorites">Add to favorites</string>
<string name="remove_from_favorites">Remove from favorites</string>
<string name="play">Play</string>

<string-array name="shader_entries">
<item>Auto</item>
<item>CRT</item>