Skip to content

Instantly share code, notes, and snippets.

View Oleur's full-sized avatar
👨‍💻
Doing stuff with the droid!

Julien Salvi Oleur

👨‍💻
Doing stuff with the droid!
View GitHub Profile
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine.UI;
using UnityEngine;
public class CapsuleController : MonoBehaviour {
[SerializeField] private Vector3 moveUp = new Vector3(0, 1, 0);
class UnityGameActivity : UnityPlayerActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Do something
}
}
public class UnityPlayerActivity extends Activity implements IUnityPlayerLifecycleEvents {
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
protected String updateUnityCommandLineArguments(String cmdLine) {
return cmdLine;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
class UnityGameActivity : UnityPlayerActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mUnityPlayer += MaterialButton(this).apply {
...
text = "RANDOMIZE COLOR"
setOnClickListener {
@Oleur
Oleur / LocaleAndroid.kt
Last active December 11, 2020 17:40
Getting Locale on Android
// Default Locale of your application
val defaultLocale = Locale.getDefault()
// Locale from a given IETF BCP 47 language tag
val localeByTag = Locale.forLanguageTag("fr-CA")
val localeFrCA = Locale("fr", "CA")
// Used as the language/country neutral locale
// for the locale sensitive operations
val root = Locale.ROOT
android {
defaultConfig {
resConfigs "en", "fr", "de" // All supported languages in your app
}
}
// Default Locale of your application
val defaultLocale = Locale.getDefault()
// Current Locale of your device
val fLocale = Resources.getSystem().configuration.locales[0] // Since API 24
val fLocale = ConfigurationCompat.getLocales(Resources.getSystem().configuration)[0] // Compat method
setupWebview() // init and load webview
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val res = context.resources
val config = res.configuration
val appLanguage = languageGateWay.getAppLocale() // get app locale from pref, storage...
config.setLocale(appLanguage)
res.updateConfiguration(config, res.displayMetrics)
}
override fun attachBaseContext(newBase: Context) {
var base: Context = newBase
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val config = resources.configuration
val locales = languageGateWay.getSupportedLocales()
config.setLocales(locales)
base = createConfigurationContext(config)
}
super.attachBaseContext(base)
}
val nf = NumberFormat.getInstance(Locale.FRENCH) // 89 786,5
val ne = NumberFormat.getInstance(Locale.ENGLISH) // 89,786.5
val nc = NumberFormat.getInstance(Locale.CHINESE) // 89,786.5
val nroot = NumberFormat.getInstance(Locale.ROOT) // 89,786.5
val cfr = NumberFormat.getCurrencyInstance(Locale.FRANCE) // 67 889 786,50 €
val cen = NumberFormat.getCurrencyInstance(Locale.CANADA_FRENCH) // 67 889 786,50 $
val cde = NumberFormat.getCurrencyInstance(Locale.GERMANY) // 67.889.786,50 €
val czh = NumberFormat.getCurrencyInstance(Locale.CHINA) // ¥67,889,786.50
val croot = NumberFormat.getCurrencyInstance(Locale.ROOT) // ¤ 67,889,786.50