Skip to content

Commit

Permalink
Merge pull request #272 from tukcomCD2024/Android_Qdesign
Browse files Browse the repository at this point in the history
Android qdesign
  • Loading branch information
Chan3711 authored Sep 19, 2024
2 parents ac3180e + 35eb646 commit 5544a3c
Show file tree
Hide file tree
Showing 25 changed files with 550 additions and 379 deletions.
59 changes: 0 additions & 59 deletions android/app/src/main/java/com/coop/sharenote/AlertFragment.kt

This file was deleted.

5 changes: 1 addition & 4 deletions android/app/src/main/java/com/coop/sharenote/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ class MainActivity : AppCompatActivity() {
.commit()
true
}
R.id.fragment_alert -> {
// AlertFragment로 이동하는 코드 작성
true
}

R.id.fragment_settings -> {
supportFragmentManager.beginTransaction()
.replace(R.id.main_container, SettingsFragment())
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/java/com/coop/sharenote/NoteActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ class NoteActivity : AppCompatActivity(), PageListAdapter.OnPageClickListener, P
val layoutParams = WindowManager.LayoutParams()
layoutParams.copyFrom(dialog.window?.attributes)
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT
layoutParams.height = 1200
layoutParams.gravity = Gravity.BOTTOM
dialog.window?.attributes = layoutParams

// 리사이클러뷰 설정
Expand Down
9 changes: 5 additions & 4 deletions android/app/src/main/java/com/coop/sharenote/QuizAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@ class QuizAdapter(private val quizList: MutableList<QuizList>, private val liste
override fun onBindViewHolder(holder: QuizViewHolder, position: Int) {
val quiz = quizList[position]
holder.quizTitleTextView.text = quiz.quizTitle
holder.nicknameTextView.text = quiz.nickname
holder.nicknameTextView.text = "출제자 : ${quiz.nickname}"


// correct 값을 기반으로 배경색 변경
when (quiz.correct) {
1 -> {
holder.itemView.setBackgroundResource(R.color.lightblue)
holder.itemView.setBackgroundResource(R.drawable.correct)
holder.newImageView.visibility = View.GONE
}
0 -> {
holder.itemView.setBackgroundResource(R.color.lightcoral)
holder.itemView.setBackgroundResource(R.drawable.incorrect)
holder.newImageView.visibility = View.GONE
}
else -> {
holder.itemView.setBackgroundResource(android.R.color.transparent)
holder.itemView.setBackgroundResource(R.drawable.unsolved)
holder.newImageView.visibility = View.VISIBLE
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import java.util.concurrent.TimeUnit

object RetrofitClient {

//private const val BASE_URL = "http://10.0.2.2:8080/api/" // 엔드포인트 주소 외에는 baseUrl에 포함되어야 함
private const val BASE_URL = "http://10.0.2.2:8080/api/" // 엔드포인트 주소 외에는 baseUrl에 포함되어야 함
private const val AI_BASE_URL = "https://autodraw.shop/" // AI 서버 주소
private const val BASE_URL = "https://sharenote.shop/api/" // 배포용
//private const val BASE_URL = "https://sharenote.shop/api/" // 배포용
private val retrofit: Retrofit by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.coop.sharenote

import SearchNoteListAdapter
import SearchNoteListAdapter_f
import android.content.Intent
import android.os.Bundle
import android.text.Editable
Expand All @@ -20,7 +21,7 @@ import kotlinx.coroutines.withContext
class SearchFragment : Fragment() {
private lateinit var searchEditText: EditText
private lateinit var searchResultRecyclerView: RecyclerView
private lateinit var noteListAdapter: SearchNoteListAdapter
private lateinit var noteListAdapter: SearchNoteListAdapter_f
private var noteList: MutableList<Note> = mutableListOf()

override fun onCreateView(
Expand All @@ -36,7 +37,7 @@ class SearchFragment : Fragment() {
searchResultRecyclerView = view.findViewById(R.id.searchResultRecyclerView)

searchResultRecyclerView.layoutManager = LinearLayoutManager(context)
noteListAdapter = SearchNoteListAdapter { noteId ->
noteListAdapter = SearchNoteListAdapter_f { noteId ->
saveRecentNoteId(noteId) // 클릭된 노트의 ID를 저장합니다.
val intent = Intent(requireContext(), NoteActivity::class.java)
startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.coop.sharenote.Note
import com.coop.sharenote.R

class SearchNoteListAdapter_f(private val onItemClick: (String) -> Unit) :
RecyclerView.Adapter<SearchNoteListAdapter_f.NoteViewHolder>() {

private val noteList = mutableListOf<Note>()
private var filteredNoteList = mutableListOf<Note>()

init {
filteredNoteList.addAll(noteList)
}

inner class NoteViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener {
init {
itemView.setOnClickListener(this)
}

override fun onClick(v: View?) {
val position = adapterPosition
if (position != RecyclerView.NO_POSITION) {
val clickedNoteId = filteredNoteList[position].Id
onItemClick(clickedNoteId)
}
}

val titleTextView: TextView = itemView.findViewById(R.id.titleTextView)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NoteViewHolder {
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.item_search_note_f, parent, false)
return NoteViewHolder(itemView)
}

override fun onBindViewHolder(holder: NoteViewHolder, position: Int) {
val currentItem = filteredNoteList[position]
// 아이템의 제목 설정
holder.titleTextView.text = currentItem.title
}

override fun getItemCount() = filteredNoteList.size

fun setNotes(notes: List<Note>) {
noteList.clear()
noteList.addAll(notes)
filter("")
}

fun filter(query: String) {
filteredNoteList.clear()
if (query.isEmpty()) {
filteredNoteList.addAll(noteList)
} else {
filteredNoteList.addAll(noteList.filter { it.title.contains(query, ignoreCase = true) })
}
notifyDataSetChanged()
}
}
11 changes: 3 additions & 8 deletions android/app/src/main/java/com/coop/sharenote/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SettingsFragment : Fragment() {
binding.switch2.isChecked = sharedPreferences.getBoolean("switch2", false)
binding.switch3.isChecked = sharedPreferences.getBoolean("switch3", false)
binding.switch4.isChecked = sharedPreferences.getBoolean("switch4", false)
binding.switch5.isChecked = sharedPreferences.getBoolean("switch5", false)


// Switches
binding.switch1.setOnCheckedChangeListener { _, isChecked ->
Expand All @@ -57,15 +57,10 @@ class SettingsFragment : Fragment() {
sharedPreferences.edit().putBoolean("switch4", isChecked).apply()
}

binding.switch5.setOnCheckedChangeListener { _, isChecked ->
// Save switch state to SharedPreferences
sharedPreferences.edit().putBoolean("switch5", isChecked).apply()
}


binding.button2.setOnClickListener {
/*binding.button2.setOnClickListener {
goToMyPageActivity()
}
}*/

}

Expand Down
11 changes: 11 additions & 0 deletions android/app/src/main/res/drawable/correct.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#CCE1FF"/>
<corners
android:bottomLeftRadius="12dp"
android:bottomRightRadius="12dp"
android:topLeftRadius="12dp"
android:topRightRadius="12dp" />

</shape>
11 changes: 11 additions & 0 deletions android/app/src/main/res/drawable/incorrect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#F08080"/>
<corners
android:bottomLeftRadius="12dp"
android:bottomRightRadius="12dp"
android:topLeftRadius="12dp"
android:topRightRadius="12dp" />

</shape>
11 changes: 11 additions & 0 deletions android/app/src/main/res/drawable/unsolved.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white"/>
<corners
android:bottomLeftRadius="12dp"
android:bottomRightRadius="12dp"
android:topLeftRadius="12dp"
android:topRightRadius="12dp" />

</shape>
Loading

0 comments on commit 5544a3c

Please sign in to comment.