-
Notifications
You must be signed in to change notification settings - Fork 2
내가 찜한 메뉴 #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
내가 찜한 메뉴 #161
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
bd83a7e
내가 찜한 메뉴 내비게이션 구현
nyunn2 b4e45be
알림 받을 메뉴 레이아웃 생성
nyunn2 c377b73
내가 찜한 메뉴 api 연결 (작동 X)
nyunn2 1b7fb30
알림 받기 api 연결 (작동 확인 X)
nyunn2 70802e5
찜한 메뉴 -> 알림 메뉴 연결
nyunn2 8732763
알림 프래그먼트 UI 수정
nyunn2 4a8a532
내가 찜한 메뉴 UI 수정
nyunn2 b43cee5
알림 받을 메뉴 UI 수정
nyunn2 f57100e
스케일, 여백 조정
nyunn2 16021f5
찜한 메뉴, 알림 설정 UI 수정
nyunn2 4216873
기본 UI 구현
nyunn2 7af5350
찜한 메뉴 모달 생성
nyunn2 b6a1b42
여백 수정
nyunn2 dd55cc9
Merge branch 'develop' of https://github.com/wafflestudio/siksha-andr…
nyunn2 1dca9c6
develop 병합
nyunn2 55113e7
api 연결
nyunn2 efa2f42
ui 수정
nyunn2 a92df5f
Merge remote-tracking branch 'origin/develop' into nyunn2/favorite-menu
nyunn2 f38c544
내찜메 1차 QA
nyunn2 b845f48
알림 api 연결
nyunn2 135748c
2차 QA
nyunn2 9dc5767
푸시 알림 권한 팝업 추가, 채널 수정
nyunn2 c8ed49d
모든 메뉴 알림 api 추가
nyunn2 3272852
식당 즐겨찾기 오류 수정
nyunn2 b2971a5
버그, 푸시 아이콘 수정
nyunn2 e1e150b
토글 스위치 터치 오류 수정
nyunn2 fe2dc9b
토스트 시점, UI 변경 시점 수정
nyunn2 5a78836
conflict 해결
nyunn2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
107 changes: 107 additions & 0 deletions
107
app/src/main/java/com/wafflestudio/siksha2/components/ToggleSwitchView.kt
This file contains hidden or 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,107 @@ | ||
| package com.wafflestudio.siksha2.components | ||
|
|
||
| import android.content.Context | ||
| import android.graphics.Rect | ||
| import android.util.AttributeSet | ||
| import android.view.LayoutInflater | ||
| import android.view.MotionEvent | ||
| import android.view.TouchDelegate | ||
| import android.view.View | ||
| import android.view.animation.AccelerateDecelerateInterpolator | ||
| import android.widget.FrameLayout | ||
| import android.widget.ImageView | ||
| import com.wafflestudio.siksha2.R | ||
|
|
||
| class ToggleSwitchView @JvmOverloads constructor( | ||
| context: Context, | ||
| attrs: AttributeSet? = null, | ||
| defStyleAttr: Int = 0 | ||
| ) : FrameLayout(context, attrs, defStyleAttr) { | ||
|
|
||
| private val bgActive: ImageView | ||
| private val bgInactive: ImageView | ||
| private val knob: ImageView | ||
|
|
||
| var isActive = false | ||
| private set | ||
|
|
||
| init { | ||
| LayoutInflater.from(context).inflate(R.layout.item_toggle_switch, this, true) | ||
| bgActive = findViewById(R.id.bg_active) | ||
| bgInactive = findViewById(R.id.bg_inactive) | ||
| knob = findViewById(R.id.toggle_knob) | ||
| descendantFocusability = FOCUS_BLOCK_DESCENDANTS | ||
|
|
||
| post { | ||
| val minTouchSize = (48 * resources.displayMetrics.density).toInt() | ||
| val parent = this.parent as? View ?: return@post | ||
| parent.post { | ||
| val rect = Rect() | ||
| getHitRect(rect) | ||
| val widthDiff = (minTouchSize - rect.width()).coerceAtLeast(0) / 2 | ||
| val heightDiff = (minTouchSize - rect.height()).coerceAtLeast(0) / 2 | ||
| rect.inset(-widthDiff, -heightDiff) | ||
| parent.touchDelegate = TouchDelegate(rect, this) | ||
| } | ||
| } | ||
|
|
||
| isClickable = true | ||
| isFocusable = true | ||
| setOnClickListener { toggle() } | ||
| updateAppearance(animated = false) | ||
| } | ||
|
|
||
| fun toggle() { | ||
| isActive = !isActive | ||
| updateAppearance(animated = true) | ||
| } | ||
|
|
||
| fun setActive(active: Boolean, animated: Boolean = false) { | ||
| if (isActive != active) { | ||
| isActive = active | ||
| updateAppearance(animated) | ||
| } | ||
| } | ||
|
|
||
| private fun updateAppearance(animated: Boolean) { | ||
| bgActive.visibility = if (isActive) VISIBLE else GONE | ||
| bgInactive.visibility = if (isActive) GONE else VISIBLE | ||
|
|
||
| post { | ||
| val knobMarginPx = 2f.dp | ||
|
|
||
| val maxTravel = (width - knob.width - knobMarginPx * 2) | ||
|
|
||
| val targetX = if (isActive) { | ||
| knobMarginPx + maxTravel | ||
| } else { | ||
| knobMarginPx | ||
| } | ||
|
|
||
| if (animated) { | ||
| knob.animate() | ||
| .x(targetX) | ||
| .setInterpolator(AccelerateDecelerateInterpolator()) | ||
| .setDuration(150) | ||
| .start() | ||
| } else { | ||
| knob.x = targetX | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private val Float.dp: Float | ||
| get() = this * resources.displayMetrics.density | ||
|
|
||
| override fun onTouchEvent(event: MotionEvent): Boolean { | ||
| return super.onTouchEvent(event) | ||
| } | ||
|
|
||
| override fun dispatchTouchEvent(ev: MotionEvent): Boolean { | ||
| return super.dispatchTouchEvent(ev) | ||
| } | ||
|
|
||
| override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { | ||
| return true | ||
| } | ||
| } |
This file contains hidden or 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
83 changes: 83 additions & 0 deletions
83
app/src/main/java/com/wafflestudio/siksha2/fcm/SikshaFirebaseService.kt
This file contains hidden or 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,83 @@ | ||
| package com.wafflestudio.siksha2.fcm | ||
|
|
||
| import android.graphics.Bitmap | ||
| import android.graphics.BitmapFactory | ||
| import android.graphics.Canvas | ||
| import android.graphics.Paint | ||
| import android.graphics.RectF | ||
| import android.util.Log | ||
| import androidx.core.app.NotificationCompat | ||
| import com.google.firebase.messaging.FirebaseMessagingService | ||
| import com.google.firebase.messaging.RemoteMessage | ||
| import com.wafflestudio.siksha2.R | ||
| import com.wafflestudio.siksha2.preferences.SikshaPrefObjects | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import javax.inject.Inject | ||
|
|
||
| @AndroidEntryPoint | ||
| class SikshaFirebaseService : FirebaseMessagingService() { | ||
|
|
||
| @Inject lateinit var prefs: SikshaPrefObjects | ||
|
|
||
| override fun onNewToken(token: String) { | ||
| super.onNewToken(token) | ||
| Log.d("FCM", "New FCM token generated: $token") | ||
| prefs.fcmToken.setValue(token) | ||
| } | ||
|
|
||
| override fun onMessageReceived(remoteMessage: RemoteMessage) { | ||
| Log.d("FCM", "notification=${remoteMessage.notification}") | ||
| Log.d("FCM", "data=${remoteMessage.data}") | ||
|
|
||
| val title = remoteMessage.notification?.title | ||
| ?: remoteMessage.data["title"] | ||
| ?: "식샤" | ||
|
|
||
| val body = remoteMessage.notification?.body | ||
| ?: remoteMessage.data["body"] | ||
| ?: "" | ||
|
|
||
| val notificationManager = | ||
| getSystemService(NOTIFICATION_SERVICE) as android.app.NotificationManager | ||
|
|
||
| val builder = NotificationCompat.Builder(this, "siksha_channel") | ||
| // .setSmallIcon(R.drawable.siksha_rice_bowl) | ||
| .setSmallIcon(R.drawable.ic_notification) | ||
| // .setLargeIcon(createNotificationLargeIcon()) | ||
| .setContentTitle(title) | ||
| .setContentText(body) | ||
| .setAutoCancel(true) | ||
|
|
||
| notificationManager.notify( | ||
| System.currentTimeMillis().toInt(), | ||
| builder.build() | ||
| ) | ||
| } | ||
|
|
||
| private fun createNotificationLargeIcon(): Bitmap { | ||
| val size = 39 | ||
| val radius = 8.5f | ||
|
|
||
| val bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888) | ||
| val canvas = Canvas(bitmap) | ||
|
|
||
| val paintBg = Paint().apply { | ||
| color = resources.getColor(R.color.orange_500, null) | ||
| isAntiAlias = true | ||
| } | ||
|
|
||
| val rect = RectF(0f, 0f, size.toFloat(), size.toFloat()) | ||
| canvas.drawRoundRect(rect, radius, radius, paintBg) | ||
|
|
||
| val riceBmp = BitmapFactory.decodeResource(resources, R.drawable.siksha_rice_bowl) | ||
|
|
||
| val iconSize = (size * 0.55).toInt() | ||
| val left = (size - iconSize) / 2 | ||
| val top = (size - iconSize) / 2 | ||
| val resized = Bitmap.createScaledBitmap(riceBmp, iconSize, iconSize, true) | ||
|
|
||
| canvas.drawBitmap(resized, left.toFloat(), top.toFloat(), null) | ||
|
|
||
| return bitmap | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.