-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from msarac99/develop
TL-013 change language for each activity [MI, SM]
- Loading branch information
Showing
10 changed files
with
166 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 32 additions & 1 deletion
33
Tutorly/app/src/main/java/com/example/tutorly/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,59 @@ | ||
package com.example.tutorly | ||
|
||
import android.app.AlertDialog | ||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.widget.Button | ||
import androidx.appcompat.app.AppCompatActivity | ||
import kotlin.system.exitProcess | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val button: Button = findViewById(R.id.btnTownSelection) | ||
val changeLang: Button = findViewById(R.id.btn_change_lang_main_activity) | ||
|
||
button.setOnClickListener { | ||
val intent = Intent(this, TownSelection::class.java) | ||
startActivity(intent); | ||
|
||
} | ||
|
||
changeLang.setOnClickListener { | ||
val list = arrayOf("English", "Russian") | ||
val builder = AlertDialog.Builder(this@MainActivity) | ||
builder.setTitle(R.string.choose_lang) | ||
|
||
builder.setSingleChoiceItems(list, -1) { dialog, which -> | ||
if (which == 0) { | ||
Translation().changeLang("default", this) | ||
recreate() | ||
} | ||
else if (which == 1) { | ||
Translation().changeLang("kv", this) | ||
recreate() | ||
} | ||
dialog.dismiss() | ||
} | ||
builder.show() | ||
} | ||
} | ||
|
||
|
||
|
||
fun switchToFilter(view: View) { | ||
val switchIntent = Intent(this, FilterActivity::class.java).apply() { | ||
} | ||
startActivity(switchIntent) | ||
} | ||
|
||
override fun onBackPressed() { | ||
|
||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Tutorly/app/src/main/java/com/example/tutorly/Translation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.example.tutorly | ||
|
||
import android.app.Activity | ||
import android.app.AlertDialog | ||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.content.ContextCompat.startActivity | ||
import java.util.* | ||
|
||
class Translation : AppCompatActivity(){ | ||
|
||
lateinit var locale: Locale | ||
|
||
fun changeLang(localeName: String, context: Context) { | ||
locale = Locale(localeName) | ||
val res = context.resources | ||
val dm = res.displayMetrics | ||
val conf = res.configuration | ||
conf.locale = locale | ||
res.updateConfiguration(conf, dm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters