-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nech
committed
Feb 5, 2024
1 parent
b8535d5
commit 83d2b9d
Showing
17 changed files
with
618 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
126 changes: 126 additions & 0 deletions
126
app/src/main/java/com/notation/campusnote/setting/SettingActivity.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,126 @@ | ||
package com.notation.campusnote.setting | ||
|
||
import android.content.Context | ||
import android.content.res.Resources | ||
import android.os.Build | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.MenuItem | ||
import android.view.View | ||
import android.widget.PopupMenu | ||
import com.notation.campusnote.R | ||
import com.notation.campusnote.databinding.ActivitySettingBinding | ||
import java.util.Locale | ||
|
||
|
||
class SettingActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivitySettingBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivitySettingBinding.inflate(layoutInflater) | ||
|
||
val preferences = getSharedPreferences("MyAppPreferences", Context.MODE_PRIVATE) | ||
val savedLanguage = preferences.getString("language", "ko") ?: "ko" // 기본값은 "ko" | ||
setLanguageTags(savedLanguage) | ||
|
||
binding.settingProfileNextIv.setOnClickListener { | ||
// 계정관리로 이동 | ||
} | ||
|
||
binding.settingAutoRecodeOffIv.setOnClickListener { | ||
binding.settingAutoRecodeOffIv.visibility = View.GONE | ||
binding.settingAutoRecodeOnIv.visibility = View.VISIBLE | ||
// 녹음 설정 코드 | ||
} | ||
binding.settingAutoRecodeOnIv.setOnClickListener { | ||
binding.settingAutoRecodeOffIv.visibility = View.VISIBLE | ||
binding.settingAutoRecodeOnIv.visibility = View.GONE | ||
// 녹음 설정 코드 | ||
} | ||
binding.settingAlarmOffIv.setOnClickListener { | ||
binding.settingAlarmOffIv.visibility = View.GONE | ||
binding.settingAlarmOnIv.visibility = View.VISIBLE | ||
// 알람 설정 코드 | ||
} | ||
binding.settingAlarmOnIv.setOnClickListener { | ||
binding.settingAlarmOffIv.visibility = View.VISIBLE | ||
binding.settingAlarmOnIv.visibility = View.GONE | ||
// 알람 설정 코드 | ||
} | ||
binding.settingLanguageNextIv.setOnClickListener { | ||
Log.d("click", "Setting Language Next Clicked") | ||
showLanguageMenu(it)//언어 변경 기능 구현해보다가 막힌 상태 | ||
} | ||
binding.settingSubscribeNextIv.setOnClickListener { | ||
// 구독 설정 코드 | ||
} | ||
binding.settingDirectoryNextIv.setOnClickListener { | ||
// 녹음파일 경로 설정 코드 | ||
} | ||
binding.settingBackBtn.setOnClickListener { | ||
finish() | ||
} | ||
|
||
setContentView(binding.root) | ||
} | ||
|
||
private fun showLanguageMenu(view: View) { | ||
val popupMenu = PopupMenu(this, view) | ||
popupMenu.menuInflater.inflate(R.menu.language_menu, popupMenu.menu) | ||
|
||
popupMenu.setOnMenuItemClickListener { item: MenuItem -> | ||
when (item.itemId) { | ||
R.id.menu_korean -> { | ||
binding.settingLanguageSelectEnglishTv.visibility = View.GONE | ||
binding.settingLanguageSelectKoreanTv.visibility = View.VISIBLE | ||
setLanguageTags("ko") | ||
true | ||
} | ||
R.id.menu_english -> { | ||
binding.settingLanguageSelectKoreanTv.visibility = View.GONE | ||
binding.settingLanguageSelectEnglishTv.visibility = View.VISIBLE | ||
setLanguageTags("en") | ||
true | ||
} | ||
else -> false | ||
} | ||
} | ||
|
||
popupMenu.show() | ||
} | ||
|
||
private fun setLanguageTags(languageCode: String) { | ||
val locale = Locale(languageCode) | ||
Locale.setDefault(locale) | ||
saveLanguagePreference(languageCode) | ||
|
||
val resources: Resources = resources | ||
val configuration = resources.configuration | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | ||
configuration.setLocale(locale) | ||
} else { | ||
configuration.locale = locale | ||
} | ||
|
||
resources.updateConfiguration(configuration, resources.displayMetrics) | ||
|
||
// 액티비티를 재시작하지 않고 언어 설정을 적용합니다. | ||
// 이 부분만 수정되도록 하기 위해서 레이아웃 변경을 막습니다. | ||
binding = ActivitySettingBinding.bind(binding.root) | ||
|
||
// 여기서 필요한 언어에 따른 뷰 초기화 코드를 추가할 수 있습니다. | ||
// 예: binding.settingLanguageSelectKoreanTv.visibility = if (languageCode == "ko") View.VISIBLE else View.GONE | ||
} | ||
|
||
|
||
|
||
private fun saveLanguagePreference(languageCode: String) { | ||
val preferences = getSharedPreferences("MyAppPreferences", Context.MODE_PRIVATE) | ||
val editor = preferences.edit() | ||
editor.putString("language", languageCode) | ||
editor.apply() | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="17dp" | ||
android:height="20dp" | ||
android:viewportWidth="17" | ||
android:viewportHeight="20"> | ||
<path | ||
android:pathData="M8.935,4C9.438,4 9.92,4.2 10.275,4.555C10.63,4.91 10.83,5.392 10.83,5.895V9.684C10.83,10.187 10.63,10.669 10.275,11.024C9.92,11.379 9.438,11.579 8.935,11.579C8.433,11.579 7.951,11.379 7.595,11.024C7.24,10.669 7.04,10.187 7.04,9.684V5.895C7.04,5.392 7.24,4.91 7.595,4.555C7.951,4.2 8.433,4 8.935,4ZM13.356,9.684C13.356,11.914 11.708,13.752 9.567,14.061V16H8.304V14.061C6.163,13.752 4.514,11.914 4.514,9.684H5.777C5.777,10.522 6.11,11.325 6.702,11.917C7.294,12.509 8.098,12.842 8.935,12.842C9.773,12.842 10.576,12.509 11.168,11.917C11.76,11.325 12.093,10.522 12.093,9.684H13.356Z" | ||
android:fillColor="@color/black"/> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="125dp" | ||
android:height="180dp" | ||
android:viewportWidth="125" | ||
android:viewportHeight="180"> | ||
<path | ||
android:pathData="M125,180l-125,-0l-0,-180l125,-0z" | ||
android:strokeColor="#00000000"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:startX="62.5" | ||
android:startY="180" | ||
android:endX="62.5" | ||
android:endY="-0" | ||
android:type="linear"> | ||
<item android:offset="0" android:color="#FFB7B7B7"/> | ||
<item android:offset="1" android:color="#FFF2F2F2"/> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
<path | ||
android:pathData="m0.47,179.42c-0.58,-0.65 -0.65,-42.21 -0.08,-43.28 0.57,-1.06 3.58,-2.4 6.42,-2.86 2.26,-0.37 4.04,-1 2.82,-1 -0.23,0 -0.42,-0.24 -0.42,-0.53 0,-0.29 0.15,-0.53 0.34,-0.53 0.19,0 1.2,-0.83 2.26,-1.85 1.05,-1.02 3.15,-2.48 4.65,-3.25 1.5,-0.77 2.81,-1.62 2.92,-1.89 0.23,-0.59 6.02,-3.33 9.44,-4.47 2.33,-0.77 2.59,-0.97 4.49,-3.42 1.25,-1.6 1.94,-2.8 1.8,-3.13 -0.12,-0.29 -0.73,-2.52 -1.36,-4.94 -0.99,-3.81 -2.03,-6.9 -2.49,-7.38 -0.07,-0.08 -0.39,0.08 -0.71,0.34 -0.49,0.41 -0.64,0.39 -0.98,-0.07 -0.22,-0.3 -1.05,-0.88 -1.83,-1.28 -1.1,-0.56 -1.68,-1.22 -2.56,-2.93 -0.62,-1.21 -1.13,-2.48 -1.13,-2.81 0,-0.34 -0.22,-1.15 -0.5,-1.81 -0.27,-0.66 -0.92,-2.94 -1.44,-5.07 -1.09,-4.52 -2.12,-7.86 -3.05,-9.97 -0.46,-1.03 -0.66,-2.3 -0.66,-4.06 0.01,-2.53 0.2,-3.15 1.98,-6.4 0.7,-1.27 0.74,-2.77 0.16,-6.76 -0.25,-1.75 -0.44,-4.79 -0.4,-6.75l0.06,-3.57 -0.9,0.17c-1.06,0.2 -1.07,0.18 -0.33,-1.31 0.43,-0.86 0.65,-1.03 0.87,-0.67 0.17,0.28 0.21,-0.08 0.08,-0.86 -0.17,-1.05 -0.06,-1.51 0.5,-2.12 0.9,-0.99 1.41,-2.75 1.46,-5.08 0.02,-1.01 0.21,-2.26 0.41,-2.8 0.2,-0.53 0.27,-1.42 0.15,-1.97 -0.16,-0.71 -0.01,-1.26 0.52,-1.93 0.4,-0.51 0.73,-1.11 0.73,-1.33 0,-0.22 0.53,-1.19 1.18,-2.16 0.65,-0.97 1.31,-2.15 1.46,-2.64 0.15,-0.48 0.69,-1.28 1.2,-1.78 0.51,-0.5 1.2,-1.37 1.53,-1.95 1.89,-3.24 5.07,-6.87 8.84,-8.37 14.9,-5.94 32.51,-3.75 48.11,-0.05 1.62,0.38 2.96,1.51 4.45,2.24 0.62,0.3 1.15,0.41 1.87,0.89 0.72,0.49 1.51,0.88 1.77,0.88 1.04,0 6.38,4.23 7.26,5.75 1.56,2.71 3.4,4.6 4.26,4.38 0.42,-0.11 0.98,-0.11 1.25,-0.01 0.73,0.28 0.6,1.45 -0.19,1.7 -0.63,0.2 -0.56,0.41 0.88,2.56 0.86,1.29 1.57,2.48 1.57,2.64 0,0.16 0.42,0.96 0.94,1.78 0.52,0.82 0.98,1.84 1.03,2.26 0.17,1.53 0.58,3.16 1.27,5.06 0.78,2.14 0.97,5.47 0.34,6.1 -0.22,0.22 -0.4,1.02 -0.4,1.79 0,0.76 -0.18,1.98 -0.39,2.7 -0.32,1.08 -0.29,1.51 0.2,2.46 0.51,0.99 0.52,1.21 0.09,1.56 -0.28,0.23 -0.7,1.35 -0.94,2.49l-0.44,2.08 1.12,0.88c0.62,0.48 1.26,1.23 1.42,1.65 0.16,0.43 0.16,3.78 0,7.46 -0.33,7.56 -1.12,11.95 -2.75,15.21 -0.57,1.14 -1.14,2.5 -1.26,3.03 -0.51,2.11 -3.73,4.73 -6.81,5.54l-1.47,0.39 -0.2,3.08c-0.28,4.26 -1.71,9.94 -3.39,13.45 -1.93,4.03 -1.88,4.75 0.55,7.6 2.21,2.58 4.65,4.28 6.56,4.57 1.74,0.26 5.18,2.94 7.51,5.85 1.04,1.29 3.09,3.6 4.58,5.12 1.48,1.53 2.71,2.96 2.74,3.18 0.02,0.22 0.06,0.57 0.09,0.77 0.06,0.5 1.45,2.3 3.58,4.65l1.77,1.95 0.11,15.15c0.09,13.04 0.04,15.22 -0.42,15.67 -0.78,0.78 -123.39,0.77 -124.08,-0l-0,0z" | ||
android:fillColor="#808080"/> | ||
</vector> |
Oops, something went wrong.