From a4395ecd75e52756bb3c6db9f991e8ab2305df35 Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Fri, 8 May 2015 19:54:56 -0400 Subject: [PATCH 1/7] Have Picasso load images into memory at the size they will be displayed. --- Source/Android/app/build.gradle | 2 +- .../java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java | 2 ++ .../org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java | 2 ++ Source/Android/app/src/main/res/layout/card_game.xml | 1 - Source/Android/app/src/main/res/layout/dialog_game_details.xml | 1 - 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index 0fd64d013c..ae34d82377 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -56,5 +56,5 @@ dependencies { compile 'de.hdodenhof:circleimageview:1.2.2' // For loading huge screenshots from the disk. - compile "com.squareup.picasso:picasso:2.4.0" + compile 'com.squareup.picasso:picasso:2.5.2' } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index 30bc9daad6..d868ed46de 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -64,6 +64,8 @@ public class GameAdapter extends RecyclerView.Adapter // Fill in the view contents. Picasso.with(holder.imageScreenshot.getContext()) .load(game.getScreenPath()) + .fit() + .centerCrop() .error(R.drawable.no_banner) .into(holder.imageScreenshot); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java index 19c6621345..e22b30ea18 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -84,6 +84,8 @@ public class GameDetailsDialog extends DialogFragment // Fill in the view contents. Picasso.with(imageGameScreen.getContext()) .load(getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH)) + .fit() + .centerCrop() .noFade() .noPlaceholder() .into(imageGameScreen); diff --git a/Source/Android/app/src/main/res/layout/card_game.xml b/Source/Android/app/src/main/res/layout/card_game.xml index a89e5bdb21..e0aa7f01f4 100644 --- a/Source/Android/app/src/main/res/layout/card_game.xml +++ b/Source/Android/app/src/main/res/layout/card_game.xml @@ -15,7 +15,6 @@ android:id="@+id/image_game_screen" android:layout_width="match_parent" android:layout_height="0dp" - android:scaleType="centerCrop" android:transitionName="image_game_screen" android:layout_weight="1" tools:src="@drawable/placeholder_screenshot"/> diff --git a/Source/Android/app/src/main/res/layout/dialog_game_details.xml b/Source/Android/app/src/main/res/layout/dialog_game_details.xml index 885dc91676..a135c99c86 100644 --- a/Source/Android/app/src/main/res/layout/dialog_game_details.xml +++ b/Source/Android/app/src/main/res/layout/dialog_game_details.xml @@ -31,7 +31,6 @@ android:layout_alignParentRight="true" android:layout_alignParentStart="true" android:layout_alignParentTop="true" - android:scaleType="centerCrop" android:transitionName="image_game_screen" tools:src="@drawable/placeholder_screenshot"/> From 700225f8c8898406fa8cc655891f15b0fe3f6d3d Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Fri, 8 May 2015 19:57:44 -0400 Subject: [PATCH 2/7] Add floating action button to GameGridActivity. --- .../{oval_ripple.xml => oval_ripple_gc.xml} | 3 +- .../src/main/res/drawable/oval_ripple_wii.xml | 8 +++++ .../main/res/layout/activity_game_grid.xml | 31 +++++++++++++++---- .../main/res/layout/dialog_game_details.xml | 2 +- .../app/src/main/res/values/colors.xml | 10 +++--- .../app/src/main/res/values/styles.xml | 4 +-- 6 files changed, 43 insertions(+), 15 deletions(-) rename Source/Android/app/src/main/res/drawable/{oval_ripple.xml => oval_ripple_gc.xml} (66%) create mode 100644 Source/Android/app/src/main/res/drawable/oval_ripple_wii.xml diff --git a/Source/Android/app/src/main/res/drawable/oval_ripple.xml b/Source/Android/app/src/main/res/drawable/oval_ripple_gc.xml similarity index 66% rename from Source/Android/app/src/main/res/drawable/oval_ripple.xml rename to Source/Android/app/src/main/res/drawable/oval_ripple_gc.xml index 554d5f834a..0477ba84fe 100644 --- a/Source/Android/app/src/main/res/drawable/oval_ripple.xml +++ b/Source/Android/app/src/main/res/drawable/oval_ripple_gc.xml @@ -1,9 +1,8 @@ - - + \ No newline at end of file diff --git a/Source/Android/app/src/main/res/drawable/oval_ripple_wii.xml b/Source/Android/app/src/main/res/drawable/oval_ripple_wii.xml new file mode 100644 index 0000000000..35c767805c --- /dev/null +++ b/Source/Android/app/src/main/res/drawable/oval_ripple_wii.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/Source/Android/app/src/main/res/layout/activity_game_grid.xml b/Source/Android/app/src/main/res/layout/activity_game_grid.xml index f026322f3d..e87f859787 100644 --- a/Source/Android/app/src/main/res/layout/activity_game_grid.xml +++ b/Source/Android/app/src/main/res/layout/activity_game_grid.xml @@ -13,12 +13,31 @@ android:minHeight="?android:attr/actionBarSize" android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"/> - + android:layout_height="match_parent"> + + + + + \ No newline at end of file diff --git a/Source/Android/app/src/main/res/layout/dialog_game_details.xml b/Source/Android/app/src/main/res/layout/dialog_game_details.xml index a135c99c86..b431991baf 100644 --- a/Source/Android/app/src/main/res/layout/dialog_game_details.xml +++ b/Source/Android/app/src/main/res/layout/dialog_game_details.xml @@ -124,7 +124,7 @@ android:layout_alignBottom="@+id/image_game_screen" android:layout_alignEnd="@+id/text_game_title" android:layout_marginBottom="-28dp" - android:background="@drawable/oval_ripple" + android:background="@drawable/oval_ripple_wii" android:src="@drawable/ic_play" android:stateListAnimator="@anim/button_elevation" android:elevation="4dp"/> diff --git a/Source/Android/app/src/main/res/values/colors.xml b/Source/Android/app/src/main/res/values/colors.xml index 608cc9afd7..a4174647c7 100644 --- a/Source/Android/app/src/main/res/values/colors.xml +++ b/Source/Android/app/src/main/res/values/colors.xml @@ -1,8 +1,10 @@ - #5bc0de - #428bca + #2196f3 + #1976d2 + #651fff - #663399 - #311b92 + #673ab7 + #512da8 + #2979ff \ No newline at end of file diff --git a/Source/Android/app/src/main/res/values/styles.xml b/Source/Android/app/src/main/res/values/styles.xml index 40d406b20f..a0bfbb1865 100644 --- a/Source/Android/app/src/main/res/values/styles.xml +++ b/Source/Android/app/src/main/res/values/styles.xml @@ -8,13 +8,13 @@ @color/dolphin_wii_dark - @color/dolphin_gamecube + @color/dolphin_wii_accent + + + - - \ No newline at end of file From 3f1465196c7ea13a99517ddcdcd56f75d4359f99 Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Sun, 10 May 2015 10:29:29 -0400 Subject: [PATCH 4/7] Add touch feedback to GameGridActivity and AddDirectoryActivity. --- .../dolphinemu/adapters/FileAdapter.java | 50 +++++++++-- .../dolphinemu/adapters/GameAdapter.java | 52 +++++++++++- .../viewholders/GameViewHolder.java | 47 +---------- .../app/src/main/res/layout/card_game.xml | 83 ++++++++----------- .../src/main/res/layout/list_item_file.xml | 21 ++--- .../src/main/res/menu/menu_add_directory.xml | 1 + .../app/src/main/res/values/strings.xml | 3 +- 7 files changed, 145 insertions(+), 112 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java index 7f4acf6abe..2414883279 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java @@ -4,6 +4,7 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.model.FileListItem; @@ -102,8 +103,14 @@ public class FileAdapter extends RecyclerView.Adapter implements return mFileList.size(); } + /** + * When a file is clicked, determine if it is a directory; if it is, show that new directory's + * contents. If it is not, end the activity successfully. + * + * @param view + */ @Override - public void onClick(View view) + public void onClick(final View view) { String path = (String) view.getTag(); @@ -111,8 +118,26 @@ public class FileAdapter extends RecyclerView.Adapter implements if (clickedFile.isDirectory()) { - mFileList = generateFileList(clickedFile); - notifyDataSetChanged(); + final ArrayList fileList = generateFileList(clickedFile); + + if (fileList.isEmpty()) + { + Toast.makeText(view.getContext(), R.string.add_directory_empty_folder, Toast.LENGTH_SHORT).show(); + } else + { + // Delay the loading of the new directory to give a little bit of time for UI feedback + // to happen. Hacky, but good enough for now; this is necessary because we're modifying + // the RecyclerView's contents, rather than constructing a new one. + view.getHandler().postDelayed(new Runnable() + { + @Override + public void run() + { + mFileList = fileList; + notifyDataSetChanged(); + } + }, 200); + } } else { // Pass the activity the path of the parent directory of the clicked file. @@ -120,6 +145,12 @@ public class FileAdapter extends RecyclerView.Adapter implements } } + /** + * For a given directory, return a list of Files it contains. + * + * @param directory + * @return + */ private ArrayList generateFileList(File directory) { File[] children = directory.listFiles(); @@ -145,6 +176,12 @@ public class FileAdapter extends RecyclerView.Adapter implements return mPath; } + /** + * Mostly just allows the activity's menu option to kick us up a level in the directory + * structure. + * + * @param path + */ public void setPath(String path) { mPath = path; @@ -154,8 +191,11 @@ public class FileAdapter extends RecyclerView.Adapter implements notifyDataSetChanged(); } - public static interface FileClickListener + /** + * Callback for when the user wants to add the visible directory to the library. + */ + public interface FileClickListener { - public void finishSuccessfully(); + void finishSuccessfully(); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index bf7bf435b7..883107a410 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -1,5 +1,7 @@ package org.dolphinemu.dolphinemu.adapters; +import android.app.Activity; +import android.content.Intent; import android.graphics.Rect; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -9,12 +11,16 @@ import android.view.ViewGroup; import com.squareup.picasso.Picasso; import org.dolphinemu.dolphinemu.R; +import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog; +import org.dolphinemu.dolphinemu.emulation.EmulationActivity; import org.dolphinemu.dolphinemu.model.Game; import org.dolphinemu.dolphinemu.viewholders.GameViewHolder; import java.util.ArrayList; -public class GameAdapter extends RecyclerView.Adapter +public class GameAdapter extends RecyclerView.Adapter implements + View.OnClickListener, + View.OnLongClickListener { private ArrayList mGameList; @@ -42,6 +48,9 @@ public class GameAdapter extends RecyclerView.Adapter View gameCard = LayoutInflater.from(parent.getContext()) .inflate(R.layout.card_game, parent, false); + gameCard.setOnClickListener(this); + gameCard.setOnLongClickListener(this); + // Use that view to create a ViewHolder. GameViewHolder holder = new GameViewHolder(gameCard); return holder; @@ -74,7 +83,6 @@ public class GameAdapter extends RecyclerView.Adapter { holder.textDescription.setText(game.getDescription()); } - holder.buttonDetails.setTag(game.getGameId()); holder.path = game.getPath(); holder.screenshotPath = game.getScreenPath(); @@ -92,6 +100,45 @@ public class GameAdapter extends RecyclerView.Adapter return mGameList.size(); } + /** + * Launches the game that was clicked on. + * + * @param view The card representing the game the user wants to play. + */ + @Override + public void onClick(View view) + { + GameViewHolder holder = (GameViewHolder) view.getTag(); + + // Start the emulation activity and send the path of the clicked ISO to it. + Intent intent = new Intent(view.getContext(), EmulationActivity.class); + + intent.putExtra("SelectedGame", holder.path); + + view.getContext().startActivity(intent); + } + + /** + * Launches the details activity for this Game, using an ID stored in the + * details button's Tag. + * + * @param view The Card button that was long-clicked. + */ + @Override + public boolean onLongClick(View view) + { + GameViewHolder holder = (GameViewHolder) view.getTag(); + + // Get the ID of the game we want to look at. + // TODO This should be all we need to pass in, eventually. + // String gameId = (String) holder.gameId; + + Activity activity = (Activity) view.getContext(); + GameDetailsDialog.newInstance(holder.game).show(activity.getFragmentManager(), "game_details"); + + return true; + } + public static class SpacesItemDecoration extends RecyclerView.ItemDecoration { private int space; @@ -108,7 +155,6 @@ public class GameAdapter extends RecyclerView.Adapter outRect.right = space; outRect.bottom = space; outRect.top = space; - } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java index 47acf588de..18e271e0f5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java @@ -19,7 +19,6 @@ public class GameViewHolder extends RecyclerView.ViewHolder public ImageView imageScreenshot; public TextView textGameTitle; public TextView textDescription; - public ImageButton buttonDetails; // Used to handle onClick(). Set this in onBindViewHolder(). public String path; @@ -30,54 +29,10 @@ public class GameViewHolder extends RecyclerView.ViewHolder { super(itemView); - itemView.setOnClickListener(mCardClickListener); + itemView.setTag(this); imageScreenshot = (ImageView) itemView.findViewById(R.id.image_game_screen); textGameTitle = (TextView) itemView.findViewById(R.id.text_game_title); textDescription = (TextView) itemView.findViewById(R.id.text_game_description); - buttonDetails = (ImageButton) itemView.findViewById(R.id.button_details); - - buttonDetails.setOnClickListener(mDetailsButtonListener); } - - private View.OnClickListener mCardClickListener = new View.OnClickListener() - { - /** - * Launches the game that was clicked on. - * - * @param view The card representing the game the user wants to play. - */ - @Override - public void onClick(View view) - { - // Start the emulation activity and send the path of the clicked ROM to it. - Intent intent = new Intent(view.getContext(), EmulationActivity.class); - - intent.putExtra("SelectedGame", path); - - view.getContext().startActivity(intent); - } - }; - - private View.OnClickListener mDetailsButtonListener = new View.OnClickListener() - { - - /** - * Launches the details activity for this Game, using an ID stored in the - * details button's Tag. - * - * @param view The Details button that was clicked on. - */ - @Override - public void onClick(View view) - { - // Get the ID of the game we want to look at. - // TODO This should be all we need to pass in, eventually. - // String gameId = (String) view.getTag(); - - Activity activity = (Activity) view.getContext(); - GameDetailsDialog.newInstance(game).show(activity.getFragmentManager(), "game_details"); - } - }; - } diff --git a/Source/Android/app/src/main/res/layout/card_game.xml b/Source/Android/app/src/main/res/layout/card_game.xml index e0aa7f01f4..dc8321f8f8 100644 --- a/Source/Android/app/src/main/res/layout/card_game.xml +++ b/Source/Android/app/src/main/res/layout/card_game.xml @@ -2,9 +2,14 @@ + android:layout_width="0dp" + tools:layout_width="224dp" + android:layout_height="256dp" + android:transitionName="card_game" + android:focusable="true" + android:clickable="true" + android:foreground="?android:attr/selectableItemBackground" + > + tools:src="@drawable/placeholder_screenshot" + tools:scaleType="centerCrop"/> - + + - - - - - - diff --git a/Source/Android/app/src/main/res/layout/list_item_file.xml b/Source/Android/app/src/main/res/layout/list_item_file.xml index 3999d0368b..7d54e77d27 100644 --- a/Source/Android/app/src/main/res/layout/list_item_file.xml +++ b/Source/Android/app/src/main/res/layout/list_item_file.xml @@ -1,30 +1,31 @@ + android:layout_height="56dp" + android:background="?android:attr/selectableItemBackground" + android:orientation="horizontal"> + android:background="@drawable/oval_ripple_grey" + android:padding="4dp" + tools:src="@drawable/ic_wii"/> + tools:text="File Name"/> \ No newline at end of file diff --git a/Source/Android/app/src/main/res/menu/menu_add_directory.xml b/Source/Android/app/src/main/res/menu/menu_add_directory.xml index c459811868..667d28a4f0 100644 --- a/Source/Android/app/src/main/res/menu/menu_add_directory.xml +++ b/Source/Android/app/src/main/res/menu/menu_add_directory.xml @@ -1,5 +1,6 @@ + Other - Add Directory to Library + Add Folder to Library Up one level + That folder is empty. From ca4bec35399185dc57e250b54d5308abbc4f464e Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Sun, 10 May 2015 10:46:46 -0400 Subject: [PATCH 5/7] Don't show "Error" when a blank string is returned from a native method. --- .../activities/AddDirectoryActivity.java | 8 ++ .../activities/GameGridActivity.java | 23 +++- Source/Core/DolphinWX/MainAndroid.cpp | 107 +++++++++--------- 3 files changed, 78 insertions(+), 60 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java index 3a282f6433..04e6ffb9f6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java @@ -15,6 +15,10 @@ import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.adapters.FileAdapter; +/** + * 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 static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path"; @@ -74,6 +78,7 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl return super.onOptionsItemSelected(item); } + @Override protected void onSaveInstanceState(Bundle outState) { @@ -83,6 +88,9 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl outState.putString(KEY_CURRENT_PATH, mAdapter.getPath()); } + /** + * Tell the GameGridActivity that launched this Activity that the user picked a folder. + */ @Override public void finishSuccessfully() { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java index 14633d1277..e5a8572e5b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java @@ -3,16 +3,11 @@ package org.dolphinemu.dolphinemu.activities; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; -import android.database.Cursor; -import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.preference.PreferenceManager; -import android.provider.DocumentsContract; -import android.provider.OpenableColumns; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.View; @@ -32,6 +27,10 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; +/** + * 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 { private static final int REQUEST_ADD_DIRECTORY = 1; @@ -83,21 +82,33 @@ public final class GameGridActivity extends Activity } } + /** + * Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity. + * + * @param requestCode + * @param resultCode + * @param result + */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent result) { + // If the user picked a file, as opposed to just backing out. if (resultCode == RESULT_OK) { + // Sanity check to make sure the Activity that just returned was the AddDirectoryActivity; + // other activities might use this callback in the future (don't forget to change Javadoc!) if (requestCode == REQUEST_ADD_DIRECTORY) { String path = result.getStringExtra(AddDirectoryActivity.KEY_CURRENT_PATH); + // Store this path as a preference. + // TODO Use SQLite instead. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putString(AddDirectoryActivity.KEY_CURRENT_PATH, path); - // Using commit in order to block so the next method has the correct data to load. + // Using commit, not apply, in order to block so the next method has the correct data to load. editor.commit(); mAdapter.setGameList(getGameList()); diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index a38f312f49..44e9f370d7 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -219,7 +219,7 @@ static std::string GetTitle(std::string filename) return name; } - return std::string ("Error"); + return std::string (""); } static std::string GetDescription(std::string filename) @@ -256,7 +256,7 @@ static std::string GetDescription(std::string filename) return descriptions.cbegin()->second; } - return std::string ("Error"); + return std::string (""); } static std::string GetGameId(std::string filename) @@ -271,7 +271,7 @@ static std::string GetGameId(std::string filename) return id; } - return std::string ("Error"); + return std::string (""); } static std::string GetApploaderDate(std::string filename) @@ -286,7 +286,7 @@ static std::string GetApploaderDate(std::string filename) return date; } - return std::string ("Error"); + return std::string (""); } static u64 GetFileSize(std::string filename) @@ -349,17 +349,17 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv * JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj) { -PowerPC::Start(); + PowerPC::Start(); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv *env, jobject obj) { -PowerPC::Pause(); + PowerPC::Pause(); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv *env, jobject obj) { -Core::Stop(); -updateMainFrameEvent.Set(); // Kick the waiting event + Core::Stop(); + updateMainFrameEvent.Set(); // Kick the waiting event } JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Button, jint Action) { @@ -367,7 +367,7 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePa } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Axis, jfloat Value) { -ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value); + ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value); } JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv *env, jobject obj, jstring jFile) @@ -437,12 +437,12 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Supports JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv *env, jobject obj) { -Core::SaveScreenShot(); + Core::SaveScreenShot(); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv *env, jobject obj, jint api) { -eglBindAPI(api); + eglBindAPI(api); } JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault) @@ -460,59 +460,58 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig return env->NewStringUTF(value.c_str()); } -JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, -jstring jValue) +JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue) { -IniFile ini; -std::string file = GetJString(env, jFile); -std::string section = GetJString(env, jSection); -std::string key = GetJString(env, jKey); -std::string value = GetJString(env, jValue); + IniFile ini; + std::string file = GetJString(env, jFile); + std::string section = GetJString(env, jSection); + std::string key = GetJString(env, jKey); + std::string value = GetJString(env, jValue); -ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file)); + ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file)); -ini.GetOrCreateSection(section)->Set(key, value); -ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file)); + ini.GetOrCreateSection(section)->Set(key, value); + ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file)); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv *env, jobject obj, jstring jFile) { -g_filename = GetJString(env, jFile); + g_filename = GetJString(env, jFile); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv *env, jobject obj, jint slot) { -State::Save(slot); + State::Save(slot); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv *env, jobject obj, jint slot) { -State::Load(slot); + State::Load(slot); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_CreateUserFolders(JNIEnv *env, jobject obj) { -File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX)); -File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); -File::CreateFullPath(File::GetUserPath(D_WIIUSER_IDX)); -File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); -File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); -File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); -File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); -File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); -File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); -File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); -File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX)); -File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP); -File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP); -File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP); + File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX)); + File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); + File::CreateFullPath(File::GetUserPath(D_WIIUSER_IDX)); + File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); + File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); + File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); + File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); + File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); + File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); + File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); + File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX)); + File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP); + File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP); + File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(JNIEnv *env, jobject obj, jstring jDirectory) { -std::string directory = GetJString(env, jDirectory); -g_set_userpath = directory; -UICommon::SetUserDirectory(directory); + std::string directory = GetJString(env, jDirectory); + g_set_userpath = directory; + UICommon::SetUserDirectory(directory); } JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv *env, jobject obj) @@ -522,24 +521,24 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDi JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf) { -surf = ANativeWindow_fromSurface(env, _surf); + surf = ANativeWindow_fromSurface(env, _surf); -// Install our callbacks -OSD::AddCallback(OSD::OSD_INIT, ButtonManager::Init); -OSD::AddCallback(OSD::OSD_SHUTDOWN, ButtonManager::Shutdown); + // Install our callbacks + OSD::AddCallback(OSD::OSD_INIT, ButtonManager::Init); + OSD::AddCallback(OSD::OSD_SHUTDOWN, ButtonManager::Shutdown); -RegisterMsgAlertHandler(&MsgAlert); + RegisterMsgAlertHandler(&MsgAlert); -UICommon::SetUserDirectory(g_set_userpath); -UICommon::Init(); + UICommon::SetUserDirectory(g_set_userpath); + UICommon::Init(); -// No use running the loop when booting fails -if ( BootManager::BootCore( g_filename.c_str() ) ) -while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) -updateMainFrameEvent.Wait(); + // No use running the loop when booting fails + if ( BootManager::BootCore( g_filename.c_str() ) ) + while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) + updateMainFrameEvent.Wait(); -UICommon::Shutdown(); -ANativeWindow_release(surf); + UICommon::Shutdown(); + ANativeWindow_release(surf); } From abaf41baa7ead3f4106a4493dc737cd9340bc448 Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Sun, 10 May 2015 11:07:16 -0400 Subject: [PATCH 6/7] Add a subtitle to AddDirectoryActivity containing the currently displayed folder's path. --- .../activities/AddDirectoryActivity.java | 16 ++++++--- .../activities/GameGridActivity.java | 9 +++-- .../dolphinemu/adapters/FileAdapter.java | 35 ++++++++++++------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java index 04e6ffb9f6..1c536d8f91 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java @@ -24,6 +24,7 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl public static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path"; private FileAdapter mAdapter; + private Toolbar mToolbar; @Override protected void onCreate(Bundle savedInstanceState) @@ -32,8 +33,8 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl setContentView(R.layout.activity_add_directory); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_folder_list); - setActionBar(toolbar); + mToolbar = (Toolbar) findViewById(R.id.toolbar_folder_list); + setActionBar(mToolbar); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list_files); @@ -46,7 +47,8 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl if (savedInstanceState == null) { path = Environment.getExternalStorageDirectory().getPath(); - } else + } + else { // Get the path we were looking at before we rotated. path = savedInstanceState.getString(KEY_CURRENT_PATH); @@ -71,7 +73,7 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl switch (item.getItemId()) { case R.id.menu_up_one_level: - mAdapter.setPath(mAdapter.getPath() + "/.."); + mAdapter.upOneLevel(); break; } @@ -101,4 +103,10 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl finish(); } + + @Override + public void updateSubtitle(String path) + { + mToolbar.setSubtitle(path); + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java index e5a8572e5b..bd922ecbed 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java @@ -69,6 +69,8 @@ public final class GameGridActivity extends Activity public void onClick(View view) { Intent fileChooser = new Intent(GameGridActivity.this, AddDirectoryActivity.class); + + // The second argument to this method is read below in onActivityResult(). startActivityForResult(fileChooser, REQUEST_ADD_DIRECTORY); } }); @@ -85,9 +87,9 @@ public final class GameGridActivity extends Activity /** * Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity. * - * @param requestCode - * @param resultCode - * @param result + * @param requestCode An int describing whether the Activity that is returning did so successfully. + * @param resultCode An int describing what Activity is giving us this callback. + * @param result The information the returning Activity is providing us. */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent result) @@ -99,6 +101,7 @@ public final class GameGridActivity extends Activity // other activities might use this callback in the future (don't forget to change Javadoc!) if (requestCode == REQUEST_ADD_DIRECTORY) { + // Get the path the user selected in AddDirectoryActivity. String path = result.getStringExtra(AddDirectoryActivity.KEY_CURRENT_PATH); // Store this path as a preference. diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java index 2414883279..9ae238d36c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java @@ -26,12 +26,14 @@ public class FileAdapter extends RecyclerView.Adapter implements * Initializes the dataset to be displayed, and associates the Adapter with the * Activity as an event listener. * - * @param gameList + * @param path A String containing the path to the directory to be shown by this Adapter. + * @param listener An Activity that can respond to callbacks from this Adapter. */ public FileAdapter(String path, FileClickListener listener) { mFileList = generateFileList(new File(path)); mListener = listener; + mListener.updateSubtitle(path); } /** @@ -107,12 +109,12 @@ public class FileAdapter extends RecyclerView.Adapter implements * When a file is clicked, determine if it is a directory; if it is, show that new directory's * contents. If it is not, end the activity successfully. * - * @param view + * @param view The View representing the file the user clicked on. */ @Override public void onClick(final View view) { - String path = (String) view.getTag(); + final String path = (String) view.getTag(); File clickedFile = new File(path); @@ -135,6 +137,7 @@ public class FileAdapter extends RecyclerView.Adapter implements { mFileList = fileList; notifyDataSetChanged(); + mListener.updateSubtitle(path); } }, 200); } @@ -148,7 +151,7 @@ public class FileAdapter extends RecyclerView.Adapter implements /** * For a given directory, return a list of Files it contains. * - * @param directory + * @param directory A File representing the directory that should have its contents displayed. * @return */ private ArrayList generateFileList(File directory) @@ -176,26 +179,32 @@ public class FileAdapter extends RecyclerView.Adapter implements return mPath; } - /** - * Mostly just allows the activity's menu option to kick us up a level in the directory - * structure. - * - * @param path - */ public void setPath(String path) { - mPath = path; - File parentDirectory = new File(path); + File directory = new File(path); + + mFileList = generateFileList(directory); + notifyDataSetChanged(); + mListener.updateSubtitle(path); + } + + public void upOneLevel() + { + File currentDirectory = new File(mPath); + File parentDirectory = currentDirectory.getParentFile(); mFileList = generateFileList(parentDirectory); notifyDataSetChanged(); + mListener.updateSubtitle(mPath); } /** - * Callback for when the user wants to add the visible directory to the library. + * Callback to the containing Activity. */ public interface FileClickListener { void finishSuccessfully(); + + void updateSubtitle(String path); } } From f3aec526b14faa34af0b99996998dabfb2637ac2 Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Sun, 10 May 2015 17:48:46 -0400 Subject: [PATCH 7/7] Add an IntelliJ settings file describing the Dolphin project code style. --- Contributing.md | 8 ++++---- Source/Android/app/src/main/AndroidManifest.xml | 1 - .../dolphinemu/adapters/FileAdapter.java | 8 +++++--- .../dolphinemu/model/FileListItem.java | 12 ++++++++---- Source/Android/code-style-java.jar | Bin 0 -> 1534 bytes 5 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 Source/Android/code-style-java.jar diff --git a/Contributing.md b/Contributing.md index 8784f85fbb..7a7d030170 100644 --- a/Contributing.md +++ b/Contributing.md @@ -3,7 +3,6 @@ If you make any contributions to Dolphin after December 1st, 2014, you are agreeing that any code you have contributed will be licensed under the GNU GPL version 2 (or any later version). ## Coding Style ---- - [Introduction] (#introduction) - [Styling and formatting] (#styling-and-formatting) @@ -20,14 +19,12 @@ If you make any contributions to Dolphin after December 1st, 2014, you are agree ## Introduction ---- This guide is for developers who wish to contribute to the Dolphin codebase. It will detail how to properly style and format code to fit this project. This guide also offers suggestions on specific functions and other varia that may be used in code. Following this guide and formatting your code as detailed will likely get your pull request merged much faster than if you don't (assuming the written code has no mistakes in itself). ## Styling and formatting ---- ### General - Try to limit lines of code to a maximum of 100 characters. @@ -130,7 +127,6 @@ private: ``` ## Code Specific ---- ### General - Using C++11 features is OK and recommended. @@ -229,3 +225,7 @@ private: // Class definitions }; ``` + +## Java + +The Android project is currently written in Java. If you are using Android Studio to contribute, you can import the project's code style from `code-style-java.jar`, located in `[Dolphin Root]/Source/Android`. Please organize imports before committing. \ No newline at end of file diff --git a/Source/Android/app/src/main/AndroidManifest.xml b/Source/Android/app/src/main/AndroidManifest.xml index d10632b868..9042094c43 100644 --- a/Source/Android/app/src/main/AndroidManifest.xml +++ b/Source/Android/app/src/main/AndroidManifest.xml @@ -30,7 +30,6 @@ android:theme="@style/DolphinWii" android:label="@string/add_directory_title"/> - implements * Initializes the dataset to be displayed, and associates the Adapter with the * Activity as an event listener. * - * @param path A String containing the path to the directory to be shown by this Adapter. + * @param path A String containing the path to the directory to be shown by this Adapter. * @param listener An Activity that can respond to callbacks from this Adapter. */ public FileAdapter(String path, FileClickListener listener) @@ -125,7 +125,8 @@ public class FileAdapter extends RecyclerView.Adapter implements if (fileList.isEmpty()) { Toast.makeText(view.getContext(), R.string.add_directory_empty_folder, Toast.LENGTH_SHORT).show(); - } else + } + else { // Delay the loading of the new directory to give a little bit of time for UI feedback // to happen. Hacky, but good enough for now; this is necessary because we're modifying @@ -141,7 +142,8 @@ public class FileAdapter extends RecyclerView.Adapter implements } }, 200); } - } else + } + else { // Pass the activity the path of the parent directory of the clicked file. mListener.finishSuccessfully(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java index e15516dbaf..69b39438e8 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java @@ -26,7 +26,8 @@ public class FileListItem implements Comparable if (file.isDirectory()) { mType = TYPE_FOLDER; - } else + } + else { String fileExtension = mPath.substring(mPath.lastIndexOf('.')); @@ -37,7 +38,8 @@ public class FileListItem implements Comparable if (allowedExtensions.contains(fileExtension)) { mType = NativeLibrary.IsWiiTitle(mPath) ? TYPE_WII : TYPE_GC; - } else + } + else { mType = TYPE_OTHER; } @@ -67,12 +69,14 @@ public class FileListItem implements Comparable if (theOther.getType() == getType()) { return getFilename().toLowerCase().compareTo(theOther.getFilename().toLowerCase()); - } else + } + else { if (getType() > theOther.getType()) { return 1; - } else + } + else { return -1; } diff --git a/Source/Android/code-style-java.jar b/Source/Android/code-style-java.jar new file mode 100644 index 0000000000000000000000000000000000000000..8140ad66f9d0318f07681facaddb87e9cc037492 GIT binary patch literal 1534 zcmWIWW@Zs#VBp|j(Cu2~R_l6&v66v-VLA}YF|aV?7nEe?=N0QG=clCV6_-@z0LkQx z)ZEl!y^7qNf2SB2Hhb!5oH*&@r*rbm`OS}m0ycP_JFk1(^R!IUo^kH)E=F7JauvZ8zF`Opu@R<4rgEx+_Kya=w3MB z2C_g72D`UdAEXfBL*s(f-S3zf7^=k?7^G1Zy5#2+WMt;)dL@=6g1q-O;&k3@2a&tq zwFO>j1=)ID_0`GAWD;(l;?A<8clV2qM=KXTOgw1OzyCdJa+36%BUzapujW2Kcc=Kd z%zbu+%9B$rp7|Vkq~%8M4Tq3P1@G8DwtIiSCffd<#nJ1TjmM*+-!ZDQoOss=SEWuY z{u(8ccejAidZNaHUzL%ExA~?P=U7}Ze0f7HS z4(pxm;`XQR<|uqBIq0JJSdV{Ckkj@o$gv9 z+iFyzH`~7DOxhgwk2>0ma}GS+s@I=;{K`sS8Fy2+vesQ?iJZ30+Oe;rgzaXmbaRWC z7xE)DU(u_0fsn_iZHGA)N}m^7@Wx@!k@yWaMBbe_WVCRbabw?Rr~eV1_pVfY|9GLZ zI8m#5rvNWYn_kw0^&!E$mySr*G*z5R$`hLxIaP6MJy(?GRDFXZ|*qpc-pr9^0e!d7UtYOFw6h;!&;GJk^ARF z2x;YfU0nH1{IKLPZAmEy>*jX{ez{It|2Bu+ZR-i4Rk49ivt3j|ly4jTy?61o!FglN zxtmHV%rqA)h!#8D*KyhU)qV^0nsd)dQLbvK>Em>Bmjy-u(HMY)W?Uwm%8(Pa@naBsC`|(@VkA#nn;4JtsdYF-IXdwWK67 zFTFUxn~_O`0g+$POC-2SU*ag6tz~ pL5nbmlLalHksXgMBoSIefm#WKD=QmFIV%uGFfuSq0BT@h003GOMzsI{ literal 0 HcmV?d00001