Large diffs are not rendered by default.

@@ -1,9 +1,9 @@
package org.dolphinemu.dolphinemu.adapters;

import android.app.Activity;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.graphics.Rect;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
@@ -202,7 +202,7 @@ public void onClick(View view)
{
GameViewHolder holder = (GameViewHolder) view.getTag();

EmulationActivity.launch((Activity) view.getContext(),
EmulationActivity.launch((FragmentActivity) view.getContext(),
holder.path,
holder.title,
holder.screenshotPath,
@@ -225,13 +225,13 @@ public boolean onLongClick(View view)
// TODO This should be all we need to pass in, eventually.
// String gameId = (String) holder.gameId;

Activity activity = (Activity) view.getContext();
FragmentActivity activity = (FragmentActivity) view.getContext();
GameDetailsDialog.newInstance(holder.title,
holder.description,
holder.country,
holder.company,
holder.path,
holder.screenshotPath).show(activity.getFragmentManager(), "game_details");
holder.screenshotPath).show(activity.getSupportFragmentManager(), "game_details");

return true;
}
@@ -1,10 +1,10 @@
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.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ImageSpan;
@@ -2,9 +2,9 @@

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -1,9 +1,10 @@
package org.dolphinemu.dolphinemu.fragments;

import android.app.Fragment;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.SurfaceHolder;
@@ -14,15 +15,12 @@

import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.overlay.InputOverlay;
import org.dolphinemu.dolphinemu.utils.Log;

public final class EmulationFragment extends Fragment implements SurfaceHolder.Callback
{
public static final String FRAGMENT_TAG = "emulation_fragment";

private static final String ARG_GAME_PATH = "game_path";

private SharedPreferences mPreferences;

private Surface mSurface;
@@ -31,18 +29,22 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C

private Thread mEmulationThread;

private boolean mEmulationStarted;
private boolean mEmulationRunning;
private String mGamePath;
private final EmulationState mEmulationState = new EmulationState();

public static EmulationFragment newInstance(String path)
@Override
public void onAttach(Context context)
{
EmulationFragment fragment = new EmulationFragment();
super.onAttach(context);

Bundle arguments = new Bundle();
arguments.putString(ARG_GAME_PATH, path);
fragment.setArguments(arguments);

return fragment;
if (context instanceof EmulationActivity)
{
NativeLibrary.setEmulationActivity((EmulationActivity) context);
}
else
{
throw new IllegalStateException("EmulationFragment must have EmulationActivity parent");
}
}

/**
@@ -67,38 +69,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
{
View contents = inflater.inflate(R.layout.fragment_emulation, container, false);

SurfaceView surfaceView = (SurfaceView) contents.findViewById(R.id.surface_emulation);
mInputOverlay = (InputOverlay) contents.findViewById(R.id.surface_input_overlay);

SurfaceView surfaceView = contents.findViewById(R.id.surface_emulation);
surfaceView.getHolder().addCallback(this);

// If the input overlay was previously disabled, then don't show it.
mInputOverlay = contents.findViewById(R.id.surface_input_overlay);
if (mInputOverlay != null)
{
// If the input overlay was previously disabled, then don't show it.
if (!mPreferences.getBoolean("showInputOverlay", true))
{
mInputOverlay.setVisibility(View.GONE);
}
}

if (savedInstanceState == null)
{
mEmulationThread = new Thread(mEmulationRunner);
}
else
{
// Likely a rotation occurred.
// TODO Pass native code the Surface, which will have been recreated, from surfaceChanged()
// TODO Also, write the native code that will get the video backend to accept the new Surface as one of its own.
}

return contents;
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
Button doneButton = (Button) view.findViewById(R.id.done_control_config);
Button doneButton = contents.findViewById(R.id.done_control_config);
if (doneButton != null)
{
doneButton.setOnClickListener(new View.OnClickListener()
@@ -110,29 +94,29 @@ public void onClick(View v)
}
});
}
}

@Override
public void onStart()
{
super.onStart();
startEmulation();
// The new Surface created here will get passed to the native code via onSurfaceChanged.

return contents;
}

@Override
public void onStop()
{
pauseEmulation();
super.onStop();
}

@Override
public void onDestroyView()
public void onDetach()
{
super.onDestroyView();
if (getActivity().isFinishing() && mEmulationStarted)
{
NativeLibrary.StopEmulation();
}
NativeLibrary.clearEmulationActivity();
super.onDetach();
}

public void setGamePath(String gamePath)
{
mGamePath = gamePath;
}

public void toggleInputOverlayVisibility()
@@ -171,6 +155,12 @@ public void surfaceCreated(SurfaceHolder holder)
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
Log.debug("[EmulationFragment] Surface changed. Resolution: " + width + "x" + height);

if (mEmulationState.isPaused())
{
NativeLibrary.UnPauseEmulation();
}

mSurface = holder.getSurface();
NativeLibrary.SurfaceChanged(mSurface);
}
@@ -181,64 +171,75 @@ public void surfaceDestroyed(SurfaceHolder holder)
Log.debug("[EmulationFragment] Surface destroyed.");
NativeLibrary.SurfaceDestroyed();

if (mEmulationRunning)
if (mEmulationState.isRunning())
{
pauseEmulation();
}
}

private void startEmulation()
public void startEmulation()
{
if (!mEmulationStarted)
synchronized (mEmulationState)
{
Log.debug("[EmulationFragment] Starting emulation thread.");
if (mEmulationState.isStopped())
{
Log.debug("[EmulationFragment] Starting emulation thread.");

mEmulationThread.start();
mEmulationThread = new Thread(mEmulationRunner, "NativeEmulation");
mEmulationThread.start();
// The thread will call mEmulationState.run()
}
else if (mEmulationState.isPaused())
{
Log.debug("[EmulationFragment] Resuming emulation.");
NativeLibrary.UnPauseEmulation();
mEmulationState.run();
}
else
{
Log.debug("[EmulationFragment] Bug, startEmulation called while running.");
}
}
else
}

public void stopEmulation() {
synchronized (mEmulationState)
{
Log.debug("[EmulationFragment] Resuming emulation.");
NativeLibrary.UnPauseEmulation();
if (!mEmulationState.isStopped())
{
NativeLibrary.StopEmulation();
mEmulationState.stop();
}
}

mEmulationRunning = true;
}

private void pauseEmulation()
{
Log.debug("[EmulationFragment] Pausing emulation.");

NativeLibrary.PauseEmulation();
mEmulationRunning = false;
}
synchronized (mEmulationState)
{
Log.debug("[EmulationFragment] Pausing emulation.");

/**
* Called by containing activity to tell the Fragment emulation is already stopping,
* so it doesn't try to stop emulation on its way to the garbage collector.
*/
public void notifyEmulationStopped()
{
mEmulationStarted = false;
mEmulationRunning = false;
NativeLibrary.PauseEmulation();
mEmulationState.pause();
}
}

private Runnable mEmulationRunner = new Runnable()
{
@Override
public void run()
{
mEmulationRunning = true;
mEmulationStarted = true;

while (mSurface == null)
if (!mEmulationRunning)
return;
// Busy-wait for surface to be set
while (mSurface == null) {}

Log.info("[EmulationFragment] Starting emulation: " + mSurface);
synchronized (mEmulationState)
{
Log.info("[EmulationFragment] Starting emulation: " + mSurface);

mEmulationState.run();
}
// Start emulation using the provided Surface.
String path = getArguments().getString(ARG_GAME_PATH);
NativeLibrary.Run(path);
NativeLibrary.Run(mGamePath);
}
};

@@ -258,4 +259,50 @@ public boolean isConfiguringControls()
{
return mInputOverlay.isInEditMode();
}

private static class EmulationState
{
private enum State
{
STOPPED, RUNNING, PAUSED
}

private State state;

EmulationState()
{
// Starting state is stopped.
state = State.STOPPED;
}

public boolean isStopped()
{
return state == State.STOPPED;
}

public boolean isRunning()
{
return state == State.RUNNING;
}

public boolean isPaused()
{
return state == State.PAUSED;
}

public void run()
{
state = State.RUNNING;
}

public void pause()
{
state = State.PAUSED;
}

public void stop()
{
state = State.STOPPED;
}
}
}
@@ -1,8 +1,8 @@
package org.dolphinemu.dolphinemu.fragments;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.View;
@@ -16,7 +16,7 @@

