diff --git a/README.md b/README.md
index 17ee761..864fd1a 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,10 @@
![](https://i.imgur.com/LkDevQK.png)
-복지 사각지대에 계신 분들이 앱 하나로 자신에게 **최적화된 복지 혜택**을 받아 볼 수 있습니다.
-**최적의 맞춤형 정보제공 챗봇과 실시간 푸시 알림, 주변 복지시설 안내, 관심복지 저장**의 기능을 통해 **복지 사각지대**의 사람들에게 편의를 제공합니다.
-([2021 프로보노 공모전](https://www.hanium.or.kr/portal/subscription/info.do?trackSeq=2) **대상 과학기술정보통신부장관상** 수상작입니다.)
+- 복지 사각지대에 계신 분들이 앱 하나로 자신에게 **최적화된 복지 혜택**을 받아 볼 수 있습니다.
+- **최적의 맞춤형 정보제공 챗봇과 실시간 푸시 알림, 주변 복지시설 안내, 관심복지 저장**의 기능을 통해 **복지 사각지대**의 사람들에게 편의를 제공합니다.
+- [2021 프로보노 공모전](https://www.hanium.or.kr/portal/subscription/info.do?trackSeq=2) 대상 과학기술정보통신부장관상 수상작입니다.
+- 구글 플레이 스토어에 정식으로 다운로드 받으실 수 있습니다.([다운로드 링크](https://play.google.com/store/apps/details?id=com.product.welfareapp), 버전 : 1.0.2, 업데이트 날짜 : 22.08.29)
## 기술 스택
@@ -20,97 +21,114 @@
- KoSBERT에 대해 알고 싶다면? : [KoSBERT](https://www.notion.so/welfareforeveryone/KoSBERT-15ecbf962da646d0a88909700f8bebd8)
## 실행 스크립트
-
+---
### 앱 실행 스크립트
+- Android Studio Emulator 환경에서 동작시키기(Android Studio 필요)
+ ```java
+ cd ./client/
+ 1. Download Android Emulator
+ 2. Build -> Make Project
+ 3. Run -> Run 'app'
+ ```
-```java
-Execute Android Eumulator
-Build Project
-Run
-```
-
-### 서버 실행 스크립트
+- Android Studio에서 .aab 혹은 .apk 파일 생성하기
+ ```java
+ 1. Build -> Build Bundle(s) / APK(s)
+ 2. Download welfare.aab / welfare.apk from local
+ ```
-server/.env를 참고해서 환경변수 파일을 만들어주세요.
-server/config/ 폴더에 chatbot.json파일을 [여기서](https://www.notion.so/welfareforeveryone/391ccf431eaa449db00c9a36658ee6e8) 다운받아서 넣어주세요.
-server/config/ 폴더에 firebase 인증 키 정보를 넣어주고 추가해주세요.
+- 디바이스 환경(모바일) : 구글 플레이 스토어에서 [다운로드](https://play.google.com/store/apps/details?id=com.product.welfareapp) 후 사용 가능
-```NodeJs
-cd (backend folder)
-npm install
-npm run prod (production version)
-npm start (development version)
-```
+
+---
+### 서버 실행 스크립트
+- 서버 실행 순서
+ 1. server/.env를 참고해서 환경변수 파일을 만들어주세요.
+ 2. server/config/ 폴더에 chatbot.json파일을 [여기서](https://www.notion.so/welfareforeveryone/391ccf431eaa449db00c9a36658ee6e8) 다운받아서 넣어주세요.
+ 3. server/config/ 폴더에 firebase 인증 키 정보를 넣어주고 추가해주세요.
+
+
+ ```NodeJs
+ cd (backend folder)
+ npm install
+ npm run prod (production version)
+ npm start (development version)
+ ```
+
+
+---
### AI 일상대화 챗봇 실행 스크립트(KcELECTRA)
> docker image 다운로드: kmg2933/welfare-for-everyone:0921
- 파일
+ model.pt 파일은 해당 [링크](https://welfareforeveryone.notion.site/391ccf431eaa449db00c9a36658ee6e8)에서 받아가세요.
-model.pt 파일은 해당 [링크](https://welfareforeveryone.notion.site/391ccf431eaa449db00c9a36658ee6e8)에서 받아가세요.
-
-```python
-config = {
- 'port':'number'
-}
-```
+ ```python
+ config = {
+ 'port':'number'
+ }
+ ```
- 실행 스크립트
-
-```script
-sudo cp model.pt WelfareForEveryOne/ai/KcELECTRAchatbot/flask/model.pt
-sudo cp config.py WelfareForEveryOne/ai/KcELECTRAchatbot/flask/config.py
-
-cd WelfareForEveryOne/ai/KcELECTRAchatbot/flask
-
-// image build
-docker build --no-cache -t kmg2933/welfare-for-everyone:prod .
-
-// cpu
-docker run --rm -it -p [host port]:[container port] kmg2933/welfare-for-everyone:prod
-
-```
-
+ ```script
+ sudo cp model.pt WelfareForEveryOne/ai/KcELECTRAchatbot/flask/model.pt
+ sudo cp config.py WelfareForEveryOne/ai/KcELECTRAchatbot/flask/config.py
+
+ cd WelfareForEveryOne/ai/KcELECTRAchatbot/flask
+
+ // image build
+ docker build --no-cache -t kmg2933/welfare-for-everyone:prod .
+
+ // cpu
+ docker run --rm -it -p [host port]:[container port] kmg2933/welfare-for-everyone:prod
+
+ ```
+
+
+---
### AI 복지정보 챗봇 실행 스크립트(KoSBERT)
-
-> docker image 다운로드:bookbug/kosbert_image:latest
+>docker image 다운로드:bookbug/kosbert_image:latest
(참고 : CPU로 실행되도록 설정되어 있습니다. GPU로 실행하고 싶으시다면 [GPU 실행](https://github.com/BM-K/KoSentenceBERT-SKT/issues/8)을 참고해주세요.)
- 파일
-result.pt 파일은 해당 [링크](https://drive.google.com/drive/folders/1fLYRi7W6J3rxt-KdGALBXMUS2W4Re7II)의 sts/result.pt 파일을 다운받으세요.
-corpus_embedding.csv는 해당 [링크](https://www.notion.so/welfareforeveryone/391ccf431eaa449db00c9a36658ee6e8)에서 다운받으세요. [출처](https://www.data.go.kr/data/15090532/openapi.do)는 공공데이터포털입니다.
+ * result.pt 파일은 해당 [링크](https://drive.google.com/drive/folders/1fLYRi7W6J3rxt-KdGALBXMUS2W4Re7II)의 sts/result.pt 파일을 다운받으세요.
+ * corpus_embedding.csv는 해당 [링크](https://www.notion.so/welfareforeveryone/391ccf431eaa449db00c9a36658ee6e8)에서 다운받으세요. [출처](https://www.data.go.kr/data/15090532/openapi.do)는 공공데이터포털입니다.
-```python
-config = {
- 'port':'number'
-}
-```
+ ```python
+ config = {
+ 'port':'number'
+ }
+ ```
- 실행 스크립트
+ ```script
+ // file copy
+ sudo cp result.pt WelfareForEveryOne/ai/KoSentenceBERTchatbot/KoSentenceBERT/output/training_sts/0_Transformer/result.pt
+ sudo cp corpus_embedding.csv WelfareForEveryOne/ai/KoSentenceBERTchatbot/KoSentenceBERT/corpus_embedding.csv
+ sudo cp config.py WelfareForEveryOne/ai/KoSentenceBERTchatbot/KoSentenceBERT/config.py
-```script
-// file copy
-sudo cp result.pt WelfareForEveryOne/ai/KoSentenceBERTchatbot/KoSentenceBERT/output/training_sts/0_Transformer/result.pt
-sudo cp corpus_embedding.csv WelfareForEveryOne/ai/KoSentenceBERTchatbot/KoSentenceBERT/corpus_embedding.csv
-sudo cp config.py WelfareForEveryOne/ai/KoSentenceBERTchatbot/KoSentenceBERT/config.py
+ cd WelfareForEveryOne/ai/KoSentenceBERTchatbot
-cd WelfareForEveryOne/ai/KoSentenceBERTchatbot
+ // image build
+ docker build --no-cache -t kosbert_image:prod .
-// image build
-docker build --no-cache -t kosbert_image:prod .
+ // cpu
+ docker run --rm -it -p [host port]:[container port] kosbert_image:prod
-// cpu
-docker run --rm -it -p [host port]:[container port] kosbert_image:prod
+ // gpu
+ docker run --gpus all --rm -it -p [host port]:[container port] kosbert_image:prod
-// gpu
-docker run --gpus all --rm -it -p [host port]:[container port] kosbert_image:prod
+ ```
-```
## 어플리케이션 시연
+---
-전체 시연 영상은 다음 [데모 영상](https://www.youtube.com/watch?v=YdwjrgnP7SM)을 참고해 주세요.
+데모 및 설명은 다음 [데모 영상](https://www.youtube.com/watch?v=YdwjrgnP7SM)을 참고해 주세요.
+실제 어플리케이션 시연 영상은 다음 [시연 영상](https://www.youtube.com/watch?v=MDyH8tj1s0g)을 참고해 주세요.
+~~실제 어플리케이션은 [다운로드 링크](https://play.google.com/store/apps/details?id=com.product.welfareapp)를 통해 다운 후 사용해보실 수 있습니다.~~ (현재 서비스 중지)
|추천 복지 열람|챗봇|복지시설 |푸시알림|관심복지 추가|
|:---:|:---:|:---:|:---:|:---:|
diff --git a/WelfareForEveryOne b/WelfareForEveryOne
deleted file mode 160000
index eddbd20..0000000
--- a/WelfareForEveryOne
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit eddbd2037be76b32aeb02e058e4afe544e090e83
diff --git a/ai/KoSentenceBERTchatbot/Dockerfile b/ai/KoSentenceBERTchatbot/Dockerfile
index 71fb794..351296a 100644
--- a/ai/KoSentenceBERTchatbot/Dockerfile
+++ b/ai/KoSentenceBERTchatbot/Dockerfile
@@ -6,6 +6,7 @@ WORKDIR /workspace/KoSentenceBERT
COPY KoSentenceBERT/main.py .
COPY KoSentenceBERT/utils.py .
+COPY KoSentenceBERT/config.py .
COPY KoSentenceBERT/wsgi.py .
COPY KoSentenceBERT/corpus_embedding.csv .
# COPY KoSentenceBERT/device/serialization.py /torch/ #GPU
diff --git a/ai/KoSentenceBERTchatbot/KoSentenceBERT/main.py b/ai/KoSentenceBERTchatbot/KoSentenceBERT/main.py
index 9042643..1b8ee37 100644
--- a/ai/KoSentenceBERTchatbot/KoSentenceBERT/main.py
+++ b/ai/KoSentenceBERTchatbot/KoSentenceBERT/main.py
@@ -2,7 +2,7 @@
import pandas as pd
import json
-from utils import extract_top
+from utils import extract_top, extract_welfare_id
from flask import Flask, request
@@ -33,9 +33,11 @@ def method():
standard = params['standard']
em_se_embedding = corpus_embedding['embedding_'+standard]
+ corpus_welfare_id = corpus_embedding['welfare_id']
top_k=3
top_results = extract_top(em_se_embedding, query_embedding, top_k)
+ top_welfare_id = extract_welfare_id(corpus_welfare_id, top_results)
- return json.dumps({"recommend":top_results},ensure_ascii=False)
+ return json.dumps({"recommend":top_welfare_id},ensure_ascii=False)
diff --git a/ai/KoSentenceBERTchatbot/KoSentenceBERT/utils.py b/ai/KoSentenceBERTchatbot/KoSentenceBERT/utils.py
index d5fa2b1..9b3e207 100644
--- a/ai/KoSentenceBERTchatbot/KoSentenceBERT/utils.py
+++ b/ai/KoSentenceBERTchatbot/KoSentenceBERT/utils.py
@@ -5,7 +5,7 @@
import json
def cos_sim(A, B):
- return dot(A, B)/(norm(A)*norm(B)) ## A, B는 array
+ return dot(A, B)/(norm(A)*norm(B)) ## A, B는 array
def extract_top(em_se_embedding, em_query, top_k):
cos_sim_query = pd.DataFrame()
@@ -13,4 +13,8 @@ def extract_top(em_se_embedding, em_query, top_k):
cos_sim_query.loc[i, 'cos_sim'] = cos_sim(np.array(json.loads(em_se_embedding[i])), em_query)
cos_sim_query = cos_sim_query.sort_values("cos_sim", ascending=False)
top_sm = cos_sim_query.index[0:top_k].tolist()
- return top_sm
\ No newline at end of file
+ return top_sm
+
+def extract_welfare_id(corpus_welfare_id, top_results):
+ top_welfare_id = corpus_welfare_id[top_results].tolist()
+ return top_welfare_id
\ No newline at end of file
diff --git a/client/.idea/deploymentTargetDropDown.xml b/client/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..1d75ac7
--- /dev/null
+++ b/client/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/client/.idea/misc.xml b/client/.idea/misc.xml
index 7c94525..7b3de87 100644
--- a/client/.idea/misc.xml
+++ b/client/.idea/misc.xml
@@ -19,10 +19,14 @@
+
-
+
+
+
+
-
+
@@ -30,6 +34,7 @@
+
diff --git a/client/README.md b/client/README.md
index 4fd49a5..de2b8a3 100644
--- a/client/README.md
+++ b/client/README.md
@@ -1,20 +1,24 @@
# 모두의 복지
-프로보노 공모전 프론트엔드 개발 프로젝트 by TAVE
-- Email address :
+개인 맞춤형 복지 추천 앱 모두의 복지 프론트엔드 개발 소개 페이지입니다.
+- Developer email address :
- App Developer(김진수) : wlstn5376@gmail.com
- - App Developer(박해미) :
+ - App Developer(박해미) :
- Demo Video : https://www.youtube.com/watch?v=YdwjrgnP7SM
-- 기술 스택 정리 : https://welfareforeveryone.notion.site/Front-end-Framework-and-Structure-2e8b6b629ea844fd87a32a198ee49fff
+- 기술 스택 정리(notion) : https://welfareforeveryone.notion.site/Front-end-Framework-and-Structure-2e8b6b629ea844fd87a32a198ee49fff
## Introduction
-모두의 복지는 복지 사각지대에 계신 분들에게 사용자 기반 추천 알고리즘을 적용한 최적화된 복지 혜택을 실시간 제공해주는 어플리케이션입니다.
+모두의 복지는 복지 사각지대에 계신 분들에게 사용자 기반 추천 알고리즘을 적용한 최적화된 복지 혜택을 실시간 제공해주는 어플리케이션입니다.
+기본적으로 복지 정보 열람 서비스를 제공하고 있으며 (1) 카테고리별 복지 정보 (2) 키워드 기반 추천 복지 정보 (3) 사용자 관심 복지 정보 (4) 대화형 UI 챗봇을 통한 추천 복지의 형태로 실시간 복지 정보를 제공합니다.
+복지 정보 외에도 복지 시설에 대한 위치 제공 서비스와, 챗봇 UI를 활용한 대화 서비스 또한 제공하며, 더 나아가 푸시 알람 기능을 활용해 사용자가 관심을 가질만한 복지 정보에 대한 마감일 알림 서비스 또한 제공하고 있습니다.
-모두의 복지가 갖는 기능은 다음과 같습니다.
+## UI Implementation
+현재까지 프론트엔드에서 구현된 기능은 다음과 같습니다.
1. 리스트 뷰 형태로 최적의 맞춤형 복지 정보 제공
-2. 챗봇을 통한 실시간 복지 추천 정보 제공
-3. 사용자 위치에 따른 복지시설 안내(병원, 공공기관, 노인 복지 등)
+2. 챗봇을 통한 실시간 추천 복지 정보 제공
+3. 챗봇을 통한 실시간 대화 서비스 기능
+4. 사용자 위치에 따른 복지시설 안내(병원, 공공기관, 노인 복지 등)
4. 복지 정보에 대한 푸시 알림
5. 관심 복지 정보에 대한 찜 기능
@@ -22,8 +26,9 @@
- Tool : Android Studio(ver 2020.03.01 patch2)
- Language : Java
- Library to use
- - http networking : volley
+ - http networking : Volley
- Push Notification : Firebase
+ - Map UI & Place Searching : Google Map API, Google Place API
## APIs
- Google Map API : MapActivity google map 시각화
@@ -40,4 +45,7 @@ build project
run app
```
+## Download Application
+- 구글 플레이스토어 링크 : https://play.google.com/store/apps/details?id=com.product.welfareapp
+
* 본 프로젝트는 Google의 GCP Credit 지원을 받고 있습니다. (Google supported this work by providing Google Cloud credit)
\ No newline at end of file
diff --git a/client/app/build.gradle b/client/app/build.gradle
index f175f93..df629b6 100644
--- a/client/app/build.gradle
+++ b/client/app/build.gradle
@@ -13,8 +13,8 @@ android {
applicationId "com.product.welfareapp"
minSdk 24
targetSdk 30
- versionCode 3
- versionName "1.0.0"
+ versionCode 5
+ versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -37,6 +37,7 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
+ compileSdkVersion 31
}
dependencies {
@@ -44,12 +45,12 @@ dependencies {
implementation 'com.android.volley:volley:1.2.1'
// implementation map api
- implementation 'com.google.android.gms:play-services-location:18.0.0'
- implementation 'com.google.android.gms:play-services-maps:18.0.0'
+ implementation 'com.google.android.gms:play-services-location:19.0.1'
+ implementation 'com.google.android.gms:play-services-maps:18.0.2'
// implementation place api
implementation 'noman.placesapi:placesAPI:1.1.3'
- implementation 'com.google.android.libraries.places:places:2.5.0'
+ implementation 'com.google.android.libraries.places:places:2.6.0'
// fcm module
implementation platform('com.google.firebase:firebase-bom:28.4.2')
@@ -58,11 +59,10 @@ dependencies {
implementation 'com.google.firebase:firebase-auth'
// general utils
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation 'com.google.android.material:material:1.4.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
- implementation 'androidx.room:room-compiler:2.2.6'
- testImplementation 'junit:junit:4.+'
+ implementation 'androidx.appcompat:appcompat:1.4.1'
+ implementation 'com.google.android.material:material:1.5.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
+ annotationProcessor 'androidx.room:room-compiler:2.4.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
@@ -72,5 +72,7 @@ dependencies {
//profile
implementation 'com.makeramen:roundedimageview:2.3.0'
+ // secrets gradle plugin
+ implementation "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
}
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
diff --git a/client/app/src/main/AndroidManifest.xml b/client/app/src/main/AndroidManifest.xml
index 681b658..4701bf7 100644
--- a/client/app/src/main/AndroidManifest.xml
+++ b/client/app/src/main/AndroidManifest.xml
@@ -28,6 +28,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.welfareapp"
android:usesCleartextTraffic="true"
+ android:hardwareAccelerated="true"
tools:replace="android:allowBackup, android:label">
do not call from response
+ if(chat_mode == 1){
+ Log.v("ChatActivity", "chat_mode = 1 response : " + response.toString());
+ Boolean isSuccess = response.getBoolean("success");
+ int statusCode = response.getInt("statusCode");
+ String message_content = response.getString("message_content");
+
+ editor.putBoolean("success", isSuccess);
+ editor.putInt("statusCode", statusCode);
+ editor.putString("message_content", message_content);
+ editor.putInt("message_type", 0);
+ editor.commit();
+ }
+ else if(chat_mode == 0){
+ Boolean isSuccess = response.getBoolean("success");
+ int statusCode = response.getInt("statusCode");
+ JSONArray welfare_info = response.getJSONArray("welfare_info");
+
+ int jar_len = welfare_info.length();
+ if(jar_len >0){
+ for(int i = 0; i < jar_len; i++){
+ // using JSONObject
+ JSONObject obj = welfare_info.getJSONObject(i);
+
+ String titleName = "welfare_title" + Integer.toString(i+1);
+ String summaryName = "welfare_summary" + Integer.toString(i+1);
+
+ int welfare_id = obj.getInt("welfare_id");
+ String title = obj.getString("title");
+ String summary = obj.getString("summary");
+
+ String key = "welfare_info_" + Integer.toString(i);
+ ArrayList list = new ArrayList();
+ list.add(Integer.toString(welfare_id));
+ list.add(title);
+ list.add(summary);
+
+ JSONArray a = new JSONArray();
+ for (int j = 0; j < list.size(); j++) {
+ a.put(list.get(j));
+ }
+ if (!list.isEmpty()) {
+ editor.putString(key, a.toString());
+ Log.v("ChatActivity json array", a.toString());
+ } else {
+ editor.putString(key, null);
+ }
+ }
+ }
+
+ editor.putInt("num_info", jar_len);
+ editor.putBoolean("success", isSuccess);
+ editor.putInt("statusCode", statusCode);
+ editor.putInt("message_type", 1);
+ editor.commit();
+ }
+
volleyCallBack.onSuccess();
}
catch(JSONException e){
diff --git a/client/app/src/main/java/com/product/welfareapp/DetailActivity.java b/client/app/src/main/java/com/product/welfareapp/DetailActivity.java
index 3c21199..aada0c7 100644
--- a/client/app/src/main/java/com/product/welfareapp/DetailActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/DetailActivity.java
@@ -45,8 +45,6 @@ protected void onCreate(Bundle savedInstanceState) {
Boolean is_liked = bundle.getBoolean("is_liked", false);
try{
- //getDetailInfo(welfare_id, token);
-
requestDetailInfo(welfare_id, token, new VolleyCallBack() {
@Override
public void onSuccess() {
@@ -122,7 +120,7 @@ public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
});
- Toast.makeText(buttonView.getContext(), "내 관심복지 리스트에 등록되었습니다.", Toast.LENGTH_LONG).show();
+ Toast.makeText(buttonView.getContext(), "내 관심복지 리스트에 등록되었습니다.", Toast.LENGTH_SHORT).show();
VolleySingleton.getInstance(buttonView.getContext()).addToRequestQueue(jsonObjectRequest);
}
else{
@@ -156,7 +154,7 @@ public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
});
- Toast.makeText(buttonView.getContext(), "내 관심복지 리스트에서 삭제되었습니다.", Toast.LENGTH_LONG).show();
+ Toast.makeText(buttonView.getContext(), "내 관심복지 리스트에서 삭제되었습니다.", Toast.LENGTH_SHORT).show();
VolleySingleton.getInstance(buttonView.getContext()).addToRequestQueue(jsonObjectRequest);
}
}
@@ -200,6 +198,8 @@ public void onResponse(JSONObject response) {
int category = response.getInt("category");
Boolean isLiked = response.getBoolean("isLiked");
+ Log.v("DetailActivity requestDetailInfo", "succeed");
+
editor.putBoolean("success", isSuccess);
editor.putInt("statusCode", statusCode);
editor.putInt("welfare_id", welfare_id);
diff --git a/client/app/src/main/java/com/product/welfareapp/ListActivity.java b/client/app/src/main/java/com/product/welfareapp/ListActivity.java
index c10f264..2ccf3be 100644
--- a/client/app/src/main/java/com/product/welfareapp/ListActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/ListActivity.java
@@ -10,6 +10,7 @@
import android.view.View;
import android.widget.ImageButton;
import android.widget.ListView;
+import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -33,6 +34,9 @@ public class ListActivity extends AppCompatActivity {
private ArrayList welfareInfoComponentArrayList;
private WelfareViewAdapter welfareViewAdapter;
+ // back button listener
+ private static long back_pressed;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -71,10 +75,14 @@ public void onSuccess() {
btn_back.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
+ /**
+ * 2022.08.28 : replace startActivity to onBackPressed
Intent intent = new Intent(ListActivity.this, MainActivity.class);
intent.putExtras(bundle);
startActivity(intent);
finish();
+ */
+ ListActivity.super.onBackPressed();
}
});
@@ -83,6 +91,11 @@ public interface VolleyCallBack {
void onSuccess();
}
+ @Override
+ public void onBackPressed() {
+ super.onBackPressed();
+ }
+
public synchronized void requestCategoricalWelfareInfo(String token, int category, final VolleyCallBack volleyCallBack){
JSONObject params = new JSONObject();
try{
diff --git a/client/app/src/main/java/com/product/welfareapp/LoadUserImg.java b/client/app/src/main/java/com/product/welfareapp/LoadUserImg.java
deleted file mode 100644
index 0c7d06d..0000000
--- a/client/app/src/main/java/com/product/welfareapp/LoadUserImg.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.product.welfareapp;
-
-public class LoadUserImg {
-
- private void selectImgIdx(){
-
- }
-}
diff --git a/client/app/src/main/java/com/product/welfareapp/MainActivity.java b/client/app/src/main/java/com/product/welfareapp/MainActivity.java
index 55012f2..f0d706e 100644
--- a/client/app/src/main/java/com/product/welfareapp/MainActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/MainActivity.java
@@ -110,7 +110,7 @@ public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, MainViewAllActivity.class);
intent.putExtras(bundle);
startActivity(intent);
- finish();
+ // finish();
}
});
@@ -313,7 +313,6 @@ private void updateRecommendWelfareInfoOnUi(String token){
}
catch(Exception error){
error.printStackTrace();
- Boolean isLiked = false;
welfareInfoComponentArrayList.add(new com.product.welfareapp.WelfareInfoComponent(
Integer.parseInt(decode_list.get(0)),
decode_list.get(1),
@@ -326,7 +325,7 @@ private void updateRecommendWelfareInfoOnUi(String token){
decode_list.get(8),
Integer.parseInt(decode_list.get(9)),
token,
- isLiked
+ false
));
}
welfareViewAdapter.notifyDataSetChanged();
@@ -339,222 +338,6 @@ private void updateRecommendWelfareInfoOnUi(String token){
}
}
- private void getRecommendWelfareInfo(String token){
- JSONObject params = new JSONObject();
- try{
- params.put("token", token);
- Log.v("MainActivity getRecommendWelfareInfo params complete", "true");
- }
- catch(JSONException e){
- e.printStackTrace();
- return;
- }
- SharedPreferences recommendWelfareInfo = getSharedPreferences("recommendWelfareInfo", MODE_PRIVATE);
- SharedPreferences.Editor editor = recommendWelfareInfo.edit();
-
- final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_welfare_recommend, params, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- Log.v("MainActivity welfare response", "success");
- try{
- Boolean isSuccess = response.getBoolean("success");
- int statusCode = response.getInt("statusCode");
- String responseToken = response.getString("token");
- JSONArray jar = response.getJSONArray("recommend_welfare_list");
-
- Log.v("MainActivity response isSuccess", isSuccess.toString());
- Log.v("MainActivity response statusCode", Integer.toString(statusCode));
- Log.v("MainActivity number of welfare_list", Integer.toString(jar.length()));
- Log.v("MainActivity jar", jar.toString());
-
- editor.putBoolean("success", isSuccess);
- editor.putInt("statusCode", statusCode);
- editor.putInt("totalNum", jar.length());
-
- if(jar.length() > 0){
- for(int i = 0; i < jar.length();i++){
- Log.v("MainActivity for loop start",Integer.toString(i));
- Log.v("MainActivity jar", jar.toString());
- Log.v("MainActivity jar JSONObject", jar.getJSONObject(i).toString());
- Log.v("MainActivity jar obj", jar.get(i).toString());
-
- int welfare_id = jar.getJSONObject(i).getInt("welfare_id");
- String title = jar.getJSONObject(i).getString("title");
- String summary = jar.getJSONObject(i).getString("summary");
- String who = jar.getJSONObject(i).getString("who");
- String criteria = jar.getJSONObject(i).getString("criteria");
- String what = jar.getJSONObject(i).getString("what");
- String how = jar.getJSONObject(i).getString("how");
- String info_calls = jar.getJSONObject(i).getString("calls");
- String sites = jar.getJSONObject(i).getString("sites");
- int category = jar.getJSONObject(i).getInt("category");
- Boolean isLiked = jar.getJSONObject(i).getBoolean("isLiked");
-
- Log.v("MainActivity welfare_id", Integer.toString(welfare_id));
- Log.v("MainActivity isLiked", isLiked.toString());
-
- String key = "welfare_info_" + Integer.toString(i);
- ArrayList list = new ArrayList();
- list.add(Integer.toString(welfare_id));
- list.add(title);
- list.add(summary);
- list.add(who);
- list.add(criteria);
- list.add(what);
- list.add(how);
- list.add(info_calls);
- list.add(sites);
- list.add(Integer.toString(category));
-
- if(isLiked){
- list.add(Integer.toString(1));
- }
- else{
- list.add(Integer.toString(0));
- }
-
- JSONArray a = new JSONArray();
- for (int j = 0; j < list.size(); j++) {
- a.put(list.get(j));
- }
- if (!list.isEmpty()) {
- editor.putString(key, a.toString());
- Log.v("MainActivity json array", a.toString());
- } else {
- editor.putString(key, null);
- }
- }
- editor.commit();
- }
- }
- catch(JSONException e){
- e.printStackTrace();
- Log.v("MainActivity JSONExcetion error", e.getMessage());
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Log.v("MainActivity welfare response", "failed");
- Log.v("MainActivity VolleyError error", error.toString());
- editor.putBoolean("success", false);
- editor.commit();
- }
- });
-
- Log.v("MainActivity jsonObjectRequest", jsonObjectRequest.toString());
- Log.v("MainActivity jsonObjectRequest url", jsonObjectRequest.getUrl());
-
- jsonObjectRequest.setShouldCache(false);
- VolleySingleton.getInstance(this).addToRequestQueue(jsonObjectRequest);
-
- new Handler().postDelayed(
- new Runnable() {
- @Override
- public void run() {
- if(recommendWelfareInfo.getBoolean("success",false)){
-
- String text = "총 "+ Integer.toString(recommendWelfareInfo.getInt("totalNum",0)) + "개의 복지가 있습니다.";
- TextView tv_num_list = (TextView)findViewById(R.id.sub_title);
- tv_num_list.setText(text);
-
- int totalNum = recommendWelfareInfo.getInt("totalNum", 0);
-
- if(totalNum >= 2){
- totalNum = 2;
- }
-
- for(int i = 0; i < totalNum; i++){
-
- String key = "welfare_info_" + Integer.toString(i);
- String json = recommendWelfareInfo.getString(key, null);
- Log.v("MainActivity JSON string type loaded", json.toString());
- ArrayList decode_list = new ArrayList();
- if (json != null) {
- try {
- JSONArray a = new JSONArray(json);
- for (int j = 0; j < a.length(); j++) {
- String str = a.optString(j);
- Log.v("MainActivity JSON string parsing", str);
- decode_list.add(str);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
-
- Log.v("MainActivity welfare component isLiked", decode_list.get(10));
- try{
-
- if(Integer.parseInt(decode_list.get(10)) == 1){
- Boolean isLiked = true;
- welfareInfoComponentArrayList.add(new com.product.welfareapp.WelfareInfoComponent(
- Integer.parseInt(decode_list.get(0)),
- decode_list.get(1),
- decode_list.get(2),
- decode_list.get(3),
- decode_list.get(4),
- decode_list.get(5),
- decode_list.get(6),
- decode_list.get(7),
- decode_list.get(8),
- Integer.parseInt(decode_list.get(9)),
- token,
- isLiked
- ));
- }
- else{
- Boolean isLiked = false;
- welfareInfoComponentArrayList.add(new com.product.welfareapp.WelfareInfoComponent(
- Integer.parseInt(decode_list.get(0)),
- decode_list.get(1),
- decode_list.get(2),
- decode_list.get(3),
- decode_list.get(4),
- decode_list.get(5),
- decode_list.get(6),
- decode_list.get(7),
- decode_list.get(8),
- Integer.parseInt(decode_list.get(9)),
- token,
- isLiked
- ));
- }
- }
- catch(Exception error){
- error.printStackTrace();
- Log.v("MainActivity welfare isLiked loaded","failed");
- Boolean isLiked = false;
- welfareInfoComponentArrayList.add(new com.product.welfareapp.WelfareInfoComponent(
- Integer.parseInt(decode_list.get(0)),
- decode_list.get(1),
- decode_list.get(2),
- decode_list.get(3),
- decode_list.get(4),
- decode_list.get(5),
- decode_list.get(6),
- decode_list.get(7),
- decode_list.get(8),
- Integer.parseInt(decode_list.get(9)),
- token,
- isLiked
- ));
- }
-
- welfareViewAdapter.notifyDataSetChanged();
- }
- }
- else{
- String text = "총 0개의 복지가 있습니다.";
- TextView tv_num_list = (TextView)findViewById(R.id.sub_title);
- tv_num_list.setText(text);
- }
- }
- },
- 1024
- );
- }
-
@Override
public void onBackPressed() {
if (back_pressed + 2000 > System.currentTimeMillis()){
diff --git a/client/app/src/main/java/com/product/welfareapp/MainRVAdapter.java b/client/app/src/main/java/com/product/welfareapp/MainRVAdapter.java
index 5666c13..9554d4e 100644
--- a/client/app/src/main/java/com/product/welfareapp/MainRVAdapter.java
+++ b/client/app/src/main/java/com/product/welfareapp/MainRVAdapter.java
@@ -66,6 +66,8 @@ public void onClick(View v) {
Intent intent = new Intent(context, com.product.welfareapp.ListActivity.class);
intent.putExtras(bundle);
context.startActivity(intent);
+ // main activity should be finished
+
}
catch(Exception err){
Log.v("Category to ListActivity intent process","error");
diff --git a/client/app/src/main/java/com/product/welfareapp/MainViewAllActivity.java b/client/app/src/main/java/com/product/welfareapp/MainViewAllActivity.java
index 31c499e..3fa6180 100644
--- a/client/app/src/main/java/com/product/welfareapp/MainViewAllActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/MainViewAllActivity.java
@@ -13,6 +13,7 @@
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.Response;
@@ -31,6 +32,9 @@ public class MainViewAllActivity extends AppCompatActivity {
private WelfareViewAdapter welfareViewAdapter;
private ArrayList welfareInfoComponentArrayList;
+ // back button listener
+ private static long back_pressed;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -67,10 +71,14 @@ public void onSuccess() {
btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ /**
+ * 2022.08.28 : replace startActivity to onBackPressed
Intent intent = new Intent(MainViewAllActivity.this, MainActivity.class);
intent.putExtras(bundle);
startActivity(intent);
finish();
+ */
+ MainViewAllActivity.super.onBackPressed();
}
});
}
@@ -79,6 +87,11 @@ public interface VolleyCallBack{
void onSuccess();
}
+ @Override
+ public void onBackPressed() {
+ super.onBackPressed();
+ }
+
public synchronized void requestRecommendWelfareInfoAll(String token, final VolleyCallBack volleyCallBack){
JSONObject params = new JSONObject();
try{
@@ -106,6 +119,7 @@ public void onResponse(JSONObject response) {
if(jar.length() > 0){
for(int i = 0; i < jar.length();i++){
+ Log.v("MainViewAllActivity","jar script : " + jar.getJSONObject(i).toString());
int welfare_id = jar.getJSONObject(i).getInt("welfare_id");
String title = jar.getJSONObject(i).getString("title");
String summary = jar.getJSONObject(i).getString("summary");
diff --git a/client/app/src/main/java/com/product/welfareapp/MapActivity.java b/client/app/src/main/java/com/product/welfareapp/MapActivity.java
index 91d1e32..4d47b00 100644
--- a/client/app/src/main/java/com/product/welfareapp/MapActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/MapActivity.java
@@ -102,7 +102,8 @@ public class MapActivity extends AppCompatActivity implements OnMapReadyCallback
private List previous_marker = null;
// Place API key
- private final String placeAPIKey = BuildConfig.GOOGLE_PLACE_KEY;
+ // private final String placeAPIKey = BuildConfig.GOOGLE_PLACE_KEY;
+ private final String placeAPIKey = "AIzaSyDmaHqwSUJSjaS07Hod_L81DUynQBeV8m4";
private int searchRadius = 500;
@@ -669,9 +670,9 @@ public class DownloadUrl{
public String getUrl(String placeType, int searchRadius, String placeAPIKey, LatLng position){
StringBuilder googleURL = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
- double latitide = position.latitude;
+ double latitude = position.latitude;
double longitude = position.longitude;
- googleURL.append("location=" + latitide + "," + longitude);
+ googleURL.append("location=" + latitude + "," + longitude);
googleURL.append("&radius=" + searchRadius);
googleURL.append("&name=" + placeType);
googleURL.append("&sensor=true");
diff --git a/client/app/src/main/java/com/product/welfareapp/MyProfileListActivity.java b/client/app/src/main/java/com/product/welfareapp/MyProfileListActivity.java
index a3d58e2..2292518 100644
--- a/client/app/src/main/java/com/product/welfareapp/MyProfileListActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/MyProfileListActivity.java
@@ -13,6 +13,7 @@
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.Response;
@@ -30,6 +31,9 @@ public class MyProfileListActivity extends AppCompatActivity {
private WelfareViewAdapter welfareViewAdapter;
private ArrayList welfareInfoComponentArrayList;
+ // back button listener
+ private static long back_pressed;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -49,7 +53,6 @@ protected void onCreate(Bundle savedInstanceState) {
/* data loaded from server */
try{
- //getWelfareInfo(token);
requestWelfareInfo(token, new VolleyCallBack() {
@Override
public void onSuccess() {
@@ -202,156 +205,14 @@ public void updateWelfareInfoOnUI(String token){
}
}
}
-
- private void getWelfareInfo(String token){
- JSONObject params = new JSONObject();
- try{
- params.put("token", token);
- Log.v("MyProfileList params complete: ", "true");
+ @Override
+ public void onBackPressed() {
+ if (back_pressed + 2000 > System.currentTimeMillis()){
+ super.onBackPressed();
}
- catch(JSONException e){
- e.printStackTrace();
- return;
+ else {
+ Toast.makeText(getBaseContext(), "뒤로가기 버튼을 한번 더 누르면 앱이 종료됩니다.", Toast.LENGTH_SHORT).show();
}
-
- SharedPreferences welfareInfoResponse = getSharedPreferences("MyProfileListWelfareResponse", MODE_PRIVATE);
- SharedPreferences.Editor editor= welfareInfoResponse.edit();
-
- final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_my_welfare, params, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- Log.v("MyProfileListActivity welfare response", "success");
- try{
- Boolean isSuccess = response.getBoolean("success");
- int statusCode = response.getInt("statusCode");
- String responseToken = response.getString("token");
- JSONArray jar = response.getJSONArray("recommend_welfare_list");
-
- Log.v("MyProfileList response isSuccess", isSuccess.toString());
- Log.v("MyProfileList response statusCode", Integer.toString(statusCode));
- Log.v("MyProfileList response jar length", Integer.toString(jar.length()));
-
- editor.putBoolean("success", isSuccess);
- editor.putInt("statusCode", statusCode);
- editor.putInt("totalNum", jar.length());
-
-
- /* jar 로부터 복지정보 parsing */
- if(jar.length() > 0){
- for(int i = 0 ; i < jar.length() ; i++){
- Log.v("MyProfileList for loop start",Integer.toString(i));
- Log.v("MyProfileList jar", jar.toString());
- Log.v("MyProfileList jar JSONObject", jar.getJSONObject(i).toString());
- Log.v("MyProfileList jar obj", jar.get(i).toString());
-
- int welfare_id = jar.getJSONObject(i).getInt("welfare_id");
- String title = jar.getJSONObject(i).getString("title");
- String summary = jar.getJSONObject(i).getString("summary");
- String who = jar.getJSONObject(i).getString("who");
- String criteria = jar.getJSONObject(i).getString("criteria");
- String what = jar.getJSONObject(i).getString("what");
- String how = jar.getJSONObject(i).getString("how");
- String info_calls = jar.getJSONObject(i).getString("calls");
- String sites = jar.getJSONObject(i).getString("sites");
- int category = jar.getJSONObject(i).getInt("category");
- //Boolean isLiked = jar.getJSONObject(i).getBoolean("isLiked");
-
- Log.v("MyProfileListActivity welfare_id", Integer.toString(welfare_id));
-
- String key = "welfare_info_" + Integer.toString(i);
- ArrayList list = new ArrayList();
- list.add(Integer.toString(welfare_id));
- list.add(title);
- list.add(summary);
- list.add(who);
- list.add(criteria);
- list.add(what);
- list.add(how);
- list.add(info_calls);
- list.add(sites);
- list.add(Integer.toString(category));
- //list.add(Boolean.toString(isLiked));
-
- JSONArray a = new JSONArray();
- for (int j = 0; j < list.size(); j++) {
- a.put(list.get(j));
- }
- if (!list.isEmpty()) {
- editor.putString(key, a.toString());
- Log.v("MyProfileListActivity json array", a.toString());
- } else {
- editor.putString(key, null);
- }
- }
- editor.commit();
- }
- }
- catch(JSONException e){
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Log.v("MyProfileListActivity welfare response", "failed");
- editor.putBoolean("success", false);
- editor.commit();
- }
- });
-
- Log.v("MyProfileList jsonObjectRequest", jsonObjectRequest.toString());
- Log.v("MyProfileList jsonObjectRequest url", jsonObjectRequest.getUrl());
-
- jsonObjectRequest.setShouldCache(false);
- VolleySingleton.getInstance(this).addToRequestQueue(jsonObjectRequest);
-
- new Handler().postDelayed(
- new Runnable() {
- @Override
- public void run() {
- if(welfareInfoResponse.getBoolean("success", false)){
-
- for(int i = 0; i < welfareInfoResponse.getInt("totalNum", 0); i++){
-
- String key = "welfare_info_" + Integer.toString(i);
- String json = welfareInfoResponse.getString(key, null);
- Log.v("MyProfileList JSON string type loaded", json.toString());
- ArrayList decode_list = new ArrayList();
- if (json != null) {
- try {
- JSONArray a = new JSONArray(json);
- for (int j = 0; j < a.length(); j++) {
- String str = a.optString(j);
- Log.v("MyProfileList JSON string parsing", str);
- decode_list.add(str);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
-
- int category = Integer.parseInt(decode_list.get(9));
- welfareInfoComponentArrayList.add(new com.product.welfareapp.WelfareInfoComponent(
- Integer.parseInt(decode_list.get(0)),
- decode_list.get(1),
- decode_list.get(2),
- decode_list.get(3),
- decode_list.get(4),
- decode_list.get(5),
- decode_list.get(6),
- decode_list.get(7),
- decode_list.get(8),
- category,
- token,
- true
- ));
- welfareViewAdapter.notifyDataSetChanged();
- }
- }
-
- }
- },
- 1024
- );
- };
+ back_pressed = System.currentTimeMillis();
+ }
}
\ No newline at end of file
diff --git a/client/app/src/main/java/com/product/welfareapp/ProfileActivity.java b/client/app/src/main/java/com/product/welfareapp/ProfileActivity.java
index 94b5030..046d538 100644
--- a/client/app/src/main/java/com/product/welfareapp/ProfileActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/ProfileActivity.java
@@ -93,6 +93,9 @@ public class ProfileActivity extends AppCompatActivity {
// User Image
ImageView user_img_view;
+ // back button listener
+ private static long back_pressed;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -664,4 +667,15 @@ public void onErrorResponse(VolleyError error) {
VolleySingleton.getInstance(this).addToRequestQueue(jsonRequest);
Toast.makeText(getApplicationContext(), "개인 정보수정에 성공하셨습니다.", Toast.LENGTH_SHORT).show();
};
+
+ @Override
+ public void onBackPressed() {
+ if (back_pressed + 2000 > System.currentTimeMillis()){
+ super.onBackPressed();
+ }
+ else {
+ Toast.makeText(getBaseContext(), "뒤로가기 버튼을 한번 더 누르면 앱이 종료됩니다.", Toast.LENGTH_SHORT).show();
+ }
+ back_pressed = System.currentTimeMillis();
+ }
}
\ No newline at end of file
diff --git a/client/app/src/main/java/com/product/welfareapp/PushActivity.java b/client/app/src/main/java/com/product/welfareapp/PushActivity.java
index 27d62e8..783e7f4 100644
--- a/client/app/src/main/java/com/product/welfareapp/PushActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/PushActivity.java
@@ -13,6 +13,7 @@
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.Response;
@@ -30,6 +31,9 @@ public class PushActivity extends AppCompatActivity {
private PushViewAdapter pushViewAdapter;
private ArrayList pushNotificationComponentArrayList;
+ // back button listener
+ private static long back_pressed;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -194,6 +198,17 @@ public void run() {
}
}, 1024 * 2
);
+ }
+ @Override
+ public void onBackPressed() {
+ if (back_pressed + 2000 > System.currentTimeMillis()){
+ super.onBackPressed();
+ }
+ else {
+ Toast.makeText(getBaseContext(), "뒤로가기 버튼을 한번 더 누르면 앱이 종료됩니다.", Toast.LENGTH_SHORT).show();
+ }
+ back_pressed = System.currentTimeMillis();
}
+
}
\ No newline at end of file
diff --git a/client/app/src/main/java/com/product/welfareapp/PushNotificationActivity.java b/client/app/src/main/java/com/product/welfareapp/PushNotificationActivity.java
index 00dff45..8dc59f7 100644
--- a/client/app/src/main/java/com/product/welfareapp/PushNotificationActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/PushNotificationActivity.java
@@ -23,6 +23,9 @@
public class PushNotificationActivity extends AppCompatActivity {
+ // back button listener
+ private static long back_pressed;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -96,4 +99,14 @@ public void onErrorResponse(VolleyError error) {
AppHelper.requestQueue.add(jsonObjectRequest);
}
+ @Override
+ public void onBackPressed() {
+ if (back_pressed + 2000 > System.currentTimeMillis()){
+ super.onBackPressed();
+ }
+ else {
+ Toast.makeText(getBaseContext(), "뒤로가기 버튼을 한번 더 누르면 앱이 종료됩니다.", Toast.LENGTH_SHORT).show();
+ }
+ back_pressed = System.currentTimeMillis();
+ }
}
\ No newline at end of file
diff --git a/client/app/src/main/java/com/product/welfareapp/RegisterActivity.java b/client/app/src/main/java/com/product/welfareapp/RegisterActivity.java
index 3a0bd30..c9288fd 100644
--- a/client/app/src/main/java/com/product/welfareapp/RegisterActivity.java
+++ b/client/app/src/main/java/com/product/welfareapp/RegisterActivity.java
@@ -103,6 +103,10 @@ public class RegisterActivity extends AppCompatActivity {
// User ImageView
ImageView user_img_view;
+
+ // back button listener
+ private static long back_pressed;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -669,6 +673,15 @@ public void onErrorResponse(VolleyError error) {
Log.v("register process -- jsonRequest", jsonRequest.toString());
Log.v("register process -- jsonRequest url: ", jsonRequest.getUrl());
AppHelper.requestQueue.add(jsonRequest);
-
+ }
+ @Override
+ public void onBackPressed() {
+ if (back_pressed + 2000 > System.currentTimeMillis()){
+ super.onBackPressed();
+ }
+ else {
+ Toast.makeText(getBaseContext(), "뒤로가기 버튼을 한번 더 누르면 앱이 종료됩니다.", Toast.LENGTH_SHORT).show();
+ }
+ back_pressed = System.currentTimeMillis();
}
}
\ No newline at end of file
diff --git a/client/app/src/main/java/com/product/welfareapp/WelfareViewAdapter.java b/client/app/src/main/java/com/product/welfareapp/WelfareViewAdapter.java
index 803aa91..29730d6 100644
--- a/client/app/src/main/java/com/product/welfareapp/WelfareViewAdapter.java
+++ b/client/app/src/main/java/com/product/welfareapp/WelfareViewAdapter.java
@@ -158,81 +158,46 @@ public void onClick(View v) {
// toggle button
holder.toggle_favorite.setChecked(favorite);
- holder.toggle_favorite.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ holder.toggle_favorite.setOnClickListener(new View.OnClickListener() {
@Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if(isChecked){
-
- JSONObject params = new JSONObject();
- try{
- params.put("token", token);
- params.put("welfare_id", welfare_id);
- }
- catch(JSONException err)
- {
- err.printStackTrace();
- return;
- }
- JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, URLs.url_favorite_create, params, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- try{
- Boolean isSuccess = response.getBoolean("success");
- int statusCode = response.getInt("statusCode");
- Log.v("welfareInfo create favorite info", "true");
- Log.v("welfareInfo create favorite, isSuccess", isSuccess.toString());
- Log.v("welfareInfo create favorite, statusCode", Integer.toString(statusCode));
- }
- catch(JSONException err){
- err.printStackTrace();
- }
+ public void onClick(View view) {
+ JSONObject params = new JSONObject();
+ try{
+ params.put("token", token);
+ params.put("welfare_id", welfare_id);
+ }
+ catch(JSONException err)
+ {
+ err.printStackTrace();
+ return;
+ }
+ JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, URLs.url_favorite_create, params, new Response.Listener() {
+ @Override
+ public void onResponse(JSONObject response) {
+ try{
+ Boolean isSuccess = response.getBoolean("success");
+ int statusCode = response.getInt("statusCode");
+ Log.v("welfareInfo create favorite info", "true");
+ Log.v("welfareInfo create favorite, isSuccess", isSuccess.toString());
+ Log.v("welfareInfo create favorite, statusCode", Integer.toString(statusCode));
}
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- error.printStackTrace();
+ catch(JSONException err){
+ err.printStackTrace();
}
- });
-
- Toast.makeText(buttonView.getContext(), "내 관심복지 리스트에 등록되었습니다.", Toast.LENGTH_LONG).show();
- VolleySingleton.getInstance(buttonView.getContext()).addToRequestQueue(jsonObjectRequest);
- }
- else{
-
- JSONObject params = new JSONObject();
- try{
- params.put("token", token);
- params.put("welfare_id", welfare_id);
}
- catch(JSONException err)
- {
- err.printStackTrace();
- return;
+ }, new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ error.printStackTrace();
}
- JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, URLs.url_favorite_delete, params, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- try{
- Boolean isSuccess = response.getBoolean("success");
- int statusCode = response.getInt("statusCode");
- Log.v("welfareInfo delete favorite info", "true");
- Log.v("welfareInfo delete favorite, isSuccess", isSuccess.toString());
- Log.v("welfareInfo delete favorite, statusCode", Integer.toString(statusCode));
- }
- catch(JSONException err){
- err.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- error.printStackTrace();
- }
- });
-
- Toast.makeText(buttonView.getContext(), "내 관심복지 리스트에서 삭제되었습니다.", Toast.LENGTH_LONG).show();
- VolleySingleton.getInstance(buttonView.getContext()).addToRequestQueue(jsonObjectRequest);
+ });
+ if(holder.toggle_favorite.isChecked()){
+ Toast.makeText(holder.toggle_favorite.getContext(), "내 관심복지 리스트에 등록되었습니다.", Toast.LENGTH_SHORT).show();
+ }
+ else{
+ Toast.makeText(holder.toggle_favorite.getContext(), "내 관심복지 리스트에서 삭제되었습니다.", Toast.LENGTH_SHORT).show();
}
+ VolleySingleton.getInstance(holder.toggle_favorite.getContext()).addToRequestQueue(jsonObjectRequest);
}
});
}
diff --git a/client/app/src/main/res/font/font.xml b/client/app/src/main/res/font/font.xml
index 42e3c5d..982118e 100644
--- a/client/app/src/main/res/font/font.xml
+++ b/client/app/src/main/res/font/font.xml
@@ -4,5 +4,6 @@
+ android:font = "@font/noto_sans_kr_medium"
+ />
\ No newline at end of file
diff --git a/client/app/src/main/res/layout/activity_intro.xml b/client/app/src/main/res/layout/activity_intro.xml
index 7ff26aa..a19dee5 100644
--- a/client/app/src/main/res/layout/activity_intro.xml
+++ b/client/app/src/main/res/layout/activity_intro.xml
@@ -6,15 +6,16 @@
android:layout_height="match_parent"
android:background="@drawable/intro_background_fit"
tools:context=".IntroActivity">
+
+ android:layout_width="240dp"
+ android:layout_height ="wrap_content"
+ android:text=" 모두의 복지로 간편하게 찾아보세요">
diff --git a/client/app/src/main/res/layout/activity_main.xml b/client/app/src/main/res/layout/activity_main.xml
index 1e2306b..893cc6d 100644
--- a/client/app/src/main/res/layout/activity_main.xml
+++ b/client/app/src/main/res/layout/activity_main.xml
@@ -30,6 +30,7 @@
android:id = "@+id/main_title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
@@ -45,6 +46,7 @@
android:id = "@+id/sub_title"
app:layout_constraintTop_toBottomOf="@id/main_title"
app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/list_container"
android:layout_marginLeft="25dp"
android:layout_marginTop="-20dp"
android:layout_width="wrap_content"
@@ -54,40 +56,53 @@
android:textSize="12sp"
android:textColor="#99FFFFFF"
android:lineSpacingExtra="5sp"
- android:text="총 10개의 복지가 있습니다"/>
+ android:text="총 0개의 복지가 있습니다"/>
-
+ android:minHeight="300dp"
+ android:layout_height="wrap_content">
+
+ android:minHeight="230dp"
+ android:layout_height="wrap_content"/>
-
+
diff --git a/client/app/src/main/res/layout/activity_my_profile.xml b/client/app/src/main/res/layout/activity_my_profile.xml
index 43c7496..99ab344 100644
--- a/client/app/src/main/res/layout/activity_my_profile.xml
+++ b/client/app/src/main/res/layout/activity_my_profile.xml
@@ -132,9 +132,9 @@
android:textSize="12sp"
android:textColor="#000000"
android:id = "@+id/text_num_list"
- android:text="총 10개의 복지가 있습니다"/>
+ android:text="총 0개의 복지가 있습니다"/>
-
+ android:minHeight="220dp"
+ android:layout_height="wrap_content"/>
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{
+// res.send(JSON.stringify({
+// "success": true,
+// "statusCode" : 200,
+// "message_content": "인공지능 채팅 서비스는 5월 중 업데이트 예정입니다."
+// }));
+// }
+
exports.counseling = (req, res, next) => {
// 토큰 복호화
const user_info = jwt.verify(req.body.token, secretObj);
@@ -50,9 +61,43 @@ exports.counseling = (req, res, next) => {
})
}
+// Recommend Dummy API
+// exports.get_wel_rcmd = (req, res, next) => {
+// let dummy_wel_list = [1, 2, 3]
+// let category_list = []
+
+// Welfare_category.findAll({where:{welfare_id:dummy_wel_list}})
+// .then(result => {
+// console.log(result);
+// result.forEach(element => {
+// category_list.push(element.category_id);
+// })
+// })
+// .then(() => {
+// Welfare.findAll({where: {welfare_id: dummy_wel_list}, raw: true})
+// .then(result => {
+// result.forEach(element => {
+// element.isLiked = false;
+// });
+// result.forEach(element => {
+// element.category = category_list.pop();
+// });
+// return result;
+// })
+// .then(result => {
+// res.send(JSON.stringify({
+// "success": true,
+// "statusCode" : 200,
+// "welfare_info": result
+// }));
+// })
+// })
+// }
+
exports.get_wel_rcmd = (req, res, next) => {
// 토큰 복호화
const user_info = jwt.verify(req.body.token, secretObj);
+ let category_list = []
// Request로부터 user message 추출
let user_message = req.body.chat_message;
@@ -84,34 +129,49 @@ exports.get_wel_rcmd = (req, res, next) => {
kobertResponse = body;
const welfareIdsKobert = kobertResponse.recommend;
- Welfare.findAll({where: { welfare_id: welfareIdsKobert }, raw: true})
- .then(result=>{
- // 해당 welfare 정보가 user가 찜을 한 것인지 검사하고 isLiked attribute 추가
- result.forEach(element => {
- if(likedWelfareIds.includes(element.welfare_id)){
- element.isLiked = true;
- }
- else {
- element.isLiked = false;
- }
- });
- return result;
- })
+ Welfare_category.findAll({where:{welfare_id:welfareIdsKobert}})
.then(result => {
- // App으로 Response를 보낸다.
- res.send(JSON.stringify({
- "success": true,
- "statusCode" : 200,
- "welfare_info": result
- }));
- })
- .catch(err => {
- console.log(err);
+ result.forEach(element => {
+ category_list.push(element.category_id);
+ })
})
+ .then(() => {
+ Welfare.findAll({where: { welfare_id: welfareIdsKobert }, raw: true})
+ .then(result=>{
+ // 해당 welfare 정보가 user가 찜을 한 것인지 검사하고 isLiked attribute 추가
+ result.forEach(element => {
+ if(likedWelfareIds.includes(element.welfare_id)){
+ element.isLiked = true;
+ }
+ else {
+ element.isLiked = false;
+ }
+ });
+ idx = 0;
+ result.forEach(element => {
+ element.category = category_list[idx];
+ idx += 1;
+ });
+ return result;
+ })
+ .then(result => {
+ // App으로 Response를 보낸다.
+ res.send(JSON.stringify({
+ "success": true,
+ "statusCode" : 200,
+ "welfare_info": result
+ }));
+ })
+ .catch(err => {
+ console.log(err);
+ })
+
+ });
}
});
}
+
/*
Chatbot Server API
diff --git a/server/controllers/welfareController.js b/server/controllers/welfareController.js
index 02db4b0..5112c8c 100644
--- a/server/controllers/welfareController.js
+++ b/server/controllers/welfareController.js
@@ -176,6 +176,26 @@ exports.searchWelfare = (req, res, next) => {
"welfare" : ["welfareid1","welfareid2","welfareid3","welfareid4","welfareid5","welfareid6"]
}
*/
+// exports.recommendedWelfare = (req, res, next) => {
+// let dummy_wel_list = [0, 1, 2, 3, 4, 5]
+
+// Welfare.findAll({where: {welfare_id: dummy_wel_list}, raw: true})
+// .then(result => {
+// result.forEach(element => {
+// element.isLiked = false;
+// });
+// return result;
+// })
+// .then(result => {
+// res.send(JSON.stringify({
+// "success" : true,
+// "statusCode": 200,
+// "recommend_welfare_list" :result,
+// "token" : req.body.token
+// }));
+// })
+// }
+
exports.recommendedWelfare = (req, res, next) => {
// 토큰 복호화
const user_info = jwt.verify(req.body.token, secretObj);
@@ -202,39 +222,55 @@ exports.recommendedWelfare = (req, res, next) => {
});
})
+ let category_list = [];
+
// Request를 보내서 추천 복지정보 Response로 얻는다.
request(options, function (error, response, body) {
let welfare_list = []
if (!error && response.statusCode == 200) {
- Welfare.findAll({where: {welfare_id:body['welfare']}, raw: true})
+ Welfare_category.findAll({where:{welfare_id:body['welfare']}})
.then(result => {
- welfare_list = result;
- Welfare_category.findAll({where:{welfare_id:body['welfare']}, raw: true})
- .then(result=>{
- result.forEach(element1 => {
- welfare_list.forEach(element2 => {
- // AI로부터 추천받은 복지 정보가 사용자가 찜한 복지정보인지 검사하고 isLiked attribute 추가
- if(element1.welfare_id == element2.welfare_id){
- element2.category = element1.category_id
- }
- if(likedWelfareIds.includes(element2.welfare_id)){
- element2.isLiked = true;
- }
- else {
- element2.isLiked = false;
- }
- })
- });
+ result.forEach(element => {
+ category_list.push(element.category_id);
})
- .then(()=>{
- // App에 Repsonse 보내기
- res.send(JSON.stringify({
- "success" : true,
- "statusCode": 200,
- "recommend_welfare_list" :welfare_list,
- "token" : req.body.token
- }));
+ })
+ .then(() => {
+ Welfare.findAll({where: {welfare_id:body['welfare']}, raw: true})
+ .then(result => {
+ welfare_list = result;
+ Welfare_category.findAll({where:{welfare_id:body['welfare']}, raw: true})
+ .then(result=>{
+ result.forEach(element1 => {
+ welfare_list.forEach(element2 => {
+ // AI로부터 추천받은 복지 정보가 사용자가 찜한 복지정보인지 검사하고 isLiked attribute 추가
+ if(element1.welfare_id == element2.welfare_id){
+ element2.category = element1.category_id
+ }
+ if(likedWelfareIds.includes(element2.welfare_id)){
+ element2.isLiked = true;
+ }
+ else {
+ element2.isLiked = false;
+ }
+ })
+ let idx = 0;
+ welfare_list.forEach(element => {
+ element.category = category_list[idx];
+ idx += 1;
+ });
+ });
+ })
+ .then(()=>{
+ // App에 Repsonse 보내기
+ res.send(JSON.stringify({
+ "success" : true,
+ "statusCode": 200,
+ "recommend_welfare_list" :welfare_list,
+ "token" : req.body.token
+ }));
+ })
})
+
})
}