Android: Add memory card editor

This commit is contained in:
Connor McLaughlin
2021-03-21 00:57:56 +10:00
parent 6d4a3bb5a5
commit 02e8c7de58
18 changed files with 931 additions and 13 deletions

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,6h-8l-2,-2L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM19,14h-3v3h-2v-3h-3v-2h3L14,9h2v3h3v2z"/>
</vector>

View File

@ -4,7 +4,7 @@
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" />
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M15,16h4v2h-4zM15,8h7v2h-7zM15,12h6v2h-6zM3,18c0,1.1 0.9,2 2,2h6c1.1,0 2,-0.9 2,-2L13,8L3,8v10zM14,5h-3l-1,-1L6,4L5,5L2,5v2h12z"/>
</vector>

View File

@ -4,7 +4,7 @@
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z" />
<path
android:fillColor="@android:color/white"
android:pathData="M20,6h-8l-2,-2L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,8c0,-1.1 -0.9,-2 -2,-2zM20,18L4,18L4,8h16v10z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M17.5,4.5c-1.95,0 -4.05,0.4 -5.5,1.5c-1.45,-1.1 -3.55,-1.5 -5.5,-1.5S2.45,4.9 1,6v14.65c0,0.65 0.73,0.45 0.75,0.45C3.1,20.45 5.05,20 6.5,20c1.95,0 4.05,0.4 5.5,1.5c1.35,-0.85 3.8,-1.5 5.5,-1.5c1.65,0 3.35,0.3 4.75,1.05C22.66,21.26 23,20.86 23,20.6V6C21.51,4.88 19.37,4.5 17.5,4.5zM21,18.5c-1.1,-0.35 -2.3,-0.5 -3.5,-0.5c-1.7,0 -4.15,0.65 -5.5,1.5V8c1.35,-0.85 3.8,-1.5 5.5,-1.5c1.2,0 2.4,0.15 3.5,0.5V18.5z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M18,2h-8L4.02,8 4,20c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,4c0,-1.1 -0.9,-2 -2,-2zM12,8h-2L10,4h2v4zM15,8h-2L13,4h2v4zM18,8h-2L16,4h2v4z"/>
</vector>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextAppearance="@style/TabTextAppearance"
app:tabMinWidth="150dp"
app:tabMode="scrollable" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/open_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="@dimen/fab_margin"
android:layout_marginRight="96dp"
app:backgroundTint="@color/fab_background"
app:srcCompat="@drawable/ic_baseline_folder_open_24" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/close_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/fab_background"
app:srcCompat="@drawable/ic_baseline_close_24" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="8dp"
android:foregroundGravity="center_vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@drawable/ic_media_cdrom" />
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="80dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="Save Title"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/icon"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/filename"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="80dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:paddingBottom="8px"
android:text="Save Filename"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/icon"
app:layout_constraintTop_toBottomOf="@+id/title" />
<TextView
android:id="@+id/block_size"
android:layout_width="64dp"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:paddingBottom="8px"
android:text="1 Block"
android:textAlignment="viewEnd"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_baseline_lock_24" />
<TextView
android:id="@+id/file_size"
android:layout_width="64dp"
android:layout_height="20dp"
android:layout_marginEnd="8dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="16KB"
android:textAlignment="viewEnd"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:srcCompat="@drawable/ic_star_5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/block_size" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -14,14 +14,14 @@
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_baseline_settings_24"
android:orderInCategory="101"
android:orderInCategory="103"
android:title="@string/action_settings"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_switch_view"
android:icon="@drawable/ic_baseline_settings_24"
android:orderInCategory="100"
android:title="Switch View"
android:title="@string/action_switch_view"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_controller_settings"
@ -29,6 +29,12 @@
android:orderInCategory="102"
android:title="@string/action_controller_mapping"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_memory_card_editor"
android:icon="@drawable/ic_baseline_sd_card_24"
android:orderInCategory="101"
android:title="@string/action_memory_card_editor"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_edit_game_directories"
android:title="@string/menu_main_edit_game_directories" />

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_new_card"
android:title="@string/action_memory_card_editor_new_card"
android:enabled="false"
android:icon="@drawable/ic_baseline_create_new_folder_24" />
<item
android:id="@+id/action_import_card"
android:title="@string/action_memory_card_editor_import_card"
android:icon="@drawable/ic_baseline_import_contacts_24"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_format_card"
android:title="@string/action_memory_card_editor_format_card"
android:enabled="false"
android:icon="@drawable/ic_baseline_delete_sweep_24" />
<item
android:id="@+id/action_delete_card"
android:title="@string/action_memory_card_editor_delete_card"
android:icon="@drawable/ic_baseline_delete_24"
app:showAsAction="ifRoom"
/>
</menu>

