Showing
18 changed files
with
144 additions
and
43 deletions
... | @@ -5,21 +5,79 @@ import android.content.Intent | ... | @@ -5,21 +5,79 @@ import android.content.Intent |
5 | import android.content.SharedPreferences | 5 | import android.content.SharedPreferences |
6 | import androidx.appcompat.app.AppCompatActivity | 6 | import androidx.appcompat.app.AppCompatActivity |
7 | import android.os.Bundle | 7 | import android.os.Bundle |
8 | +import android.util.Log | ||
8 | import android.widget.TextView | 9 | import android.widget.TextView |
10 | +import android.widget.Toast | ||
9 | import androidx.appcompat.app.AlertDialog | 11 | import androidx.appcompat.app.AlertDialog |
12 | +import com.google.android.gms.tasks.OnCompleteListener | ||
13 | +import com.google.firebase.auth.FirebaseAuth | ||
14 | +import com.google.firebase.database.FirebaseDatabase | ||
15 | +import com.google.firebase.iid.FirebaseInstanceId | ||
10 | import kotlinx.android.synthetic.main.activity_input_profil_second_one.* | 16 | import kotlinx.android.synthetic.main.activity_input_profil_second_one.* |
11 | 17 | ||
12 | class InputProfilSecondOneActivity : AppCompatActivity() { | 18 | class InputProfilSecondOneActivity : AppCompatActivity() { |
13 | 19 | ||
20 | + private val firebaseAuth = FirebaseAuth.getInstance() | ||
21 | + val user_db = FirebaseDatabase.getInstance("https://capstone-vip-user.firebaseio.com/").reference | ||
22 | + | ||
23 | + private fun sendToken(){ | ||
24 | + FirebaseInstanceId.getInstance().instanceId | ||
25 | + .addOnCompleteListener(OnCompleteListener { task -> | ||
26 | + if (!task.isSuccessful) { | ||
27 | + //Log.w(TAG, "getInstanceId failed", task.exception) | ||
28 | + return@OnCompleteListener | ||
29 | + } | ||
30 | + | ||
31 | + // Get new Instance ID token | ||
32 | + tkn = task.result!!.token | ||
33 | + | ||
34 | + // Log and toast | ||
35 | + val msg = getString(R.string.msg_token_fmt, tkn) | ||
36 | + //Log.d(TAG, msg) | ||
37 | + Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() | ||
38 | + }) | ||
39 | + } | ||
40 | + | ||
41 | + private fun writeNewUser(u_id: String, u_token: String, Policy: String?) { | ||
42 | + val user = User(u_token, Policy!!) | ||
43 | + user_db.child(u_id).setValue(user)/// .setValue(user) | ||
44 | + } | ||
45 | + | ||
46 | + | ||
14 | override fun onCreate(savedInstanceState: Bundle?) { | 47 | override fun onCreate(savedInstanceState: Bundle?) { |
15 | super.onCreate(savedInstanceState) | 48 | super.onCreate(savedInstanceState) |
16 | setContentView(R.layout.activity_input_profil_second_one) | 49 | setContentView(R.layout.activity_input_profil_second_one) |
17 | 50 | ||
51 | + val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE) | ||
52 | + val editor: SharedPreferences.Editor=prof.edit() | ||
53 | + | ||
18 | // 1. 툴바 사용 설정 | 54 | // 1. 툴바 사용 설정 |
19 | setSupportActionBar(toolbar) | 55 | setSupportActionBar(toolbar) |
20 | 56 | ||
57 | + //pushing code start | ||
58 | + intent.extras?.let { | ||
59 | + for (key in it.keySet()) { | ||
60 | + val value = intent.extras?.get(key) | ||
61 | + //Log.d(TAG, "Key: $key Value: $value") | ||
62 | + } | ||
63 | + } | ||
64 | + //pushing code end | ||
65 | + | ||
66 | + | ||
21 | skipButton.setOnClickListener { | 67 | skipButton.setOnClickListener { |
22 | - var intent = Intent(this, InputProfilSecondOneActivity::class.java) | 68 | + sendToken() |
69 | + val user=firebaseAuth?.currentUser | ||
70 | + val cat_list=listOf("c1_1") | ||
71 | + val policy_string_list=listOf("") | ||
72 | + var policy_string="" | ||
73 | + prof.getInt("c1_1",1) | ||
74 | + if(prof.getInt("c1_1",1)==1){ | ||
75 | + policy_string=policy_string | ||
76 | + } | ||
77 | + | ||
78 | + writeNewUser(user!!.uid,"$tkn",policy_string) | ||
79 | + | ||
80 | + var intent = Intent(this, SignInActivity::class.java) | ||
23 | startActivity(intent) | 81 | startActivity(intent) |
24 | } | 82 | } |
25 | 83 | ||
... | @@ -53,8 +111,7 @@ class InputProfilSecondOneActivity : AppCompatActivity() { | ... | @@ -53,8 +111,7 @@ class InputProfilSecondOneActivity : AppCompatActivity() { |
53 | startActivity(intent) | 111 | startActivity(intent) |
54 | } | 112 | } |
55 | 113 | ||
56 | - val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE) | 114 | + |
57 | - val editor: SharedPreferences.Editor=prof.edit() | ||
58 | 115 | ||
59 | 116 | ||
60 | nextButton.setOnClickListener { | 117 | nextButton.setOnClickListener { | ... | ... |
... | @@ -14,7 +14,10 @@ import android.view.View | ... | @@ -14,7 +14,10 @@ import android.view.View |
14 | import android.view.ViewGroup | 14 | import android.view.ViewGroup |
15 | import android.widget.ImageView | 15 | import android.widget.ImageView |
16 | import android.widget.Toast | 16 | import android.widget.Toast |
17 | +import com.google.android.gms.tasks.OnCompleteListener | ||
17 | import com.google.firebase.auth.FirebaseAuth | 18 | import com.google.firebase.auth.FirebaseAuth |
19 | +import com.google.firebase.iid.FirebaseInstanceId | ||
20 | +import com.google.firebase.iid.FirebaseInstanceId.getInstance | ||
18 | import kotlinx.android.synthetic.main.activity_main.* | 21 | import kotlinx.android.synthetic.main.activity_main.* |
19 | import org.w3c.dom.Node | 22 | import org.w3c.dom.Node |
20 | import java.lang.Boolean.getBoolean | 23 | import java.lang.Boolean.getBoolean |
... | @@ -28,10 +31,8 @@ class MainActivity : AppCompatActivity() { | ... | @@ -28,10 +31,8 @@ class MainActivity : AppCompatActivity() { |
28 | super.onCreate(savedInstanceState) | 31 | super.onCreate(savedInstanceState) |
29 | setContentView(R.layout.activity_main) | 32 | setContentView(R.layout.activity_main) |
30 | 33 | ||
31 | - | 34 | + emailSigninBtn.setOnClickListener{ |
32 | - emailSigninBtn.setOnClickListener{ | ||
33 | loginEmail() | 35 | loginEmail() |
34 | - | ||
35 | } | 36 | } |
36 | 37 | ||
37 | textview2.setOnClickListener{ | 38 | textview2.setOnClickListener{ |
... | @@ -48,6 +49,8 @@ class MainActivity : AppCompatActivity() { | ... | @@ -48,6 +49,8 @@ class MainActivity : AppCompatActivity() { |
48 | 49 | ||
49 | } | 50 | } |
50 | 51 | ||
52 | + | ||
53 | + | ||
51 | private fun loginEmail(){ | 54 | private fun loginEmail(){ |
52 | firebaseAuth!!.signInWithEmailAndPassword(edit_email.text.toString(), edit_password.text.toString()) | 55 | firebaseAuth!!.signInWithEmailAndPassword(edit_email.text.toString(), edit_password.text.toString()) |
53 | .addOnCompleteListener(this) { | 56 | .addOnCompleteListener(this) { |
... | @@ -62,12 +65,13 @@ class MainActivity : AppCompatActivity() { | ... | @@ -62,12 +65,13 @@ class MainActivity : AppCompatActivity() { |
62 | 65 | ||
63 | } | 66 | } |
64 | 67 | ||
65 | - | ||
66 | } else { | 68 | } else { |
67 | // If sign in fails, display a message to the user. | 69 | // If sign in fails, display a message to the user. |
68 | Toast.makeText(this, "signInWithEmail failed.",Toast.LENGTH_SHORT).show() | 70 | Toast.makeText(this, "signInWithEmail failed.",Toast.LENGTH_SHORT).show() |
69 | 71 | ||
70 | } | 72 | } |
73 | + | ||
74 | + | ||
71 | } | 75 | } |
72 | } | 76 | } |
73 | 77 | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -32,32 +32,31 @@ | ... | @@ -32,32 +32,31 @@ |
32 | android:layout_width="10dp" | 32 | android:layout_width="10dp" |
33 | android:layout_height="match_parent" | 33 | android:layout_height="match_parent" |
34 | android:layout_weight="1.5" | 34 | android:layout_weight="1.5" |
35 | - android:text="건너뛰기" /> | 35 | + android:background="#FFFFFF" |
36 | - | 36 | + android:text="나가기" |
37 | + android:textColor="#29ABE2" | ||
38 | + android:textSize="16dp" /> | ||
37 | <LinearLayout | 39 | <LinearLayout |
38 | android:layout_width="10dp" | 40 | android:layout_width="10dp" |
39 | android:layout_height="match_parent" | 41 | android:layout_height="match_parent" |
40 | - android:layout_weight="1" | 42 | + android:orientation="horizontal" |
41 | - android:orientation="horizontal" /> | 43 | + android:layout_weight="1"/> |
42 | - | ||
43 | <ImageView | 44 | <ImageView |
44 | android:layout_width="77dp" | 45 | android:layout_width="77dp" |
45 | android:layout_height="44dp" | 46 | android:layout_height="44dp" |
46 | android:layout_gravity="center" | 47 | android:layout_gravity="center" |
47 | android:layout_weight="1" | 48 | android:layout_weight="1" |
48 | android:src="@drawable/toolbar_logo" /> | 49 | android:src="@drawable/toolbar_logo" /> |
49 | - | ||
50 | <LinearLayout | 50 | <LinearLayout |
51 | android:layout_width="10dp" | 51 | android:layout_width="10dp" |
52 | android:layout_height="match_parent" | 52 | android:layout_height="match_parent" |
53 | - android:layout_weight="1" | 53 | + android:orientation="horizontal" |
54 | - android:orientation="horizontal" /> | 54 | + android:layout_weight="1"/> |
55 | - | ||
56 | <LinearLayout | 55 | <LinearLayout |
57 | android:layout_width="10dp" | 56 | android:layout_width="10dp" |
58 | android:layout_height="match_parent" | 57 | android:layout_height="match_parent" |
59 | - android:layout_weight="1.5" | 58 | + android:orientation="horizontal" |
60 | - android:orientation="horizontal" /> | 59 | + android:layout_weight="1.5"/> |
61 | 60 | ||
62 | </LinearLayout> | 61 | </LinearLayout> |
63 | 62 | ... | ... |
... | @@ -32,32 +32,31 @@ | ... | @@ -32,32 +32,31 @@ |
32 | android:layout_width="10dp" | 32 | android:layout_width="10dp" |
33 | android:layout_height="match_parent" | 33 | android:layout_height="match_parent" |
34 | android:layout_weight="1.5" | 34 | android:layout_weight="1.5" |
35 | - android:text="건너뛰기" /> | 35 | + android:background="#FFFFFF" |
36 | - | 36 | + android:text="나가기" |
37 | + android:textColor="#29ABE2" | ||
38 | + android:textSize="16dp" /> | ||
37 | <LinearLayout | 39 | <LinearLayout |
38 | android:layout_width="10dp" | 40 | android:layout_width="10dp" |
39 | android:layout_height="match_parent" | 41 | android:layout_height="match_parent" |
40 | - android:layout_weight="1" | 42 | + android:orientation="horizontal" |
41 | - android:orientation="horizontal" /> | 43 | + android:layout_weight="1"/> |
42 | - | ||
43 | <ImageView | 44 | <ImageView |
44 | android:layout_width="77dp" | 45 | android:layout_width="77dp" |
45 | android:layout_height="44dp" | 46 | android:layout_height="44dp" |
46 | android:layout_gravity="center" | 47 | android:layout_gravity="center" |
47 | android:layout_weight="1" | 48 | android:layout_weight="1" |
48 | android:src="@drawable/toolbar_logo" /> | 49 | android:src="@drawable/toolbar_logo" /> |
49 | - | ||
50 | <LinearLayout | 50 | <LinearLayout |
51 | android:layout_width="10dp" | 51 | android:layout_width="10dp" |
52 | android:layout_height="match_parent" | 52 | android:layout_height="match_parent" |
53 | - android:layout_weight="1" | 53 | + android:orientation="horizontal" |
54 | - android:orientation="horizontal" /> | 54 | + android:layout_weight="1"/> |
55 | - | ||
56 | <LinearLayout | 55 | <LinearLayout |
57 | android:layout_width="10dp" | 56 | android:layout_width="10dp" |
58 | android:layout_height="match_parent" | 57 | android:layout_height="match_parent" |
59 | - android:layout_weight="1.5" | 58 | + android:orientation="horizontal" |
60 | - android:orientation="horizontal" /> | 59 | + android:layout_weight="1.5"/> |
61 | 60 | ||
62 | </LinearLayout> | 61 | </LinearLayout> |
63 | 62 | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
... | @@ -31,7 +31,10 @@ | ... | @@ -31,7 +31,10 @@ |
31 | android:layout_width="10dp" | 31 | android:layout_width="10dp" |
32 | android:layout_height="match_parent" | 32 | android:layout_height="match_parent" |
33 | android:layout_weight="1.5" | 33 | android:layout_weight="1.5" |
34 | - android:text="건너뛰기"/> | 34 | + android:background="#FFFFFF" |
35 | + android:text="나가기" | ||
36 | + android:textColor="#29ABE2" | ||
37 | + android:textSize="16dp" /> | ||
35 | <LinearLayout | 38 | <LinearLayout |
36 | android:layout_width="10dp" | 39 | android:layout_width="10dp" |
37 | android:layout_height="match_parent" | 40 | android:layout_height="match_parent" | ... | ... |
-
Please register or login to post a comment