Merge pull request #2644 from sigmabeta/android-material-design
Android: Numerous Material Design additions to the UI.
This commit is contained in:
commit
2cea910431
|
@ -75,11 +75,10 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compile 'com.android.support:support-v4:22.1.1'
|
||||
compile 'com.android.support:support-v13:22.0.0'
|
||||
compile 'com.android.support:cardview-v7:21.0.3'
|
||||
compile 'com.android.support:recyclerview-v7:21.0.3'
|
||||
compile 'com.android.support:support-v13:22.2.0'
|
||||
compile 'com.android.support:cardview-v7:22.2.0'
|
||||
compile 'com.android.support:recyclerview-v7:22.2.0'
|
||||
compile 'com.android.support:design:22.2.0'
|
||||
|
||||
// For showing the banner as a circle a-la Material Design Guidelines
|
||||
compile 'de.hdodenhof:circleimageview:1.2.2'
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
android:banner="@drawable/banner_tv">
|
||||
|
||||
<activity
|
||||
android:name=".activities.GameGridActivity"
|
||||
android:name=".activities.MainActivity"
|
||||
android:theme="@style/DolphinGamecube">
|
||||
|
||||
<!-- This intentfilter marks this Activity as the one that gets launched from Home screen. -->
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.OverlayConfigActivity"
|
||||
android:theme="@style/DolphinEmulationGamecube"/>
|
||||
android:theme="@style/DolphinSettingsGamecube"/>
|
||||
|
||||
|
||||
<service android:name=".services.AssetCopyService"/>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.dolphinemu.dolphinemu.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.AsyncQueryHandler;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.Menu;
|
||||
|
@ -24,7 +24,7 @@ import org.dolphinemu.dolphinemu.model.GameProvider;
|
|||
* An Activity that shows a list of files and folders, allowing the user to tell the app which folder(s)
|
||||
* contains the user's games.
|
||||
*/
|
||||
public class AddDirectoryActivity extends Activity implements FileAdapter.FileClickListener
|
||||
public class AddDirectoryActivity extends AppCompatActivity implements FileAdapter.FileClickListener
|
||||
{
|
||||
public static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path";
|
||||
|
||||
|
@ -97,8 +97,6 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl
|
|||
|
||||
/**
|
||||
* Add a directory to the library, and if successful, end the activity.
|
||||
*
|
||||
* @param path The target directory's path.
|
||||
*/
|
||||
@Override
|
||||
public void addDirectory()
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package org.dolphinemu.dolphinemu.activities;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -19,7 +22,7 @@ import org.dolphinemu.dolphinemu.fragments.EmulationFragment;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public final class EmulationActivity extends Activity
|
||||
public final class EmulationActivity extends AppCompatActivity
|
||||
{
|
||||
private View mDecorView;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.dolphinemu.dolphinemu.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.CursorLoader;
|
||||
import android.content.Intent;
|
||||
|
@ -9,71 +8,79 @@ import android.content.SharedPreferences;
|
|||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.adapters.GameAdapter;
|
||||
import org.dolphinemu.dolphinemu.adapters.PlatformPagerAdapter;
|
||||
import org.dolphinemu.dolphinemu.fragments.PlatformGamesFragment;
|
||||
import org.dolphinemu.dolphinemu.model.Game;
|
||||
import org.dolphinemu.dolphinemu.model.GameDatabase;
|
||||
import org.dolphinemu.dolphinemu.model.GameProvider;
|
||||
import org.dolphinemu.dolphinemu.services.AssetCopyService;
|
||||
|
||||
/**
|
||||
* The main Activity of the Lollipop style UI. Shows a grid of games on tablets & landscape phones,
|
||||
* shows a list of games on portrait phones.
|
||||
* The main Activity of the Lollipop style UI. Manages several PlatformGamesFragments, which
|
||||
* individually display a grid of available games for each Fragment, in a tabbed layout.
|
||||
*/
|
||||
public final class GameGridActivity extends Activity implements LoaderManager.LoaderCallbacks<Cursor>
|
||||
public final class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor>
|
||||
{
|
||||
private static final int REQUEST_ADD_DIRECTORY = 1;
|
||||
|
||||
private static final int LOADER_ID_GAMES = 1;
|
||||
// TODO When each platform has its own tab, there should be a LOADER_ID for each platform.
|
||||
/**
|
||||
* It is important to keep track of loader ID separately from platform ID (see Game.java)
|
||||
* because we could potentially have Loaders that load things other than Games.
|
||||
*/
|
||||
public static final int LOADER_ID_ALL = 100; // TODO
|
||||
public static final int LOADER_ID_GAMECUBE = 0;
|
||||
public static final int LOADER_ID_WII = 1;
|
||||
public static final int LOADER_ID_WIIWARE = 2;
|
||||
|
||||
private GameAdapter mAdapter;
|
||||
private ViewPager mViewPager;
|
||||
private PlatformPagerAdapter mPlatformPagerAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_game_grid);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_game_list);
|
||||
setActionBar(toolbar);
|
||||
|
||||
ImageButton buttonAddDirectory = (ImageButton) findViewById(R.id.button_add_directory);
|
||||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.grid_games);
|
||||
// Set up the Toolbar.
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_main);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// TODO Rather than calling into native code, this should use the commented line below.
|
||||
// String versionName = BuildConfig.VERSION_NAME;
|
||||
String versionName = NativeLibrary.GetVersionString();
|
||||
toolbar.setSubtitle(versionName);
|
||||
|
||||
// Specifying the LayoutManager determines how the RecyclerView arranges views.
|
||||
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this,
|
||||
getResources().getInteger(R.integer.game_grid_columns));
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
// Set up the Tab bar.
|
||||
mViewPager = (ViewPager) findViewById(R.id.pager_platforms);
|
||||
|
||||
recyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));
|
||||
mPlatformPagerAdapter = new PlatformPagerAdapter(getFragmentManager(), this);
|
||||
mViewPager.setAdapter(mPlatformPagerAdapter);
|
||||
|
||||
// Create an adapter that will relate the dataset to the views on-screen.
|
||||
getLoaderManager().initLoader(LOADER_ID_GAMES, null, this);
|
||||
mAdapter = new GameAdapter();
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs_platforms);
|
||||
tabLayout.setupWithViewPager(mViewPager);
|
||||
|
||||
// Set up the FAB.
|
||||
FloatingActionButton buttonAddDirectory = (FloatingActionButton) findViewById(R.id.button_add_directory);
|
||||
buttonAddDirectory.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
Intent fileChooser = new Intent(GameGridActivity.this, AddDirectoryActivity.class);
|
||||
Intent fileChooser = new Intent(MainActivity.this, AddDirectoryActivity.class);
|
||||
|
||||
// The second argument to this method is read below in onActivityResult().
|
||||
startActivityForResult(fileChooser, REQUEST_ADD_DIRECTORY);
|
||||
|
@ -115,7 +122,7 @@ public final class GameGridActivity extends Activity implements LoaderManager.Lo
|
|||
// other activities might use this callback in the future (don't forget to change Javadoc!)
|
||||
if (requestCode == REQUEST_ADD_DIRECTORY)
|
||||
{
|
||||
getLoaderManager().restartLoader(LOADER_ID_GAMES, null, this);
|
||||
refreshFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +154,7 @@ public final class GameGridActivity extends Activity implements LoaderManager.Lo
|
|||
|
||||
case R.id.menu_refresh:
|
||||
getContentResolver().insert(GameProvider.URI_REFRESH, null);
|
||||
getLoaderManager().restartLoader(LOADER_ID_GAMES, null, this);
|
||||
refreshFragment();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -155,6 +162,15 @@ public final class GameGridActivity extends Activity implements LoaderManager.Lo
|
|||
return false;
|
||||
}
|
||||
|
||||
public void refreshFragment()
|
||||
{
|
||||
PlatformGamesFragment fragment = getPlatformFragment(mViewPager.getCurrentItem());
|
||||
if (fragment != null)
|
||||
{
|
||||
fragment.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback that's invoked when the system has initialized the Loader and
|
||||
|
@ -173,16 +189,30 @@ public final class GameGridActivity extends Activity implements LoaderManager.Lo
|
|||
// Take action based on the ID of the Loader that's being created.
|
||||
switch (id)
|
||||
{
|
||||
case LOADER_ID_GAMES:
|
||||
case LOADER_ID_ALL:
|
||||
// TODO Play some sort of load-starting animation; maybe fade the list out.
|
||||
|
||||
return new CursorLoader(
|
||||
this, // Parent activity context
|
||||
GameProvider.URI_GAME, // URI of table to query
|
||||
null, // Return all columns
|
||||
null, // No selection clause
|
||||
null, // No selection arguments
|
||||
GameDatabase.KEY_GAME_TITLE + " asc" // Sort by game name, ascending order
|
||||
this, // Parent activity context
|
||||
GameProvider.URI_GAME, // URI of table to query
|
||||
null, // Return all columns
|
||||
null, // No selection clause
|
||||
null, // No selection arguments
|
||||
GameDatabase.KEY_GAME_TITLE + " asc" // Sort by game name, ascending order
|
||||
);
|
||||
|
||||
case LOADER_ID_GAMECUBE:
|
||||
case LOADER_ID_WII:
|
||||
case LOADER_ID_WIIWARE:
|
||||
// TODO Play some sort of load-starting animation; maybe fade the list out.
|
||||
|
||||
return new CursorLoader(
|
||||
this, // Parent activity context
|
||||
GameProvider.URI_GAME, // URI of table to query
|
||||
null, // Return all columns
|
||||
GameDatabase.KEY_GAME_PLATFORM + " = ?", // Select by platform
|
||||
new String[]{Integer.toString(id)}, // Platform id is Loader id minus 1
|
||||
GameDatabase.KEY_GAME_TITLE + " asc" // Sort by game name, ascending order
|
||||
);
|
||||
|
||||
default:
|
||||
|
@ -205,25 +235,73 @@ public final class GameGridActivity extends Activity implements LoaderManager.Lo
|
|||
int id = loader.getId();
|
||||
Log.d("DolphinEmu", "Loader finished with id: " + id);
|
||||
|
||||
// TODO When each platform has its own tab, this should just call into those tabs instead.
|
||||
PlatformGamesFragment fragment = null;
|
||||
switch (id)
|
||||
{
|
||||
case LOADER_ID_GAMES:
|
||||
mAdapter.swapCursor(data);
|
||||
// TODO Play some sort of load-finished animation; maybe fade the list in.
|
||||
case LOADER_ID_GAMECUBE:
|
||||
fragment = getPlatformFragment(Game.PLATFORM_GC);
|
||||
break;
|
||||
|
||||
case LOADER_ID_WII:
|
||||
fragment = getPlatformFragment(Game.PLATFORM_WII);
|
||||
break;
|
||||
|
||||
case LOADER_ID_WIIWARE:
|
||||
fragment = getPlatformFragment(Game.PLATFORM_WII_WARE);
|
||||
break;
|
||||
|
||||
// TODO case LOADER_ID_ALL:
|
||||
|
||||
default:
|
||||
Log.e("DolphinEmu", "Bad ID passed in.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (fragment != null)
|
||||
{
|
||||
fragment.onLoadFinished(loader, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader)
|
||||
{
|
||||
Log.d("DolphinEmu", "Loader resetting.");
|
||||
int id = loader.getId();
|
||||
Log.e("DolphinEmu", "Loader resetting with id: " + id);
|
||||
|
||||
// TODO ¯\_(ツ)_/¯
|
||||
PlatformGamesFragment fragment = null;
|
||||
switch (id)
|
||||
{
|
||||
case LOADER_ID_GAMECUBE:
|
||||
fragment = getPlatformFragment(Game.PLATFORM_GC);
|
||||
break;
|
||||
|
||||
case LOADER_ID_WII:
|
||||
fragment = getPlatformFragment(Game.PLATFORM_WII);
|
||||
break;
|
||||
|
||||
case LOADER_ID_WIIWARE:
|
||||
fragment = getPlatformFragment(Game.PLATFORM_WII_WARE);
|
||||
break;
|
||||
|
||||
// TODO case LOADER_ID_ALL:
|
||||
|
||||
default:
|
||||
Log.e("DolphinEmu", "Bad ID passed in.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (fragment != null)
|
||||
{
|
||||
fragment.onLoaderReset();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PlatformGamesFragment getPlatformFragment(int platform)
|
||||
{
|
||||
String fragmentTag = "android:switcher:" + mViewPager.getId() + ":" + platform;
|
||||
|
||||
return (PlatformGamesFragment) getFragmentManager().findFragmentByTag(fragmentTag);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ package org.dolphinemu.dolphinemu.activities;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
|
@ -16,7 +17,7 @@ import org.dolphinemu.dolphinemu.overlay.OverlayConfigButton;
|
|||
/**
|
||||
* {@link Activity} used for configuring the input overlay.
|
||||
*/
|
||||
public final class OverlayConfigActivity extends Activity
|
||||
public final class OverlayConfigActivity extends AppCompatActivity
|
||||
{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package org.dolphinemu.dolphinemu.activities;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
|
||||
import org.dolphinemu.dolphinemu.fragments.SettingsFragment;
|
||||
import org.dolphinemu.dolphinemu.services.SettingsSaveService;
|
||||
|
||||
public final class SettingsActivity extends Activity
|
||||
public final class SettingsActivity extends AppCompatActivity
|
||||
{
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package org.dolphinemu.dolphinemu.adapters;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v13.app.FragmentPagerAdapter;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ImageSpan;
|
||||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.fragments.PlatformGamesFragment;
|
||||
|
||||
public class PlatformPagerAdapter extends FragmentPagerAdapter
|
||||
{
|
||||
private Context mContext;
|
||||
|
||||
private final static int[] TAB_ICONS = {
|
||||
R.drawable.ic_gamecube,
|
||||
R.drawable.ic_wii,
|
||||
R.drawable.ic_folder// wiiware TODO Have an icon here.
|
||||
};
|
||||
|
||||
public PlatformPagerAdapter(FragmentManager fm, Context context)
|
||||
{
|
||||
super(fm);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position)
|
||||
{
|
||||
return PlatformGamesFragment.newInstance(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
return TAB_ICONS.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position)
|
||||
{
|
||||
// Hax from https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout#design-support-library
|
||||
// Apparently a workaround for TabLayout not supporting icons.
|
||||
// TODO This workaround will eventually not be necessary; switch to more legit methods when that is the case
|
||||
// TODO Also remove additional hax from styles.xml
|
||||
Drawable drawable = mContext.getResources().getDrawable(TAB_ICONS[position]);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
|
||||
ImageSpan imageSpan = new ImageSpan(drawable, ImageSpan.ALIGN_BOTTOM);
|
||||
|
||||
SpannableString sb = new SpannableString(" ");
|
||||
sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
return sb;
|
||||
}
|
||||
}
|
|
@ -6,9 +6,9 @@ import android.app.Dialog;
|
|||
import android.app.DialogFragment;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -61,7 +61,7 @@ public final class GameDetailsDialog extends DialogFragment
|
|||
TextView textCountry = (TextView) contents.findViewById(R.id.text_country);
|
||||
TextView textDate = (TextView) contents.findViewById(R.id.text_date);
|
||||
|
||||
ImageButton buttonLaunch = (ImageButton) contents.findViewById(R.id.button_launch);
|
||||
FloatingActionButton buttonLaunch = (FloatingActionButton) contents.findViewById(R.id.button_launch);
|
||||
|
||||
int countryIndex = getArguments().getInt(ARGUMENT_GAME_COUNTRY);
|
||||
String country = getResources().getStringArray(R.array.country_names)[countryIndex];
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package org.dolphinemu.dolphinemu.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Loader;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.dolphinemu.dolphinemu.BuildConfig;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.adapters.GameAdapter;
|
||||
|
||||
public class PlatformGamesFragment extends Fragment
|
||||
{
|
||||
private static final String ARG_PLATFORM = BuildConfig.APPLICATION_ID + ".PLATFORM";
|
||||
|
||||
private int mPlatform;
|
||||
|
||||
private GameAdapter mAdapter;
|
||||
|
||||
public static PlatformGamesFragment newInstance(int platform)
|
||||
{
|
||||
PlatformGamesFragment fragment = new PlatformGamesFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_PLATFORM, platform);
|
||||
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mPlatform = getArguments().getInt(ARG_PLATFORM);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
View rootView = inflater.inflate(R.layout.fragment_grid, container, false);
|
||||
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.grid_games);
|
||||
|
||||
// Specifying the LayoutManager determines how the RecyclerView arranges views.
|
||||
|
||||
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(),
|
||||
getResources().getInteger(R.integer.game_grid_columns));
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
recyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));
|
||||
|
||||
// Create an adapter that will relate the dataset to the views on-screen. +1 because of LOADER_ID_ALL
|
||||
getLoaderManager().initLoader(mPlatform, null,
|
||||
(LoaderManager.LoaderCallbacks<Cursor>) getActivity());
|
||||
|
||||
mAdapter = new GameAdapter();
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity)
|
||||
{
|
||||
super.onAttach(activity);
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
Log.d("DolphinEmu", "[PlatformGamesFragment] " + mPlatform + ": Refreshing...");
|
||||
// +1 because of LOADER_ID_ALL
|
||||
getLoaderManager().restartLoader(mPlatform, null, (LoaderManager.LoaderCallbacks<Cursor>) getActivity());
|
||||
}
|
||||
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data)
|
||||
{
|
||||
// TODO Play some sort of load-finished animation; maybe fade the list in.
|
||||
|
||||
Log.d("DolphinEmu", "[PlatformGamesFragment] " + mPlatform + ": Load finished, swapping cursor...");
|
||||
Log.d("DolphinEmu", "[PlatformGamesFragment] " + mPlatform + ": Cursor size: " + data.getCount());
|
||||
if (mAdapter != null)
|
||||
{
|
||||
mAdapter.swapCursor(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e("DolphinEmu", "[PlatformGamesFragment] " + mPlatform + ": No adapter available.");
|
||||
}
|
||||
}
|
||||
|
||||
public void onLoaderReset()
|
||||
{
|
||||
Log.e("DolphinEmu", "[PlatformGamesFragment] " + mPlatform + ": Loader reset; clearing data from view.");
|
||||
if (mAdapter != null)
|
||||
{
|
||||
mAdapter.swapCursor(null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -196,7 +196,14 @@ public final class GameDatabase extends SQLiteOpenHelper
|
|||
gameId = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.lastIndexOf("."));
|
||||
}
|
||||
|
||||
ContentValues game = Game.asContentValues(NativeLibrary.GetPlatform(filePath),
|
||||
// If the game's platform field is empty, file under Wiiware. // TODO Something less dum
|
||||
int platform = NativeLibrary.GetPlatform(filePath);
|
||||
if (platform == -1)
|
||||
{
|
||||
platform = Game.PLATFORM_WII_WARE;
|
||||
}
|
||||
|
||||
ContentValues game = Game.asContentValues(platform,
|
||||
name,
|
||||
NativeLibrary.GetDescription(filePath).replace("\n", " "),
|
||||
NativeLibrary.GetCountry(filePath),
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:colorControlHighlight">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="?android:colorAccent"/>
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
|
@ -1,44 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Toolbar
|
||||
android:id="@+id/toolbar_game_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:colorPrimary"
|
||||
android:minHeight="?android:attr/actionBarSize"
|
||||
android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"
|
||||
android:elevation="6dp"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/grid_games"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/grid_card_game"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/button_add_directory"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_alignBottom="@+id/image_game_screen"
|
||||
android:layout_alignEnd="@+id/text_game_title"
|
||||
android:layout_marginBottom="28dp"
|
||||
android:background="@drawable/oval_ripple_accent"
|
||||
android:src="@drawable/ic_add"
|
||||
android:stateListAnimator="@anim/button_elevation"
|
||||
android:elevation="4dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/coordinator_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
app:layout_scrollFlags="scroll|enterAlways"/>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tabs_platforms"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabTextAppearance="@style/MyCustomTextAppearance"
|
||||
app:tabMode="fixed"
|
||||
app:tabGravity="fill"/>
|
||||
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/pager_platforms"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/button_add_directory"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_margin="32dp"
|
||||
android:src="@drawable/ic_add"
|
||||
app:borderWidth="0dp"
|
||||
app:rippleColor="?android:colorPrimaryDark"
|
||||
app:layout_anchor="@+id/pager_platforms"
|
||||
app:layout_anchorGravity="bottom|right|end"/>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -113,17 +114,20 @@
|
|||
android:gravity="center_vertical"
|
||||
tools:text="Nintendo"/>
|
||||
|
||||
<ImageButton
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/button_launch"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_alignBottom="@+id/image_game_screen"
|
||||
android:layout_alignEnd="@+id/text_game_title"
|
||||
android:layout_marginBottom="-28dp"
|
||||
android:background="@drawable/oval_ripple_accent"
|
||||
android:src="@drawable/ic_play"
|
||||
android:stateListAnimator="@anim/button_elevation"
|
||||
android:elevation="4dp"/>
|
||||
app:rippleColor="?android:colorPrimaryDark"
|
||||
app:borderWidth="0dp"
|
||||
app:elevation="6dp"
|
||||
app:pressedTranslationZ="12dp"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/grid_games"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
tools:listitem="@layout/grid_card_game"/>
|
||||
</FrameLayout>
|
|
@ -1,14 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_refresh"
|
||||
android:title="@string/grid_menu_refresh"
|
||||
android:icon="@drawable/ic_refresh"
|
||||
android:showAsAction="ifRoom"/>
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/menu_settings"
|
||||
android:title="@string/grid_menu_settings"
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:showAsAction="ifRoom"/>
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
|
@ -7,4 +7,6 @@
|
|||
<dimen name="elevation_low">1dp</dimen>
|
||||
<dimen name="elevation_high">4dp</dimen>
|
||||
<dimen name="add_button_margin">16dp</dimen>
|
||||
|
||||
<dimen name="main_appbar_height">128dp</dimen>
|
||||
</resources>
|
||||
|
|
|
@ -1,83 +1,90 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- inherit from the material theme -->
|
||||
<style name="DolphinBase" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<style name="DolphinBase" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Main theme colors -->
|
||||
<!-- your app branding color for the app bar -->
|
||||
<item name="android:colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="colorPrimary">@color/dolphin_blue</item>
|
||||
<!-- darker variant for the status bar and contextual app bars -->
|
||||
<item name="android:colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- Same as above, but use default action bar, and mandate margins. -->
|
||||
<style name="DolphinSettingsBase" parent="android:Theme.Material.Light.DarkActionBar">
|
||||
<item name="android:colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="android:colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
<style name="DolphinSettingsBase" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- Inherit from the Base Dolphin Theme-->
|
||||
<style name="DolphinWii" parent="DolphinBase">
|
||||
<!-- theme UI controls like checkboxes and text fields -->
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wii</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wii</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinGamecube" parent="DolphinBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinWiiware" parent="DolphinBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
</style>
|
||||
|
||||
<!-- Inherit from the Base Dolphin Settings Theme-->
|
||||
<style name="DolphinSettingsWii" parent="DolphinSettingsBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wii</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wii</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinSettingsGamecube" parent="DolphinSettingsBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinSettingsWiiware" parent="DolphinSettingsBase">
|
||||
<!-- theme UI controls like checkboxes and text fields -->
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
</style>
|
||||
|
||||
<!-- Themes for Dialogs -->
|
||||
<style name="DolphinDialogBase" parent="android:Theme.Material.Light.Dialog">
|
||||
<item name="android:colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="android:colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
<style name="DolphinDialogBase" parent="Theme.AppCompat.Light.Dialog">
|
||||
<item name="colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- Inherit from the Base Dolphin Dialog Theme-->
|
||||
<style name="DolphinDialogWii" parent="DolphinDialogBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wii</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wii</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinDialogGamecube" parent="DolphinDialogBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinDialogWiiware" parent="DolphinDialogBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinEmulationBase" parent="android:Theme.Material.Light.DarkActionBar">
|
||||
<item name="android:colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="android:colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
<style name="DolphinEmulationBase" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/dolphin_blue</item>
|
||||
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
</style>
|
||||
|
||||
<!-- Inherit from the Base Dolphin Emulation Theme-->
|
||||
<style name="DolphinEmulationWii" parent="DolphinEmulationBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wii</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wii</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinEmulationGamecube" parent="DolphinEmulationBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_gamecube</item>
|
||||
</style>
|
||||
|
||||
<style name="DolphinEmulationWiiware" parent="DolphinEmulationBase">
|
||||
<item name="android:colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
<item name="colorAccent">@color/dolphin_accent_wiiware</item>
|
||||
</style>
|
||||
|
||||
|
||||
<!-- Hax to make Tablayout render icons -->
|
||||
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
|
||||
<item name="textAllCaps">false</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue