Skip to content

Commit

Permalink
Merge branch 'develop' into feat/apple
Browse files Browse the repository at this point in the history
  • Loading branch information
dogdduddy authored Mar 17, 2023
2 parents 267d105 + 6be7657 commit aa8b52d
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 37 deletions.
58 changes: 31 additions & 27 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,37 @@ name: Android CI

on:
push:
branches: [ "master" ]
branches: [ "develop" ]
pull_request:
branches: [ "master" ]
branches: [ "develop" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build

- name: Build debug APK
run: ./gradlew assembleDebug
- name: Upload APK
uses: actions/upload-artifact@v1
with:
name: app
path: app/build/outputs/apk/debug
apk:
name: Generate APK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- name: Build debug APK
run: bash ./gradlew assembleDebug --stacktrace

- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: app
path: app/build/outputs/apk/debug

- name: Slack - Upload APK
uses: MeilCli/[email protected]
with:
slack_token: ${{ secrets.SLACK_TOKEN }}
channels: ${{ secrets.SLACK_CHANNEL }}
initial_comment: 'APK File Upload'
file_path: 'app/build/outputs/apk/debug/app-debug.apk'
file_name: 'app-debug.apk'
file_type: 'apk'
15 changes: 8 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
android:usesCleartextTraffic="true">
<activity
android:name=".view.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
android:exported="false">
</activity>
<activity
android:name=".view.WebViewActivity"
android:exported="false" />
<activity
android:name=".view.MainActivity"
android:exported="false">
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/assets/webviewexam.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
</head>
<body>
<p>
로딩이 완료된 웹뷰 입니다.
</p>

<input type="button" value="Say hello" onClick="showAndroidToast('Hello Black Jin World!')"/>
<script type="text/javascript">
function showAndroidToast(toast) {
Android.showToast(toast);
}

</script>
</body>
</html>
34 changes: 34 additions & 0 deletions app/src/main/java/com/dogdduddy/jmt/utils/extentions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.dogdduddy.jmt.utils

import android.os.Build
import android.util.DisplayMetrics
import androidx.fragment.app.Fragment

val Fragment.deviceMetrics
get() = run {

val displayMetrics = DisplayMetrics()

// target version above 30
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {

val windowManager = requireActivity().windowManager

// target version above 31
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {

val metrics = windowManager.currentWindowMetrics
metrics.bounds.also { bounds ->
displayMetrics.widthPixels = bounds.width()
displayMetrics.heightPixels = bounds.height()
}
} else {
val display = requireActivity().display
display?.getRealMetrics(displayMetrics)
}

} else {
requireActivity().windowManager.defaultDisplay?.getMetrics(displayMetrics)
}
displayMetrics
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.dogdduddy.jmt.view

import android.app.Activity
import android.util.Log
import com.dogdduddy.jmt.R
import com.google.android.gms.auth.api.identity.BeginSignInRequest
import com.google.android.gms.auth.api.identity.Identity
Expand All @@ -19,7 +18,7 @@ class GoogleLoginManager() {
BeginSignInRequest.GoogleIdTokenRequestOptions.builder()
.setSupported(true)
.setServerClientId(activity.getString(R.string.my_web_client_id))
.setFilterByAuthorizedAccounts(true)
.setFilterByAuthorizedAccounts(false)
.build())
.setAutoSelectEnabled(true)
.build()
Expand Down
76 changes: 76 additions & 0 deletions app/src/main/java/com/dogdduddy/jmt/view/JmtConfirmDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.dogdduddy.jmt.view

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.dogdduddy.jmt.R
import com.dogdduddy.jmt.databinding.JmtConfirmDialogBinding
import com.dogdduddy.jmt.utils.deviceMetrics

class JmtConfirmDialog(private val context: Context) : DialogFragment() {

private var _binding: JmtConfirmDialogBinding? = null
private val binding
get() = _binding ?: run {
_binding = LayoutInflater.from(context).let {
JmtConfirmDialogBinding.inflate(it)
}
_binding!!
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
super.onCreateView(inflater, container, savedInstanceState)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

dialog?.window?.setBackgroundDrawableResource(R.drawable.jmt_confirm_dialog_background)
isCancelable = false

binding.confirmButton.setOnClickListener {
dismiss()
}
}

override fun onResume() {
super.onResume()

val displayMetrics = deviceMetrics

val displayWidth = displayMetrics.widthPixels
val displayHeight = displayMetrics.heightPixels

val dialogWindowWidth = (displayWidth * 0.9f).toInt()
val dialogWindowHeight = (displayHeight * 0.25f).toInt()

dialog?.window?.setLayout(dialogWindowWidth, dialogWindowHeight)
}

fun setTitle(title: String): JmtConfirmDialog {
binding.titleText.text = title
return this
}

fun setContent(content: String): JmtConfirmDialog {
binding.contentText.text = content
return this
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

companion object {
const val TAG = "JmtConfirmDialog"
}
}
15 changes: 15 additions & 0 deletions app/src/main/java/com/dogdduddy/jmt/view/WebAppInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dogdduddy.jmt.view

import android.content.Context
import android.webkit.JavascriptInterface
import android.widget.Toast

/** Instantiate the interface and set the context */
class WebAppInterface(private val mContext: Context) {

/** Show a toast from the web page */
@JavascriptInterface
fun showToast(toast: String) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class WebViewActivity : AppCompatActivity() {

webView = binding.webView
webViewInit()

intent.extras?.let {
binding.webView.loadUrl(it.getString("url")!!)
}
Expand All @@ -35,5 +34,6 @@ class WebViewActivity : AppCompatActivity() {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) //화면이 계속 켜짐
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_USER
webView.setWebViewClient(WebViewClient())
webView.addJavascriptInterface(WebAppInterface(this), "Android")
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/jmt_confirm_dialog_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="20dp" />
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/main800">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/main600" />
<corners android:radius="8dp" />
</shape>
</item>
</ripple>
57 changes: 57 additions & 0 deletions app/src/main/res/layout/jmt_confirm_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/title_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="74.5dp"
android:layout_marginTop="24dp"
android:gravity="center_horizontal"
android:textSize="18sp"
android:textColor="@color/black"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="회원가입을 할 수 없습니다"/>

<TextView
android:id="@+id/content_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center_horizontal"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_text"
tools:text="와이파이 연결상태를\n 다시 확인해주세요."/>

<com.google.android.material.button.MaterialButton
android:id="@+id/confirm_button"
android:text="@string/confirm"
android:textSize="20sp"
android:layout_width="0dp"
android:layout_height="62dp"
android:layout_marginHorizontal="27.5dp"
android:layout_marginTop="24dp"
android:background="@drawable/jmt_confirm_dialog_button_background"
app:backgroundTint="#20BC2F"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/content_text"
tools:text="확인"/>
<Space
android:layout_width="wrap_content"
android:layout_height="24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/confirm_button"/>

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>

<color name="main600">#20BC2F</color>
<color name="main800">#116419</color>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<string name="app_name">JMT</string>
<string name="my_web_client_id">846233671186-4vknaa3i38pfkeourp2q37lolncdbmhl.apps.googleusercontent.com</string>
<string name="ios_client_id">846233671186-1ri677r59p8slvhu0ph98kg2ir0kuk45.apps.googleusercontent.com</string>
<string name="confirm">확인</string>
</resources>

0 comments on commit aa8b52d

Please sign in to comment.