Skip to content
Merged

. #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,6 @@ fabric.properties
!/gradle/wrapper/gradle-wrapper.jar

# End of https://www.toptal.com/developers/gitignore/api/macos,gradle,androidstudio,android,java
=======
/build
>>>>>>> ce01560af1ee5d401f95b7d0e4eb8569aa810f83
58 changes: 52 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,56 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'com.android.application'
}

android {
compileSdk 32

defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
dependencies {
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
}
}

task clean(type: Delete) {
delete rootProject.buildDir
dependencies {

implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'

implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0'
implementation 'androidx.navigation:navigation-fragment:2.5.0'
implementation 'androidx.navigation:navigation-ui:2.5.0'
implementation 'com.android.volley:volley:1.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
21 changes: 21 additions & 0 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.myapplication;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.myapplication", appContext.getPackageName());
}
}
38 changes: 38 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myapplication">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication"
tools:targetApi="31">
<activity
android:name=".ui.login.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.mainPage.MainActivity" />
<activity android:name=".ui.mainPage.NewActivity" />
<activity android:name=".ui.mainPage.ChatbotWeb" />
<activity android:name=".ui.join.JoinActivity" />
<activity android:name=".ui.setting.SettingActivity" />
<activity android:name=".ui.join.PasswordChangeActivity" />
<activity android:name=".ui.petSelect.PetSelectActivity" />
<activity android:name=".ui.petSelect.AddPetActivity" />
<activity android:name=".ui.setting.PetProfileActivity" />
<activity android:name=".ui.setting.ProfileActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.myapplication.ui.ServiceSetting;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

//HTTP 통신에 사용하는 Request 객체 생성.
public class AuthenticationInterceptor implements Interceptor {

private String authToken;

public AuthenticationInterceptor(String token) {
this.authToken = token;
}

@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();

Request.Builder builder = original.newBuilder()
.header("Authorization", authToken);

Request request = builder.build();
return chain.proceed(request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.example.myapplication.ui.ServiceSetting;

import com.example.myapplication.ui.join.EmailCodeData;
import com.example.myapplication.ui.join.EmailValidationData;
import com.example.myapplication.ui.join.JoinData;
import com.example.myapplication.ui.join.JoinResponse;
import com.example.myapplication.ui.login.LoginRequest;
import com.example.myapplication.ui.login.LoginResponse;
import com.example.myapplication.ui.setting.PetinfoData;
import com.example.myapplication.ui.setting.ProfileResponse;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;

public interface ServiceAPI {
//로그인
@POST("/login")
Call<LoginResponse> getLoginResponse(@Body LoginRequest loginRequest);

@POST("/enterEmailCode/join")
Call<JoinResponse> userJoin(@Body JoinData data);

@POST("/sendEmail")
Call<JoinResponse> sendEmail(@Body EmailValidationData data);

@POST("/validateDuplicateEmail")
Call<JoinResponse> emailValidation(@Body EmailValidationData data);

@POST("/changePw") //정보 수정.. put으로 가능함!
Call<JoinResponse> changePw(@Body LoginRequest data);

@POST("/enterEmailCode/changePw")
Call<JoinResponse> enterEmailCode(@Body EmailCodeData data);

//반려동물 정보 등록, 초기 셋팅값
@POST("/PetSelect")
Call<ProfileResponse> getPetinfo(@Body PetinfoData petinfoData);

//회원 탈퇴
@DELETE("/Profile/{memberEmail}")
Call<ProfileResponse> deletePost(@Path("memberEmail")int id);

//반려동물 정보 수정
@PUT("/Profile/{petAge}")
Call<ProfileResponse> updatePetPost(@Path("petAge") String petAge,
@Body PetinfoData petinfoData);

//반려동물 삭제
@DELETE("/Profile/{petName}")
Call<ProfileResponse> deletePetPost(@Path("petName")int name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.example.myapplication.ui.ServiceSetting;

import android.text.TextUtils;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class ServiceGenerator {

public static final String BASE_URL = "https://12b969e5-87a6-4fca-a942-178ea253fdbc.mock.pstmn.io";
//옌 post 서버 : https://12b969e5-87a6-4fca-a942-178ea253fdbc.mock.pstmn.io
//주현 서버 : https://7919ceb2-3999-4ed8-8bcc-16baaf4e62d4.mock.pstmn.io

private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

private static Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create());

private static Retrofit retrofit = builder.build();

public static <S> S createService(Class<S> serviceClass) {
return createService(serviceClass, null);
}

public static <S> S createService(
Class<S> serviceClass, final String authToken) {
if (!TextUtils.isEmpty(authToken)) {
AuthenticationInterceptor interceptor =
new AuthenticationInterceptor("Bearer " + authToken);

if (!httpClient.interceptors().contains(interceptor)) {
httpClient.addInterceptor(interceptor);

builder.client(httpClient.build());
retrofit = builder.build();
}
}

return retrofit.create(serviceClass);
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/example/myapplication/ui/join/EmailCodeData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.myapplication.ui.join;

import com.google.gson.annotations.SerializedName;

public class EmailCodeData {
@SerializedName("sendCode")
private int sendCode;

@SerializedName("receivedCode")
private int receivedCode;

public EmailCodeData(int sendCode, int receivedCode) {
this.sendCode = sendCode;
this.receivedCode = receivedCode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.myapplication.ui.join;

import com.google.gson.annotations.SerializedName;

public class EmailValidationData {
@SerializedName("receiveMail")
private String userEmail;

public EmailValidationData(String userEmail) {
this.userEmail = userEmail;
}
}
Loading