This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 순서 | |
*** 시간이 지난 자료라 현재 document에서 제공하는 코드와 다르기 때문에 하단 코드를 이용하기 바람 | |
1. project 시작 | |
2. Firebase 프로젝트 시작 -> 안드로이드 기기 연결 클릭 -> 디버그 인증서 출력(Manifest내 Gradle -> 프로젝트 -> android -> signingReport -> SHA1값 복붙 | |
-> JSON 파일은 APP 디렉토리에 삽입 -> classpath 및 apply plugin 입력 | |
3. Firebase 문서로 이동 -> 인증 -> 구글 로그인 -> 앱 수준 gradle에 코드 복사 | |
4. 레이아웃 생성(SignButton 활용) | |
5. 메인 클래스에서 선언 및 호출 + setOn... 호출 | |
6. 문서 창 내 파이어베이스로 인증하기 코드 복붙하기 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. 이메일, 비밀번호 기능 활성화 | |
2. 레이아웃에 EditText로 Emadil 및 Password 만들기 + Button 만들기 + id 및 힌트 삽입 | |
3. firebase 문서로 이동 - 비밀번호 인증으로 이동 | |
* createUserWith...Password 인스턴스 메소드 복사 -> createUser라는 새로운 메소드를 생성하고 바디 부분에 입력. 해당 메소드의 파라미터 값은 둘 다 String | |
* if 문은 로그인 실패의 경우니까 return을 시키던 try ~ catch 구문을 쓰던 알아서 하자. | |
* else문 써서 Toast 기능 활성화 시킵니다 | |
* Tag 삭제합니다. | |
4. 생성한 요소들 호출하고 버튼 바디 부분에 생성 메소드를 입력합니다. | |
5. 디자인을 위해 디자인 라이브러리를 불러옵니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
기존 프로젝트를 불러옵니다. | |
Firebase 문서 - 인증 - Facebook 로그인 접속으로 이동합니다. | |
1. 시작하기 전에 - 5번 c 항목 리디렉션 부분으로 이동합니다. 페이스북 개발자 사이트로 이동됩니다. | |
2. 시작하기 - 정보 입력 - 등록 - 내 앱으로 이동 - 새로운 앱 추가 | |
3. 파이어베이스 auth - 로그인 방법에 페이스북 추가 - 페이스북 개발자 사이트에 설정 - 기본 설정 - 앱 id와 시크릿 코드 복사해서 파이어베이스 입력란에 삽입 | |
4. 고급 설정 - 파이어베이스 사이트의 리디렉션 코드를 붙여넣고 저장 - 다시 로그인 기능으로 이동 - 페이스북 sdk 다운(선택 사항 - 불러오기 가능합니다) - 가져오기(2) 란의 코드를 안드로이드 스튜디오에 복붙. | |
5. project 및 app 단계에 필요한 요소들을 붙입니다. | |
6. 패키지 이름을 저장합니다. 기본 액티비티 클래스 이름에는 패키지 이름.MainActivity를 입력합니다. | |
패키지 이름과 관련한 오류가 발생하지만 테스트 중이므로 넘어갑니다. | |
7. 릴리스 해시 추가 탭의 openssl-for-windows openssl 라이브러리를 다운받습니다. 그리고 안드로이드 스튜디오 터미널에 해당 코드를 입력합니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Firebase Auth Listener | |
: 객체와 객체간에 데이터를 주고 받는 것. 데이터를 넘겨 줬을 때 “~ 해” 이런 식으로 사용 가능 | |
-> 로그인 시 아이디/비밀번호 값을 넘겨주면 서버에서 확인 후 로그인 진행하는 기능을 사용할 수 있습니다. | |
-> 아이디 중복 시 에러를 방지할 수 있습니다. | |
// 예전 문서에 기반하므로 코드를 보고 하는 편이 낫습니다. | |
1. 파이어베이스 문서로 이동합니다. 비밀번호 인증 탭으로 이동합니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5. 파이어베이스에 데이터 저장하기 | |
● 스토리지(문서, 이미지, 영상)를 활용합니다. | |
1. 기존 drawer 레이아웃을 활용할 수 있으므로 HomeActivity의 id가 gallery인 부분에 사진을 불러오는 코드를 작성합니다. | |
Intent intent = new Intent(Intent.ACTION_PICK); | |
intent.setType(MediaStore.Images.Media.CONTENT_TYPE); | |
// 상수 입력이 필요합니다. 10으로 넣습니다. | |
startActivityForResult(intent,GALLERY_CODE); | |
2. 이미지를 누르면 결과값을 불러오므로 onActivityResult 메소드를 오버라이딩합니다. 내부 코드는 다음과 같습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6. Firebase – setValue | |
- 스토리지 및 DB에 데이터를 전송했을 경우 해당 데이터에 관한 설명, 내용을 업로드하는 메소드 | |
- 결국 업로드의 추가 기능을 활용하기 위함입니다. | |
● getDownloaduri() 메소드를 사용할 수 없습니다. | |
Firebase에서 더 이상 지원을 하지 않는데, gradle 버전을 다운그레이드 하면 사용 가능합니다(ex – 12.0.1). | |
1. homeActivity 레이아웃으로 이동합니다. | |
인크루드(호출하는)하는 레이아웃으로 이동합니다. 해당 레이아웃에서도 호출하는 레이아웃으로 또 들어갑니다. 이중 접속으로 볼 수 있습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7. Firebase – 데이터 활용 | |
● 저장된 데이터를 불러와 활용할 수 있습니다. | |
● 테스트로 저장된 이미지 데이터들을 불러오겠습니다. | |
1. NavigationView의 import item을 board로 변경합시다. | |
마찬가지로 해당 액티비티 코드로 돌아가 아이디를 변경해준 뒤 코드를 작성합니다. | |
* 프레그먼트를 적용하면 더 좋습니다. 이 부분은 필요할 시 자습해봅시다. | |
2. 일단은 액티비티로 전환하게끔 만들어보겠습니다. 새로운 액티비티를 생성합니다. | |
생성 뒤, 해당 탭을 누를 경우 다음 액티비티로 넘어가도록 Intent를 부여합니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8. Firebase – Transaction | |
● 데이터 입력 중에 업로드 버튼을 눌렀을 경우 이중으로 쌓이는 것을 방지하는 입력 방식 | |
● 페이스북의 좋아요 버튼을 생성할 경우 사용됩니다. | |
1. material.io 사이트로 이동해 favorite 아이콘을 받아옵니다. 이미지 버튼처럼 전환 가능한 아이콘 2개를 PNG로 받아줍니다. | |
2. drawable 폴더에 우클릭 – Reveal in Finder한 뒤, 아까 받은 아이콘 폴더의 android 폴더내의 세부 폴더들을 복사해 붙여줍니다. | |
3. item 레이아웃으로 이동해 하단에 좋아요 버튼을 생성합니다. 이미지 뷰로 생성하면 됩니다. 디폴트 이미지(ex- 빈 하트)를 설정합니다. 사이즈는 wrap이 좋음. id 생성. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9. Firebase – Storage File Delete | |
● 스토리지 파일 삭제입니다. 게시글 삭제는 다음에. | |
● 기존 데이터들을 삭제해야 될 것 같습니다. | |
1. DTO 클래스에 String imageName;을 생성합니다. 해당 이름의 파일을 삭제하겠다는 의미입니다. | |
2. 업로드 메소드 하단의 DTO 인스턴스들을 나열한 곳에 | |
imageDTO.imageName = file.getLastPathSegment()를 입력합니다. | |
파일을 업로드 할 경우 이미지의 이름도 업로드 됩니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10. Firebase – Database Delete | |
● 게시글을 완전히 삭제하는 기능입니다. | |
1. delete_content 메소드에서 코드를 작성합니다. | |
// 이미지 삭제 성공 시 데이터 베이스 값 삭제합니다. | |
private void delete_content(final int position){ | |
storage.getReference().child("images") | |
.child(imageDTOs.get(position).imageName) | |
.delete().addOnSuccessListener(new OnSuccessListener<Void>() { | |
// 데이터 베이스 값 삭제 |
OlderNewer