mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	android: Deduplicate GetJString
This commit is contained in:
		
							parent
							
								
									bf6e4a41d7
								
							
						
					
					
						commit
						e65ca8b907
					
				
					 5 changed files with 37 additions and 22 deletions
				
			
		|  | @ -1,4 +1,6 @@ | ||||||
| add_library(citra-android SHARED | add_library(citra-android SHARED | ||||||
|  |     android_common/android_common.cpp | ||||||
|  |     android_common/android_common.h | ||||||
|     applets/mii_selector.cpp |     applets/mii_selector.cpp | ||||||
|     applets/mii_selector.h |     applets/mii_selector.h | ||||||
|     applets/swkbd.cpp |     applets/swkbd.cpp | ||||||
|  |  | ||||||
|  | @ -0,0 +1,20 @@ | ||||||
|  | // Copyright 2022 Citra Emulator Project
 | ||||||
|  | // Licensed under GPLv2 or any later version
 | ||||||
|  | // Refer to the license.txt file included.
 | ||||||
|  | 
 | ||||||
|  | #include "jni/android_common/android_common.h" | ||||||
|  | 
 | ||||||
|  | #include <string> | ||||||
|  | 
 | ||||||
|  | #include <jni.h> | ||||||
|  | 
 | ||||||
|  | std::string GetJString(JNIEnv *env, jstring jstr) { | ||||||
|  |     if (!jstr) { | ||||||
|  |         return {}; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const char *s = env->GetStringUTFChars(jstr, nullptr); | ||||||
|  |     std::string result = s; | ||||||
|  |     env->ReleaseStringUTFChars(jstr, s); | ||||||
|  |     return result; | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								src/android/app/src/main/jni/android_common/android_common.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/android/app/src/main/jni/android_common/android_common.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | ||||||
|  | // Copyright 2022 Citra Emulator Project
 | ||||||
|  | // Licensed under GPLv2 or any later version
 | ||||||
|  | // Refer to the license.txt file included.
 | ||||||
|  | 
 | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <string> | ||||||
|  | 
 | ||||||
|  | #include <jni.h> | ||||||
|  | 
 | ||||||
|  | std::string GetJString(JNIEnv* env, jstring jstr); | ||||||
|  | @ -3,22 +3,14 @@ | ||||||
| // Refer to the license.txt file included.
 | // Refer to the license.txt file included.
 | ||||||
| 
 | 
 | ||||||
| #include <map> | #include <map> | ||||||
|  | 
 | ||||||
| #include <jni.h> | #include <jni.h> | ||||||
|  | 
 | ||||||
| #include "core/core.h" | #include "core/core.h" | ||||||
|  | #include "jni/android_common/android_common.h" | ||||||
| #include "jni/applets/swkbd.h" | #include "jni/applets/swkbd.h" | ||||||
| #include "jni/id_cache.h" | #include "jni/id_cache.h" | ||||||
| 
 | 
 | ||||||
| static std::string GetJString(JNIEnv* env, jstring jstr) { |  | ||||||
|     if (!jstr) { |  | ||||||
|         return {}; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     const char* s = env->GetStringUTFChars(jstr, nullptr); |  | ||||||
|     std::string result = s; |  | ||||||
|     env->ReleaseStringUTFChars(jstr, s); |  | ||||||
|     return result; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static jclass s_software_keyboard_class; | static jclass s_software_keyboard_class; | ||||||
| static jclass s_keyboard_config_class; | static jclass s_keyboard_config_class; | ||||||
| static jclass s_keyboard_data_class; | static jclass s_keyboard_data_class; | ||||||
|  |  | ||||||
|  | @ -27,6 +27,7 @@ | ||||||
| #include "core/hle/service/nfc/nfc.h" | #include "core/hle/service/nfc/nfc.h" | ||||||
| #include "core/savestate.h" | #include "core/savestate.h" | ||||||
| #include "core/settings.h" | #include "core/settings.h" | ||||||
|  | #include "jni/android_common/android_common.h" | ||||||
| #include "jni/applets/mii_selector.h" | #include "jni/applets/mii_selector.h" | ||||||
| #include "jni/applets/swkbd.h" | #include "jni/applets/swkbd.h" | ||||||
| #include "jni/camera/ndk_camera.h" | #include "jni/camera/ndk_camera.h" | ||||||
|  | @ -58,17 +59,6 @@ std::condition_variable running_cv; | ||||||
| 
 | 
 | ||||||
| } // Anonymous namespace
 | } // Anonymous namespace
 | ||||||
| 
 | 
 | ||||||
| static std::string GetJString(JNIEnv* env, jstring jstr) { |  | ||||||
|     if (!jstr) { |  | ||||||
|         return {}; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     const char* s = env->GetStringUTFChars(jstr, nullptr); |  | ||||||
|     std::string result = s; |  | ||||||
|     env->ReleaseStringUTFChars(jstr, s); |  | ||||||
|     return result; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static bool DisplayAlertMessage(const char* caption, const char* text, bool yes_no) { | static bool DisplayAlertMessage(const char* caption, const char* text, bool yes_no) { | ||||||
|     JNIEnv* env = IDCache::GetEnvForThread(); |     JNIEnv* env = IDCache::GetEnvForThread(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue