Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add maps activity and auth #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions GeoTag.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="GeoTag" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
163 changes: 163 additions & 0 deletions app/app.iml

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.android.geotag"
minSdkVersion 15
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
Expand All @@ -23,7 +24,18 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
/*implementation 'com.google.android.gms:play-services:12.0.1'*/
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.7'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-base:16.1.0'
}
48 changes: 48 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"project_info": {
"project_number": "738961992255",
"firebase_url": "https://geotag-132b1.firebaseio.com",
"project_id": "geotag-132b1",
"storage_bucket": "geotag-132b1.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:738961992255:android:ecd6ace57e76d9a0a5e68a",
"android_client_info": {
"package_name": "com.example.android.geotag"
}
},
"oauth_client": [
{
"client_id": "738961992255-77psa62dbf840amvf4n62s9pbqe57fse.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.example.android.geotag",
"certificate_hash": "be538e123a2a75a47a281f9a25722d3c07cb7568"
}
},
{
"client_id": "738961992255-ehpu3gd9kvtetfge2p84v94aedp77bgl.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAkm6w7-QM9XiJ3uhiDQKiwxkWf9XT_bvw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "738961992255-ehpu3gd9kvtetfge2p84v94aedp77bgl.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".map"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyAyYIU7BcSG1-QIuJrHOQxMOlK2Izuf2Rc" />

</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


</manifest>
100 changes: 100 additions & 0 deletions app/src/main/java/com/example/android/geotag/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,114 @@
package com.example.android.geotag;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.IdpResponse;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;

import java.util.Arrays;
import java.util.List;


public class MainActivity extends AppCompatActivity {

public static final int RC_SIGN_IN = 1;

private FirebaseAuth mFirebaseAuth;
private FirebaseAuth.AuthStateListener mAuthStateListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mFirebaseAuth = FirebaseAuth.getInstance();

mAuthStateListener = new FirebaseAuth.AuthStateListener() {

@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
updateUi();
}
};
}

private void updateUi() {
FirebaseUser user = mFirebaseAuth.getCurrentUser();
if (user == null) {
// Choose authentication providers
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build());
// Create and launch sign-in intent
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);

} else {

TextView nameText = findViewById(R.id.nameText);
TextView emailText = findViewById(R.id.emailText);
nameText.setText(mFirebaseAuth.getCurrentUser().getDisplayName());
emailText.setText(mFirebaseAuth.getCurrentUser().getEmail());

}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);

if (resultCode == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// ...
} else {
// Sign in failed. If response is null the user canceled the
// sign-in flow using the back button. Otherwise check
// response.getError().getErrorCode() and handle the error.
// ...
}
}
}

@Override
protected void onResume() {
super.onResume();
mFirebaseAuth.addAuthStateListener(mAuthStateListener);
}

@Override
protected void onPause() {
super.onPause();
if (mAuthStateListener != null) {
mFirebaseAuth.removeAuthStateListener(mAuthStateListener);
}
}

//signout the user
public void signOut(View view){
FirebaseAuth.getInstance().signOut();
}

//go to activity_map.xml
public void map(View view) {
startActivity(new Intent(MainActivity.this, map.class));
}
}
Loading