Skip to content

Commit

Permalink
feat : capture image
Browse files Browse the repository at this point in the history
  • Loading branch information
오원석 authored and 오원석 committed Sep 4, 2019
1 parent 8179601 commit 96a9b31
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 52 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified FashionToday_App/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions FashionToday_App/Pashion_Today/.idea/vcs.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,32 @@ import okhttp3.*
import org.json.JSONArray
import java.io.IOException

// 로그인 화면
/*****
* 프로그램 ID : HAM-PA-100
* 프로그램명 : LoginActivity.kt
* 작성자명 : 오원석
* 작성일자 : 2019.09.01
* 버전 : v0.1
*/
class LoginActivity : AppCompatActivity() {

// 모든 유저리스트
var user_list=ArrayList<HashMap<String,String>>()

override fun onCreate(savedInstanceState: Bundle?) {
// 액티비티 생성 메소드
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.login_acitivity)


// 회원가입 버튼 메서드
RegisterButton.setOnClickListener { view->
var intent= Intent(this, RegisterActivity::class.java)
startActivity(intent)
Register_button.setOnClickListener { view->
var register_intent= Intent(this, RegisterActivity::class.java)
startActivity(register_intent)
}

// 로그인 버튼 메서드
LoginButton.setOnClickListener { view->
Login_button.setOnClickListener { view->
/*var thread=getDataThread()
thread.start()
Expand All @@ -53,12 +61,12 @@ class LoginActivity : AppCompatActivity() {
var t1=Toast.makeText(this,"존재하지 않은 아이디입니다",Toast.LENGTH_SHORT)
t1.show()
}*/
if("ppp"==IdText.text.toString()){
if("ppp"==PasswordText.text.toString()){
var t1= Toast.makeText(this,"로그인 되었습니다", Toast.LENGTH_SHORT)
t1.show()
var intent=Intent(this, PashionActivity::class.java)
startActivity(intent)
if("ppp"==Login_user_id.text.toString()){
if("ppp"==Login_user_pw.text.toString()){
var toast_msg= Toast.makeText(this,"로그인 되었습니다", Toast.LENGTH_SHORT)
toast_msg.show()
var pashion_intent=Intent(this, PashionActivity::class.java)
startActivity(pashion_intent)

}
}
Expand All @@ -73,30 +81,30 @@ class LoginActivity : AppCompatActivity() {
var builder= Request.Builder()
var url=builder.url("http://172.30.1.22:8085/SomaServer/get_list.jsp")
var request=url.build()
var callback=Callback1()
var get_user_callback=Get_user_Callback()

client.newCall(request).enqueue(callback)
client.newCall(request).enqueue(get_user_callback)
}
}

// 데이터 받는 쓰레드
inner class Callback1: Callback {
inner class Get_user_Callback: Callback {
override fun onFailure(call: Call, e: IOException) {

}

override fun onResponse(call: Call, response: Response) {
var result=response.body?.string()
var response_result=response.body?.string()

user_list.clear()

var root= JSONArray(result)
var temp_user_list= JSONArray(response_result)

for(i in 0 until root.length()){
var obj=root.getJSONObject(i)
for(i in 0 until temp_user_list.length()){
var user_obj=temp_user_list.getJSONObject(i)

var user_id=obj.getString("user_id")
var user_password=obj.getString("user_passwo rd")
var user_id=user_obj.getString("user_id")
var user_password=user_obj.getString("user_passwo rd")

var map=HashMap<String,String>()
map.put("user_id",user_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ import kotlinx.android.synthetic.main.register_activity.*
import okhttp3.*
import java.io.IOException

// 회원가입 화면
/*****
* 프로그램 ID : HAM-PA-200
* 프로그램명 : RegisterActivity.kt
* 작성자명 : 오원석
* 작성일자 : 2019.09.01
* 버전 : v0.1
*/
class RegisterActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.register_activity)

// 회원가입하기 버튼 구현
registerButton.setOnClickListener { view->
Register_finish_button.setOnClickListener { view->
// 여기서 회원가입 중복 판단 후 중복이 되지 않은 경우 서버에 연결
var builder= AlertDialog.Builder(this)
if(idText.text.toString()!="ows"){
if(Register_user_id.text.toString()!="ows"){

builder.setMessage("회원가입 성공")
builder.setPositiveButton("확인",null)
Expand Down Expand Up @@ -48,10 +54,10 @@ class RegisterActivity : AppCompatActivity() {
// 서버에게 멀티 바디 객체로 사용하겠다고 전달
multipart_builder.setType(MultipartBody.FORM)

multipart_builder.addFormDataPart("userId",idText.text.toString())
multipart_builder.addFormDataPart("userPassword",passwordText.text.toString())
multipart_builder.addFormDataPart("userName",nameText.text.toString())
multipart_builder.addFormDataPart("userAge",ageText.text.toString())
multipart_builder.addFormDataPart("userId",Register_user_id.text.toString())
multipart_builder.addFormDataPart("userPassword",Register_user_pw.text.toString())
multipart_builder.addFormDataPart("userName",Register_user_name.text.toString())
multipart_builder.addFormDataPart("userAge",Register_user_age.text.toString())

var body=multipart_builder.build()
var post=url.post(body)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package com.example.pashion_today.Page

import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.CalendarView
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.widget.Toolbar
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import com.example.pashion_today.R
import com.google.android.material.navigation.NavigationView



/*****
* 프로그램 ID : HAM-PA-500
* 프로그램명 : CalendarActivity.kt
* 작성자명 : 오원석
* 작성일자 : 2019.09.01
* 버전 : v0.1
*/
class CalendarActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {


Expand All @@ -21,6 +32,12 @@ class CalendarActivity : AppCompatActivity(), NavigationView.OnNavigationItemSel
setSupportActionBar(toolbar)


var calendar=findViewById<CalendarView>(R.id.calendarView)





val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view)
val toggle = ActionBarDrawerToggle(
Expand Down Expand Up @@ -87,3 +104,4 @@ class CalendarActivity : AppCompatActivity(), NavigationView.OnNavigationItemSel
return true
}
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.example.pashion_today.Page

import android.Manifest
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -20,15 +26,26 @@ import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import com.example.pashion_today.R
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.closet_camera.*
import kotlinx.android.synthetic.main.closet_camera.view.*
import kotlinx.android.synthetic.main.closet_content.*
import java.io.File


// 옷장 화면
/*****
* 프로그램 ID : HAM-PA-400
* 프로그램명 : ClosetActivity.kt
* 작성자명 : 오원석
* 작성일자 : 2019.09.04
* 버전 : v0.1
*/
class ClosetActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {

val CAMERA_ACTIVITY=1

// 옷 타입 분류 변수
var clothes_type = arrayOf("전체","상의","하의","신발")
var color_type=arrayOf("","","","","","","")
// 임시 변수
var closet_list= intArrayOf(
R.drawable.top,
Expand All @@ -48,10 +65,11 @@ class ClosetActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelec
Manifest.permission.WRITE_EXTERNAL_STORAGE
)

// 경로
// 폴더경로
var dirPath:String?=null
// 파일의 전체경로
// 파일의 전체 uri
var contentUri:Uri?=null
// 파일 전체경로
var pic_path:String?=null

// 액티비티 create 메서드
Expand Down Expand Up @@ -173,8 +191,6 @@ class ClosetActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelec

}
}


}

// back버튼 클릭 메서드
Expand Down Expand Up @@ -207,7 +223,7 @@ class ClosetActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelec
requestPermissions(permission_list,0)
}
else{
init()
camera_capture()
}
}
}
Expand All @@ -221,7 +237,7 @@ class ClosetActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelec
return
}
}
init()
camera_capture()
}

override fun onNavigationItemSelected(item: MenuItem): Boolean {
Expand Down Expand Up @@ -255,7 +271,8 @@ class ClosetActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelec
return true
}

fun init(){
fun camera_capture(){


var tempPath=Environment.getExternalStorageDirectory().absolutePath
dirPath="${tempPath}/Android/data/${packageName}"
Expand All @@ -281,7 +298,57 @@ class ClosetActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelec
contentUri=Uri.fromFile(file2)
}
camera_intent.putExtra(MediaStore.EXTRA_OUTPUT,contentUri)
startActivityForResult(camera_intent,1)
startActivityForResult(camera_intent,CAMERA_ACTIVITY)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

if(requestCode== CAMERA_ACTIVITY){

if(resultCode== Activity.RESULT_OK){



var builder=AlertDialog.Builder(this)
builder.setTitle(" 옷 등록 ")

var v1=layoutInflater.inflate(R.layout.closet_camera,null)

var type_adapter=ArrayAdapter(this,android.R.layout.simple_spinner_item,clothes_type)
type_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
v1.type_spinner.adapter=type_adapter

var color_adapter=ArrayAdapter(this,android.R.layout.simple_spinner_item,color_type)
color_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
v1.color_spinner.adapter=color_adapter

var bitmap=BitmapFactory.decodeFile(contentUri?.path)
v1.capture_img.setImageBitmap(bitmap)

builder.setView(v1)

var listener=object:DialogInterface.OnClickListener{
override fun onClick(p0: DialogInterface?, p1: Int) {
when(p1){
DialogInterface.BUTTON_POSITIVE->{

}
DialogInterface.BUTTON_NEUTRAL->{

}
}
}
}

builder.setNeutralButton("취소",null)
builder.setPositiveButton("확인",null)

builder.show()


}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import androidx.appcompat.widget.Toolbar
import android.view.Menu
import com.example.pashion_today.R


/*****
* 프로그램 ID : HAM-PA-300
* 프로그램명 : PashionActivity.kt
* 작성자명 : 오원석
* 작성일자 : 2019.09.01
* 버전 : v0.1
*/
class PashionActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
android:id="@+id/container"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/calendar_app_bar"
tools:context=".Page.CalendarActivity">
<TextView
android:text="캘린더입니다"
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="80dp"
tools:layout_editor_absoluteX="37dp" android:id="@+id/textView4"/>
tools:context=".Page.CalendarActivity" android:orientation="vertical">
<CalendarView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/calendarView" android:minDate="01/01/2019"
android:layout_marginTop="30dp"/>
</LinearLayout>
Loading

0 comments on commit 96a9b31

Please sign in to comment.