Skip to content
Snippets Groups Projects
Commit 8f6275a9 authored by John Carlson's avatar John Carlson
Browse files

Don't use any android.R.string resources so that we do not have to force the locale

parent 316d61a4
No related branches found
No related tags found
No related merge requests found
Loading
@@ -2,8 +2,6 @@ package com.commit451.gitlab
Loading
@@ -2,8 +2,6 @@ package com.commit451.gitlab
   
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import android.content.res.Resources
import android.support.annotation.VisibleForTesting
import android.support.multidex.MultiDex import android.support.multidex.MultiDex
import com.commit451.gitlab.api.GitLab import com.commit451.gitlab.api.GitLab
import com.commit451.gitlab.api.GitLabFactory import com.commit451.gitlab.api.GitLabFactory
Loading
@@ -22,12 +20,11 @@ import okhttp3.OkHttpClient
Loading
@@ -22,12 +20,11 @@ import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus
import timber.log.Timber import timber.log.Timber
import java.util.*
   
/** /**
* App for one time init things and to house singletons * App for one time init things and to house singletons
*/ */
open class App : Application() { class App : Application() {
   
companion object { companion object {
   
Loading
@@ -64,8 +61,6 @@ open class App : Application() {
Loading
@@ -64,8 +61,6 @@ open class App : Application() {
setupThreeTen() setupThreeTen()
   
Prefs.init(this) Prefs.init(this)
//So that we don't get weird half translations
forceLocale(Locale.ENGLISH)
setupCrashReporting() setupCrashReporting()
   
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Loading
@@ -109,47 +104,27 @@ open class App : Application() {
Loading
@@ -109,47 +104,27 @@ open class App : Application() {
return currentAccount return currentAccount
} }
   
@VisibleForTesting fun setupMultidex() {
protected open fun setupMultidex() {
MultiDex.install(this) MultiDex.install(this)
} }
   
@VisibleForTesting fun setupCrashReporting() {
protected open fun setupCrashReporting() {
FabricUtil.init(this) FabricUtil.init(this)
} }
   
@VisibleForTesting fun setupLeakCanary() {
protected open fun setupLeakCanary() {
LeakCanary.install(this) LeakCanary.install(this)
} }
   
@VisibleForTesting fun setupThreeTen() {
protected open fun setupThreeTen() {
AndroidThreeTen.init(this) AndroidThreeTen.init(this)
} }
   
private fun forceLocale(locale: Locale) { fun initGitLab(account: Account, clientBuilder: OkHttpClient.Builder) {
try {
Locale.setDefault(locale)
val resources = arrayOf(Resources.getSystem(), baseContext.resources)
for (res in resources) {
val configuration = res.configuration
configuration.locale = locale
res.updateConfiguration(configuration, res.displayMetrics)
}
} catch (e: Exception) {
Timber.e(e)
}
}
private fun initGitLab(account: Account, clientBuilder: OkHttpClient.Builder) {
gitLab = GitLabFactory.createGitLab(account, clientBuilder) gitLab = GitLabFactory.createGitLab(account, clientBuilder)
} }
   
private fun initPicasso(client: OkHttpClient) { fun initPicasso(client: OkHttpClient) {
picasso = PicassoFactory.createPicasso(client) picasso = PicassoFactory.createPicasso(client)
} }
} }
Loading
@@ -105,8 +105,8 @@ class AddIssueActivity : MorphActivity() {
Loading
@@ -105,8 +105,8 @@ class AddIssueActivity : MorphActivity() {
AlertDialog.Builder(this@AddIssueActivity) AlertDialog.Builder(this@AddIssueActivity)
.setTitle(R.string.remove) .setTitle(R.string.remove)
.setMessage(R.string.are_you_sure_you_want_to_remove) .setMessage(R.string.are_you_sure_you_want_to_remove)
.setPositiveButton(android.R.string.yes) { _, _ -> adapterLabels.removeLabel(label) } .setPositiveButton(R.string.yes) { _, _ -> adapterLabels.removeLabel(label) }
.setNegativeButton(android.R.string.no) { dialog, _ -> dialog.dismiss() } .setNegativeButton(R.string.no) { dialog, _ -> dialog.dismiss() }
.show() .show()
} }
}) })
Loading
@@ -273,8 +273,8 @@ class AddIssueActivity : MorphActivity() {
Loading
@@ -273,8 +273,8 @@ class AddIssueActivity : MorphActivity() {
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setTitle(R.string.discard) .setTitle(R.string.discard)
.setMessage(R.string.are_you_sure_you_want_to_discard) .setMessage(R.string.are_you_sure_you_want_to_discard)
.setPositiveButton(android.R.string.yes) { _, _ -> dismiss() } .setPositiveButton(R.string.yes) { _, _ -> dismiss() }
.setNegativeButton(android.R.string.no) { dialog, _ -> dialog.dismiss() } .setNegativeButton(R.string.no) { dialog, _ -> dialog.dismiss() }
.show() .show()
} }
   
Loading
Loading
Loading
@@ -145,7 +145,11 @@ class IssueActivity : BaseActivity() {
Loading
@@ -145,7 +145,11 @@ class IssueActivity : BaseActivity() {
   
@OnClick(R.id.fab_edit_issue) @OnClick(R.id.fab_edit_issue)
fun onEditIssueClick(fab: View) { fun onEditIssueClick(fab: View) {
Navigator.navigateToEditIssue(this@IssueActivity, fab, project!!, issue!!) val project = project
val issue = issue
if (project != null && issue != null) {
Navigator.navigateToEditIssue(this@IssueActivity, fab, project, issue)
}
} }
   
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
Loading
Loading
Loading
@@ -76,8 +76,8 @@ class ProjectFragment : ButterKnifeFragment() {
Loading
@@ -76,8 +76,8 @@ class ProjectFragment : ButterKnifeFragment() {
AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setTitle(R.string.project_fork_title) .setTitle(R.string.project_fork_title)
.setMessage(R.string.project_fork_message) .setMessage(R.string.project_fork_message)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(android.R.string.ok) { _, _ -> .setPositiveButton(R.string.ok) { _, _ ->
App.get().gitLab.forkProject(it.id) App.get().gitLab.forkProject(it.id)
.setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW)) .setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe(object : CustomSingleObserver<String>() { .subscribe(object : CustomSingleObserver<String>() {
Loading
Loading
Loading
@@ -5,6 +5,10 @@
Loading
@@ -5,6 +5,10 @@
<string name="app_name">LabCoat</string> <string name="app_name">LabCoat</string>
<string name="unknown">Unknown</string> <string name="unknown">Unknown</string>
<string name="or">or</string> <string name="or">or</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="yes">Yes</string>
<string name="no">No</string>
   
<!-- Drawer --> <!-- Drawer -->
<string name="nav_projects">Projects</string> <string name="nav_projects">Projects</string>
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment