From 7a2b4eea0a5d656433fc2989827afb307d00a8f3 Mon Sep 17 00:00:00 2001 From: xiushu <461474853@qq.com> Date: Sun, 21 Feb 2016 11:23:00 +0800 Subject: [PATCH 1/2] Add inputbox for android For inputting IP and NickName ,or something else in future on Android --- UI/GameSettingsScreen.cpp | 8 ++++++++ UI/NativeApp.cpp | 9 +++++++++ android/src/org/ppsspp/ppsspp/NativeActivity.java | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index fb586e4591..0e395b677c 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -472,6 +472,8 @@ void GameSettingsScreen::CreateViews() { #ifdef _WIN32 networkingSettings->Add(new PopupTextInputChoice(&g_Config.proAdhocServer, n->T("Change proAdhocServer Address"), "", 255, screenManager())); +#elif defined(ANDROID) + networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.proAdhocServer, sy->T("Change proAdhocServer Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeproAdhocServerAddress); #else networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.proAdhocServer, n->T("Change proAdhocServer Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeproAdhocServerAddress); #endif @@ -605,6 +607,8 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new PopupTextInputChoice(&g_Config.sNickName, sy->T("Change Nickname"), "", 32, screenManager())); #elif defined(USING_QT_UI) systemSettings->Add(new Choice(sy->T("Change Nickname")))->OnClick.Handle(this, &GameSettingsScreen::OnChangeNickname); +#elif defined(ANDROID) + systemSettings->Add(new ChoiceWithValueDisplay(&g_Config.sNickName, sy->T("Change Nickname"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeNickname); #endif #if defined(_WIN32) || (defined(USING_QT_UI) && !defined(MOBILE_DEVICE)) // Screenshot functionality is not yet available on non-Windows/non-Qt @@ -912,6 +916,8 @@ UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) { if (System_InputBoxGetString("Enter a new PSP nickname", g_Config.sNickName.c_str(), name, name_len)) { g_Config.sNickName = name; } +#elif defined(ANDROID) + System_SendMessage("inputbox", ("nickname :" + g_Config.sNickName).c_str()); #endif return UI::EVENT_DONE; } @@ -930,6 +936,8 @@ UI::EventReturn GameSettingsScreen::OnChangeproAdhocServerAddress(UI::EventParam } else screenManager()->push(new ProAdhocServerScreen); +#elif defined(ANDROID) + System_SendMessage("inputbox", ("IP :" + g_Config.proAdhocServer).c_str()); #else screenManager()->push(new ProAdhocServerScreen); #endif diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index b758914106..3cc43ad899 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -143,6 +143,7 @@ static recursive_mutex pendingMutex; static std::vector pendingMessages; static Thin3DContext *thin3d; static UIContext *uiContext; +static std::vector inputboxValue; #ifdef _WIN32 WindowsAudioBackend *winAudioBackend; @@ -736,6 +737,14 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { if (msg == "inputDeviceConnected") { KeyMap::NotifyPadConnected(value); } + if (msg == "inputbox_completed") { + SplitString(value, ':', inputboxValue); + if (inputboxValue[0] == "IP ") + g_Config.proAdhocServer = inputboxValue[1]; + if (inputboxValue[0] == "nickname ") + g_Config.sNickName = inputboxValue[1]; + inputboxValue.clear(); + } } void NativeUpdate(InputState &input) { diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 9c383fb7b5..206de462ae 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -794,7 +794,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback { } // The return value is sent elsewhere. TODO in java, in SendMessage in C++. - public void inputBox(String title, String defaultText, String defaultAction) { + public void inputBox(final String title, String defaultText, String defaultAction) { final FrameLayout fl = new FrameLayout(this); final EditText input = new EditText(this); input.setGravity(Gravity.CENTER); @@ -824,7 +824,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback { .setPositiveButton(defaultAction, new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface d, int which) { - NativeApp.sendMessage("inputbox_completed", input.getText().toString()); + NativeApp.sendMessage("inputbox_completed", title + ":" + input.getText().toString()); d.dismiss(); } }) From 80938a39ceb94ee63a9147d5cbb8aff90b84c3a2 Mon Sep 17 00:00:00 2001 From: xiushu <461474853@qq.com> Date: Sun, 21 Feb 2016 13:12:35 +0800 Subject: [PATCH 2/2] Just remove useless space and fix translations Oops --- UI/GameSettingsScreen.cpp | 6 +++--- UI/NativeApp.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0e395b677c..6afb8510d9 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -473,7 +473,7 @@ void GameSettingsScreen::CreateViews() { #ifdef _WIN32 networkingSettings->Add(new PopupTextInputChoice(&g_Config.proAdhocServer, n->T("Change proAdhocServer Address"), "", 255, screenManager())); #elif defined(ANDROID) - networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.proAdhocServer, sy->T("Change proAdhocServer Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeproAdhocServerAddress); + networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.proAdhocServer, n->T("Change proAdhocServer Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeproAdhocServerAddress); #else networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.proAdhocServer, n->T("Change proAdhocServer Address"), nullptr))->OnClick.Handle(this, &GameSettingsScreen::OnChangeproAdhocServerAddress); #endif @@ -917,7 +917,7 @@ UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) { g_Config.sNickName = name; } #elif defined(ANDROID) - System_SendMessage("inputbox", ("nickname :" + g_Config.sNickName).c_str()); + System_SendMessage("inputbox", ("nickname:" + g_Config.sNickName).c_str()); #endif return UI::EVENT_DONE; } @@ -937,7 +937,7 @@ UI::EventReturn GameSettingsScreen::OnChangeproAdhocServerAddress(UI::EventParam else screenManager()->push(new ProAdhocServerScreen); #elif defined(ANDROID) - System_SendMessage("inputbox", ("IP :" + g_Config.proAdhocServer).c_str()); + System_SendMessage("inputbox", ("IP:" + g_Config.proAdhocServer).c_str()); #else screenManager()->push(new ProAdhocServerScreen); #endif diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 3cc43ad899..461998d0ef 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -739,9 +739,9 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { } if (msg == "inputbox_completed") { SplitString(value, ':', inputboxValue); - if (inputboxValue[0] == "IP ") + if (inputboxValue[0] == "IP") g_Config.proAdhocServer = inputboxValue[1]; - if (inputboxValue[0] == "nickname ") + if (inputboxValue[0] == "nickname") g_Config.sNickName = inputboxValue[1]; inputboxValue.clear(); }