Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve getCurrentLanguage to android #1784

Merged
merged 2 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cocos/platform/android/CCApplication-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ void Application::setPreferredFramesPerSecond(int fps)

std::string Application::getCurrentLanguageCode() const
{
std::string language = getCurrentLanguageJNI();
return language;
return getCurrentLanguageCodeJNI();
}

bool Application::isDisplayStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ public static String getWritablePath() {
public static String getCurrentLanguage() {
return Locale.getDefault().getLanguage();
}


public static String getCurrentLanguageCode() {
return Locale.getDefault().toString();
}

public static String getDeviceModel(){
return Build.MODEL;
}
Expand Down
5 changes: 5 additions & 0 deletions cocos/platform/android/jni/JniImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,11 @@ std::string getCurrentLanguageJNI()
return JniHelper::callStaticStringMethod(JCLS_HELPER, "getCurrentLanguage");
}

std::string getCurrentLanguageCodeJNI()
{
return JniHelper::callStaticStringMethod(JCLS_HELPER, "getCurrentLanguageCode");
}

std::string getSystemVersionJNI()
{
return JniHelper::callStaticStringMethod(JCLS_HELPER, "getSystemVersion");
Expand Down
1 change: 1 addition & 0 deletions cocos/platform/android/jni/JniImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern int getDeviceSampleRateJNI();
extern int getDeviceAudioBufferSizeInFramesJNI();

extern std::string getCurrentLanguageJNI();
extern std::string getCurrentLanguageCodeJNI();
extern std::string getSystemVersionJNI();
extern bool openURLJNI(const std::string& url);
extern void copyTextToClipboardJNI(const std::string& text);
Expand Down