Android: Switch all activities to AppCompat-based Material themes, and use Support Library version of Floating Action Button.

This commit is contained in:
sigmabeta 2015-06-20 19:37:36 -04:00 committed by Eder Bastos
parent bb89a81053
commit fa2d06e7a4
12 changed files with 58 additions and 59 deletions

View File

@ -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'

View File

@ -54,7 +54,7 @@
<activity
android:name=".activities.OverlayConfigActivity"
android:theme="@style/DolphinEmulationGamecube"/>
android:theme="@style/DolphinSettingsGamecube"/>
<service android:name=".services.AssetCopyService"/>

View File

@ -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()

View File

@ -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;

View File

@ -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,6 +8,8 @@ import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
@ -16,7 +17,6 @@ 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;
@ -30,7 +30,7 @@ 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.
*/
public final class GameGridActivity extends Activity implements LoaderManager.LoaderCallbacks<Cursor>
public final class GameGridActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor>
{
private static final int REQUEST_ADD_DIRECTORY = 1;
@ -48,7 +48,7 @@ public final class GameGridActivity extends Activity implements LoaderManager.Lo
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_game_list);
setActionBar(toolbar);
ImageButton buttonAddDirectory = (ImageButton) findViewById(R.id.button_add_directory);
FloatingActionButton buttonAddDirectory = (FloatingActionButton) findViewById(R.id.button_add_directory);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.grid_games);
// TODO Rather than calling into native code, this should use the commented line below.

View File

@ -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)

View File

@ -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)

View File

@ -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];

View File

@ -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>

View File

@ -1,5 +1,6 @@
<?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"
@ -26,17 +27,18 @@
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
<ImageButton
<android.support.design.widget.FloatingActionButton
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"
app:borderWidth="0dp"
app:rippleColor="?android:colorPrimaryDark"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_gravity="bottom|right"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
</FrameLayout>

View File

@ -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>

View File

@ -1,83 +1,83 @@
<?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>
</resources>