mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Don't show "Error" when a blank string is returned from a native method.
This commit is contained in:
@ -15,6 +15,10 @@ import org.dolphinemu.dolphinemu.BuildConfig;
|
|||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.adapters.FileAdapter;
|
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 class AddDirectoryActivity extends Activity implements FileAdapter.FileClickListener
|
||||||
{
|
{
|
||||||
public static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path";
|
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);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState)
|
protected void onSaveInstanceState(Bundle outState)
|
||||||
{
|
{
|
||||||
@ -83,6 +88,9 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl
|
|||||||
outState.putString(KEY_CURRENT_PATH, mAdapter.getPath());
|
outState.putString(KEY_CURRENT_PATH, mAdapter.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the GameGridActivity that launched this Activity that the user picked a folder.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void finishSuccessfully()
|
public void finishSuccessfully()
|
||||||
{
|
{
|
||||||
|
@ -3,16 +3,11 @@ package org.dolphinemu.dolphinemu.activities;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.DocumentsContract;
|
|
||||||
import android.provider.OpenableColumns;
|
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -32,6 +27,10 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
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
|
public final class GameGridActivity extends Activity
|
||||||
{
|
{
|
||||||
private static final int REQUEST_ADD_DIRECTORY = 1;
|
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
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent result)
|
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)
|
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)
|
if (requestCode == REQUEST_ADD_DIRECTORY)
|
||||||
{
|
{
|
||||||
String path = result.getStringExtra(AddDirectoryActivity.KEY_CURRENT_PATH);
|
String path = result.getStringExtra(AddDirectoryActivity.KEY_CURRENT_PATH);
|
||||||
|
|
||||||
|
// Store this path as a preference.
|
||||||
|
// TODO Use SQLite instead.
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
|
||||||
editor.putString(AddDirectoryActivity.KEY_CURRENT_PATH, path);
|
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();
|
editor.commit();
|
||||||
|
|
||||||
mAdapter.setGameList(getGameList());
|
mAdapter.setGameList(getGameList());
|
||||||
|
@ -219,7 +219,7 @@ static std::string GetTitle(std::string filename)
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string ("Error");
|
return std::string ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetDescription(std::string filename)
|
static std::string GetDescription(std::string filename)
|
||||||
@ -256,7 +256,7 @@ static std::string GetDescription(std::string filename)
|
|||||||
return descriptions.cbegin()->second;
|
return descriptions.cbegin()->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string ("Error");
|
return std::string ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetGameId(std::string filename)
|
static std::string GetGameId(std::string filename)
|
||||||
@ -271,7 +271,7 @@ static std::string GetGameId(std::string filename)
|
|||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
return std::string ("Error");
|
return std::string ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetApploaderDate(std::string filename)
|
static std::string GetApploaderDate(std::string filename)
|
||||||
@ -286,7 +286,7 @@ static std::string GetApploaderDate(std::string filename)
|
|||||||
|
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
return std::string ("Error");
|
return std::string ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 GetFileSize(std::string filename)
|
static u64 GetFileSize(std::string filename)
|
||||||
@ -460,8 +460,7 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig
|
|||||||
|
|
||||||
return env->NewStringUTF(value.c_str());
|
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,
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue)
|
||||||
jstring jValue)
|
|
||||||
{
|
{
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
std::string file = GetJString(env, jFile);
|
std::string file = GetJString(env, jFile);
|
||||||
|
Reference in New Issue
Block a user