View File

@ -485,4 +485,8 @@
<item>Port2Only</item>
<item>BothPorts</item>
</string-array>
<string-array name="memory_card_editor_save_menu">
<item>Copy Save</item>
<item>Delete Save</item>
</string-array>
</resources>

View File

@ -276,4 +276,39 @@
<string name="controller_settings_category_ports">Ports</string>
<string name="controller_settings_main_port_format">Port %d</string>
<string name="controller_settings_sub_port_format">Port %1$d%2$c</string>
<string name="action_switch_view">Switch View</string>
<string name="title_activity_memory_card_editor">Memory Card Editor</string>
<string name="action_memory_card_editor">Memory Card Editor</string>
<string name="action_memory_card_editor_import_card">Import Card</string>
<string name="action_memory_card_editor_open_card">Open Card</string>
<string name="action_memory_card_editor_new_card">New Card</string>
<string name="action_memory_card_editor_format_card">Format Card</string>
<string name="action_memory_card_editor_delete_card">Delete Card</string>
<string name="memory_card_editor_no_cards_found">No memory cards found.</string>
<string name="memory_card_editor_card_already_open">This card is already open.</string>
<string name="memory_card_editor_failed_to_open_card">Failed to open or read memory card.</string>
<string name="memory_card_editor_must_have_at_least_two_cards_to_copy">Must have at least two cards open to copy.</string>
<string name="memory_card_editor_copy_save_to">Copy %s to...</string>
<string name="memory_card_editor_select_card">Select Card</string>
<string name="memory_card_editor_error">Error</string>
<string name="memory_card_editor_copy_insufficient_blocks">This file requires %1$d blocks, but only %2$d blocks are free.</string>
<string name="memory_card_editor_copy_already_exists">File \'%s\' already exists on destination card.</string>
<string name="memory_card_editor_copy_read_failed">Failed to read file \'%s\' from source card.</string>
<string name="memory_card_editor_copy_write_failed">Failed to write file \'%s\' to destination card.</string>
<string name="memory_card_editor_copy_success">Copied \'%1$s\' to \'%2$s\'.</string>
<string name="memory_card_editor_delete_confirm">Are you sure you want to delete the save \'%s\'?</string>
<string name="memory_card_editor_delete_success">Deleted save \'%s\'.</string>
<string name="memory_card_editor_delete_failed">Failed to delete file \'%s\'.</string>
<string name="memory_card_editor_no_card_selected">No card is selected.</string>
<string name="memory_card_editor_import_failed">Failed to import card. It may not be a supported format.</string>
<string name="memory_card_editor_delete_card_confirm_message">Memory card \'%s\' will be deleted, and cannot be recovered. Are you sure you want to delete this card?</string>
<string name="memory_card_editor_delete_card_failed">Failed to delete \'%s\'.</string>
<string name="memory_card_editor_delete_card_success">Deleted card \'%s\'.</string>
<string name="memory_card_editor_format_card_confirm_message">Memory card \'%s\' will be formatted, clearing all saves. Are you sure you want to format this card?</string>
<string name="memory_card_editor_format_card_failed">Failed to format \'%s\'.</string>
<string name="memory_card_editor_format_card_success">Formatted card \'%s\'.</string>
<string name="memory_card_editor_import_card_confirm_message">Importing \'%1$s\' will remove all saves in \'%2$s\'. Do you want to continue?</string>
<string name="memory_card_editor_import_card_read_failed">Failed to read \'%s\'.</string>
<string name="memory_card_editor_import_card_failed">Failed to import card \'%s\'. It may not be a supported format.</string>
<string name="memory_card_editor_import_card_success">Imported card \'%s\'.</string>
</resources>