|
|
|
@ -3,6 +3,7 @@ package net.pokeranalytics.android.ui.activity.components |
|
|
|
import android.Manifest.permission.ACCESS_FINE_LOCATION |
|
|
|
import android.Manifest.permission.ACCESS_FINE_LOCATION |
|
|
|
import android.content.pm.ActivityInfo |
|
|
|
import android.content.pm.ActivityInfo |
|
|
|
import android.content.pm.PackageManager |
|
|
|
import android.content.pm.PackageManager |
|
|
|
|
|
|
|
import android.os.Build |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.PersistableBundle |
|
|
|
import android.os.PersistableBundle |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
@ -21,6 +22,8 @@ import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.util.CrashLogging |
|
|
|
import net.pokeranalytics.android.util.CrashLogging |
|
|
|
import net.pokeranalytics.android.util.LocationManager |
|
|
|
import net.pokeranalytics.android.util.LocationManager |
|
|
|
import net.pokeranalytics.android.util.PermissionRequest |
|
|
|
import net.pokeranalytics.android.util.PermissionRequest |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.Preferences |
|
|
|
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
class RootBottomSheetViewModel: ViewModel() { |
|
|
|
class RootBottomSheetViewModel: ViewModel() { |
|
|
|
var rowRepresentable: RowRepresentable? = null |
|
|
|
var rowRepresentable: RowRepresentable? = null |
|
|
|
@ -55,12 +58,14 @@ abstract class BaseActivity : AppCompatActivity() { |
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
CrashLogging.log("$this.localClassName onCreate, savedInstanceState=$savedInstanceState") |
|
|
|
CrashLogging.log("$this.localClassName onCreate, savedInstanceState=$savedInstanceState") |
|
|
|
|
|
|
|
setLanguage() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { |
|
|
|
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { |
|
|
|
super.onCreate(savedInstanceState, persistentState) |
|
|
|
super.onCreate(savedInstanceState, persistentState) |
|
|
|
CrashLogging.log("$this.localClassName onCreate: bundle=$savedInstanceState, persistentState=$persistentState") |
|
|
|
CrashLogging.log("$this.localClassName onCreate: bundle=$savedInstanceState, persistentState=$persistentState") |
|
|
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT // fixes crash |
|
|
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT // fixes crash |
|
|
|
|
|
|
|
setLanguage() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
override fun onResume() { |
|
|
|
@ -129,6 +134,26 @@ abstract class BaseActivity : AppCompatActivity() { |
|
|
|
fragmentTransaction.commit() |
|
|
|
fragmentTransaction.commit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setLanguage() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Preferences.getLanguageCode(this)?.let { languageCode -> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val config = resources.configuration |
|
|
|
|
|
|
|
// val lang = "de" // your language code |
|
|
|
|
|
|
|
val locale = Locale(languageCode) |
|
|
|
|
|
|
|
Locale.setDefault(locale) |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { |
|
|
|
|
|
|
|
config.setLocale(locale) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
config.locale = locale |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) |
|
|
|
|
|
|
|
createConfigurationContext(config) |
|
|
|
|
|
|
|
resources.updateConfiguration(config, resources.displayMetrics) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the realm instance |
|
|
|
* Return the realm instance |
|
|
|
|