손장민

Add Welcome Screen, should edit Titlebar visibility

......@@ -50,4 +50,5 @@ dependencies {
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
......
......@@ -6,12 +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="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"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
......@@ -19,30 +18,32 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".WelcomActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN"/>\
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".LoginActivity"/>
<activity android:name=".ProfileActivity"/>
<activity android:name=".MainActivity"/>
<activity
android:name=".Main2Activity"
android:label="@string/title_activity_main2"
android:theme="@style/AppTheme.NoActionBar"/>
<activity android:name=".PostActivity"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key"/>
<service
android:name=".MyFirebaseInstanceIDService">
<service android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<service
android:name=".MyFirebaseMessagingService">
<service android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
......
......@@ -111,6 +111,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
finish();
}
@Override
......@@ -203,7 +204,6 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
}
if(view == textViewSignUp){
finish();
startActivity(new Intent(this, MainActivity.class));
}
}
......
......@@ -13,6 +13,7 @@ import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
......@@ -25,7 +26,8 @@ import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
public class MainActivity extends AppCompatActivity implements View.OnClickListener
{
private Button buttonRegister;
......@@ -41,22 +43,26 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private DatabaseReference mDatabase;
@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
progressDialog = new ProgressDialog(MainActivity.this);
firebaseAuth = FirebaseAuth.getInstance();
mDatabase = FirebaseDatabase.getInstance().getReference().child("Users");
Log.d("", "퍼미션 체크전");
checkLocationPermission();
if(firebaseAuth.getCurrentUser() != null){
if (firebaseAuth.getCurrentUser() != null)
{
//profile activity here
finish();
startActivity(new Intent(getApplicationContext(), Main2Activity.class));
}
buttonRegister = (Button) findViewById(R.id.buttonRegister);
......@@ -71,24 +77,28 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
textViewSignIn.setOnClickListener(this);
}
private void registerUser(){
private void registerUser()
{
final String name = editTextName.getText().toString().trim();
final String email = editTextEmail.getText().toString().trim();
final String password = editTextPassword.getText().toString().trim();
if(TextUtils.isEmpty(name)){
if (TextUtils.isEmpty(name))
{
Toast.makeText(this, "이름을 입력하세요", Toast.LENGTH_SHORT).show();
return;
}
if(TextUtils.isEmpty(email)){
if (TextUtils.isEmpty(email))
{
//email is empty
Toast.makeText(this, "이메일을 입력하세요요", Toast.LENGTH_SHORT).show();
//stopping the function execution further
return;
}
if(TextUtils.isEmpty(password)) {
if (TextUtils.isEmpty(password))
{
//password is empty
Toast.makeText(this, "패스워드를 입력하세요", Toast.LENGTH_SHORT).show();
//stopping the function execution further
......@@ -102,17 +112,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.show();
//creating a new user
firebaseAuth.createUserWithEmailAndPassword(email,password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
firebaseAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>()
{
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
public void onComplete(@NonNull Task<AuthResult> task)
{
if (task.isSuccessful())
{
finish();
DatabaseReference newPost = mDatabase.push();
newPost.child("name").setValue(name);
newPost.child("email").setValue(email);
startActivity(new Intent(getApplicationContext(), Main2Activity.class));
}else{
}
else
{
Toast.makeText(MainActivity.this, "등록할 수 없습니다.", Toast.LENGTH_SHORT).show();
}
progressDialog.dismiss();
......@@ -121,36 +135,32 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
@Override
public void onClick(View view) {
if(view == buttonRegister){
public void onClick(View view)
{
if (view == buttonRegister)
{
registerUser();
}
if(view == textViewSignIn){
if (view == textViewSignIn)
{
//will open login activity here
startActivity(new Intent(this, LoginActivity.class));
}
}
public boolean checkLocationPermission()
{
Log.d("", "퍼미션 체크안");
if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED)
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))
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);
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);
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_CODE);
}
return false;
}
......
......@@ -47,10 +47,6 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
/**
* Created by HYB on 2017. 10. 11..
*/
public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener
{
......@@ -59,32 +55,22 @@ public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient
private static final String TAG = "googlemap_example";
private static final int GPS_ENABLE_REQUEST_CODE = 2001;
private static final int PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION = 2002;
private static final int UPDATE_INTERVAL_MS = 15000;
private static final int FASTEST_UPDATE_INTERVAL_MS = 15000;
private static final int UPDATE_INTERVAL_MS = 5000;
private static final int FASTEST_UPDATE_INTERVAL_MS = 5000;
private GoogleMap googleMap = null;
private MapView mapView = null;
private GoogleApiClient googleApiClient = null;
private Marker currentMarker = null;
private final static int MAXENTRIES = 5;
private String[] LikelyPlaceNames = null;
private String[] LikelyAddresses = null;
private String[] LikelyAttributions = null;
private LatLng[] LikelyLatLngs = null;
public Map()
{
}
public void setCurrentLocation(Location location, String markerTitle, String markerSnippet)
{
if (currentMarker != null)
{ currentMarker.remove(); }
{
currentMarker.remove();
}
if (location != null)
{
Log.i(TAG, " Got my Loc!! ");
//현재위치의 위도 경도 가져옴
LatLng currentLocation = new LatLng(location.getLatitude(), location.getLongitude());
......@@ -139,7 +125,6 @@ public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient
setCurrentLocation(location, place.getName().toString(), place.getAddress().toString());
}
@Override
public void onError(Status status)
{
......@@ -331,9 +316,9 @@ public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient
{
Log.i(TAG, "onLocationChanged call..");
lastLocation = location;
if(currentMarker != null)
if (currentMarker != null)
{
currentMarker .remove();
currentMarker.remove();
}
LatLng mlanglang = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
......@@ -344,14 +329,12 @@ public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient
currentMarker = googleMap.addMarker(markerOptions);
googleMap.moveCamera(CameraUpdateFactory.newLatLng(mlanglang));
googleMap.animateCamera(CameraUpdateFactory.zoomBy(10));
googleMap.animateCamera(CameraUpdateFactory.zoomTo((17.0f)));
}
@Override
public void onConnected(@Nullable Bundle bundle)
{
Log.i(TAG, "An error occurred: onConnected");
if (!checkLocationServicesStatus())
{
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
......@@ -378,7 +361,6 @@ public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient
builder.create().show();
}
Log.i(TAG, "An error occurred: onConnected2");
LocationRequest locationRequest = new LocationRequest();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(UPDATE_INTERVAL_MS);
......@@ -390,6 +372,8 @@ public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient
{
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
this.googleMap.getUiSettings().setCompassEnabled(true);
this.googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
}
}
else
......@@ -400,8 +384,6 @@ public class Map extends Fragment implements OnMapReadyCallback, GoogleApiClient
this.googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
}
Log.i(TAG, "An error occurred: onConnected3");
}
@Override
......
package com.example.user.firebaseauthdemo;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
public class WelcomActivity extends AppCompatActivity
{
private static int SPLASH_TIME_OUT = 2000;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_welcom);
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
Intent myintent = new Intent(WelcomActivity.this, MainActivity.class);
startActivity(myintent);
finish();
}
}
, SPLASH_TIME_OUT);
}
}
......@@ -7,63 +7,76 @@
tools:context="com.example.user.firebaseauthdemo.LoginActivity">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:orientation="vertical"
android:layout_width="368dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp" >
app:srcCompat="@drawable/common_google_signin_btn_icon_dark"/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="30dp"
android:text="HELPLIST"
android:textAppearance="?android:attr/textAppearanceLarge" />
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:layout_margin="15dp"
android:inputType="textEmailAddress"
android:hint="이메일을 입력하세요"
android:id="@+id/editTextEmail"
android:layout_width="368dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp" />
android:layout_margin="15dp"
android:hint="이메일을 입력하세요"
android:inputType="textEmailAddress"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp"/>
<EditText
android:layout_margin="15dp"
android:inputType="textPassword"
android:hint="패스워드를 입력하세요"
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp" />
android:layout_margin="15dp"
android:hint="패스워드를 입력하세요"
android:inputType="textPassword"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp"/>
<Button
android:id="@+id/buttonSignIn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:text="로그인" />
android:text="로그인"/>
<com.google.android.gms.common.SignInButton
android:id="@+id/buttonGoogleSignIn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/buttonGoogleSignIn">
android:layout_height="wrap_content">
</com.google.android.gms.common.SignInButton>
<TextView
android:textAlignment="center"
android:id="@+id/textViewSignUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:text="계정이 없나요? 이곳을 클릭하세요" />
android:text="계정이 없나요? 이곳을 클릭하세요"
android:textAlignment="center"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
......
......@@ -7,67 +7,81 @@
tools:context="com.example.user.firebaseauthdemo.MainActivity">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:orientation="vertical"
android:layout_width="368dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.495">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp" >
app:srcCompat="@drawable/common_google_signin_btn_icon_dark_normal"/>
<TextView
android:layout_margin="30dp"
android:text="환영합니다"
android:id="@+id/textView"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
android:layout_gravity="center_horizontal"
android:layout_margin="30dp"
android:text="환영합니다"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:layout_margin="15dp"
android:inputType="textPersonName"
android:hint="Enter your name"
android:id="@+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp" />
android:layout_margin="15dp"
android:hint="Enter your name"
android:inputType="textPersonName"
android:singleLine="false"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp"/>
<EditText
android:layout_margin="15dp"
android:inputType="textEmailAddress"
android:hint="Enter your email"
android:id="@+id/editTextEmail"
android:layout_width="368dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp" />
android:layout_margin="15dp"
android:hint="Enter your email"
android:inputType="textEmailAddress"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp"/>
<EditText
android:layout_margin="15dp"
android:inputType="textPassword"
android:hint="Enter your password"
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="8dp" />
android:layout_margin="15dp"
android:hint="Enter your password"
android:inputType="textPassword"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp"/>
<Button
android:layout_margin="15dp"
android:id="@+id/buttonRegister"
android:text="가입"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:text="가입"/>
<TextView
android:textAlignment="center"
android:text="이미 가입했나요? 이곳을 클릭하세요"
android:id="@+id/textViewSignIn"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:text="이미 가입했나요? 이곳을 클릭하세요"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
android:visibility="visible"
app:layout_collapseParallaxMultiplier="1.0"
tools:context="com.example.user.firebaseauthdemo.WelcomActivity">
<ImageView
android:id="@+id/imageView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/common_google_signin_btn_icon_light_normal"/>
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@android:style/Theme.NoTitleBar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.user.firebaseauthdemo.WelcomActivity"
tools:showIn="@layout/activity_welcom">
</android.support.constraint.ConstraintLayout>
......@@ -7,4 +7,5 @@
<string name="action_settings">Settings</string>
<string name="title_activity_maps">Map</string>
<string name="title_activity_welcom">WelcomActivity</string>
</resources>
......
......@@ -13,8 +13,8 @@
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
......