public final class MenuFragment extends Fragment implements View.OnClickListener
{
private TextView mTitleText;
private static final String KEY_TITLE = "title";
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static {
buttonsActionsMap.append(R.id.menu_take_screenshot, EmulationActivity.MENU_ACTION_TAKE_SCREENSHOT);
@@ -28,6 +28,17 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
}

public static MenuFragment newInstance(String title)
{
MenuFragment fragment = new MenuFragment();

Bundle arguments = new Bundle();
arguments.putSerializable(KEY_TITLE, title);
fragment.setArguments(arguments);

return fragment;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
@@ -42,7 +53,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
button.setOnClickListener(this);
}

mTitleText = (TextView) rootView.findViewById(R.id.text_game_title);
TextView titleText = rootView.findViewById(R.id.text_game_title);
String title = getArguments().getString(KEY_TITLE);
if (title != null)
{
titleText.setText(title);
}

return rootView;
}
@@ -57,9 +73,4 @@ public void onClick(View button)
((EmulationActivity) getActivity()).handleMenuAction(action);
}
}

public void setTitleText(String title)
{
mTitleText.setText(title);
}
}
@@ -1,8 +1,8 @@
package org.dolphinemu.dolphinemu.fragments;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.View;
@@ -0,0 +1,25 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2+
* Refer to the license.txt file included.
*/

