Skip to content
Open
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
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
Expand All @@ -16,6 +19,25 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
// Main source set is Kotlin!
main.java.srcDirs += 'src/main/kotlin'

// Unit tests live in src/unitTest.
test.java.srcDir 'src/unitTests/kotlin'

// Integration tests live in src/integrationTest.
test.java.srcDir 'src/integrationTests/kotlin'

// Unit tests for debug build type specific code live in src/debugUnitTest.
testDebug.java.srcDir 'src/debugUnitTests/kotlin'

// Unit tests for release build type specific code live in src/releaseUnitTest.
testRelease.java.srcDir 'src/releaseUnitTests/kotlin'

// Functional tests live in src/functionalTests.
androidTest.java.srcDir 'src/functionalTests/kotlin'
}
}

dependencies {
Expand All @@ -25,6 +47,7 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dsm2018.get_terra_android_v2">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
android:theme="@style/AppTheme">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
package com.dsm2018.get_terra_android_v2.Connector;

import android.content.Intent;

import com.google.gson.JsonObject;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Path;

public interface API {
@GET("/auth/{gameKey}")
Call<JsonObject> key_certified(@Header("gameKey") Integer jsonObject);

@POST("/auth/{gameKey}")
Call<JsonObject> login(
@Path("gameKey") String gameKey,
@Body JsonObject jsonObject);

@GET("/team")
Call<JsonObject> teamList(@Header("Authorization") String jsonObject);

@POST("/team")
Call<Void> team_choice(@Body JsonObject jsonObject);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

public class Connector {


}
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package com.dsm2018.get_terra_android_v2.Connector;

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

public class ServiceGenerator {

private static final String URL = "http://localhost:5000/";
private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
private static Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient.build());
private static Retrofit retrofit = builder.build();
private static final String URL = "http://ec2.istruly.sexy:1234/";

public static <S> S createService(Class<S> serviceClass) {
return retrofit.create(serviceClass);
private static Retrofit retrofit = null;
public static Retrofit getClient() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
return retrofit;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,93 @@
package com.dsm2018.get_terra_android_v2;

public class LoginActivity {
}
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.dsm2018.get_terra_android_v2.Connector.API;
import com.dsm2018.get_terra_android_v2.Connector.ServiceGenerator;
import com.dsm2018.get_terra_android_v2.sibal.PrefManager;
import com.google.gson.JsonObject;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


public class LoginActivity extends AppCompatActivity {
Button login;
EditText key_certificate;
EditText email;
EditText ID;
EditText password;
String getID;
String getPassword;
String getKeyCertificate;
String getEmail;
String getAccessToken;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

key_certificate = (EditText) findViewById(R.id.key_certificate_et);
login = (Button) findViewById(R.id.login_btn);
ID = (EditText) findViewById(R.id.id_et);
password = (EditText) findViewById(R.id.password_et);
email = (EditText) findViewById(R.id.email_et);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getID = ID.getText().toString();
getPassword = password.getText().toString();
getKeyCertificate = key_certificate.getText().toString();
getEmail = email.getText().toString();
getID = getID.trim();
getPassword = getPassword.trim();
getKeyCertificate = getKeyCertificate.trim();
getEmail = getEmail.trim();
if (getID.getBytes().length <= 0 | getPassword.getBytes().length <= 0 | getKeyCertificate.getBytes().length <= 0 | getEmail.getBytes().length <= 0) {
Toast.makeText(getApplicationContext(), "입력이 완료되지 않았습니다", Toast.LENGTH_SHORT).show();
} else {
post();
}
}
});
}

public void post() {
API retrofit = ServiceGenerator.getClient().create(API.class);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("id", getID);
jsonObject.addProperty("password", getPassword);
jsonObject.addProperty("email", getEmail);
Call<JsonObject> call = retrofit.login(getKeyCertificate, jsonObject);
call.enqueue(new Callback<JsonObject>() {
@Override
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
JsonObject repo = response.body();
getAccessToken=repo.get("accessToken").getAsString();
if (response.code() == 200) {
Intent intent = new Intent(LoginActivity.this, TeamChoiceActivity.class);
intent.putExtra("accessToken", getAccessToken);
startActivity(intent);
} else if (response.code() == 204) {
Toast.makeText(getApplicationContext(), "인증번호가 맞지 않습니다.", Toast.LENGTH_SHORT).show();
}
PrefManager prefManager = new PrefManager();
prefManager.saveToken(getApplicationContext(), getAccessToken, true);
}

@Override
public void onFailure(Call<JsonObject> call, Throwable t) {

}
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.dsm2018.get_terra_android_v2;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class TeamChoiceActivity extends AppCompatActivity {
Button teamblue, teamgreen, teamyellow, teamviolet;
String getToken;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teamchoice);

getToken = getIntent().getStringExtra("accessToken");
teamblue = (Button)findViewById(R.id.teamblue_btn);
teamblue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent1 = new Intent(TeamChoiceActivity.this,TeamMemberActivity.class);
intent1.putExtra("teamNum","1");
intent1.putExtra("accessToken",getToken);
startActivity(intent1);
}
});
teamgreen = (Button)findViewById(R.id.teamgreen_btn);
teamgreen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent2 = new Intent(TeamChoiceActivity.this,TeamMemberActivity.class);
intent2.putExtra("teamNum","2");
intent2.putExtra("accessToken",getToken);
startActivity(intent2);
}
});
teamyellow = (Button)findViewById(R.id.teamyellow_btn);
teamyellow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent3 = new Intent(TeamChoiceActivity.this,TeamMemberActivity.class);
intent3.putExtra("teamNum","3");
intent3.putExtra("accessToken",getToken);
startActivity(intent3);
}
});
teamviolet = (Button)findViewById(R.id.teamviolet_btn);
teamviolet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent4 = new Intent(TeamChoiceActivity.this,TeamMemberActivity.class);
intent4.putExtra("teamNum","4");
intent4.putExtra("accessToken",getToken);
startActivity(intent4);
}
});

}

}
Loading