chore: 학습/단어장, 날씨 API, Wear OS 워치 연동 기능 제거
- Wear OS 워치 연동 제거: * app/build.gradle.kts: play-services-wearable 의존성 제거 * AndroidManifest.xml & workers/WatchGestureService.kt: WatchGestureService 선언 및 파일 삭제 * LauncherActivity.kt & NeoRssActivity.kt: Wearable.getMessageClient() 리스너 등록/해제 및 messageListener 제거 - 학습/단어장 제거: * home/LearningFragment.kt 삭제 및 NeoRssActivity.kt 내 btn_learn 분기 제거 - 날씨 API 및 미사용 날씨 UI 제거: * LocationUpdateService.kt: api.weatherapi.com HTTP 호출 로직 제거 (위치 기록/전송만 유지) * LunaticLauncher.kt: MyWallpaperService.weatherSummaryProvider 바인딩 제거 * SettingsActivity.kt: 주석 처리된 WeatherSettings 호출 제거 * 미사용/주석 파일 삭제: OpenWeatherGetter.kt, WeatherSettings.kt, WeatherInfoManager.kt, WeatherAdapter.kt, WeatherDressAdatper.kt, WeatherHourlyAdater.kt, WeatherExecutor.kt, WeatherClient.kt 및 미사용 DataBinding XML 3종(recommended_hourly_dress.xml, item_rec_hourly_dress.xml, item_hourly_weather.xml) - 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (15s, 133 actionable tasks)
This commit is contained in:
@@ -144,7 +144,6 @@ dependencies {
|
||||
implementation(project(":feature:feature-torrent"))
|
||||
implementation(project(":feature:feature-wallpaper"))
|
||||
implementation(project(":gdrive"))
|
||||
implementation("com.google.android.gms:play-services-wearable:19.0.0")
|
||||
val kotlinVersion: String? by extra
|
||||
val realmVersion = "2.0.0"
|
||||
implementation ("androidx.appcompat:appcompat:1.7.1")
|
||||
|
||||
@@ -228,11 +228,6 @@
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".workers.WatchGestureService"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".workers.TorrentService"
|
||||
android:enabled="true"
|
||||
|
||||
@@ -74,8 +74,6 @@ import bums.lunatic.launcher.workers.TorrentService
|
||||
import bums.lunatic.launcher.workers.UsageLogType
|
||||
import bums.lunatic.launcher.workers.UsageUpdateType
|
||||
import bums.lunatic.launcher.workers.WorkersDb
|
||||
import com.google.android.gms.wearable.MessageClient
|
||||
import com.google.android.gms.wearable.Wearable
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import io.realm.kotlin.UpdatePolicy
|
||||
import io.realm.kotlin.ext.query
|
||||
@@ -678,7 +676,6 @@ open class LauncherActivity : CommonActivity() {
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
widgetResizeOverlay?.detach()
|
||||
Wearable.getMessageClient(this).removeListener(messageListener)
|
||||
}
|
||||
// 위젯 선택기 실행
|
||||
fun selectWidget() {
|
||||
@@ -1074,32 +1071,6 @@ open class LauncherActivity : CommonActivity() {
|
||||
}
|
||||
|
||||
|
||||
private val messageListener = MessageClient.OnMessageReceivedListener { messageEvent ->
|
||||
when (messageEvent.path) {
|
||||
"/gesture/right",
|
||||
"/gesture/next" -> {
|
||||
// 시계에서 오른쪽으로 휘둘렀을 때: 예) 다음 배경화면으로 변경
|
||||
|
||||
}
|
||||
"/gesture/left",
|
||||
"/gesture/prev" -> {
|
||||
onSwipeRight()
|
||||
// 시계에서 왼쪽으로 휘둘렀을 때: 예) 앱 서랍 열기
|
||||
|
||||
// showToast("시계 제스처: 앱 서랍")
|
||||
}
|
||||
"/gesture/down" ->{
|
||||
onSwipeDown()
|
||||
}
|
||||
"/gesture/up"->{
|
||||
val intent = Intent("ACTION_NEXT_WALLPAPER").setPackage(packageName)
|
||||
sendBroadcast(intent)
|
||||
showToast("시계 제스처: 다음 배경화면")
|
||||
// showAppDrawer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O_MR1)
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
@@ -1110,7 +1081,6 @@ open class LauncherActivity : CommonActivity() {
|
||||
requestPermission()
|
||||
}
|
||||
resumeCount += 1
|
||||
Wearable.getMessageClient(this).addListener(messageListener)
|
||||
}
|
||||
|
||||
private fun openSearch() {
|
||||
|
||||
@@ -125,9 +125,6 @@ prefs:
|
||||
currentPageId = R.id.current_page
|
||||
currentChapterId = R.id.current_chapter
|
||||
}
|
||||
bums.lunatic.launcher.wall.MyWallpaperService.weatherSummaryProvider = {
|
||||
bums.lunatic.launcher.workers.LocationUpdateService.lastWeather
|
||||
}
|
||||
bums.lunatic.launcher.wall.MyWallpaperService.symbolFontResId = R.font.material_symbols
|
||||
bums.lunatic.launcher.wall.MyWallpaperService.wallpaperFontResIds = listOf(
|
||||
R.font.cafe24ohsquareair, R.font.cafe24oneprettynight, R.font.cafe24ssukssukregular,
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
package bums.lunatic.launcher.home
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.model.ExpressionItem
|
||||
import bums.lunatic.launcher.workers.WorkersDb
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.chip.ChipGroup
|
||||
import io.realm.kotlin.ext.query
|
||||
|
||||
class LearningFragment : Fragment() {
|
||||
|
||||
private lateinit var recyclerExpressions: RecyclerView
|
||||
private lateinit var layoutTopics: ViewGroup
|
||||
private lateinit var layoutLanguages: ViewGroup
|
||||
|
||||
private val adapter = ExpressionAdapter()
|
||||
private var currentTopic: String = ""
|
||||
private var currentLang: String = "EN" // 기본 영어
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val view = inflater.inflate(R.layout.fragment_learning, container, false)
|
||||
|
||||
recyclerExpressions = view.findViewById(R.id.recycler_expressions)
|
||||
layoutTopics = view.findViewById(R.id.layout_topics)
|
||||
layoutLanguages = view.findViewById(R.id.layout_languages)
|
||||
|
||||
recyclerExpressions.layoutManager = LinearLayoutManager(requireContext())
|
||||
recyclerExpressions.adapter = adapter
|
||||
|
||||
setupFilters()
|
||||
loadExpressions()
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
private fun setupFilters() {
|
||||
val realm = WorkersDb.getRealm()
|
||||
|
||||
// 1. 언어 필터 세팅
|
||||
val langs = listOf(
|
||||
"EN" to "영어",
|
||||
"ES" to "스페인어",
|
||||
"JA" to "일본어",
|
||||
"ZH" to "중국어" // 추가된 부분!
|
||||
)
|
||||
layoutLanguages.removeAllViews()
|
||||
langs.forEach { (code, name) ->
|
||||
val btn = Button(requireContext()).apply {
|
||||
text = name
|
||||
setBackgroundColor(if (currentLang == code) Color.DKGRAY else Color.TRANSPARENT)
|
||||
setTextColor(if (currentLang == code) Color.WHITE else Color.LTGRAY)
|
||||
setOnClickListener {
|
||||
currentLang = code
|
||||
setupFilters() // 색상 갱신을 위해 재호출
|
||||
loadExpressions()
|
||||
}
|
||||
}
|
||||
layoutLanguages.addView(btn)
|
||||
}
|
||||
|
||||
// 2. 주제(Topic) 필터 세팅 (DB에서 고유값 가져오기)
|
||||
// 참고: Realm Kotlin은 distinct를 바로 지원하진 않으므로 전체를 가져와서 Set으로 필터링합니다.
|
||||
val allItems = realm.query<ExpressionItem>().find()
|
||||
val topics = allItems.map { it.topic }.distinct()
|
||||
|
||||
layoutTopics.removeAllViews()
|
||||
|
||||
// '전체' 보기 버튼
|
||||
val allBtn = Button(requireContext()).apply {
|
||||
text = "전체"
|
||||
setBackgroundColor(if (currentTopic.isEmpty()) Color.DKGRAY else Color.TRANSPARENT)
|
||||
setTextColor(if (currentTopic.isEmpty()) Color.WHITE else Color.LTGRAY)
|
||||
setOnClickListener {
|
||||
currentTopic = ""
|
||||
setupFilters()
|
||||
loadExpressions()
|
||||
}
|
||||
}
|
||||
layoutTopics.addView(allBtn)
|
||||
|
||||
topics.forEach { topic ->
|
||||
val btn = Button(requireContext()).apply {
|
||||
text = topic
|
||||
setBackgroundColor(if (currentTopic == topic) Color.DKGRAY else Color.TRANSPARENT)
|
||||
setTextColor(if (currentTopic == topic) Color.WHITE else Color.LTGRAY)
|
||||
setOnClickListener {
|
||||
currentTopic = topic
|
||||
setupFilters()
|
||||
loadExpressions()
|
||||
}
|
||||
}
|
||||
layoutTopics.addView(btn)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadExpressions() {
|
||||
val realm = WorkersDb.getRealm()
|
||||
|
||||
var query = realm.query<ExpressionItem>("lang == $0", currentLang)
|
||||
if (currentTopic.isNotEmpty()) {
|
||||
query = query.query("topic == $0", currentTopic)
|
||||
}
|
||||
|
||||
// 최신순으로 정렬
|
||||
val results = query.sort("timestamp", io.realm.kotlin.query.Sort.DESCENDING).find()
|
||||
adapter.submitList(results.toList())
|
||||
}
|
||||
|
||||
// --- 내부 RecyclerView 어댑터 ---
|
||||
inner class ExpressionAdapter : RecyclerView.Adapter<ExpressionAdapter.ViewHolder>() {
|
||||
private var items: List<ExpressionItem> = emptyList()
|
||||
|
||||
fun submitList(newItems: List<ExpressionItem>) {
|
||||
items = newItems
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
// 1. 전체 카드 컨테이너
|
||||
val view = LinearLayout(parent.context).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setPadding(40, 40, 40, 40)
|
||||
layoutParams = ViewGroup.MarginLayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply { setMargins(0, 0, 0, 24) }
|
||||
// 모서리가 둥근 반투명 배경 효과 (간단히 Color 설정)
|
||||
setBackgroundColor(Color.parseColor("#22FFFFFF"))
|
||||
}
|
||||
|
||||
// 2. 문장 텍스트
|
||||
val mainText = TextView(parent.context).apply {
|
||||
textSize = 22f
|
||||
setTextColor(Color.WHITE)
|
||||
setTypeface(null, android.graphics.Typeface.BOLD)
|
||||
}
|
||||
|
||||
// 3. 발음 텍스트
|
||||
val pronText = TextView(parent.context).apply {
|
||||
textSize = 15f
|
||||
setTextColor(Color.parseColor("#80DEEA")) // Cyan 계열
|
||||
setPadding(0, 12, 0, 0)
|
||||
}
|
||||
|
||||
// 4. 뜻 텍스트
|
||||
val subText = TextView(parent.context).apply {
|
||||
textSize = 14f
|
||||
setTextColor(Color.LTGRAY)
|
||||
setPadding(0, 8, 0, 24)
|
||||
}
|
||||
|
||||
// 💡 5. 단어들을 담을 ChipGroup (자동 줄바꿈 지원)
|
||||
val chipGroup = ChipGroup(parent.context).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
isSingleLine = false // 공간이 부족하면 아래로 자동 줄바꿈
|
||||
chipSpacingHorizontal = 16
|
||||
chipSpacingVertical = 16
|
||||
}
|
||||
|
||||
view.addView(mainText)
|
||||
view.addView(pronText)
|
||||
view.addView(subText)
|
||||
view.addView(chipGroup) // ChipGroup 추가
|
||||
|
||||
return ViewHolder(view, mainText, pronText, subText, chipGroup)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
|
||||
// 언어별 폰트 느낌 살리기 (옵션)
|
||||
when (item.lang) {
|
||||
"ZH" -> holder.mainText.textLocale = java.util.Locale.SIMPLIFIED_CHINESE
|
||||
"JA" -> holder.mainText.textLocale = java.util.Locale.JAPAN
|
||||
else -> holder.mainText.textLocale = java.util.Locale.US
|
||||
}
|
||||
|
||||
holder.mainText.text = item.mainText
|
||||
holder.pronText.text = "[${item.pronunciation}]"
|
||||
holder.subText.text = item.subText
|
||||
|
||||
// 💡 단어 Chip 생성 로직
|
||||
holder.chipGroup.removeAllViews() // 재사용 방지를 위해 기존 칩 지우기
|
||||
|
||||
item.words.forEach { wordItem ->
|
||||
val chip = Chip(holder.itemView.context).apply {
|
||||
text = wordItem.word
|
||||
isCheckable = false
|
||||
isClickable = true
|
||||
setChipBackgroundColorResource(android.R.color.darker_gray)
|
||||
setTextColor(Color.WHITE)
|
||||
|
||||
var isShowingMeaning = false
|
||||
setOnClickListener {
|
||||
isShowingMeaning = !isShowingMeaning
|
||||
if (isShowingMeaning) {
|
||||
// 💡 터치 시: 단어 [발음] : 뜻 형태로 보여줌
|
||||
text = "${wordItem.word} [${wordItem.pronunciation}] : ${wordItem.meaning}"
|
||||
setChipBackgroundColorResource(android.R.color.holo_blue_dark)
|
||||
} else {
|
||||
// 다시 터치 시: 원단어만 보임
|
||||
text = wordItem.word
|
||||
setChipBackgroundColorResource(android.R.color.darker_gray)
|
||||
}
|
||||
}
|
||||
setOnLongClickListener {
|
||||
// 언어별 사전 URL 분기 처리
|
||||
val baseUrl = when (item.lang) {
|
||||
"EN" -> "https://en.dict.naver.com/#/search?query="
|
||||
"JA" -> "https://ja.dict.naver.com/#/search?query="
|
||||
"ZH" -> "https://zh.dict.naver.com/#/search?query="
|
||||
"ES" -> "https://dict.naver.com/eskodict/#/search?query="
|
||||
else -> "https://dict.naver.com/search.dict?dicQuery=" // 예비용 통합 검색
|
||||
}
|
||||
|
||||
val searchUrl = baseUrl + wordItem.word
|
||||
|
||||
// 브라우저 띄우기 Intent 생성
|
||||
val intent = android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(searchUrl))
|
||||
|
||||
// 혹시 액티비티 밖에서 실행될 경우를 대비한 플래그 (어댑터 안에서는 보통 필요 없지만 안전하게 추가)
|
||||
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
holder.itemView.context.startActivity(intent)
|
||||
|
||||
// true를 반환해야 일반 클릭(setOnClickListener)이 동시에 실행되지 않음
|
||||
true
|
||||
}
|
||||
}
|
||||
holder.chipGroup.addView(chip)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
inner class ViewHolder(
|
||||
view: View,
|
||||
val mainText: TextView,
|
||||
val pronText: TextView,
|
||||
val subText: TextView,
|
||||
val chipGroup: ChipGroup // ChipGroup 참조 추가
|
||||
) : RecyclerView.ViewHolder(view)
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,6 @@ import bums.lunatic.launcher.home.tokiz.TokiFragment
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.utils.beforeDay
|
||||
import bums.lunatic.launcher.workers.WorkersDb
|
||||
import com.google.android.gms.wearable.MessageClient
|
||||
import com.google.android.gms.wearable.Wearable
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import com.yausername.ffmpeg.FFmpeg
|
||||
import com.yausername.youtubedl_android.YoutubeDL
|
||||
@@ -111,69 +109,6 @@ open class NeoRssActivity : CommonActivity() {
|
||||
var lastAction = MotionEvent.ACTION_HOVER_EXIT
|
||||
|
||||
|
||||
private val messageListener = MessageClient.OnMessageReceivedListener { messageEvent ->
|
||||
val currentFragment = targetFragment ?: supportFragmentManager.fragments.find { it.isVisible }
|
||||
if (currentFragment is RemoteGestureFragment && currentFragment.isRemoteEnabled) {
|
||||
// when(keyType) {
|
||||
// "UP_ARROW"->{currentFragment.onRemoteUp(isDouble)}
|
||||
// "DOWN_ARROW"->{currentFragment.onRemoteDown(isDouble)}
|
||||
//
|
||||
// "LEFT_ARROW"->{currentFragment.onRemoteLeft(isDouble)}
|
||||
// "CENTER_SINGLE_TAP" -> { currentFragment.onRemoteCenterClick() }
|
||||
// "CENTER_DOUBLE_TAP" -> { currentFragment.onRemoteCenterDoubleClick() }
|
||||
// }
|
||||
// when(currentFragment) {
|
||||
// is RssHome ->{
|
||||
// if (currentFragment.binding.layoutRssSummary.root.isVisible) {
|
||||
// currentFragment.openGecko(rssData = currentFragment.randomOrNull())
|
||||
// } else {
|
||||
// currentFragment.doNextPage()
|
||||
// }
|
||||
// }
|
||||
// is TokiFragment -> {
|
||||
// currentFragment.back()
|
||||
// }
|
||||
// is CompletedFilesFragment -> {
|
||||
// currentFragment.backPress()
|
||||
// }
|
||||
// else -> {
|
||||
//// showContents(R.id.close)
|
||||
// }
|
||||
// }
|
||||
|
||||
when (messageEvent.path) {
|
||||
"/gesture/right",
|
||||
"/gesture/next" -> {
|
||||
when(currentFragment) {
|
||||
is RssHome ->{
|
||||
if (currentFragment.binding.layoutRssSummary.root.isVisible) {
|
||||
currentFragment.openGecko(rssData = currentFragment.randomOrNull())
|
||||
} else {
|
||||
currentFragment.doNextPage()
|
||||
}
|
||||
}
|
||||
is TokiFragment -> {
|
||||
currentFragment.back()
|
||||
}
|
||||
// is CompletedFilesFragment -> {
|
||||
// currentFragment.backPress()
|
||||
// }
|
||||
else -> {
|
||||
// showContents(R.id.close)
|
||||
}
|
||||
}
|
||||
}
|
||||
"/gesture/left",
|
||||
"/gesture/prev" -> {
|
||||
currentFragment.onRemoteLeft(false)
|
||||
}
|
||||
"/gesture/up" ->{}
|
||||
"/gesture/down" ->{}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onKeyLongPress(keyCode: Int, ev: KeyEvent?): Boolean {
|
||||
Blog.LOGE("keyEvent >>>>> ${ev?.device?.name}:${keyCode}: onKeyLongPress >>> ${ev} ")
|
||||
return super.onKeyLongPress(keyCode, ev)
|
||||
@@ -573,7 +508,6 @@ open class NeoRssActivity : CommonActivity() {
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
Wearable.getMessageClient(this).removeListener(messageListener)
|
||||
}
|
||||
|
||||
|
||||
@@ -633,8 +567,6 @@ open class NeoRssActivity : CommonActivity() {
|
||||
// R.id.btn_img1 -> TokiFragment.newInstanceArtStation()
|
||||
R.id.btn_torrent -> TorrentListFragment()
|
||||
R.id.btn_info -> SystemStatusFragment()
|
||||
|
||||
R.id.btn_learn -> LearningFragment()
|
||||
R.id.books -> {
|
||||
startActivity(Intent(this@NeoRssActivity, WebReaderActivity::class.java))
|
||||
finish()
|
||||
@@ -701,7 +633,6 @@ open class NeoRssActivity : CommonActivity() {
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Blog.LOGE("LauncherActivity onResume")
|
||||
Wearable.getMessageClient(this).addListener(messageListener)
|
||||
}
|
||||
|
||||
private fun openSearch() {
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
//package bums.lunatic.launcher.home.adapters
|
||||
//
|
||||
//import android.annotation.SuppressLint
|
||||
//import android.view.LayoutInflater
|
||||
//import android.view.View
|
||||
//import android.view.ViewGroup
|
||||
//import androidx.recyclerview.widget.LinearLayoutManager
|
||||
//import androidx.recyclerview.widget.LinearSnapHelper
|
||||
//import androidx.recyclerview.widget.RecyclerView
|
||||
//import bums.lunatic.launcher.databinding.WeatherBookBinding
|
||||
//import bums.lunatic.launcher.utils.Blog
|
||||
//
|
||||
//class WeatherAdapter(
|
||||
// private val pages: List<Int>,
|
||||
// private val adatpers: List<RecyclerView.Adapter<out RecyclerView.ViewHolder>?>,
|
||||
// private val weatherBook: WeatherBookBinding? = null)
|
||||
// : RecyclerView.Adapter<WeatherAdapter.PageViewHolder>() {
|
||||
//
|
||||
// class PageViewHolder(val view: View): RecyclerView.ViewHolder(view)
|
||||
//
|
||||
//
|
||||
// var childs : ArrayList<RecyclerView> = arrayListOf<RecyclerView>()
|
||||
//
|
||||
//
|
||||
// @SuppressLint("ResourceType")
|
||||
// override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PageViewHolder {
|
||||
//
|
||||
//
|
||||
// val layoutInflater = LayoutInflater.from(parent.context).inflate(pages[viewType], parent, false)
|
||||
//// var first = layoutInflater.findViewById<RecyclerView>(R.id.recycler_hourly_weather)
|
||||
//// var second = layoutInflater.findViewById<RecyclerView>(R.id.weather_dress_recycller)
|
||||
//
|
||||
// return PageViewHolder(layoutInflater)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// fun syncScroll(newPosition: Int) {
|
||||
// childs[newPosition].let {recyclerView ->
|
||||
// Blog.LOGE("recyclerView >>> ${recyclerView} 1 ")
|
||||
// if (!isSyncingScroll) {
|
||||
// isSyncingScroll = true
|
||||
// Blog.LOGE("recyclerView >>> ${recyclerView} 2 ")
|
||||
// childs.forEach { c ->
|
||||
//// val visibleItemCount = (layoutManager?.findLastVisibleItemPosition() ?: 0) - (layoutManager?.findFirstVisibleItemPosition() ?: 0)
|
||||
// if (c != recyclerView) {
|
||||
// (c.layoutManager as LinearLayoutManager)?.let {
|
||||
// it.findFirstVisibleItemPosition()?.let {
|
||||
// (recyclerView?.layoutManager as? LinearLayoutManager)?.let { target ->
|
||||
// target.scrollToPositionWithOffset(it, 0)
|
||||
// }
|
||||
//// .scrollToPosition(it)
|
||||
// }
|
||||
// }
|
||||
// Blog.LOGE("recyclerView >>> ${recyclerView} 3 ")
|
||||
// }
|
||||
// }
|
||||
// isSyncingScroll = false
|
||||
// Blog.LOGE("recyclerView >>> ${recyclerView} 4 ")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// val mOnScrollListener = object : RecyclerView.OnScrollListener() {
|
||||
// override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
// super.onScrollStateChanged(recyclerView, newState)
|
||||
//// recyclerView.postDelayed({syncScroll(recyclerView)},10L)
|
||||
//// recyclerView.post{syncScroll(recyclerView)}
|
||||
// }
|
||||
//
|
||||
// override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
// super.onScrolled(recyclerView, dx, dy)
|
||||
// }
|
||||
// }
|
||||
// var isSyncingScroll = false
|
||||
// override fun onBindViewHolder(holder: PageViewHolder, position: Int) {
|
||||
// if (adatpers[position] != null) {
|
||||
// (holder.view as RecyclerView).apply {
|
||||
// this.adapter = adatpers[position]
|
||||
// this.layoutManager = LinearLayoutManager(this.context, LinearLayoutManager.HORIZONTAL, false)
|
||||
// if (!childs.contains(this)) {
|
||||
// childs.add(this)
|
||||
// this.addOnScrollListener(mOnScrollListener)
|
||||
// LinearSnapHelper().attachToRecyclerView(this)
|
||||
// }
|
||||
// }
|
||||
//// when (position) {
|
||||
//// 0 -> holder.view.findViewById<RecyclerView>(R.id.recycler_hourly_weather).apply {
|
||||
//// this.adapter = adatpers[position]
|
||||
//// this.layoutManager =
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// else -> holder.view.findViewById<RecyclerView>(R.id.weather_dress_recycller).apply {
|
||||
//// this.adapter = adatpers[position]
|
||||
//// this.layoutManager =
|
||||
//// LinearLayoutManager(this.context, LinearLayoutManager.HORIZONTAL, false)
|
||||
//// }
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun getItemCount(): Int = pages.size
|
||||
//
|
||||
// override fun getItemViewType(position: Int): Int = position
|
||||
//}
|
||||
@@ -1,71 +0,0 @@
|
||||
//package bums.lunatic.launcher.home.adapters
|
||||
//
|
||||
//import android.annotation.SuppressLint
|
||||
//import android.graphics.Color
|
||||
//import android.view.LayoutInflater
|
||||
//import android.view.View
|
||||
//import android.view.ViewGroup
|
||||
//import androidx.recyclerview.widget.RecyclerView
|
||||
//import bums.lunatic.launcher.databinding.ItemRecHourlyDressBinding
|
||||
//import bums.lunatic.launcher.model.Hour
|
||||
//import bums.lunatic.launcher.model.WeatherInfoManager
|
||||
//import java.util.Calendar
|
||||
//
|
||||
//class WeatherDressAdatper (private val dataSet: ArrayList<Hour>) : RecyclerView.Adapter<WeatherDressAdatper.ViewHolder>(){
|
||||
// var isChangedAmOrPm: Boolean = true
|
||||
//
|
||||
// class ViewHolder(val viewItem: ItemRecHourlyDressBinding): RecyclerView.ViewHolder(viewItem.root)
|
||||
//
|
||||
// // @SuppressLint("NotifyDataSetChanged")
|
||||
// fun update(li: Collection<Hour>) {
|
||||
// li.toList()
|
||||
// this.dataSet.clear()
|
||||
// this.dataSet.addAll(li)
|
||||
//// notifyDataSetChanged()
|
||||
// }
|
||||
//
|
||||
// override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WeatherDressAdatper.ViewHolder {
|
||||
//// val view = LayoutInflater.from(parent.context)
|
||||
//// .inflate(R.layout.item_rec_hourly_dress, parent, false)
|
||||
//// val itemBinding: ItemRecHourlyDressBinding = DataBindingUtil.
|
||||
// val binding = ItemRecHourlyDressBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
// return WeatherDressAdatper.ViewHolder(binding)
|
||||
// }
|
||||
//
|
||||
// fun getToday() = Calendar.getInstance().get(Calendar.DAY_OF_YEAR)
|
||||
//
|
||||
// @SuppressLint("SetTextI18n")
|
||||
// override fun onBindViewHolder(holder: WeatherDressAdatper.ViewHolder, position: Int) {
|
||||
// val data = dataSet[position] as? Hour
|
||||
//// BLog.LOGE("saved weatherForcast >>> asFlow ${dataSet.size}")
|
||||
//// val today = Calendar.getInstance()
|
||||
//// today.time = Date(data?.time_epoch?.toLong()?.times(1000L) ?: 0L)
|
||||
//// val dayOfItem = today.get(Calendar.DAY_OF_YEAR)
|
||||
// data?.let {
|
||||
//// total.loc = WorkersDb.getRealm().query<Location>().also {
|
||||
//// BLog.LOGE("re >>> ${it.description()}") // 쿼리 로그
|
||||
//// }.find().first()
|
||||
// WeatherInfoManager.getShowingInfo(it).apply {
|
||||
//// total.setInfo(this)
|
||||
// holder.viewItem.setInfo(this)
|
||||
// }
|
||||
//// BLog.LOGE("reeeeeeeeeee >>> ${holder.viewItem.hour.text}")
|
||||
// holder.viewItem.amOrPm.visibility =
|
||||
// if (arrayListOf(12, 0).contains(WeatherInfoManager.toZonedDateTime(it.time_epoch).hour) || position == 0) {
|
||||
// View.VISIBLE
|
||||
// } else View.INVISIBLE
|
||||
// holder.viewItem.hour.apply {
|
||||
// if (WeatherInfoManager.toZonedDateTime(it.time_epoch).hour == 0) {
|
||||
// this@apply.setTextColor(Color.BLACK)
|
||||
// this@apply.isSelected = true
|
||||
// } else {
|
||||
// this@apply.setTextColor(Color.WHITE)
|
||||
// this@apply.isSelected = false
|
||||
// }
|
||||
// }
|
||||
// holder.viewItem.imgWeather.setImageLevel(it.temp_c.toInt())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun getItemCount(): Int = dataSet.size
|
||||
//}
|
||||
@@ -1,54 +0,0 @@
|
||||
//package bums.lunatic.launcher.home.adapters
|
||||
//
|
||||
//import android.graphics.Color
|
||||
//import android.view.LayoutInflater
|
||||
//import android.view.ViewGroup
|
||||
//import androidx.recyclerview.widget.RecyclerView
|
||||
//import bums.lunatic.launcher.databinding.ItemHourlyWeatherBinding
|
||||
//import bums.lunatic.launcher.model.Hour
|
||||
//import bums.lunatic.launcher.model.WeatherInfoManager
|
||||
//import com.squareup.picasso.Picasso
|
||||
//
|
||||
//class WeatherHourlyAdapter(private val dataSet: ArrayList<Hour>): RecyclerView.Adapter<WeatherHourlyAdapter.ViewHolder>() {
|
||||
// class ViewHolder(val viewItem: ItemHourlyWeatherBinding): RecyclerView.ViewHolder(viewItem.root)
|
||||
//
|
||||
// override fun onCreateViewHolder(parent: ViewGroup, type: Int): WeatherHourlyAdapter.ViewHolder {
|
||||
// val binding = ItemHourlyWeatherBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
// return WeatherHourlyAdapter.ViewHolder(binding)
|
||||
// }
|
||||
//
|
||||
// override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
// val data = dataSet[position] as? Hour
|
||||
//// BLog.LOGE("saved weatherForcast >>> asFlow ${dataSet.size}")
|
||||
// data?.let {
|
||||
// WeatherInfoManager.getShowingInfo(it).apply {
|
||||
// holder.viewItem.setInfo(this)
|
||||
// Picasso.get()
|
||||
// .load(this.urlImgWeather)
|
||||
// .into(holder.viewItem.imgWeather)
|
||||
// }
|
||||
//// BLog.LOGE("reeeeeeeeeee >>> ${holder.viewItem.hour.text}")
|
||||
//// holder.viewItem.amOrPm.visibility =
|
||||
//// if (arrayListOf(12, 0).contains(WeatherInfoManager.toZonedDateTime(it.time_epoch).hour) || position == 0) {
|
||||
//// View.VISIBLE
|
||||
//// } else View.INVISIBLE
|
||||
// holder.viewItem.hour.apply {
|
||||
// if (WeatherInfoManager.toZonedDateTime(it.time_epoch).hour == 0) {
|
||||
// this@apply.setTextColor(Color.BLACK)
|
||||
// this@apply.isSelected = true
|
||||
// } else {
|
||||
// this@apply.setTextColor(Color.WHITE)
|
||||
// this@apply.isSelected = false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun getItemCount(): Int = dataSet.size
|
||||
//
|
||||
// fun update(li: Collection<Hour>) {
|
||||
// li.toList()
|
||||
// this.dataSet.clear()
|
||||
// this.dataSet.addAll(li)
|
||||
// }
|
||||
//}
|
||||
@@ -1,61 +0,0 @@
|
||||
///*
|
||||
// * Lunar Launcher
|
||||
// * Copyright (C) 2022 Md Rasel Hossain
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//package bums.lunatic.launcher.home.weather
|
||||
//
|
||||
//import java.io.BufferedReader
|
||||
//import java.io.InputStreamReader
|
||||
//import java.net.HttpURLConnection
|
||||
//import java.net.URL
|
||||
//
|
||||
//
|
||||
//internal class WeatherClient {
|
||||
//
|
||||
// fun fetchWeather(wUrl: String?): String? {
|
||||
// var httpURLConnection: HttpURLConnection? = null
|
||||
// var bufferedReader: BufferedReader? = null
|
||||
//
|
||||
// try {
|
||||
// httpURLConnection = URL(wUrl).openConnection() as HttpURLConnection
|
||||
// httpURLConnection.connect()
|
||||
// bufferedReader = BufferedReader(InputStreamReader(httpURLConnection.inputStream))
|
||||
//
|
||||
// val stringBuilder = StringBuilder()
|
||||
// var line: String?
|
||||
// while (bufferedReader.readLine().also { line = it } != null) {
|
||||
// stringBuilder.append("$line\n")
|
||||
// }
|
||||
//
|
||||
// if (stringBuilder.isNotEmpty()) return stringBuilder.toString()
|
||||
// } catch (exception: Exception) {
|
||||
// exception.printStackTrace()
|
||||
// } finally {
|
||||
// httpURLConnection?.disconnect()
|
||||
// if (bufferedReader != null) {
|
||||
// try {
|
||||
// bufferedReader.close()
|
||||
// } catch (exception: Exception) {
|
||||
// exception.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return null
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,97 +0,0 @@
|
||||
///*
|
||||
// * Lunar Launcher
|
||||
// * Copyright (C) 2022 Md Rasel Hossain
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//package bums.lunatic.launcher.home.weather
|
||||
//
|
||||
//import android.annotation.SuppressLint
|
||||
//import android.content.SharedPreferences
|
||||
//import android.os.Handler
|
||||
//import android.os.Looper
|
||||
//import android.view.View
|
||||
//import bums.lunatic.launcher.helpers.Constants.Companion.KEY_CITY_NAME
|
||||
//import bums.lunatic.launcher.helpers.Constants.Companion.KEY_OWM_API
|
||||
//import bums.lunatic.launcher.helpers.Constants.Companion.KEY_SHOW_CITY
|
||||
//import bums.lunatic.launcher.helpers.Constants.Companion.KEY_TEMP_UNIT
|
||||
//import bums.lunatic.launcher.helpers.UniUtils.Companion.isNetworkAvailable
|
||||
//import com.google.android.material.textview.MaterialTextView
|
||||
//import java.util.concurrent.Executors
|
||||
//
|
||||
//
|
||||
//internal class WeatherExecutor(sharedPreferences: SharedPreferences) {
|
||||
//
|
||||
// companion object {
|
||||
// var lastedCheckTime = 0L
|
||||
// var weather: Weather? = null
|
||||
// }
|
||||
//
|
||||
// private val cityName: String
|
||||
// private val owmApi: String
|
||||
// private val weatherUrl: String
|
||||
// private val tempUnit: Int
|
||||
// private val showCity: Boolean
|
||||
//
|
||||
// @SuppressLint("SetTextI18n")
|
||||
// fun generateWeatherString(materialTextView: MaterialTextView) {
|
||||
// materialTextView.visibility = View.GONE
|
||||
// /* run the executor if network is available,
|
||||
// and city name and owm api values are not empty */
|
||||
// if (System.currentTimeMillis() - lastedCheckTime > (1000 * 60 * 15) && isNetworkAvailable && cityName.isNotEmpty() && owmApi.isNotEmpty()) {
|
||||
// try {
|
||||
// Executors.newSingleThreadExecutor().execute {
|
||||
// WeatherClient().fetchWeather(weatherUrl).let {
|
||||
// if (!it.isNullOrEmpty()) weather = JsonParser().getMyWeather(it)
|
||||
// }
|
||||
//
|
||||
// Handler(Looper.getMainLooper()).post {
|
||||
// if (weather != null) {
|
||||
// materialTextView.apply {
|
||||
// visibility = View.VISIBLE
|
||||
// text = weather!!.temperature.toString().substringBefore(".") +
|
||||
// (if (tempUnit == 0) "ºC" else "ºF") +
|
||||
// (if (showCity) " at ${weather!!.cityName}" else "")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (exception: Exception) {
|
||||
// exception.printStackTrace()
|
||||
// }
|
||||
// } else {
|
||||
// Handler(Looper.getMainLooper()).post {
|
||||
// if (weather != null) {
|
||||
// materialTextView.apply {
|
||||
// visibility = View.VISIBLE
|
||||
// text = weather!!.temperature.toString().substringBefore(".") +
|
||||
// (if (tempUnit == 0) "ºC" else "ºF") +
|
||||
// (if (showCity) " at ${weather!!.cityName}" else "")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// lastedCheckTime = System.currentTimeMillis()
|
||||
// }
|
||||
//
|
||||
// init {
|
||||
// cityName = sharedPreferences.getString(KEY_CITY_NAME, "").toString()
|
||||
// owmApi = sharedPreferences.getString(KEY_OWM_API, "").toString()
|
||||
// tempUnit = sharedPreferences.getInt(KEY_TEMP_UNIT, 0)
|
||||
// showCity = sharedPreferences.getBoolean(KEY_SHOW_CITY, false)
|
||||
// weatherUrl = "https://api.openweathermap.org/data/2.5/weather?q=$cityName&APPID=$owmApi&units=" + if (tempUnit == 0) "metric" else "imperial"
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,137 +0,0 @@
|
||||
package bums.lunatic.launcher.model
|
||||
|
||||
import bums.lunatic.launcher.R
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import bums.lunatic.launcher.workers.WorkersDb
|
||||
import io.realm.kotlin.ext.query
|
||||
import io.realm.kotlin.types.RealmList
|
||||
import java.time.Instant
|
||||
import java.time.ZoneId
|
||||
import java.time.ZonedDateTime
|
||||
import java.util.Calendar
|
||||
|
||||
class ShowingWeatherInfo() {
|
||||
var textLocation: String? = null
|
||||
var amOrPm: String? = null
|
||||
var textHour: String? = null
|
||||
var dress: String? = null
|
||||
var imgDress: Int? = null
|
||||
var temp: String? = null
|
||||
var textCondition: String? = null
|
||||
var urlImgWeather: String? = null
|
||||
|
||||
fun setLocation(loc: Location?): ShowingWeatherInfo {
|
||||
textLocation = "${loc?.name ?: "도시"} / ${loc?.country ?: "나라"}"
|
||||
return this
|
||||
}
|
||||
fun setHour(hour: Hour): ShowingWeatherInfo {
|
||||
setAmOrPm(hour)
|
||||
setTextHour(hour)
|
||||
setDress(hour)
|
||||
setTemp(hour)
|
||||
setTextCondition(hour)
|
||||
setUrlImgWeather(hour)
|
||||
return this
|
||||
}
|
||||
private fun setAmOrPm(hour: Hour) = WeatherInfoManager.toZonedDateTime(hour.time_epoch).hour.run {
|
||||
amOrPm = if (this < 12) "오전" else "오후"
|
||||
}
|
||||
private fun setTextHour(hour: Hour) {
|
||||
textHour = WeatherInfoManager.toZonedDateTime(hour.time_epoch).run {
|
||||
if (this.hour == 0) {
|
||||
when (this.dayOfYear - Calendar.getInstance().get(Calendar.DAY_OF_YEAR)) {
|
||||
1 -> "내일"
|
||||
2 -> "모레"
|
||||
3 -> "글피"
|
||||
else -> "${this.dayOfMonth}일"
|
||||
}
|
||||
} else {
|
||||
"${this.hour}시"
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun setDress(hour: Hour) {
|
||||
if (hour.temp_c >= 23) {
|
||||
dress = "반팔"
|
||||
imgDress = R.drawable.dress_short_sleeves
|
||||
} else if ((23 > hour.temp_c) && (hour.temp_c >= 20)) {
|
||||
dress = "긴팔"
|
||||
imgDress = R.drawable.dress_long_sleeves
|
||||
} else if ((20 > hour.temp_c) && (hour.temp_c >= 17)) {
|
||||
dress = "니트"
|
||||
imgDress = R.drawable.dress_knitwear
|
||||
} else if ((17 > hour.temp_c) && (hour.temp_c >= 12)) {
|
||||
dress = "얇은겉옷"
|
||||
imgDress = R.drawable.dress_flimsy_outer
|
||||
} else if ((12 > hour.temp_c) && (hour.temp_c >= 6)) {
|
||||
dress = "두꺼운겉옷"
|
||||
imgDress = R.drawable.dress_heavy_outer
|
||||
} else {
|
||||
dress = "패딩"
|
||||
imgDress = R.drawable.dress_padded_coat
|
||||
}
|
||||
}
|
||||
private fun setTemp(hour: Hour) {temp = "${hour.temp_c}도"}
|
||||
|
||||
private fun setTextCondition(hour: Hour) {textCondition = hour.condition?.text}
|
||||
|
||||
private fun setUrlImgWeather(hour: Hour) {
|
||||
hour.condition?.icon?.let {
|
||||
urlImgWeather = if (!it.contains("https:")) "https:$it" else it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object WeatherInfoManager {
|
||||
var info: WeatherForcast? = null
|
||||
// var showingInfo: ShowingWeatherInfo? = null
|
||||
|
||||
|
||||
// fun setInfo(data: WeatherForcast) {
|
||||
// this.info = data
|
||||
// BLog.LOGE("Now WeatherForcast updated. info : ${this.info}")
|
||||
// }
|
||||
|
||||
fun readyForSaving(lat: Double, lon: Double) {
|
||||
this.info?.lastUpdateTime = System.currentTimeMillis()
|
||||
this.fill()
|
||||
setLatitudeAndLongitude(lat, lon)
|
||||
}
|
||||
|
||||
private fun setLatitudeAndLongitude(lat: Double, lon: Double) {
|
||||
info?.forecast?.forecastdayRealm?.forEach {
|
||||
it.hourRealm.forEach {h ->
|
||||
h.lat = lat
|
||||
h.lon = lon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun fill() {
|
||||
getForecast()?.let {
|
||||
if (it.forecastdayRealm.addAll(it.forecastday)) {
|
||||
it.forecastdayRealm.forEach { f -> f.hourRealm.addAll(f.hour) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun toZonedDateTime(timeEpoch: Int): ZonedDateTime = Instant.ofEpochSecond(timeEpoch.toLong())
|
||||
.atZone(ZoneId.systemDefault())
|
||||
|
||||
fun getShowingInfo(hour: Hour): ShowingWeatherInfo = ShowingWeatherInfo().setLocation(getLocation()).setHour(hour)
|
||||
|
||||
|
||||
private fun getLocation(): Location? {
|
||||
return if (info?.location == null) {
|
||||
WorkersDb.getRealm().query<Location>().also {
|
||||
Blog.LOGE("re >>> ${it.description()}") // 쿼리 로그
|
||||
}.find().first()
|
||||
} else {
|
||||
info?.location
|
||||
}
|
||||
}
|
||||
|
||||
fun getForecast(): Forecast? = info?.forecast
|
||||
fun getAllForecastDay(): RealmList<Forecastday>? = getForecast()?.forecastdayRealm
|
||||
fun getAllHour(day: Forecastday): RealmList<Hour> = day.hourRealm
|
||||
}
|
||||
@@ -131,10 +131,6 @@ internal class SettingsActivity : CommonActivity() {
|
||||
/* launch child settings dialogs on button clicks */
|
||||
// binding.timeDate.setOnClickListener {
|
||||
// TopInfos().show(supportFragmentManager, BOTTOM_SHEET_TAG)
|
||||
// }
|
||||
|
||||
// binding.weather.setOnClickListener {
|
||||
// WeatherSettings().show(supportFragmentManager, BOTTOM_SHEET_TAG)
|
||||
// }
|
||||
|
||||
binding.todo.setOnClickListener {
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Lunar Launcher
|
||||
* Copyright (C) 2022 Md Rasel Hossain
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bums.lunatic.launcher.settings.childs
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import bums.lunatic.launcher.databinding.SettingsWeatherBinding
|
||||
import bums.lunatic.launcher.helpers.PrefString
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
|
||||
internal class WeatherSettings : SettingChild() {
|
||||
|
||||
private lateinit var binding : SettingsWeatherBinding
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = SettingsWeatherBinding.inflate(inflater, container, false)
|
||||
|
||||
/* initialize views according to the saved values */
|
||||
|
||||
binding.inputOwm.setText(PrefString.weatherApiKey.get(""))
|
||||
binding.inputOwm.doOnTextChanged { text, start, before, count ->
|
||||
PrefString.weatherApiKey.set(text.toString())
|
||||
settingsChanged = true
|
||||
}
|
||||
// binding.dress.isChecked = PrefBoolean.weatherDress.get(false)
|
||||
// binding.weather.isChecked = PrefBoolean.weatherState.get(false)
|
||||
// binding.weather.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherState.set(isChecked)
|
||||
// settingsChanged = true}
|
||||
// binding.dress.setOnCheckedChangeListener { buttonView, isChecked -> PrefBoolean.weatherDress.set(isChecked)
|
||||
// settingsChanged = true}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(requireDialog() as BottomSheetDialog).dismissWithAnimation = true
|
||||
|
||||
}
|
||||
|
||||
/* save input field values while closing the dialog */
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -99,32 +99,6 @@ class LocationUpdateService : Service(), LocationListener {
|
||||
}
|
||||
|
||||
Blog.LOGE("addresses $address")
|
||||
locationScope.launch {
|
||||
kotlinx.coroutines.delay(5000L)
|
||||
try {
|
||||
val url = "https://api.weatherapi.com/v1/current.json?key=${PrefString.weatherApiKey.get()}&q=${lat},${long}&aqi=no"
|
||||
if (url.length > 10) {
|
||||
val request = Request.Builder().url(url).get().build()
|
||||
bums.lunatic.launcher.utils.NetworkClient.client.newCall(request).execute().use { response ->
|
||||
if (response.isSuccessful) {
|
||||
val result = response.body?.string()
|
||||
if (result != null) {
|
||||
val w = Gson().fromJson(result, CurrentWeather::class.java)
|
||||
w.addr = address.getAddressLine(0)
|
||||
synchronized(lastWeather) {
|
||||
lastWeather.clear()
|
||||
lastWeather.addAll(w.getSummaryInfo())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Blog.LOGE("weatherapi Error Occurred: ${response.code}")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
//package bums.lunatic.launcher.workers
|
||||
//
|
||||
//import android.content.Context
|
||||
//import androidx.work.WorkerParameters
|
||||
//import bums.lunatic.launcher.helpers.PrefString
|
||||
//import bums.lunatic.launcher.model.WeatherForcast
|
||||
//import bums.lunatic.launcher.model.WeatherInfoManager
|
||||
//import bums.lunatic.launcher.utils.Blog
|
||||
//import io.realm.kotlin.UpdatePolicy
|
||||
//import io.realm.kotlin.types.RealmObject
|
||||
//import retrofit2.Call
|
||||
//import retrofit2.Retrofit
|
||||
//import retrofit2.converter.gson.GsonConverterFactory
|
||||
//import retrofit2.create
|
||||
//import retrofit2.http.GET
|
||||
//import retrofit2.http.Path
|
||||
//import retrofit2.http.Query
|
||||
//
|
||||
//class OpenWeatherGetter(context: Context) : BaseGetter(context) {
|
||||
// companion object {
|
||||
// val TAG = "OpenWeatherGetter"
|
||||
// var lon: Double? = null // 경도
|
||||
// var lat: Double? = null // 위도
|
||||
// }
|
||||
// //////////////////////////////////////////
|
||||
// // weatherapi
|
||||
// val VER_WEATHERAPI = "v1"
|
||||
// val URI_WEATHERAPI = "https://api.weatherapi.com"
|
||||
// val KEY_WEATHERAPI = "8133d83d23ab4175a4160624241909"
|
||||
// val DAYS = 3
|
||||
// //////////////////////////////////////////
|
||||
//
|
||||
// //////////////////////////////////////////
|
||||
//
|
||||
// override fun realWork(): List<RealmObject> {
|
||||
// Blog.LOGE("${TAG} realWork()")
|
||||
// // 위치 값 가져오기
|
||||
// lat = LocationGetter.latitude
|
||||
// lon = LocationGetter.longitude
|
||||
// if (lat != null && lon != null) {
|
||||
// getWeather(lat!!, lon!!)
|
||||
// } else {
|
||||
// Blog.LOGE("lat or lon is null")
|
||||
// }
|
||||
// return Result.success()
|
||||
// }
|
||||
//
|
||||
// fun getWeather(latitude: Double, longitude: Double) {
|
||||
// Blog.LOGE("into getWeather ${PrefString.weatherApiKey.get()}")
|
||||
// ///saved weatherForcast
|
||||
// Retrofit.Builder()
|
||||
// .baseUrl(URI_WEATHERAPI)
|
||||
// .addConverterFactory(GsonConverterFactory.create())
|
||||
// .build()
|
||||
// .create<RestrofitService>()
|
||||
// .getForecast( // weatherApi
|
||||
// ver = VER_WEATHERAPI,
|
||||
// key = PrefString.weatherApiKey.get(),
|
||||
// q = "$latitude,$longitude",
|
||||
// days = (System.currentTimeMillis() % 5L).toInt().toString()
|
||||
// )?.execute()?.let { response ->
|
||||
//// BLog.LOGE("into getWeather after execute")
|
||||
//// BLog.LOGE("weatherApi forecast response >>> $response")
|
||||
// response.body()?.let { weatherInfo ->
|
||||
// WeatherInfoManager.info = weatherInfo
|
||||
// WeatherInfoManager.readyForSaving(lat ?: 0.0, lon ?: 0.0)
|
||||
// // Realm에 저장
|
||||
// WorkersDb.getRealm().writeBlocking {
|
||||
// copyToRealm(weatherInfo, UpdatePolicy.ALL).also {
|
||||
//// BLog.LOGE("saved weatherForcast >>> $it")
|
||||
// }
|
||||
// }
|
||||
//// BLog.LOGE("saved weatherForcast forecastdayRealm.size >>> ${WorkersDb.getRealm().query<WeatherForcast>().first().find()?.forecast?.forecastdayRealm?.size}")
|
||||
//// BLog.LOGE("saved weatherForcast hour.count >>> ${WorkersDb.getRealm().query<Hour>().count().find()}")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//interface RestrofitService {
|
||||
// // weather_api
|
||||
// @GET("/{ver}/forecast.json")
|
||||
// fun getForecast(
|
||||
// @Path("ver") ver: String,
|
||||
// @Query("key") key: String,
|
||||
// @Query("q") q: String,
|
||||
// @Query("days") days: String
|
||||
// ): Call<WeatherForcast?>?
|
||||
//}
|
||||
//
|
||||
@@ -1,25 +0,0 @@
|
||||
package bums.lunatic.launcher.workers
|
||||
|
||||
import bums.lunatic.launcher.utils.Blog
|
||||
import com.google.android.gms.wearable.MessageEvent
|
||||
import com.google.android.gms.wearable.WearableListenerService
|
||||
|
||||
class WatchGestureService : WearableListenerService() {
|
||||
override fun onMessageReceived(messageEvent: MessageEvent) {
|
||||
when (messageEvent.path) {
|
||||
"/gesture/next" -> {
|
||||
// 런처의 다음 페이지로 이동하거나, 이북 앱에 키 이벤트 전송
|
||||
handleGestureAction("NEXT")
|
||||
}
|
||||
"/gesture/prev" -> {
|
||||
handleGestureAction("PREV")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleGestureAction(action: String) {
|
||||
// Broadcast를 런처 메인 Activity로 쏘거나,
|
||||
// 직접 AccessibilityService를 호출하여 시스템 이벤트를 발생시킵니다.
|
||||
Blog.LOGE("WatchGesture", "Gesture Received: $action")
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
<data>
|
||||
<variable name="info" type="bums.lunatic.launcher.model.ShowingWeatherInfo"/>
|
||||
</data>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="90dp"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:padding="4dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
style="@style/small"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/amOrPm"
|
||||
android:gravity="center"
|
||||
android:text="@{info.amOrPm}"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
style="@style/small"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/hour"
|
||||
android:background="@drawable/date_bg"
|
||||
android:gravity="center"
|
||||
android:text="@{info.textHour}"
|
||||
android:textAlignment="center"/>
|
||||
<ImageView
|
||||
android:padding="8dp"
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:id="@+id/imgWeather"
|
||||
app:layout_constraintTop_toBottomOf="@id/hour"
|
||||
app:layout_constraintBottom_toTopOf="@id/textDress"
|
||||
android:layout_width="60dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/level_dress_img"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="온도별 옷차림"
|
||||
app:tint="@android:color/white"/>
|
||||
<TextView
|
||||
app:layout_constraintBottom_toTopOf="@id/temperature"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:includeFontPadding="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/textDress"
|
||||
android:maxLines="2"
|
||||
style="@style/small"
|
||||
android:text="@{info.textCondition}"
|
||||
android:gravity="center"
|
||||
android:textAlignment="center"/>
|
||||
<TextView
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
style="@style/normal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/temperature"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@{info.temp}"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:gravity="center"
|
||||
android:textAlignment="center"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
<data>
|
||||
<variable name="info" type="bums.lunatic.launcher.model.ShowingWeatherInfo"/>
|
||||
</data>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="90dp"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:padding="4dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
style="@style/small"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/amOrPm"
|
||||
android:gravity="center"
|
||||
android:text="@{info.amOrPm}"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
style="@style/small"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/hour"
|
||||
android:background="@drawable/date_bg"
|
||||
android:gravity="center"
|
||||
android:text="@{info.textHour}"
|
||||
android:textAlignment="center"/>
|
||||
<ImageView
|
||||
android:padding="12dp"
|
||||
android:layout_margin="@dimen/default_layout_margin"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:id="@+id/imgWeather"
|
||||
app:layout_constraintTop_toBottomOf="@id/hour"
|
||||
app:layout_constraintBottom_toTopOf="@id/textDress"
|
||||
android:layout_width="60dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/level_dress_img"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="온도별 옷차림"
|
||||
app:tint="@android:color/white"/>
|
||||
<TextView
|
||||
app:layout_constraintBottom_toTopOf="@id/temperature"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:includeFontPadding="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="80dp"
|
||||
android:id="@+id/textDress"
|
||||
style="@style/small"
|
||||
android:text="@{info.textCondition}"
|
||||
android:gravity="center"
|
||||
android:textAlignment="center"/>
|
||||
<TextView
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
style="@style/normal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/temperature"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@{info.temp}"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:gravity="center"
|
||||
android:textAlignment="center"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<data>
|
||||
<variable name="info" type="bums.lunatic.launcher.model.ShowingWeatherInfo"/>
|
||||
</data>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/weather_dress_recycller"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
</layout>
|
||||
Reference in New Issue
Block a user