package org.dolphinemu.dolphinemu.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

/**
* Work around a bug with the nVidia Shield.
*/
public final class NVidiaShieldWorkaroundView extends View
{
public NVidiaShieldWorkaroundView(Context context, AttributeSet attrs)
{
super(context, attrs);

// Setting this seems to workaround the bug
setWillNotDraw(false);
}
}
@@ -70,7 +70,8 @@ public void onClick(View view)

if (PermissionsHandler.hasWriteAccess(this))
{
PlatformPagerAdapter platformPagerAdapter = new PlatformPagerAdapter(getFragmentManager(), this);
PlatformPagerAdapter platformPagerAdapter = new PlatformPagerAdapter(
getSupportFragmentManager(), this);
mViewPager.setAdapter(platformPagerAdapter);
} else {
mViewPager.setVisibility(View.INVISIBLE);
@@ -162,7 +163,8 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
StartupHandler.copyAssetsIfNeeded(this);

PlatformPagerAdapter platformPagerAdapter = new PlatformPagerAdapter(getFragmentManager(), this);
PlatformPagerAdapter platformPagerAdapter = new PlatformPagerAdapter(
getSupportFragmentManager(), this);
mViewPager.setAdapter(platformPagerAdapter);
mTabLayout.setupWithViewPager(mViewPager);
mViewPager.setVisibility(View.VISIBLE);
@@ -205,6 +207,6 @@ private PlatformGamesView getPlatformGamesView(Platform platform)
{
String fragmentTag = "android:switcher:" + mViewPager.getId() + ":" + platform;

return (PlatformGamesView) getFragmentManager().findFragmentByTag(fragmentTag);
return (PlatformGamesView) getSupportFragmentManager().findFragmentByTag(fragmentTag);
}
}
@@ -1,12 +1,11 @@
package org.dolphinemu.dolphinemu.ui.main;

