손장민

Map is added with Error

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