├── .gitignore ├── .idea ├── assetWizardSettings.xml ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── google-services.json ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── gelecegiyazanlar │ │ └── com │ │ └── gykfirebaseauthentication │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── gelecegiyazanlar │ │ │ └── com │ │ │ └── gykfirebaseauthentication │ │ │ ├── activities │ │ │ ├── AddNoteActivity.java │ │ │ ├── AddPhotoActivity.java │ │ │ ├── LoginActivity.java │ │ │ ├── MainActivity.java │ │ │ └── RegisterActivity.java │ │ │ ├── adapters │ │ │ └── CustomPostAdapter.java │ │ │ ├── fragments │ │ │ ├── HomeFragment.java │ │ │ ├── MyNotesFragment.java │ │ │ └── ProfileFragment.java │ │ │ └── models │ │ │ └── PostModel.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── add_note_ic.png │ │ ├── add_photo_ic.png │ │ ├── foto1.jpg │ │ ├── foto2.jpg │ │ ├── foto3.jpg │ │ ├── foto4.jpg │ │ ├── ic_home_black_24dp.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ ├── ic_menu_slideshow.xml │ │ ├── ic_person_black_24dp.xml │ │ ├── ic_remove_circle_black_24dp.xml │ │ ├── instagram_ic.png │ │ ├── login_background.png │ │ ├── nav_profile_picture.png │ │ ├── register_login_background.png │ │ └── side_nav_bar.xml │ │ ├── layout │ │ ├── activity_add_note.xml │ │ ├── activity_add_photo.xml │ │ ├── activity_login.xml │ │ ├── activity_main.xml │ │ ├── activity_register.xml │ │ ├── app_bar_main.xml │ │ ├── content_main.xml │ │ ├── fragment_home.xml │ │ ├── fragment_my_notes.xml │ │ ├── fragment_profile.xml │ │ ├── nav_header_main.xml │ │ ├── photo_list.xml │ │ └── post_list.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ └── main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values-v21 │ │ └── styles.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── gelecegiyazanlar │ └── com │ └── gykfirebaseauthentication │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /.idea/assetWizardSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 45 | 46 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 21 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gezgin App 2 | 💃💪 3 | 4 | 5 | 6 | ![alt text](https://firebasestorage.googleapis.com/v0/b/siniffen-88d83.appspot.com/o/Screen%20Shot%202019-04-18%20at%2020.38.31.png?alt=media&token=b211f6f2-2890-4b3e-a9f7-ed31c8799f96) 7 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "gelecegiyazanlar.com.gykfirebaseauthentication" 7 | minSdkVersion 21 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:28.0.0' 24 | implementation 'com.android.support:support-v4:28.0.0' 25 | implementation 'com.android.support:design:28.0.0' 26 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 27 | implementation 'com.google.firebase:firebase-database:16.1.0' 28 | implementation 'com.google.firebase:firebase-storage:16.1.0' 29 | testImplementation 'junit:junit:4.12' 30 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 31 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 32 | implementation 'com.google.firebase:firebase-core:16.0.6' 33 | implementation 'com.google.firebase:firebase-auth:16.1.0' 34 | implementation 'com.squareup.picasso:picasso:2.5.1' 35 | compile 'com.github.bumptech.glide:glide:3.7.0' 36 | 37 | 38 | } 39 | apply plugin: 'com.google.gms.google-services' 40 | -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "772020985649", 4 | "firebase_url": "https://gykfirebaseauthsampleproject.firebaseio.com", 5 | "project_id": "gykfirebaseauthsampleproject", 6 | "storage_bucket": "gykfirebaseauthsampleproject.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:772020985649:android:a63a97c074ca99cc", 12 | "android_client_info": { 13 | "package_name": "gelecegiyazanlar.com.gykfirebaseauthentication" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "772020985649-ck07nm06ai1oclnggqkfq4t2tmko6n9b.apps.googleusercontent.com", 19 | "client_type": 1, 20 | "android_info": { 21 | "package_name": "gelecegiyazanlar.com.gykfirebaseauthentication", 22 | "certificate_hash": "3261540b1fdab7a6c56ebd9af1cd03ee09549385" 23 | } 24 | }, 25 | { 26 | "client_id": "772020985649-277k0ejic0kvv5vsi3tpv7eo98kekc5m.apps.googleusercontent.com", 27 | "client_type": 3 28 | } 29 | ], 30 | "api_key": [ 31 | { 32 | "current_key": "AIzaSyBeM_Iw1k0exUcxwEp5esOVFb_FYlJfXrA" 33 | } 34 | ], 35 | "services": { 36 | "appinvite_service": { 37 | "other_platform_oauth_client": [ 38 | { 39 | "client_id": "772020985649-277k0ejic0kvv5vsi3tpv7eo98kekc5m.apps.googleusercontent.com", 40 | "client_type": 3 41 | } 42 | ] 43 | } 44 | } 45 | } 46 | ], 47 | "configuration_version": "1" 48 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/gelecegiyazanlar/com/gykfirebaseauthentication/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("gelecegiyazanlar.com.gykfirebaseauthentication", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/activities/AddNoteActivity.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.activities; 2 | 3 | import android.content.DialogInterface; 4 | import android.content.Intent; 5 | import android.support.v7.app.AlertDialog; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.EditText; 11 | 12 | import com.google.firebase.database.DatabaseReference; 13 | import com.google.firebase.database.FirebaseDatabase; 14 | 15 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 16 | import gelecegiyazanlar.com.gykfirebaseauthentication.fragments.MyNotesFragment; 17 | 18 | public class AddNoteActivity extends AppCompatActivity { 19 | 20 | EditText userNoteEt; 21 | Button addNoteBtn; 22 | Button goToNotesPage; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_add_note); 28 | 29 | userNoteEt = (EditText) findViewById(R.id.user_notes_et); 30 | addNoteBtn = (Button) findViewById(R.id.add_notes_btn); 31 | goToNotesPage = (Button) findViewById(R.id.go_to_notes_btn); 32 | addNoteBtn.setOnClickListener(new View.OnClickListener() { 33 | @Override 34 | public void onClick(View v) { 35 | addNote(); 36 | } 37 | }); 38 | 39 | goToNotesPage.setOnClickListener(new View.OnClickListener() { 40 | @Override 41 | public void onClick(View v) { 42 | onBackPressed(); 43 | } 44 | }); 45 | 46 | } 47 | 48 | private void addNote() { 49 | FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(); 50 | DatabaseReference myRef = firebaseDatabase.getReference().child("GezdigimYerler"); 51 | String notesId = myRef.push().getKey(); 52 | String receivedUserNote = userNoteEt.getText().toString(); 53 | if (receivedUserNote.length() > 0) { 54 | myRef.child(notesId).child("sehirAdi").setValue(receivedUserNote); 55 | showDialog("Başarılı", "Notunuz Kaydedildi!"); 56 | } else { 57 | showDialog("İşlem Başarısız", "Not alanı boş bırakılamaz!"); 58 | } 59 | userNoteEt.setText(""); 60 | } 61 | 62 | private void showDialog(String title, String message) { 63 | final AlertDialog.Builder builder = new AlertDialog.Builder(AddNoteActivity.this); 64 | builder.setTitle(title); 65 | builder.setMessage(message); 66 | builder.setNegativeButton("TAMAM", new DialogInterface.OnClickListener() { 67 | public void onClick(DialogInterface dialog, int id) { 68 | 69 | } 70 | }); 71 | builder.show(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/activities/AddPhotoActivity.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.activities; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.support.annotation.NonNull; 7 | import android.support.v4.app.FragmentTransaction; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | import android.view.View; 11 | import android.widget.Button; 12 | import android.widget.ImageView; 13 | import android.widget.Toast; 14 | 15 | import com.google.android.gms.tasks.OnFailureListener; 16 | import com.google.android.gms.tasks.OnSuccessListener; 17 | import com.google.firebase.auth.FirebaseAuth; 18 | import com.google.firebase.database.DatabaseReference; 19 | import com.google.firebase.database.FirebaseDatabase; 20 | import com.google.firebase.storage.FirebaseStorage; 21 | import com.google.firebase.storage.StorageReference; 22 | import com.google.firebase.storage.UploadTask; 23 | import com.squareup.picasso.Picasso; 24 | 25 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 26 | import gelecegiyazanlar.com.gykfirebaseauthentication.fragments.ProfileFragment; 27 | 28 | public class AddPhotoActivity extends AppCompatActivity { 29 | 30 | ImageView userPhoto; 31 | Button selectPhotoBtn; 32 | Button savePhotoBtn; 33 | FirebaseStorage firebaseStorage; 34 | FirebaseAuth mAuth; 35 | Uri filePath; 36 | private ProgressDialog progressDialog; 37 | private static final int IMAGE_REQUEST = 111; 38 | 39 | 40 | @Override 41 | protected void onCreate(Bundle savedInstanceState) { 42 | super.onCreate(savedInstanceState); 43 | setContentView(R.layout.activity_add_photo); 44 | 45 | mAuth = FirebaseAuth.getInstance(); 46 | firebaseStorage = FirebaseStorage.getInstance(); 47 | 48 | userPhoto = (ImageView) findViewById(R.id.user_saved_photo); 49 | selectPhotoBtn = (Button) findViewById(R.id.select_photo_button); 50 | savePhotoBtn = (Button) findViewById(R.id.save_photo_button); 51 | 52 | showPhoto(); 53 | 54 | selectPhotoBtn.setOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View v) { 57 | selectPhoto(); 58 | } 59 | }); 60 | 61 | savePhotoBtn.setOnClickListener(new View.OnClickListener() { 62 | @Override 63 | public void onClick(View v) { 64 | savePhoto(); 65 | } 66 | }); 67 | 68 | } 69 | 70 | private void showPhoto(){ 71 | showProgressDialog(); 72 | StorageReference storageRef = firebaseStorage.getReference(); 73 | storageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener() { 74 | @Override 75 | public void onSuccess(Uri uri) { 76 | 77 | dismissProgressDialog(); 78 | Picasso.with(AddPhotoActivity.this).load(uri).fit().centerCrop().into(userPhoto); 79 | 80 | } 81 | }).addOnFailureListener(new OnFailureListener() { 82 | @Override 83 | public void onFailure(@NonNull Exception e) { 84 | 85 | dismissProgressDialog(); 86 | Toast.makeText(AddPhotoActivity.this, "Fotoğraf Yükleme işlemi başarısız", Toast.LENGTH_SHORT).show(); 87 | } 88 | }); 89 | } 90 | 91 | 92 | private void selectPhoto() { 93 | Intent intent = new Intent(); 94 | intent.setType("image/*"); 95 | intent.setAction(Intent.ACTION_GET_CONTENT); 96 | startActivityForResult(Intent.createChooser(intent, "Resim Seçiniz"), IMAGE_REQUEST); 97 | 98 | } 99 | 100 | 101 | private void savePhoto() { 102 | if (filePath != null) { 103 | showProgressDialog(); 104 | StorageReference storageRef = firebaseStorage.getReference(); 105 | storageRef.child("userprofilephoto").putFile(filePath).addOnSuccessListener(new OnSuccessListener() { 106 | @Override 107 | public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { 108 | 109 | dismissProgressDialog(); 110 | Toast.makeText(AddPhotoActivity.this, "Fotoğraf başarılı bir şekilde kaydedildi.", Toast.LENGTH_SHORT).show(); 111 | onBackPressed(); 112 | 113 | } 114 | }).addOnFailureListener(new OnFailureListener() { 115 | @Override 116 | public void onFailure(@NonNull Exception e) { 117 | 118 | dismissProgressDialog(); 119 | Toast.makeText(AddPhotoActivity.this, "Fotoğraf Kaydedilemedi", Toast.LENGTH_SHORT).show(); 120 | 121 | } 122 | }); 123 | 124 | } 125 | } 126 | 127 | private void showProgressDialog() { 128 | progressDialog = new ProgressDialog(AddPhotoActivity.this); 129 | progressDialog.setMessage("Yükleniyor..."); 130 | progressDialog.setCancelable(false); 131 | progressDialog.show(); 132 | } 133 | 134 | 135 | private void dismissProgressDialog(){ 136 | progressDialog.dismiss(); 137 | } 138 | 139 | @Override 140 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 141 | super.onActivityResult(requestCode, resultCode, data); 142 | 143 | if (requestCode == IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { 144 | filePath = data.getData(); 145 | try { 146 | Picasso.with(AddPhotoActivity.this).load(filePath).fit().centerCrop().into(userPhoto); 147 | } catch (Exception e) { 148 | e.printStackTrace(); 149 | } 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/activities/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.activities; 2 | 3 | import android.content.Intent; 4 | import android.support.annotation.NonNull; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.util.Log; 8 | import android.view.View; 9 | import android.view.Window; 10 | import android.view.WindowManager; 11 | import android.widget.Button; 12 | import android.widget.EditText; 13 | import android.widget.Toast; 14 | 15 | import com.google.android.gms.tasks.OnCompleteListener; 16 | import com.google.android.gms.tasks.Task; 17 | import com.google.firebase.auth.AuthResult; 18 | import com.google.firebase.auth.FirebaseAuth; 19 | 20 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 21 | 22 | public class LoginActivity extends AppCompatActivity { 23 | 24 | private EditText userEmailEt; 25 | private EditText userPasswordEt; 26 | private Button registerBtn; 27 | private Button loginBtn; 28 | FirebaseAuth mAuth; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_login); 34 | 35 | 36 | userEmailEt = (EditText) findViewById(R.id.user_email_login_et); 37 | userPasswordEt = (EditText) findViewById(R.id.user_password_login_et); 38 | registerBtn = (Button) findViewById(R.id.button_go_register); 39 | loginBtn = (Button) findViewById(R.id.button_login); 40 | mAuth = FirebaseAuth.getInstance(); 41 | 42 | registerBtn.setOnClickListener(new View.OnClickListener() { 43 | @Override 44 | public void onClick(View view) { 45 | goToRegister(); 46 | } 47 | }); 48 | 49 | loginBtn.setOnClickListener(new View.OnClickListener() { 50 | @Override 51 | public void onClick(View view) { 52 | String userEmail = userEmailEt.getText().toString().trim(); 53 | String userPassword = userPasswordEt.getText().toString().trim(); 54 | if (!userEmail.isEmpty() && !userPassword.isEmpty()) { 55 | login(userEmail, userPassword); 56 | } else { 57 | Toast.makeText(getApplicationContext(), "Email ya da parola boş bırakılamaz!", Toast.LENGTH_LONG).show(); 58 | } 59 | } 60 | }); 61 | } 62 | 63 | private void goToRegister() { 64 | Intent registerIntent = new Intent(getApplicationContext(), RegisterActivity.class); 65 | startActivity(registerIntent); 66 | } 67 | 68 | private void login(String email, String password) { 69 | mAuth.signInWithEmailAndPassword(email, password) 70 | .addOnCompleteListener(this, new OnCompleteListener() { 71 | @Override 72 | public void onComplete(@NonNull Task task) { 73 | if (task.isSuccessful()) { 74 | startActivity(new Intent(LoginActivity.this, MainActivity.class)); 75 | finish(); 76 | // Sign in success, update UI with the signed-in user's information 77 | Log.d("EMail", "signInWithEmail:success"); 78 | } else { 79 | // If sign in fails, display a message to the user. 80 | Log.w("Fail", "signInWithEmail:failure", task.getException()); 81 | 82 | } 83 | } 84 | }); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/activities/MainActivity.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.activities; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentTransaction; 7 | import android.support.design.widget.NavigationView; 8 | import android.support.v4.view.GravityCompat; 9 | import android.support.v4.widget.DrawerLayout; 10 | import android.support.v7.app.ActionBarDrawerToggle; 11 | import android.support.v7.app.AppCompatActivity; 12 | import android.support.v7.widget.Toolbar; 13 | import android.view.Menu; 14 | import android.view.MenuItem; 15 | 16 | import com.google.firebase.auth.FirebaseAuth; 17 | 18 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 19 | import gelecegiyazanlar.com.gykfirebaseauthentication.fragments.HomeFragment; 20 | import gelecegiyazanlar.com.gykfirebaseauthentication.fragments.MyNotesFragment; 21 | import gelecegiyazanlar.com.gykfirebaseauthentication.fragments.ProfileFragment; 22 | 23 | public class MainActivity extends AppCompatActivity 24 | implements NavigationView.OnNavigationItemSelectedListener { 25 | 26 | FirebaseAuth mAuth; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_main); 32 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 33 | setSupportActionBar(toolbar); 34 | 35 | mAuth = FirebaseAuth.getInstance(); 36 | 37 | 38 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 39 | transaction.replace(R.id.content_frame, new HomeFragment()); 40 | transaction.commit(); 41 | 42 | 43 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 44 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 45 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 46 | drawer.addDrawerListener(toggle); 47 | toggle.syncState(); 48 | 49 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 50 | navigationView.setNavigationItemSelectedListener(this); 51 | } 52 | 53 | @Override 54 | public void onBackPressed() { 55 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 56 | if (drawer.isDrawerOpen(GravityCompat.START)) { 57 | drawer.closeDrawer(GravityCompat.START); 58 | } else { 59 | super.onBackPressed(); 60 | } 61 | } 62 | 63 | @Override 64 | public boolean onCreateOptionsMenu(Menu menu) { 65 | // Inflate the menu; this adds items to the action bar if it is present. 66 | getMenuInflater().inflate(R.menu.main, menu); 67 | return true; 68 | } 69 | 70 | @Override 71 | public boolean onOptionsItemSelected(MenuItem item) { 72 | // Handle action bar item clicks here. The action bar will 73 | // automatically handle clicks on the Home/Up button, so long 74 | // as you specify a parent activity in AndroidManifest.xml. 75 | int id = item.getItemId(); 76 | 77 | //noinspection SimplifiableIfStatement 78 | if (id == R.id.action_settings) { 79 | return true; 80 | } 81 | 82 | return super.onOptionsItemSelected(item); 83 | } 84 | 85 | @SuppressWarnings("StatementWithEmptyBody") 86 | @Override 87 | public boolean onNavigationItemSelected(MenuItem item) { 88 | // Handle navigation view item clicks here. 89 | Fragment selectedFragment = null; 90 | int id = item.getItemId(); 91 | 92 | if (id == R.id.nav_home) { 93 | selectedFragment = new HomeFragment(); 94 | // Handle the camera action 95 | } else if (id == R.id.nav_profile) { 96 | selectedFragment = new ProfileFragment(); 97 | } else if (id == R.id.nav_logout) { 98 | selectedFragment = new HomeFragment(); 99 | mAuth.signOut(); 100 | Intent logoutIntent = new Intent(MainActivity.this, LoginActivity.class); 101 | startActivity(logoutIntent); 102 | } else if (id == R.id.nav_my_notes) { 103 | selectedFragment = new MyNotesFragment(); 104 | } 105 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 106 | transaction.replace(R.id.content_frame, selectedFragment); 107 | transaction.commit(); 108 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 109 | drawer.closeDrawer(GravityCompat.START); 110 | return true; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/activities/RegisterActivity.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.activities; 2 | 3 | import android.content.Intent; 4 | import android.support.annotation.NonNull; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.view.Window; 9 | import android.view.WindowManager; 10 | import android.widget.Button; 11 | import android.widget.EditText; 12 | import android.widget.Toast; 13 | 14 | import com.google.android.gms.tasks.OnCompleteListener; 15 | import com.google.android.gms.tasks.OnFailureListener; 16 | import com.google.android.gms.tasks.Task; 17 | import com.google.firebase.auth.AuthResult; 18 | import com.google.firebase.auth.FirebaseAuth; 19 | import com.google.firebase.auth.FirebaseAuthException; 20 | import com.google.firebase.auth.FirebaseUser; 21 | 22 | 23 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 24 | 25 | public class RegisterActivity extends AppCompatActivity { 26 | 27 | private EditText userEmailEt; 28 | private EditText userPasswordEt; 29 | private EditText userConfirmPasswordEt; 30 | private Button registerBtn; 31 | private FirebaseAuth mAuth; 32 | private String userEmail; 33 | private String userPassword; 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_register); 39 | 40 | userEmailEt = (EditText) findViewById(R.id.user_email_register_et); 41 | userPasswordEt = (EditText) findViewById(R.id.user_password_register_et); 42 | userConfirmPasswordEt = (EditText) findViewById(R.id.user_confirm_email_register_tv); 43 | registerBtn = (Button) findViewById(R.id.button_register); 44 | 45 | mAuth = FirebaseAuth.getInstance(); 46 | registerBtn.setOnClickListener(new View.OnClickListener() { 47 | @Override 48 | public void onClick(View view) { 49 | getUserInfoAndRegister(); 50 | } 51 | }); 52 | 53 | } 54 | 55 | private void getUserInfoAndRegister() { 56 | userEmail = userEmailEt.getText().toString().trim(); 57 | userPassword = userPasswordEt.getText().toString().trim(); 58 | String userConfirmPassword = userConfirmPasswordEt.getText().toString(); 59 | 60 | if(!userEmail.isEmpty() && !userPassword.isEmpty() && !userConfirmPassword.isEmpty()){ 61 | if(userPassword.equals(userConfirmPassword)){ 62 | register(); 63 | } 64 | } else{ 65 | Toast.makeText(getApplicationContext(), "Kayıt için tüm alanları doldurunuz!", Toast.LENGTH_LONG).show(); 66 | } 67 | } 68 | 69 | private void register() { 70 | 71 | 72 | mAuth.createUserWithEmailAndPassword(userEmail,userPassword).addOnCompleteListener(this, new OnCompleteListener() { 73 | @Override 74 | public void onComplete(@NonNull Task task) { 75 | if (task.isSuccessful()) { 76 | FirebaseUser firebaseUser = mAuth.getCurrentUser(); 77 | Toast.makeText(getApplicationContext(), "Kayıt işlemi başarılı", Toast.LENGTH_SHORT).show(); 78 | Intent loginIntent = new Intent(RegisterActivity.this,LoginActivity.class); 79 | startActivity(loginIntent); 80 | 81 | 82 | } 83 | } 84 | }).addOnFailureListener(this, new OnFailureListener() { 85 | @Override 86 | public void onFailure(@NonNull Exception e) { 87 | if (e instanceof FirebaseAuthException) { 88 | if(((FirebaseAuthException) e).getErrorCode().equals("ERROR_WEAK_PASSWORD")){ 89 | Toast.makeText(getApplicationContext(), "Eksik Şifre", Toast.LENGTH_SHORT).show(); 90 | 91 | } else if(((FirebaseAuthException) e).getErrorCode().equals("ERROR_INVALID_EMAIL")){ 92 | Toast.makeText(getApplicationContext(), "Geçersiz mail", Toast.LENGTH_SHORT).show(); 93 | 94 | } else if(((FirebaseAuthException) e).getErrorCode().equals("ERROR_EMAIL_ALREADY_IN_USE")){ 95 | Toast.makeText(getApplicationContext(), "Mail zaten kayıtlı", Toast.LENGTH_SHORT).show(); 96 | 97 | } 98 | //your other logic goes here 99 | } 100 | } 101 | }); 102 | 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/adapters/CustomPostAdapter.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.adapters; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import java.io.PipedOutputStream; 11 | import java.util.List; 12 | 13 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 14 | import gelecegiyazanlar.com.gykfirebaseauthentication.models.PostModel; 15 | 16 | public class CustomPostAdapter extends BaseAdapter { 17 | 18 | LayoutInflater layoutInflater; 19 | List postModelList; 20 | 21 | 22 | public CustomPostAdapter(LayoutInflater layoutInflater, List postModelList) { 23 | this.layoutInflater = layoutInflater; 24 | this.postModelList = postModelList; 25 | } 26 | 27 | 28 | @Override 29 | public int getCount() { 30 | return postModelList.size(); 31 | } 32 | 33 | @Override 34 | public Object getItem(int position) { 35 | return postModelList.get(position); 36 | } 37 | 38 | @Override 39 | public long getItemId(int position) { 40 | return position; 41 | } 42 | 43 | @Override 44 | public View getView(int position, View convertView, ViewGroup parent) { 45 | View postView = layoutInflater.inflate(R.layout.post_list,null); 46 | ImageView postPicture = postView.findViewById(R.id.post_picture); 47 | TextView postTitle = postView.findViewById(R.id.post_title); 48 | TextView postDescription = postView.findViewById(R.id.post_description); 49 | 50 | PostModel postModel = postModelList.get(position); 51 | postPicture.setImageResource(postModel.getPostPicture()); 52 | postTitle.setText(postModel.getPostName()); 53 | postDescription.setText(postModel.getPostDescription()); 54 | 55 | return postView; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/fragments/HomeFragment.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.fragments; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.support.v4.app.Fragment; 8 | import android.support.v7.app.AlertDialog; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.AdapterView; 13 | import android.widget.ListView; 14 | import android.widget.Toast; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 20 | import gelecegiyazanlar.com.gykfirebaseauthentication.adapters.CustomPostAdapter; 21 | import gelecegiyazanlar.com.gykfirebaseauthentication.models.PostModel; 22 | 23 | /** 24 | * A simple {@link Fragment} subclass. 25 | * Activities that contain this fragment must implement the 26 | * {@link HomeFragment.OnFragmentInteractionListener} interface 27 | * to handle interaction events. 28 | * Use the {@link HomeFragment#newInstance} factory method to 29 | * create an instance of this fragment. 30 | */ 31 | public class HomeFragment extends Fragment { 32 | // TODO: Rename parameter arguments, choose names that match 33 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 34 | private static final String ARG_PARAM1 = "param1"; 35 | private static final String ARG_PARAM2 = "param2"; 36 | List postList = new ArrayList(); 37 | 38 | // TODO: Rename and change types of parameters 39 | private String mParam1; 40 | private String mParam2; 41 | 42 | private OnFragmentInteractionListener mListener; 43 | 44 | public HomeFragment() { 45 | // Required empty public constructor 46 | } 47 | 48 | /** 49 | * Use this factory method to create a new instance of 50 | * this fragment using the provided parameters. 51 | * 52 | * @param param1 Parameter 1. 53 | * @param param2 Parameter 2. 54 | * @return A new instance of fragment HomeFragment. 55 | */ 56 | // TODO: Rename and change types and number of parameters 57 | public static HomeFragment newInstance(String param1, String param2) { 58 | HomeFragment fragment = new HomeFragment(); 59 | Bundle args = new Bundle(); 60 | args.putString(ARG_PARAM1, param1); 61 | args.putString(ARG_PARAM2, param2); 62 | fragment.setArguments(args); 63 | return fragment; 64 | } 65 | 66 | @Override 67 | public void onCreate(Bundle savedInstanceState) { 68 | super.onCreate(savedInstanceState); 69 | if (getArguments() != null) { 70 | mParam1 = getArguments().getString(ARG_PARAM1); 71 | mParam2 = getArguments().getString(ARG_PARAM2); 72 | } 73 | } 74 | 75 | @Override 76 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 77 | Bundle savedInstanceState) { 78 | // Inflate the layout for this fragment 79 | View view = inflater.inflate(R.layout.fragment_home,container,false); 80 | ListView postListView = (ListView) view.findViewById(R.id.post_list); 81 | 82 | postList.add(new PostModel(R.drawable.foto1,"Trabzon","Karadeniz'in incisi olarak tabir edilen, eşsiz doğasıyla nefes kesen bir şehir Trabzon.")); 83 | postList.add(new PostModel(R.drawable.foto2,"Mardin","Dicle ve Fırat nehirleri arasında yer alan Mardin Güneydoğu Anadolu Bölgesi'nin en çok merak edilen şehirlerinden biridir.")); 84 | postList.add(new PostModel(R.drawable.foto3,"İzmir","ürkiye'nin batısında, Ege Denizi'nin kıyısında yer alan Ege'nin İncisi İzmir, Türkiye'nin 3'üncü büyük kentidir.")); 85 | postList.add(new PostModel(R.drawable.foto4,"İstanbul","Avrupa ve Asya'yı birbirine bağlayan, çok sayıda medeniyetin izlerini taşıyan istanbul")); 86 | 87 | CustomPostAdapter customPostAdapter = new CustomPostAdapter(getLayoutInflater(),postList); 88 | postListView.setAdapter(customPostAdapter); 89 | 90 | postListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 91 | @Override 92 | public void onItemClick(AdapterView parent, View view, int position, long id) { 93 | final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 94 | builder.setTitle("Bilgiler"); 95 | String selectedName = postList.get(position).getPostName(); 96 | String selectedDescription = postList.get(position).getPostDescription(); 97 | int selectedIcon = postList.get(position).getPostPicture(); 98 | String message = selectedName + " " + selectedDescription; 99 | builder.setIcon(selectedIcon); 100 | builder.setMessage(message); 101 | builder.setNegativeButton("TAMAM", new DialogInterface.OnClickListener(){ 102 | public void onClick(DialogInterface dialog, int id) { 103 | 104 | } 105 | }); 106 | builder.show(); 107 | } 108 | }); 109 | return view; 110 | } 111 | 112 | 113 | // TODO: Rename method, update argument and hook method into UI event 114 | public void onButtonPressed(Uri uri) { 115 | if (mListener != null) { 116 | mListener.onFragmentInteraction(uri); 117 | } 118 | } 119 | 120 | @Override 121 | public void onAttach(Context context) { 122 | super.onAttach(context); 123 | } 124 | 125 | @Override 126 | public void onDetach() { 127 | super.onDetach(); 128 | mListener = null; 129 | } 130 | 131 | /** 132 | * This interface must be implemented by activities that contain this 133 | * fragment to allow an interaction in this fragment to be communicated 134 | * to the activity and potentially other fragments contained in that 135 | * activity. 136 | *

137 | * See the Android Training lesson Communicating with Other Fragments for more information. 140 | */ 141 | public interface OnFragmentInteractionListener { 142 | // TODO: Update argument type and name 143 | void onFragmentInteraction(Uri uri); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/fragments/MyNotesFragment.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.fragments; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.Bundle; 8 | import android.support.design.widget.FloatingActionButton; 9 | import android.support.design.widget.Snackbar; 10 | import android.support.v4.app.Fragment; 11 | import android.util.Log; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.widget.ArrayAdapter; 16 | import android.widget.Button; 17 | import android.widget.ListView; 18 | 19 | import com.google.firebase.database.DataSnapshot; 20 | import com.google.firebase.database.DatabaseError; 21 | import com.google.firebase.database.DatabaseReference; 22 | import com.google.firebase.database.FirebaseDatabase; 23 | import com.google.firebase.database.ValueEventListener; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 29 | import gelecegiyazanlar.com.gykfirebaseauthentication.activities.AddNoteActivity; 30 | import gelecegiyazanlar.com.gykfirebaseauthentication.activities.AddPhotoActivity; 31 | 32 | /** 33 | * A simple {@link Fragment} subclass. 34 | * Activities that contain this fragment must implement the 35 | * {@link MyNotesFragment.OnFragmentInteractionListener} interface 36 | * to handle interaction events. 37 | * Use the {@link MyNotesFragment#newInstance} factory method to 38 | * create an instance of this fragment. 39 | */ 40 | public class MyNotesFragment extends Fragment { 41 | // TODO: Rename parameter arguments, choose names that match 42 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 43 | private static final String ARG_PARAM1 = "param1"; 44 | private static final String ARG_PARAM2 = "param2"; 45 | 46 | 47 | // TODO: Rename and change types of parameters 48 | private String mParam1; 49 | private String mParam2; 50 | ArrayList myNotesList = new ArrayList(); 51 | String myPlaces; 52 | ListView myNotesListLv; 53 | ArrayAdapter arrayAdapter; 54 | private ProgressDialog progressDialog; 55 | private OnFragmentInteractionListener mListener; 56 | 57 | public MyNotesFragment() { 58 | // Required empty public constructor 59 | } 60 | 61 | /** 62 | * Use this factory method to create a new instance of 63 | * this fragment using the provided parameters. 64 | * 65 | * @param param1 Parameter 1. 66 | * @param param2 Parameter 2. 67 | * @return A new instance of fragment MyNotesFragment. 68 | */ 69 | // TODO: Rename and change types and number of parameters 70 | public static MyNotesFragment newInstance(String param1, String param2) { 71 | MyNotesFragment fragment = new MyNotesFragment(); 72 | Bundle args = new Bundle(); 73 | args.putString(ARG_PARAM1, param1); 74 | args.putString(ARG_PARAM2, param2); 75 | fragment.setArguments(args); 76 | return fragment; 77 | } 78 | 79 | @Override 80 | public void onCreate(Bundle savedInstanceState) { 81 | super.onCreate(savedInstanceState); 82 | if (getArguments() != null) { 83 | mParam1 = getArguments().getString(ARG_PARAM1); 84 | mParam2 = getArguments().getString(ARG_PARAM2); 85 | } 86 | myNotesList = getMyNotes(); 87 | 88 | 89 | } 90 | 91 | @Override 92 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 93 | Bundle savedInstanceState) { 94 | // Inflate the layout for this fragment 95 | View myNotesView = inflater.inflate(R.layout.fragment_my_notes, container, false); 96 | Button addNotesBtn = (Button) myNotesView.findViewById(R.id.fragment_add_notes_btn); 97 | addNotesBtn.setOnClickListener(new View.OnClickListener() { 98 | @Override 99 | public void onClick(View view) { 100 | Intent addNoteIntent = new Intent(getContext(), AddNoteActivity.class); 101 | startActivity(addNoteIntent); 102 | } 103 | }); 104 | myNotesListLv = (ListView) myNotesView.findViewById(R.id.my_notes_lv); 105 | 106 | arrayAdapter = new ArrayAdapter 107 | (getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, myNotesList); 108 | myNotesListLv.setAdapter(arrayAdapter); 109 | return myNotesView; 110 | } 111 | 112 | 113 | private ArrayList getMyNotes() { 114 | showProgressDialog(); 115 | final ArrayList myNotes = new ArrayList<>(); 116 | FirebaseDatabase database = FirebaseDatabase.getInstance(); 117 | final DatabaseReference myRef = database.getReference().child("GezdigimYerler"); 118 | myRef.addValueEventListener(new ValueEventListener() { 119 | @Override 120 | public void onDataChange(DataSnapshot dataSnapshot) { 121 | progressDialog.dismiss(); 122 | for (DataSnapshot ds : dataSnapshot.getChildren()) { 123 | myPlaces = ds.child("sehirAdi").getValue().toString(); 124 | myNotes.add(myPlaces); 125 | 126 | } 127 | arrayAdapter.notifyDataSetChanged(); 128 | 129 | } 130 | 131 | @Override 132 | public void onCancelled(DatabaseError databaseError) { 133 | progressDialog.dismiss(); 134 | } 135 | }); 136 | 137 | return myNotes; 138 | 139 | } 140 | 141 | private void showProgressDialog() { 142 | progressDialog = new ProgressDialog(getContext()); 143 | progressDialog.setMessage("Yükleniyor..."); 144 | progressDialog.setCancelable(false); 145 | progressDialog.show(); 146 | } 147 | 148 | // TODO: Rename method, update argument and hook method into UI event 149 | public void onButtonPressed(Uri uri) { 150 | if (mListener != null) { 151 | mListener.onFragmentInteraction(uri); 152 | } 153 | } 154 | 155 | @Override 156 | public void onAttach(Context context) { 157 | super.onAttach(context); 158 | } 159 | 160 | @Override 161 | public void onDetach() { 162 | super.onDetach(); 163 | mListener = null; 164 | } 165 | 166 | /** 167 | * This interface must be implemented by activities that contain this 168 | * fragment to allow an interaction in this fragment to be communicated 169 | * to the activity and potentially other fragments contained in that 170 | * activity. 171 | *

172 | * See the Android Training lesson Communicating with Other Fragments for more information. 175 | */ 176 | public interface OnFragmentInteractionListener { 177 | // TODO: Update argument type and name 178 | void onFragmentInteraction(Uri uri); 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/fragments/ProfileFragment.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.fragments; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.ActivityNotFoundException; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.graphics.Bitmap; 8 | import android.net.Uri; 9 | import android.os.Bundle; 10 | import android.support.annotation.NonNull; 11 | import android.support.v4.app.Fragment; 12 | import android.view.LayoutInflater; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.widget.ImageView; 16 | import android.widget.TextView; 17 | 18 | import com.bumptech.glide.Glide; 19 | import com.bumptech.glide.request.animation.GlideAnimation; 20 | import com.bumptech.glide.request.target.SimpleTarget; 21 | import com.google.android.gms.tasks.OnFailureListener; 22 | import com.google.android.gms.tasks.OnSuccessListener; 23 | import com.google.firebase.storage.FirebaseStorage; 24 | import com.google.firebase.storage.StorageReference; 25 | 26 | import gelecegiyazanlar.com.gykfirebaseauthentication.R; 27 | import gelecegiyazanlar.com.gykfirebaseauthentication.activities.AddPhotoActivity; 28 | import gelecegiyazanlar.com.gykfirebaseauthentication.models.PhotoModel; 29 | 30 | /** 31 | * A simple {@link Fragment} subclass. 32 | * Activities that contain this fragment must implement the 33 | * {@link ProfileFragment.OnFragmentInteractionListener} interface 34 | * to handle interaction events. 35 | * Use the {@link ProfileFragment#newInstance} factory method to 36 | * create an instance of this fragment. 37 | */ 38 | public class ProfileFragment extends Fragment { 39 | // TODO: Rename parameter arguments, choose names that match 40 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 41 | private static final String ARG_PARAM1 = "param1"; 42 | private static final String ARG_PARAM2 = "param2"; 43 | 44 | // TODO: Rename and change types of parameters 45 | private String mParam1; 46 | private String mParam2; 47 | ImageView profilePhoto; 48 | TextView profileName; 49 | TextView profileBio; 50 | ImageView profileUserInstagram; 51 | ImageView changeProfilePhoto; 52 | private ProgressDialog progressDialog; 53 | private OnFragmentInteractionListener mListener; 54 | 55 | public ProfileFragment() { 56 | // Required empty public constructor 57 | } 58 | 59 | /** 60 | * Use this factory method to create a new instance of 61 | * this fragment using the provided parameters. 62 | * 63 | * @param param1 Parameter 1. 64 | * @param param2 Parameter 2. 65 | * @return A new instance of fragment ProfileFragment. 66 | */ 67 | // TODO: Rename and change types and number of parameters 68 | public static ProfileFragment newInstance(String param1, String param2) { 69 | ProfileFragment fragment = new ProfileFragment(); 70 | Bundle args = new Bundle(); 71 | args.putString(ARG_PARAM1, param1); 72 | args.putString(ARG_PARAM2, param2); 73 | fragment.setArguments(args); 74 | return fragment; 75 | } 76 | 77 | @Override 78 | public void onCreate(Bundle savedInstanceState) { 79 | super.onCreate(savedInstanceState); 80 | if (getArguments() != null) { 81 | mParam1 = getArguments().getString(ARG_PARAM1); 82 | mParam2 = getArguments().getString(ARG_PARAM2); 83 | } 84 | } 85 | 86 | @Override 87 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 88 | Bundle savedInstanceState) { 89 | 90 | View profileView = inflater.inflate(R.layout.fragment_profile,container,false); 91 | profilePhoto = (ImageView) profileView.findViewById(R.id.profile_photo); 92 | changeProfilePhoto = (ImageView) profileView.findViewById(R.id.change_profile_photo); 93 | profileName = (TextView) profileView.findViewById(R.id.profile_name); 94 | profileBio = (TextView) profileView.findViewById(R.id.profile_bio); 95 | profileUserInstagram = (ImageView) profileView.findViewById(R.id.profile_user_instagram); 96 | 97 | changeProfilePhoto.setOnClickListener(new View.OnClickListener() { 98 | @Override 99 | public void onClick(View v) { 100 | Intent intent = new Intent(getContext(), AddPhotoActivity.class); 101 | startActivity(intent); 102 | } 103 | }); 104 | 105 | profileUserInstagram.setOnClickListener(new View.OnClickListener() { 106 | @Override 107 | public void onClick(View v) { 108 | openInstagram(); 109 | } 110 | }); 111 | 112 | // Inflate the layout for this fragment 113 | return profileView; 114 | } 115 | 116 | @Override 117 | public void onResume() { 118 | super.onResume(); 119 | showProfilePhoto(); 120 | 121 | } 122 | 123 | 124 | 125 | private void showProfilePhoto() { 126 | showProgressDialog(); 127 | FirebaseStorage fStorage = FirebaseStorage.getInstance(); 128 | StorageReference storageRef = fStorage.getReference(); 129 | storageRef.child("userprofilephoto").getDownloadUrl().addOnSuccessListener(new OnSuccessListener() { 130 | @Override 131 | public void onSuccess(Uri uri) { 132 | progressDialog.dismiss(); 133 | 134 | Glide.with(getContext()) 135 | .load(uri) 136 | .asBitmap() 137 | .centerCrop() 138 | .into(new SimpleTarget(200,200) { 139 | @Override 140 | public void onResourceReady(Bitmap resource,GlideAnimation glideAnimation) { 141 | profilePhoto.setImageBitmap(resource); 142 | } 143 | }); 144 | 145 | } 146 | }).addOnFailureListener(new OnFailureListener() { 147 | @Override 148 | public void onFailure(@NonNull Exception e) { 149 | progressDialog.dismiss(); 150 | 151 | } 152 | }); 153 | } 154 | 155 | private void showProgressDialog() { 156 | progressDialog = new ProgressDialog(getContext()); 157 | progressDialog.setMessage("Yükleniyor..."); 158 | progressDialog.setCancelable(false); 159 | progressDialog.show(); 160 | } 161 | 162 | private void openInstagram() { 163 | Uri instagramUri = Uri.parse("https://www.instagram.com/gezlist"); 164 | Intent instagramIntent = new Intent(Intent.ACTION_VIEW, instagramUri); 165 | 166 | instagramIntent.setPackage("com.instagram.android"); 167 | 168 | try { 169 | startActivity(instagramIntent); 170 | } catch (ActivityNotFoundException e) { 171 | startActivity(new Intent(Intent.ACTION_VIEW, 172 | Uri.parse("https://www.instagram.com/gezlist"))); 173 | } 174 | 175 | } 176 | 177 | // TODO: Rename method, update argument and hook method into UI event 178 | public void onButtonPressed(Uri uri) { 179 | if (mListener != null) { 180 | mListener.onFragmentInteraction(uri); 181 | } 182 | } 183 | 184 | @Override 185 | public void onAttach(Context context) { 186 | super.onAttach(context); 187 | } 188 | 189 | @Override 190 | public void onDetach() { 191 | super.onDetach(); 192 | mListener = null; 193 | } 194 | 195 | /** 196 | * This interface must be implemented by activities that contain this 197 | * fragment to allow an interaction in this fragment to be communicated 198 | * to the activity and potentially other fragments contained in that 199 | * activity. 200 | *

201 | * See the Android Training lesson Communicating with Other Fragments for more information. 204 | */ 205 | public interface OnFragmentInteractionListener { 206 | // TODO: Update argument type and name 207 | void onFragmentInteraction(Uri uri); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /app/src/main/java/gelecegiyazanlar/com/gykfirebaseauthentication/models/PostModel.java: -------------------------------------------------------------------------------- 1 | package gelecegiyazanlar.com.gykfirebaseauthentication.models; 2 | 3 | public class PostModel { 4 | int postPicture; 5 | String postName; 6 | String postDescription; 7 | 8 | public PostModel() { 9 | } 10 | 11 | public PostModel(int postPicture, String postName, String postDescription) { 12 | 13 | this.postPicture = postPicture; 14 | this.postName = postName; 15 | this.postDescription = postDescription; 16 | } 17 | 18 | 19 | public int getPostPicture() { 20 | return postPicture; 21 | } 22 | 23 | public void setPostPicture(int postPicture) { 24 | this.postPicture = postPicture; 25 | } 26 | 27 | public String getPostName() { 28 | return postName; 29 | } 30 | 31 | public void setPostName(String postName) { 32 | this.postName = postName; 33 | } 34 | 35 | public String getPostDescription() { 36 | return postDescription; 37 | } 38 | 39 | public void setPostDescription(String postDescription) { 40 | this.postDescription = postDescription; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/add_note_ic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/add_note_ic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/add_photo_ic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/add_photo_ic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/foto1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/foto1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/foto2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/foto2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/foto3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/foto3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/foto4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/foto4.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_home_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_person_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_remove_circle_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/instagram_ic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/instagram_ic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/login_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/login_background.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/nav_profile_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/nav_profile_picture.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/register_login_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HasibeZaferr/FirebaseAuthenticationWithNavigationDrawer/d0ae29e8173ca573c1b9c641509c511648868485/app/src/main/res/drawable/register_login_background.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_add_note.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 22 | 23 |