import android.app.Activity;
import android.app.FragmentManager;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v17.leanback.app.BrowseFragment;
import android.support.v17.leanback.app.BrowseSupportFragment;
import android.support.v17.leanback.database.CursorMapper;
import android.support.v17.leanback.widget.ArrayObjectAdapter;
import android.support.v17.leanback.widget.CursorObjectAdapter;
@@ -17,6 +16,8 @@
import android.support.v17.leanback.widget.Presenter;
import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.RowPresenter;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;

@@ -33,11 +34,11 @@
import org.dolphinemu.dolphinemu.utils.StartupHandler;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;

public final class TvMainActivity extends Activity implements MainView
public final class TvMainActivity extends FragmentActivity implements MainView
{
private MainPresenter mPresenter = new MainPresenter(this);

private BrowseFragment mBrowseFragment;
private BrowseSupportFragment mBrowseFragment;

private ArrayObjectAdapter mRowsAdapter;

@@ -57,8 +58,8 @@ protected void onCreate(Bundle savedInstanceState)
}

void setupUI() {
final FragmentManager fragmentManager = getFragmentManager();
mBrowseFragment = new BrowseFragment();
final FragmentManager fragmentManager = getSupportFragmentManager();
mBrowseFragment = new BrowseSupportFragment();
fragmentManager
.beginTransaction()
.add(R.id.content, mBrowseFragment, "BrowseFragment")
@@ -1,9 +1,9 @@
package org.dolphinemu.dolphinemu.ui.platform;

import android.app.Fragment;
import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -1,9 +1,9 @@
package org.dolphinemu.dolphinemu.ui.settings;

import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
@@ -88,7 +88,7 @@ public void onBackPressed()
@Override
public void showSettingsFragment(String menuTag, boolean addToStack)
{
FragmentTransaction transaction = getFragmentManager().beginTransaction();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

if (addToStack)
{
@@ -149,7 +149,7 @@ public void showToastMessage(String message)
@Override
public void popBackStack()
{
getFragmentManager().popBackStackImmediate();
getSupportFragmentManager().popBackStackImmediate();
}

@Override
@@ -178,6 +178,6 @@ public void onExtensionSettingChanged(String key, int value)

private SettingsFragment getFragment()
{
return (SettingsFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
return (SettingsFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG);
}
}
@@ -1,10 +1,10 @@
package org.dolphinemu.dolphinemu.ui.settings;

import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -1,6 +1,6 @@
package org.dolphinemu.dolphinemu.ui.settings;

import android.app.Activity;
import android.support.v4.app.FragmentActivity;

import org.dolphinemu.dolphinemu.model.settings.Setting;
import org.dolphinemu.dolphinemu.model.settings.SettingSection;
@@ -48,7 +48,7 @@
/**
* @return The Fragment's containing activity.
*/
Activity getActivity();
FragmentActivity getActivity();

/**
* Tell the Fragment to tell the containing Activity to show a new
@@ -2,55 +2,13 @@

import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;

public final class Animations
{
private static final Interpolator DECELERATOR = new DecelerateInterpolator();
private static final Interpolator ACCELERATOR = new AccelerateInterpolator();

private Animations()
{
}

public static ViewPropertyAnimator fadeViewOutToRight(View view)
{
return view.animate()
.withLayer()
.setDuration(200)
.setInterpolator(ACCELERATOR)
.alpha(0.0f)
.translationX(view.getWidth());
}

public static ViewPropertyAnimator fadeViewOutToLeft(View view)
{
return view.animate()
.withLayer()
.setDuration(200)
.setInterpolator(ACCELERATOR)
.alpha(0.0f)
.translationX(-view.getWidth());
}

public static ViewPropertyAnimator fadeViewInFromLeft(View view)
{

view.setVisibility(View.VISIBLE);

view.setTranslationX(-view.getWidth());
view.setAlpha(0.0f);

return view.animate()
.withLayer()
.setDuration(300)
.setInterpolator(DECELERATOR)
.alpha(1.0f)
.translationX(0.0f);
}

public static ViewPropertyAnimator fadeViewIn(View view)
{
view.setVisibility(View.VISIBLE);
@@ -1,6 +1,8 @@
package org.dolphinemu.dolphinemu.utils;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbConfiguration;
import android.hardware.usb.UsbConstants;
@@ -15,7 +17,6 @@
import org.dolphinemu.dolphinemu.services.USBPermService;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Java_GCAdapter {
@@ -29,22 +30,31 @@ public class Java_GCAdapter {

private static void RequestPermission()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
Context context = NativeLibrary.sEmulationActivity.get();
if (context != null)
{
UsbDevice dev = pair.getValue();
if (dev.getProductId() == 0x0337 && dev.getVendorId() == 0x057e)
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
{
if (!manager.hasPermission(dev))
UsbDevice dev = pair.getValue();
if (dev.getProductId() == 0x0337 && dev.getVendorId() == 0x057e)
{
Intent intent = new Intent();
PendingIntent pend_intent;
intent.setClass(NativeLibrary.sEmulationActivity, USBPermService.class);
pend_intent = PendingIntent.getService(NativeLibrary.sEmulationActivity, 0, intent, 0);
manager.requestPermission(dev, pend_intent);
if (!manager.hasPermission(dev))
{
Intent intent = new Intent();
PendingIntent pend_intent;
intent.setClass(context, USBPermService.class);
pend_intent = PendingIntent.getService(context, 0, intent, 0);
manager.requestPermission(dev, pend_intent);
}
}
}
}
else
{
Log.warning("Cannot request GameCube Adapter permission as EmulationActivity is null.");
}

}

public static void Shutdown()
@@ -124,14 +134,22 @@ public static boolean OpenAdapter()
}
}

NativeLibrary.sEmulationActivity.runOnUiThread(new Runnable()
final Activity emulationActivity = NativeLibrary.sEmulationActivity.get();
if (emulationActivity != null)
{
@Override
public void run()
emulationActivity.runOnUiThread(new Runnable()
{
Toast.makeText(NativeLibrary.sEmulationActivity, "GameCube Adapter couldn't be opened. Please re-plug the device.", Toast.LENGTH_LONG).show();
}
});
@Override
public void run()
{
Toast.makeText(emulationActivity, "GameCube Adapter couldn't be opened. Please re-plug the device.", Toast.LENGTH_LONG).show();
}
});
}
else
{
Log.warning("Cannot show toast for GameCube Adapter failure.");
}
usb_con.close();
}
}
@@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.utils;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbConfiguration;
import android.hardware.usb.UsbDevice;
@@ -33,23 +34,31 @@

private static void RequestPermission()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
Context context = NativeLibrary.sEmulationActivity.get();
if (context != null)
{
UsbDevice dev = pair.getValue();
if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID && dev.getVendorId() == NINTENDO_VENDOR_ID)
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
{
if (!manager.hasPermission(dev))
UsbDevice dev = pair.getValue();
if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID && dev.getVendorId() == NINTENDO_VENDOR_ID)
{
Log.warning("Requesting permission for Wii Remote adapter");
Intent intent = new Intent();
PendingIntent pend_intent;
intent.setClass(NativeLibrary.sEmulationActivity, USBPermService.class);
pend_intent = PendingIntent.getService(NativeLibrary.sEmulationActivity, 0, intent, 0);
manager.requestPermission(dev, pend_intent);
if (!manager.hasPermission(dev))
{
Log.warning("Requesting permission for Wii Remote adapter");
Intent intent = new Intent();
PendingIntent pend_intent;
intent.setClass(context, USBPermService.class);
pend_intent = PendingIntent.getService(context, 0, intent, 0);
manager.requestPermission(dev, pend_intent);
}
}
}
}
else
{
Log.warning("Cannot request Wiimote adapter permission as EmulationActivity is null.");
}
}

public static boolean QueryAdapter()
@@ -1,11 +1,11 @@
package org.dolphinemu.dolphinemu.utils;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;

@@ -17,7 +17,7 @@ public class PermissionsHandler {
public static final int REQUEST_CODE_WRITE_PERMISSION = 500;

@TargetApi(Build.VERSION_CODES.M)
public static boolean checkWritePermission(final Activity activity) {
public static boolean checkWritePermission(final FragmentActivity activity) {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}
@@ -45,7 +45,7 @@ public void onClick(DialogInterface dialog, int which) {
return true;
}

public static boolean hasWriteAccess(Activity activity) {
public static boolean hasWriteAccess(FragmentActivity activity) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int hasWritePermission = ContextCompat.checkSelfPermission(activity, WRITE_EXTERNAL_STORAGE);
return hasWritePermission == PackageManager.PERMISSION_GRANTED;
@@ -54,7 +54,7 @@ public static boolean hasWriteAccess(Activity activity) {
return true;
}

private static void showMessageOKCancel(final Activity activity, String message, DialogInterface.OnClickListener okListener) {
private static void showMessageOKCancel(final FragmentActivity activity, String message, DialogInterface.OnClickListener okListener) {
new AlertDialog.Builder(activity)
.setMessage(message)
.setPositiveButton(android.R.string.ok, okListener)
@@ -1,10 +1,10 @@
package org.dolphinemu.dolphinemu.utils;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;

import org.dolphinemu.dolphinemu.NativeLibrary;
@@ -13,7 +13,7 @@

public final class StartupHandler
{
public static boolean HandleInit(Activity parent)
public static boolean HandleInit(FragmentActivity parent)
{
NativeLibrary.SetUserDirectory(""); // Auto-Detect

@@ -46,7 +46,7 @@ public static boolean HandleInit(Activity parent)
return false;
}

public static void copyAssetsIfNeeded(Activity parent) {
public static void copyAssetsIfNeeded(FragmentActivity parent) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<objectAnimator
android:propertyName="translationX"
android:valueType="floatType"
android:valueFrom="-1280dp"
android:valueTo="0"
android:interpolator="@android:interpolator/decelerate_quad"
android:duration="300"/>

<objectAnimator
android:propertyName="alpha"
android:valueType="floatType"
android:valueFrom="0"
android:valueTo="1"
android:interpolator="@android:interpolator/accelerate_quad"
android:duration="300"/>

</set>
@@ -4,7 +4,7 @@
<objectAnimator
android:propertyName="translationX"
android:valueType="floatType"
android:valueFrom="1280"
android:valueFrom="1280dp"
android:valueTo="0"
android:interpolator="@android:interpolator/decelerate_quad"
android:duration="300"/>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<!-- This animation is used ONLY when a submenu is replaced. -->
<objectAnimator
android:propertyName="translationX"
android:valueType="floatType"
android:valueFrom="0"
android:valueTo="-1280dp"
android:interpolator="@android:interpolator/decelerate_quad"
android:duration="200"/>

<objectAnimator
android:propertyName="alpha"
android:valueType="floatType"
android:valueFrom="1"
android:valueTo="0"
android:interpolator="@android:interpolator/decelerate_quad"
android:duration="200"/>

</set>
@@ -6,16 +6,16 @@
android:propertyName="translationX"
android:valueType="floatType"
android:valueFrom="0"
android:valueTo="1280"
android:valueTo="1280dp"
android:interpolator="@android:interpolator/decelerate_quad"
android:duration="300"/>
android:duration="200"/>

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="alpha"
android:valueType="floatType"
android:valueFrom="1"
android:valueTo="0"
android:interpolator="@android:interpolator/decelerate_quad"
android:duration="300"/>
android:duration="200"/>

</set>
@@ -5,41 +5,41 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frame_content">

<FrameLayout
android:id="@+id/frame_emulation_fragment"
<fragment
android:id="@+id/fragment_emulation"
android:name="org.dolphinemu.dolphinemu.fragments.EmulationFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"/>
android:layout_height="match_parent"/>

<org.dolphinemu.dolphinemu.ui.NVidiaShieldWorkaroundView
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/image_screenshot"
android:transitionName="image_game_screenshot"/>


<LinearLayout
android:id="@+id/layout_ingame_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="gone"
tools:visibility="visible"
android:baselineAligned="false">
android:orientation="horizontal">

<fragment
android:id="@+id/fragment_menu"
<FrameLayout
android:id="@+id/frame_menu"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:name="org.dolphinemu.dolphinemu.fragments.MenuFragment"
android:layout_weight=".25"
tools:layout="@layout/fragment_ingame_menu"/>

<FrameLayout
android:id="@+id/frame_submenu"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"/>
android:layout_weight=".75"/>

</LinearLayout>

</FrameLayout>
</FrameLayout>
@@ -1,15 +1,7 @@
<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"
tools:context="org.dolphinemu.dolphinemu.fragments.EmulationFragment">

<!-- This is what everything is rendered to during emulation -->
<SurfaceView
android:id="@+id/surface_emulation"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:focusable="false"
android:focusableInTouchMode="false"/>

</FrameLayout>
<SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/surface_emulation"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:focusable="false"
android:focusableInTouchMode="false"
/>
@@ -3,11 +3,11 @@
android:layout_height="match_parent"
android:id="@+id/frame_content">

<FrameLayout
android:id="@+id/frame_emulation_fragment"
<fragment
android:id="@+id/fragment_emulation"
android:name="org.dolphinemu.dolphinemu.fragments.EmulationFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"/>
android:layout_height="match_parent"/>

<ImageView
android:layout_width="match_parent"
@@ -1,60 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#af000000"
android:orientation="vertical">

<GridLayout
android:id="@+id/grid_state_slots"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="3"
android:rowCount="2"
android:layout_gravity="center">

<Button
android:id="@+id/loadsave_state_button_1"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot1"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_2"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot2"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_3"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot3"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_4"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot4"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_5"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot5"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_6"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot6"
style="@style/OverlayInGameMenuOption"/>

</GridLayout>

</FrameLayout>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid_state_slots"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="3"
android:rowCount="2"
android:layout_gravity="center"
android:background="#af000000">

<Button
android:id="@+id/loadsave_state_button_1"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot1"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_2"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot2"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_3"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot3"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_4"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot4"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_5"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot5"
style="@style/OverlayInGameMenuOption"/>

<Button
android:id="@+id/loadsave_state_button_6"
android:layout_width="128dp"
android:layout_height="128dp"
android:text="@string/emulation_slot6"
style="@style/OverlayInGameMenuOption"/>

</GridLayout>
@@ -3,12 +3,15 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.3'
}
}

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
@@ -58,7 +58,6 @@ std::string s_set_userpath;

jclass s_jni_class;
jmethodID s_jni_method_alert;
jmethodID s_jni_method_end;

// The Core only supports using a single Host thread.
// If multiple threads want to call host functions then they need to queue
@@ -732,7 +731,6 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_CacheClassesAndMethods(JNIEnv* env,
// Source/Android/app/build/intermediates/classes/arm/debug/org/dolphinemu/dolphinemu/NativeLibrary.class
s_jni_method_alert =
env->GetStaticMethodID(s_jni_class, "displayAlertMsg", "(Ljava/lang/String;)V");
s_jni_method_end = env->GetStaticMethodID(s_jni_class, "endEmulationActivity", "()V");
}

// Surface Handling
@@ -816,9 +814,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv*
ANativeWindow_release(s_surf);
s_surf = nullptr;
}

// Execute the Java method.
env->CallStaticVoidMethod(s_jni_class, s_jni_method_end);
}

#ifdef __cplusplus