손장민

Map is added with Error

...@@ -39,6 +39,8 @@ dependencies { ...@@ -39,6 +39,8 @@ dependencies {
39 compile 'com.squareup.picasso:picasso:2.5.2' 39 compile 'com.squareup.picasso:picasso:2.5.2'
40 compile 'com.google.firebase:firebase-messaging:11.0.2' 40 compile 'com.google.firebase:firebase-messaging:11.0.2'
41 compile 'com.google.android.gms:play-services-maps:11.0.2' 41 compile 'com.google.android.gms:play-services-maps:11.0.2'
42 + compile 'com.google.android.gms:play-services-location:11.0.2'
43 + compile 'com.google.android.gms:play-services-places:11.0.2'
42 testCompile 'junit:junit:4.12' 44 testCompile 'junit:junit:4.12'
43 } 45 }
44 46
......
...@@ -6,13 +6,11 @@ ...@@ -6,13 +6,11 @@
6 6
7 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 7 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
8 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 8 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
9 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
10 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
11 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
12 + <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
9 13
10 - <!--
11 - The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
12 - Google Maps Android API v2, but you must specify either coarse or fine
13 - location permissions for the 'MyLocation' functionality.
14 - -->
15 - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
16 14
17 <application 15 <application
18 android:allowBackup="true" 16 android:allowBackup="true"
......
...@@ -9,39 +9,66 @@ public class Blog ...@@ -9,39 +9,66 @@ public class Blog
9 private String title; 9 private String title;
10 private String desc; 10 private String desc;
11 private String image; 11 private String image;
12 + private String nickname;
12 13
13 - public Blog(){ 14 + public Blog()
15 + {
14 16
15 } 17 }
16 18
17 - public Blog(String title, String desc, String image) { 19 + public Blog(String title, String desc, String image)
20 + {
18 this.title = title; 21 this.title = title;
19 this.desc = desc; 22 this.desc = desc;
20 this.image = image; 23 this.image = image;
21 } 24 }
22 25
23 - public String getDesc() { 26 + public Blog(String title, String desc, String image, String nickname)
27 + {
28 + this.title = title;
29 + this.desc = desc;
30 + this.image = image;
31 + this.nickname = nickname;
32 + }
33 +
34 + public String getDesc()
35 + {
24 return desc; 36 return desc;
25 } 37 }
26 38
27 - public void setDesc(String desc) { 39 + public void setDesc(String desc)
40 + {
28 this.desc = desc; 41 this.desc = desc;
29 } 42 }
30 43
31 - public String getImage() { 44 + public String getImage()
45 + {
32 return image; 46 return image;
33 } 47 }
34 48
35 - public void setImage(String image) { 49 + public void setImage(String image)
50 + {
36 this.image = image; 51 this.image = image;
37 } 52 }
38 53
39 - public String getTitle() { 54 + public String getTitle()
55 + {
40 return title; 56 return title;
41 } 57 }
42 58
43 - public void setTitle(String title) { 59 + public void setTitle(String title)
60 + {
44 this.title = title; 61 this.title = title;
45 } 62 }
46 63
64 + public String getNickname()
65 + {
66 + return nickname;
67 + }
68 +
69 + public void setNickname(String nickname)
70 + {
71 + this.nickname = nickname;
72 + }
73 +
47 } 74 }
......
...@@ -7,6 +7,7 @@ import android.support.annotation.Nullable; ...@@ -7,6 +7,7 @@ import android.support.annotation.Nullable;
7 import android.support.v4.app.Fragment; 7 import android.support.v4.app.Fragment;
8 import android.support.v7.widget.LinearLayoutManager; 8 import android.support.v7.widget.LinearLayoutManager;
9 import android.support.v7.widget.RecyclerView; 9 import android.support.v7.widget.RecyclerView;
10 +import android.util.Log;
10 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
11 import android.view.Menu; 12 import android.view.Menu;
12 import android.view.MenuInflater; 13 import android.view.MenuInflater;
...@@ -21,8 +22,10 @@ import com.google.firebase.database.DatabaseReference; ...@@ -21,8 +22,10 @@ import com.google.firebase.database.DatabaseReference;
21 import com.google.firebase.database.FirebaseDatabase; 22 import com.google.firebase.database.FirebaseDatabase;
22 import com.squareup.picasso.Picasso; 23 import com.squareup.picasso.Picasso;
23 24
25 +import org.w3c.dom.Text;
26 +
24 /** 27 /**
25 - * Created by HYB on 2017. 10. 11.. 28 + * Created by HYB on 2017. 10 . 11..
26 */ 29 */
27 30
28 public class Community extends Fragment 31 public class Community extends Fragment
...@@ -37,14 +40,17 @@ public class Community extends Fragment ...@@ -37,14 +40,17 @@ public class Community extends Fragment
37 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) 40 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState)
38 { 41 {
39 setHasOptionsMenu(true); 42 setHasOptionsMenu(true);
40 - 43 + LinearLayoutManager lm = new LinearLayoutManager(getActivity());
41 View view = inflater.inflate(R.layout.community, container, false); 44 View view = inflater.inflate(R.layout.community, container, false);
42 45
43 mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog"); 46 mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog");
44 47
48 + lm.setReverseLayout(true);
49 + lm.setStackFromEnd(true);
50 +
45 mBlogList = (RecyclerView) view.findViewById(R.id.blog_list); 51 mBlogList = (RecyclerView) view.findViewById(R.id.blog_list);
46 mBlogList.setHasFixedSize(true); 52 mBlogList.setHasFixedSize(true);
47 - mBlogList.setLayoutManager(new LinearLayoutManager(getActivity())); 53 + mBlogList.setLayoutManager(lm);
48 54
49 return view; 55 return view;
50 } 56 }
...@@ -54,9 +60,8 @@ public class Community extends Fragment ...@@ -54,9 +60,8 @@ public class Community extends Fragment
54 { 60 {
55 super.onStart(); 61 super.onStart();
56 62
57 - FirebaseRecyclerAdapter<Blog, BlogViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Blog, BlogViewHolder>( 63 + FirebaseRecyclerAdapter<Blog, BlogViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Blog, BlogViewHolder>
58 - 64 + ( Blog.class, R.layout.blog_row, BlogViewHolder.class, mDatabase)
59 - Blog.class, R.layout.blog_row, BlogViewHolder.class, mDatabase)
60 { 65 {
61 @Override 66 @Override
62 protected void populateViewHolder(BlogViewHolder viewHolder, Blog model, int position) 67 protected void populateViewHolder(BlogViewHolder viewHolder, Blog model, int position)
...@@ -64,6 +69,7 @@ public class Community extends Fragment ...@@ -64,6 +69,7 @@ public class Community extends Fragment
64 viewHolder.setTitle(model.getTitle()); 69 viewHolder.setTitle(model.getTitle());
65 viewHolder.setDesc(model.getDesc()); 70 viewHolder.setDesc(model.getDesc());
66 viewHolder.setImage(getActivity().getApplicationContext(), model.getImage()); 71 viewHolder.setImage(getActivity().getApplicationContext(), model.getImage());
72 + viewHolder.setNickname(model.getNickname());
67 } 73 }
68 }; 74 };
69 mBlogList.setAdapter(firebaseRecyclerAdapter); 75 mBlogList.setAdapter(firebaseRecyclerAdapter);
...@@ -112,6 +118,12 @@ public class Community extends Fragment ...@@ -112,6 +118,12 @@ public class Community extends Fragment
112 Picasso.with(ctx).load(image).into(post_image); 118 Picasso.with(ctx).load(image).into(post_image);
113 119
114 } 120 }
121 + public void setNickname(String nickname)
122 + {
123 + TextView nick_title = (TextView)mView.findViewById(R.id.nick_Title);
124 + nick_title.setText(nickname);
125 +
126 + }
115 127
116 } 128 }
117 129
......
1 package com.example.user.firebaseauthdemo; 1 package com.example.user.firebaseauthdemo;
2 2
3 +import android.*;
3 import android.app.ProgressDialog; 4 import android.app.ProgressDialog;
4 import android.content.Intent; 5 import android.content.Intent;
6 +import android.content.pm.PackageManager;
7 +import android.os.Build;
5 import android.os.Bundle; 8 import android.os.Bundle;
6 import android.support.annotation.NonNull; 9 import android.support.annotation.NonNull;
10 +import android.support.v4.app.ActivityCompat;
11 +import android.support.v4.content.ContextCompat;
7 import android.support.v7.app.AppCompatActivity; 12 import android.support.v7.app.AppCompatActivity;
8 import android.text.TextUtils; 13 import android.text.TextUtils;
14 +import android.util.Log;
9 import android.view.View; 15 import android.view.View;
10 import android.widget.Button; 16 import android.widget.Button;
11 import android.widget.EditText; 17 import android.widget.EditText;
...@@ -27,6 +33,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -27,6 +33,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
27 private EditText editTextEmail; 33 private EditText editTextEmail;
28 private EditText editTextPassword; 34 private EditText editTextPassword;
29 private TextView textViewSignIn; 35 private TextView textViewSignIn;
36 + public static final int REQUEST_LOCATION_CODE = 99;
30 37
31 private ProgressDialog progressDialog; 38 private ProgressDialog progressDialog;
32 39
...@@ -43,6 +50,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -43,6 +50,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
43 firebaseAuth = FirebaseAuth.getInstance(); 50 firebaseAuth = FirebaseAuth.getInstance();
44 mDatabase = FirebaseDatabase.getInstance().getReference().child("Users"); 51 mDatabase = FirebaseDatabase.getInstance().getReference().child("Users");
45 52
53 + Log.d("", "퍼미션 체크전");
54 + checkLocationPermission();
55 +
46 if(firebaseAuth.getCurrentUser() != null){ 56 if(firebaseAuth.getCurrentUser() != null){
47 //profile activity here 57 //profile activity here
48 finish(); 58 finish();
...@@ -121,4 +131,34 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -121,4 +131,34 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
121 startActivity(new Intent(this, LoginActivity.class)); 131 startActivity(new Intent(this, LoginActivity.class));
122 } 132 }
123 } 133 }
134 +
135 +
136 +
137 + public boolean checkLocationPermission()
138 + {
139 +
140 + Log.d("", "퍼미션 체크안");
141 + if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED)
142 + {
143 + Log.d("", "퍼미션 받음");
144 + if(ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.ACCESS_FINE_LOCATION))
145 + {
146 + Log.d("", "리퀘ㅡ트 띠움");
147 + ActivityCompat.requestPermissions(this, new String[] {android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_CODE);
148 + }
149 + else
150 + {
151 + Log.d("", "리퀘ㅡ트 띠움");
152 + ActivityCompat.requestPermissions(this, new String[] {android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_CODE);
153 +
154 + }
155 + return false;
156 + }
157 + else
158 + {
159 + return true;
160 + }
161 +
162 + }
163 +
124 } 164 }
......
...@@ -37,7 +37,15 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService ...@@ -37,7 +37,15 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService
37 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); 37 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT);
38 38
39 Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 39 Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
40 - NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.common_google_signin_btn_icon_dark).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)).setContentTitle("Push Title ").setContentText(message).setAutoCancel(true).setSound(defaultSoundUri).setLights(000000255, 500, 2000).setContentIntent(pendingIntent); 40 + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
41 + .setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
42 + .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
43 + .setContentTitle("Admin")
44 + .setContentText(message)
45 + .setAutoCancel(true)
46 + .setSound(defaultSoundUri)
47 + .setLights(000000255, 500, 2000)
48 + .setContentIntent(pendingIntent);
41 49
42 NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 50 NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
43 51
......
...@@ -20,6 +20,7 @@ import android.widget.Toast; ...@@ -20,6 +20,7 @@ import android.widget.Toast;
20 import com.google.android.gms.tasks.OnSuccessListener; 20 import com.google.android.gms.tasks.OnSuccessListener;
21 import com.google.firebase.auth.FirebaseAuth; 21 import com.google.firebase.auth.FirebaseAuth;
22 import com.google.firebase.auth.FirebaseUser; 22 import com.google.firebase.auth.FirebaseUser;
23 +import com.google.firebase.auth.UserInfo;
23 import com.google.firebase.database.DatabaseReference; 24 import com.google.firebase.database.DatabaseReference;
24 import com.google.firebase.database.FirebaseDatabase; 25 import com.google.firebase.database.FirebaseDatabase;
25 import com.google.firebase.storage.FirebaseStorage; 26 import com.google.firebase.storage.FirebaseStorage;
...@@ -78,7 +79,6 @@ public class PostActivity extends AppCompatActivity { ...@@ -78,7 +79,6 @@ public class PostActivity extends AppCompatActivity {
78 startActivityForResult(gallaryIntent, GALLARY_REQUEST); 79 startActivityForResult(gallaryIntent, GALLARY_REQUEST);
79 } 80 }
80 }); 81 });
81 -
82 mSubmitBtn.setOnClickListener(new View.OnClickListener() { 82 mSubmitBtn.setOnClickListener(new View.OnClickListener() {
83 @Override 83 @Override
84 public void onClick(View view) { 84 public void onClick(View view) {
...@@ -105,6 +105,7 @@ public class PostActivity extends AppCompatActivity { ...@@ -105,6 +105,7 @@ public class PostActivity extends AppCompatActivity {
105 newPost.child("title").setValue(title_val); 105 newPost.child("title").setValue(title_val);
106 newPost.child("desc").setValue(desc_val); 106 newPost.child("desc").setValue(desc_val);
107 newPost.child("uid").setValue(mCurrentUser.getUid()); 107 newPost.child("uid").setValue(mCurrentUser.getUid());
108 + newPost.child("nickname").setValue(mCurrentUser.getDisplayName());
108 109
109 mProgress.dismiss(); 110 mProgress.dismiss();
110 } 111 }
...@@ -123,6 +124,7 @@ public class PostActivity extends AppCompatActivity { ...@@ -123,6 +124,7 @@ public class PostActivity extends AppCompatActivity {
123 newPost.child("desc").setValue(desc_val); 124 newPost.child("desc").setValue(desc_val);
124 newPost.child("image").setValue(downloadUrl.toString()); 125 newPost.child("image").setValue(downloadUrl.toString());
125 newPost.child("uid").setValue(mCurrentUser.getUid()); 126 newPost.child("uid").setValue(mCurrentUser.getUid());
127 + newPost.child("nickname").setValue(mCurrentUser.getDisplayName());
126 128
127 mProgress.dismiss(); 129 mProgress.dismiss();
128 130
...@@ -130,9 +132,6 @@ public class PostActivity extends AppCompatActivity { ...@@ -130,9 +132,6 @@ public class PostActivity extends AppCompatActivity {
130 } 132 }
131 }); 133 });
132 } 134 }
133 - android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
134 - android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
135 -
136 finish(); 135 finish();
137 Toast.makeText(PostActivity.this, "Success!", Toast.LENGTH_LONG).show(); 136 Toast.makeText(PostActivity.this, "Success!", Toast.LENGTH_LONG).show();
138 137
......
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
17 <ImageButton 17 <ImageButton
18 android:id="@+id/imageSelect" 18 android:id="@+id/imageSelect"
19 android:layout_width="match_parent" 19 android:layout_width="match_parent"
20 - android:layout_height="204dp" 20 + android:layout_height="match_parent"
21 - app:srcCompat="@mipmap/add_btn" 21 + android:layout_weight="0.05"
22 - android:layout_weight="0.05" /> 22 + app:srcCompat="@mipmap/add_btn"/>
23 23
24 <EditText 24 <EditText
25 android:id="@+id/titleField" 25 android:id="@+id/titleField"
26 android:layout_width="match_parent" 26 android:layout_width="match_parent"
27 - android:layout_height="45dp" 27 + android:layout_height="match_parent"
28 android:layout_gravity="center_horizontal" 28 android:layout_gravity="center_horizontal"
29 android:layout_margin="15dp" 29 android:layout_margin="15dp"
30 android:background="@drawable/input_outline" 30 android:background="@drawable/input_outline"
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
33 android:inputType="textPersonName" 33 android:inputType="textPersonName"
34 android:singleLine="true" 34 android:singleLine="true"
35 tools:layout_editor_absoluteX="0dp" 35 tools:layout_editor_absoluteX="0dp"
36 - tools:layout_editor_absoluteY="0dp" /> 36 + tools:layout_editor_absoluteY="0dp"/>
37 37
38 <EditText 38 <EditText
39 android:id="@+id/descField" 39 android:id="@+id/descField"
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
43 android:background="@drawable/input_outline" 43 android:background="@drawable/input_outline"
44 android:ems="10" 44 android:ems="10"
45 android:hint=" Post Descriptions..." 45 android:hint=" Post Descriptions..."
46 - android:inputType="textMultiLine" /> 46 + android:inputType="textMultiLine"/>
47 47
48 <Button 48 <Button
49 android:id="@+id/submitBtn" 49 android:id="@+id/submitBtn"
......
...@@ -19,12 +19,28 @@ ...@@ -19,12 +19,28 @@
19 android:scaleType="centerCrop" 19 android:scaleType="centerCrop"
20 app:srcCompat="@mipmap/add_btn" /> 20 app:srcCompat="@mipmap/add_btn" />
21 21
22 + <LinearLayout
23 + android:layout_width="match_parent"
24 + android:layout_height="match_parent"
25 + android:orientation="horizontal">
26 +
22 <TextView 27 <TextView
23 android:id="@+id/post_title" 28 android:id="@+id/post_title"
24 android:layout_width="match_parent" 29 android:layout_width="match_parent"
25 android:layout_height="wrap_content" 30 android:layout_height="wrap_content"
31 + android:layout_weight="1"
32 + android:padding="15dp"
33 + android:text="post title in here"/>
34 +
35 + <TextView
36 + android:id="@+id/nick_Title"
37 + android:gravity="right"
38 + android:layout_width="110dp"
39 + android:layout_height="wrap_content"
26 android:padding="15dp" 40 android:padding="15dp"
27 - android:text="post title in here" /> 41 + android:text="Nickname"
42 + />
43 + </LinearLayout>
28 44
29 <TextView 45 <TextView
30 android:id="@+id/post_desc" 46 android:id="@+id/post_desc"
...@@ -33,6 +49,8 @@ ...@@ -33,6 +49,8 @@
33 android:padding="10dp" 49 android:padding="10dp"
34 android:paddingLeft="5dp" 50 android:paddingLeft="5dp"
35 android:paddingRight="5dp" 51 android:paddingRight="5dp"
36 - android:text="post description" /> 52 + android:text="post description"/>
53 +
37 </LinearLayout> 54 </LinearLayout>
55 +
38 </android.support.v7.widget.CardView> 56 </android.support.v7.widget.CardView>
...\ No newline at end of file ...\ No newline at end of file
......
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:card_view="http://schemas.android.com/apk/res-auto"
3 android:orientation="vertical" android:layout_width="match_parent" 4 android:orientation="vertical" android:layout_width="match_parent"
4 - android:layout_height="match_parent"> 5 + android:layout_height="match_parent"
6 + android:weightSum="1">
5 <TextView 7 <TextView
6 android:id="@+id/map" 8 android:id="@+id/map"
7 android:layout_width="match_parent" 9 android:layout_width="match_parent"
8 - android:layout_height="wrap_content" 10 + android:layout_height="82dp"
9 android:layout_centerHorizontal="true" 11 android:layout_centerHorizontal="true"
10 android:text="Terror inform is displayed in here." 12 android:text="Terror inform is displayed in here."
11 android:textAppearance="@style/TextAppearance.AppCompat.Headline" /> 13 android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
...@@ -13,6 +15,25 @@ ...@@ -13,6 +15,25 @@
13 <com.google.android.gms.maps.MapView 15 <com.google.android.gms.maps.MapView
14 android:id="@+id/mapView" 16 android:id="@+id/mapView"
15 android:layout_width="match_parent" 17 android:layout_width="match_parent"
16 - android:layout_height="match_parent"/> 18 + android:layout_height="250dp"
19 + android:layout_weight="0.93"/>
20 +
21 + <android.support.v7.widget.CardView
22 + android:name="@+id/card_view"
23 + android:layout_width="400dp"
24 + android:layout_height="40dp"
25 + android:layout_gravity="center"
26 + card_view:cardCornerRadius="4dp"
27 + >
28 +
29 + <fragment
30 + android:id="@+id/place_autocomplete_fragment"
31 + android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
32 + android:layout_width="match_parent"
33 + android:layout_height="wrap_content"
34 + >
35 + </fragment>
36 +
37 + </android.support.v7.widget.CardView>
17 38
18 </LinearLayout> 39 </LinearLayout>
...\ No newline at end of file ...\ No newline at end of file
......