diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/AndroidManifest.xml | 23 | ||||
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/DataKeeper.java | 10 | ||||
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/LoginActivity.java | 113 | ||||
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/MainActivity.java | 13 | ||||
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/NewObservationActivity.java | 3 | ||||
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/ResetPasswordActivity.java | 72 | ||||
-rw-r--r-- | app/src/main/java/org/marcinzelent/liberavem/SignupActivity.java | 107 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_login.xml | 98 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_new_observation.xml | 192 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_reset_password.xml | 92 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_signup.xml | 103 | ||||
-rw-r--r-- | app/src/main/res/menu/activity_main_drawer.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/values/colors.xml | 14 | ||||
-rw-r--r-- | app/src/main/res/values/dimens.xml | 1 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 31 |
15 files changed, 773 insertions, 103 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d503607..5639a98 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,11 @@ <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <!-- To auto-complete the email text field in the login form with the user's emails --> + <uses-permission android:name="android.permission.GET_ACCOUNTS" /> + <uses-permission android:name="android.permission.READ_PROFILE" /> + <uses-permission android:name="android.permission.READ_CONTACTS" /> + <application android:allowBackup="false" android:icon="@mipmap/ic_launcher" @@ -18,23 +23,29 @@ android:name=".MainActivity" android:label="@string/title_activity_main" android:theme="@style/AppTheme.NoActionBar"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> </activity> <activity android:name=".SettingsActivity" android:label="@string/title_activity_settings" /> <activity android:name=".ObservationDetailsActivity" - android:label="@string/observation_details"/> + android:label="@string/observation_details" /> <activity android:name=".NewObservationActivity" android:label="@string/title_activity_new_observation" android:theme="@style/AppTheme" /> <activity android:name=".BirdPickerActivity" /> + <activity + android:name=".LoginActivity" + android:label="@string/title_activity_login" + android:theme="@style/AppTheme.NoActionBar"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity android:name=".SignupActivity" /> + <activity android:name=".ResetPasswordActivity"></activity> </application> </manifest>
\ No newline at end of file diff --git a/app/src/main/java/org/marcinzelent/liberavem/DataKeeper.java b/app/src/main/java/org/marcinzelent/liberavem/DataKeeper.java index 5fa975b..172713d 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/DataKeeper.java +++ b/app/src/main/java/org/marcinzelent/liberavem/DataKeeper.java @@ -9,6 +9,7 @@ import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; +import com.google.firebase.auth.FirebaseAuth; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -50,7 +51,7 @@ public class DataKeeper { } public void downloadData(final Activity activity) { - downloadBirds(activity); + if (birds == null) downloadBirds(activity); downloadObservations(activity); } @@ -115,9 +116,10 @@ public class DataKeeper { ((AllObservationsFragment) fragment).populateList(observations, birds); else { List<Observation> myObservationsList = new ArrayList<>(); - for (Observation o : observations) - if (o.getUserId().equals("Sminem")) myObservationsList.add(o); - + for (Observation o : observations) { + String uid = FirebaseAuth.getInstance().getCurrentUser().getUid(); + if (o.getUserId().equals(uid)) myObservationsList.add(o); + } Observation[] myObservations = new Observation[myObservationsList.size()]; myObservations = myObservationsList.toArray(myObservations); ((MyObservationsFragment) fragment).populateList(myObservations, birds); diff --git a/app/src/main/java/org/marcinzelent/liberavem/LoginActivity.java b/app/src/main/java/org/marcinzelent/liberavem/LoginActivity.java new file mode 100644 index 0000000..25acb3d --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/LoginActivity.java @@ -0,0 +1,113 @@ +package org.marcinzelent.liberavem; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.Toast; + +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.auth.AuthResult; +import com.google.firebase.auth.FirebaseAuth; + +public class LoginActivity extends AppCompatActivity { + + private EditText inputEmail, inputPassword; + private FirebaseAuth auth; + private ProgressBar progressBar; + private Button btnSignup, btnLogin, btnReset; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + //Get Firebase auth instance + auth = FirebaseAuth.getInstance(); + + if (auth.getCurrentUser() != null) { + startActivity(new Intent(LoginActivity.this, MainActivity.class)); + finish(); + } + + // set the view now + setContentView(R.layout.activity_login); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + inputEmail = (EditText) findViewById(R.id.email); + inputPassword = (EditText) findViewById(R.id.password); + progressBar = (ProgressBar) findViewById(R.id.progressBar); + btnSignup = (Button) findViewById(R.id.btn_signup); + btnLogin = (Button) findViewById(R.id.btn_login); + btnReset = (Button) findViewById(R.id.btn_reset_password); + + //Get Firebase auth instance + auth = FirebaseAuth.getInstance(); + + btnSignup.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(LoginActivity.this, SignupActivity.class)); + } + }); + + btnReset.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(LoginActivity.this, ResetPasswordActivity.class)); + } + }); + + btnLogin.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String email = inputEmail.getText().toString(); + final String password = inputPassword.getText().toString(); + + if (TextUtils.isEmpty(email)) { + Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show(); + return; + } + + if (TextUtils.isEmpty(password)) { + Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show(); + return; + } + + progressBar.setVisibility(View.VISIBLE); + + //authenticate user + auth.signInWithEmailAndPassword(email, password) + .addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() { + @Override + public void onComplete(@NonNull Task<AuthResult> task) { + // If sign in fails, display a message to the user. If sign in succeeds + // the auth state listener will be notified and logic to handle the + // signed in user can be handled in the listener. + progressBar.setVisibility(View.GONE); + if (!task.isSuccessful()) { + // there was an error + if (password.length() < 6) { + inputPassword.setError(getString(R.string.minimum_password)); + } else { + Toast.makeText(LoginActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show(); + } + } else { + Intent intent = new Intent(LoginActivity.this, MainActivity.class); + startActivity(intent); + finish(); + } + } + }); + } + }); + } +}
\ No newline at end of file diff --git a/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java b/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java index b32358a..e53a05c 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java +++ b/app/src/main/java/org/marcinzelent/liberavem/MainActivity.java @@ -27,6 +27,7 @@ import com.android.volley.Request; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; +import com.google.firebase.auth.FirebaseAuth; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -37,7 +38,6 @@ public class MainActivity extends AppCompatActivity ObservationsFragment.OnFragmentInteractionListener, AtlasFragment.OnFragmentInteractionListener { - Fragment observationsFragment = null; @Override protected void onCreate(Bundle savedInstanceState) { @@ -47,16 +47,17 @@ public class MainActivity extends AppCompatActivity setSupportActionBar(toolbar); if (savedInstanceState ==null) { + Fragment fragment = null; Class fragmentClass = null; fragmentClass = ObservationsFragment.class; try { - observationsFragment = (Fragment) fragmentClass.newInstance(); + fragment = (Fragment) fragmentClass.newInstance(); } catch (Exception e) { e.printStackTrace(); } FragmentManager fragmentManager = getSupportFragmentManager(); - fragmentManager.beginTransaction().replace(R.id.flContent, observationsFragment).commit(); + fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit(); } DrawerLayout drawer = findViewById(R.id.drawer_layout); @@ -119,6 +120,12 @@ public class MainActivity extends AppCompatActivity startActivity(settingsIntent); } else if (id == R.id.nav_about) { + } else if (id == R.id.nav_signout) { + FirebaseAuth auth = FirebaseAuth.getInstance(); + auth.signOut(); + finish(); + Intent intent = new Intent(this, LoginActivity.class); + startActivity(intent); } if (fragmentClass != null) { try { diff --git a/app/src/main/java/org/marcinzelent/liberavem/NewObservationActivity.java b/app/src/main/java/org/marcinzelent/liberavem/NewObservationActivity.java index e69eaba..f6488e4 100644 --- a/app/src/main/java/org/marcinzelent/liberavem/NewObservationActivity.java +++ b/app/src/main/java/org/marcinzelent/liberavem/NewObservationActivity.java @@ -28,6 +28,7 @@ import com.android.volley.VolleyLog; import com.android.volley.toolbox.HttpHeaderParser; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; +import com.google.firebase.auth.FirebaseAuth; import org.json.JSONException; import org.json.JSONObject; @@ -128,7 +129,7 @@ public class NewObservationActivity extends AppCompatActivity { jsonBody.put("Longitude", ((EditText)findViewById(R.id.new_longitude)).getText()); jsonBody.put("Placename", ((EditText)findViewById(R.id.new_place)).getText()); jsonBody.put("Population", ((EditText)findViewById(R.id.new_population)).getText()); - jsonBody.put("UserId", "Sminem"); + jsonBody.put("UserId", FirebaseAuth.getInstance().getCurrentUser().getUid()); jsonBody.put("NameDanish", selectedBird.getNameDanish()); jsonBody.put("NameEnglish", selectedBird.getNameEnglish()); final String requestBody = jsonBody.toString(); diff --git a/app/src/main/java/org/marcinzelent/liberavem/ResetPasswordActivity.java b/app/src/main/java/org/marcinzelent/liberavem/ResetPasswordActivity.java new file mode 100644 index 0000000..cd53374 --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/ResetPasswordActivity.java @@ -0,0 +1,72 @@ +package org.marcinzelent.liberavem; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.Toast; + +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.auth.FirebaseAuth; + +public class ResetPasswordActivity extends AppCompatActivity { + + private EditText inputEmail; + private Button btnReset, btnBack; + private FirebaseAuth auth; + private ProgressBar progressBar; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_reset_password); + + inputEmail = (EditText) findViewById(R.id.email); + btnReset = (Button) findViewById(R.id.btn_reset_password); + btnBack = (Button) findViewById(R.id.btn_back); + progressBar = (ProgressBar) findViewById(R.id.progressBar); + + auth = FirebaseAuth.getInstance(); + + btnBack.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + btnReset.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + String email = inputEmail.getText().toString().trim(); + + if (TextUtils.isEmpty(email)) { + Toast.makeText(getApplication(), "Enter your registered email id", Toast.LENGTH_SHORT).show(); + return; + } + + progressBar.setVisibility(View.VISIBLE); + auth.sendPasswordResetEmail(email) + .addOnCompleteListener(new OnCompleteListener<Void>() { + @Override + public void onComplete(@NonNull Task<Void> task) { + if (task.isSuccessful()) { + Toast.makeText(ResetPasswordActivity.this, "We have sent you instructions to reset your password!", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(ResetPasswordActivity.this, "Failed to send reset email!", Toast.LENGTH_SHORT).show(); + } + + progressBar.setVisibility(View.GONE); + } + }); + } + }); + } + +}
\ No newline at end of file diff --git a/app/src/main/java/org/marcinzelent/liberavem/SignupActivity.java b/app/src/main/java/org/marcinzelent/liberavem/SignupActivity.java new file mode 100644 index 0000000..280072a --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/SignupActivity.java @@ -0,0 +1,107 @@ +package org.marcinzelent.liberavem; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ProgressBar; +import android.widget.Toast; + +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; +import com.google.firebase.auth.AuthResult; +import com.google.firebase.auth.FirebaseAuth; + +public class SignupActivity extends AppCompatActivity { + + private EditText inputEmail, inputPassword; + private Button btnSignIn, btnSignUp, btnResetPassword; + private ProgressBar progressBar; + private FirebaseAuth auth; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_signup); + + //Get Firebase auth instance + auth = FirebaseAuth.getInstance(); + + btnSignIn = (Button) findViewById(R.id.sign_in_button); + btnSignUp = (Button) findViewById(R.id.sign_up_button); + inputEmail = (EditText) findViewById(R.id.email); + inputPassword = (EditText) findViewById(R.id.password); + progressBar = (ProgressBar) findViewById(R.id.progressBar); + btnResetPassword = (Button) findViewById(R.id.btn_reset_password); + + btnResetPassword.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(SignupActivity.this, ResetPasswordActivity.class)); + } + }); + + btnSignIn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + btnSignUp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + String email = inputEmail.getText().toString().trim(); + String password = inputPassword.getText().toString().trim(); + + if (TextUtils.isEmpty(email)) { + Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show(); + return; + } + + if (TextUtils.isEmpty(password)) { + Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show(); + return; + } + + if (password.length() < 6) { + Toast.makeText(getApplicationContext(), "Password too short, enter minimum 6 characters!", Toast.LENGTH_SHORT).show(); + return; + } + + progressBar.setVisibility(View.VISIBLE); + //create user + auth.createUserWithEmailAndPassword(email, password) + .addOnCompleteListener(SignupActivity.this, new OnCompleteListener<AuthResult>() { + @Override + public void onComplete(@NonNull Task<AuthResult> task) { + Toast.makeText(SignupActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show(); + progressBar.setVisibility(View.GONE); + // If sign in fails, display a message to the user. If sign in succeeds + // the auth state listener will be notified and logic to handle the + // signed in user can be handled in the listener. + if (!task.isSuccessful()) { + Toast.makeText(SignupActivity.this, "Authentication failed." + task.getException(), + Toast.LENGTH_SHORT).show(); + } else { + startActivity(new Intent(SignupActivity.this, MainActivity.class)); + finish(); + } + } + }); + + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + progressBar.setVisibility(View.GONE); + } +} diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..160803c --- /dev/null +++ b/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,98 @@ +<?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="true" + tools:context="org.marcinzelent.liberavem.LoginActivity"> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@color/colorPrimary" + android:gravity="center" + android:orientation="vertical" + android:padding="@dimen/activity_horizontal_margin"> + + + <ImageView + android:layout_width="@dimen/logo_w_h" + android:layout_height="@dimen/logo_w_h" + android:layout_gravity="center_horizontal" + android:layout_marginBottom="30dp" + android:src="@mipmap/ic_launcher" /> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <EditText + android:id="@+id/email" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:hint="@string/hint_email" + android:inputType="textEmailAddress" + android:textColor="@android:color/white" + android:textColorHint="@android:color/white" /> + </android.support.design.widget.TextInputLayout> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <EditText + android:id="@+id/password" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:hint="@string/hint_password" + android:inputType="textPassword" + android:textColor="@android:color/white" + android:textColorHint="@android:color/white" /> + </android.support.design.widget.TextInputLayout> + + <!-- Login Button --> + + <Button + android:id="@+id/btn_login" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dip" + android:background="@color/colorAccent" + android:text="@string/btn_login" + android:textColor="@android:color/black" /> + + <Button + android:id="@+id/btn_reset_password" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dip" + android:background="@null" + android:text="@string/btn_forgot_password" + android:textAllCaps="false" + android:textColor="@color/colorAccent" /> + + <!-- Link to Login Screen --> + + <Button + android:id="@+id/btn_signup" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dip" + android:background="@null" + android:text="@string/btn_link_to_register" + android:textAllCaps="false" + android:textColor="@color/white" + android:textSize="15dp" /> + </LinearLayout> + + <ProgressBar + android:id="@+id/progressBar" + android:layout_width="30dp" + android:layout_height="30dp" + android:layout_gravity="center|bottom" + android:layout_marginBottom="20dp" + android:visibility="gone" /> +</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/activity_new_observation.xml b/app/src/main/res/layout/activity_new_observation.xml index 0f3b10f..76e80f8 100644 --- a/app/src/main/res/layout/activity_new_observation.xml +++ b/app/src/main/res/layout/activity_new_observation.xml @@ -6,106 +6,120 @@ android:layout_height="match_parent" tools:context=".NewObservationActivity"> - <Spinner - android:id="@+id/new_birds" + <ScrollView android:layout_width="match_parent" android:layout_height="0dp" - android:layout_marginEnd="16dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginStart="16dp" - android:layout_marginTop="16dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBottom_toTopOf="@+id/linearLayout" + app:layout_constraintTop_toTopOf="parent"> - <EditText - android:id="@+id/new_population" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:ems="10" - android:hint="@string/population" - android:inputType="textPersonName" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/new_birds" /> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> - <EditText - android:id="@+id/new_place" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:ems="10" - android:hint="@string/place" - android:inputType="textPersonName" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/new_population" /> + <Spinner + android:id="@+id/new_birds" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_marginStart="16dp" + android:layout_marginTop="16dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - <EditText - android:id="@+id/new_longitude" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:ems="10" - android:hint="@string/longitude" - android:inputType="textPersonName" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/new_place" /> + <EditText + android:id="@+id/new_population" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="8dp" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:ems="10" + android:hint="@string/population" + android:inputType="textPersonName" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/new_birds" /> - <EditText - android:id="@+id/new_latitude" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:ems="10" - android:hint="@string/latitude" - android:inputType="textPersonName" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/new_longitude" /> + <EditText + android:id="@+id/new_place" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="8dp" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:ems="10" + android:hint="@string/place" + android:inputType="textPersonName" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/new_population" /> - <EditText - android:id="@+id/new_comment" - android:layout_width="0dp" - android:layout_height="0dp" - android:layout_marginBottom="8dp" - android:layout_marginEnd="8dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:ems="10" - android:gravity="top" - android:hint="@string/comment" - android:inputType="textMultiLine" - app:layout_constraintBottom_toTopOf="@+id/linearLayout" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/new_latitude" /> + <EditText + android:id="@+id/new_latitude" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="8dp" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:ems="10" + android:hint="@string/latitude" + android:inputType="textPersonName" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/new_longitude" /> + + <EditText + android:id="@+id/new_longitude" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="8dp" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:ems="10" + android:hint="@string/longitude" + android:inputType="textPersonName" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/new_place" /> + + <EditText + android:id="@+id/new_comment" + android:layout_width="match_parent" + android:layout_height="200dp" + android:layout_marginBottom="8dp" + android:layout_marginEnd="8dp" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:ems="10" + android:gravity="top" + android:hint="@string/comment" + android:inputType="textMultiLine" + app:layout_constraintBottom_toTopOf="@+id/linearLayout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/new_latitude" /> + + </LinearLayout> + </ScrollView> <LinearLayout android:id="@+id/linearLayout" style="?android:attr/buttonBarStyle" - android:layout_width="0dp" + android:layout_width="360dp" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginEnd="8dp" diff --git a/app/src/main/res/layout/activity_reset_password.xml b/app/src/main/res/layout/activity_reset_password.xml new file mode 100644 index 0000000..d4cbff0 --- /dev/null +++ b/app/src/main/res/layout/activity_reset_password.xml @@ -0,0 +1,92 @@ +<?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:layout_gravity="center" + android:background="@color/colorPrimary" + android:fitsSystemWindows="true" + tools:context="org.marcinzelent.liberavem.LoginActivity"> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="30dp" + android:gravity="center" + android:orientation="vertical" + android:padding="@dimen/activity_horizontal_margin"> + + + <ImageView + android:layout_width="@dimen/logo_w_h" + android:layout_height="@dimen/logo_w_h" + android:layout_gravity="center_horizontal" + android:layout_marginBottom="10dp" + android:src="@mipmap/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:padding="10dp" + android:text="@string/lbl_forgot_password" + android:textColor="@android:color/white" + android:textSize="20dp" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:gravity="center_horizontal" + android:padding="@dimen/activity_horizontal_margin" + android:text="@string/forgot_password_msg" + android:textColor="@android:color/white" + android:textSize="14dp" /> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <EditText + android:id="@+id/email" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:layout_marginTop="20dp" + android:hint="@string/hint_email" + android:inputType="textEmailAddress" + android:textColor="@android:color/white" + android:textColorHint="@android:color/white" /> + </android.support.design.widget.TextInputLayout> + + <!-- Login Button --> + + <Button + android:id="@+id/btn_reset_password" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dip" + android:background="@color/colorAccent" + android:text="@string/btn_reset_password" + android:textColor="@android:color/black" /> + + <Button + android:id="@+id/btn_back" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:background="@null" + android:text="@string/btn_back" + android:textColor="@color/colorAccent" /> + + </LinearLayout> + + <ProgressBar + android:id="@+id/progressBar" + android:layout_width="30dp" + android:layout_height="30dp" + android:layout_gravity="center|bottom" + android:layout_marginBottom="20dp" + android:visibility="gone" /> +</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/activity_signup.xml b/app/src/main/res/layout/activity_signup.xml new file mode 100644 index 0000000..2d4d966 --- /dev/null +++ b/app/src/main/res/layout/activity_signup.xml @@ -0,0 +1,103 @@ +<?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="true" + tools:context="org.marcinzelent.liberavem.LoginActivity"> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@color/colorPrimaryDark" + android:gravity="center" + android:orientation="vertical" + android:padding="@dimen/activity_horizontal_margin"> + + + <ImageView + android:layout_width="@dimen/logo_w_h" + android:layout_height="@dimen/logo_w_h" + android:layout_gravity="center_horizontal" + android:layout_marginBottom="30dp" + android:src="@mipmap/ic_launcher" /> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <EditText + android:id="@+id/email" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/email" + android:inputType="textEmailAddress" + android:maxLines="1" + android:singleLine="true" + android:textColor="@android:color/white" /> + + </android.support.design.widget.TextInputLayout> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <EditText + android:id="@+id/password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:focusableInTouchMode="true" + android:hint="@string/hint_password" + android:imeActionId="@+id/login" + android:imeOptions="actionUnspecified" + android:inputType="textPassword" + android:maxLines="1" + android:singleLine="true" + android:textColor="@android:color/white" /> + + </android.support.design.widget.TextInputLayout> + + <Button + android:id="@+id/sign_up_button" + style="?android:textAppearanceSmall" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:background="@color/colorAccent" + android:text="@string/action_sign_in_short" + android:textColor="@android:color/black" + android:textStyle="bold" /> + + <Button + android:id="@+id/btn_reset_password" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dip" + android:background="@null" + android:text="@string/btn_forgot_password" + android:textAllCaps="false" + android:textColor="@color/colorAccent" /> + + <!-- Link to Login Screen --> + + <Button + android:id="@+id/sign_in_button" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="20dip" + android:background="@null" + android:text="@string/btn_link_to_login" + android:textAllCaps="false" + android:textColor="@color/white" + android:textSize="15dp" /> + </LinearLayout> + + <ProgressBar + android:id="@+id/progressBar" + android:layout_width="30dp" + android:layout_height="30dp" + android:layout_gravity="center|bottom" + android:layout_marginBottom="20dp" + android:visibility="gone" /> +</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index c6e5d7f..208efd6 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -20,6 +20,10 @@ android:id="@+id/nav_about" android:icon="@android:drawable/ic_menu_info_details" android:title="@string/about" /> + <item + android:id="@+id/nav_signout" + android:icon="@android:drawable/ic_menu_view" + android:title="@string/sign_out" /> </group> </menu> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 3ab3e9c..a3b6a98 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,4 +3,18 @@ <color name="colorPrimary">#3F51B5</color> <color name="colorPrimaryDark">#303F9F</color> <color name="colorAccent">#FF4081</color> + + <color name="bg_login">#26ae90</color> + <color name="bg_register">#2e3237</color> + <color name="bg_main">#428bca</color> + <color name="white">#ffffff</color> + <color name="input_login">#222222</color> + <color name="input_login_hint">#999999</color> + <color name="input_register">#888888</color> + <color name="input_register_bg">#3b4148</color> + <color name="input_register_hint">#5e6266</color> + <color name="btn_login">#26ae90</color> + <color name="btn_login_bg">#eceef1</color> + <color name="lbl_name">#333333</color> + <color name="btn_logut_bg">#ff6861</color> </resources> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 4ab4520..f3fc089 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -5,4 +5,5 @@ <dimen name="nav_header_vertical_spacing">8dp</dimen> <dimen name="nav_header_height">176dp</dimen> <dimen name="fab_margin">16dp</dimen> + <dimen name="logo_w_h">100dp</dimen> </resources>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4885413..15effa3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -103,4 +103,35 @@ <string name="cancel">Cancel</string> <string name="add">Add</string> <string name="observation_details">Observation details</string> + + <!-- Strings related to login --> + <string name="action_sign_in_short">Register</string> + <string name="email">Email</string> + <string name="minimum_password">Password too short, enter minimum 6 characters!</string> + <string name="auth_failed">Authentication failed, check your email and password or sign up</string> + <string name="change_email">Change Email</string> + <string name="change_password">Change Password</string> + <string name="send_password_reset_email">Send Password reset email</string> + <string name="remove_user">Remove user</string> + <string name="new_pass">New Password</string> + <string name="title_activity_profile">Firebase</string> + <string name="title_activity_login">Sign in</string> + <string name="hint_email">Email</string> + <string name="hint_password">Password</string> + <string name="hint_name">Fullname</string> + <string name="btn_login">LOGIN</string> + <string name="btn_link_to_register">Not a member? Get registered in Firebase now!</string> + <string name="btn_link_to_login">Already registered. Login Me!</string> + <string name="title_activity_reset_password">ResetPasswordActivity</string> + <string name="btn_forgot_password">Forgot your password?</string> + <string name="btn_reset_password">Reset Password</string> + <string name="btn_back"><![CDATA[<< Back]]></string> + <string name="hint_new_email">New Email</string> + <string name="btn_change">Change</string> + <string name="btn_send">Send</string> + <string name="btn_remove">Remove</string> + <string name="btn_sign_out">Sign Out</string> + <string name="lbl_forgot_password">Forgot password?</string> + <string name="forgot_password_msg">We just need your registered Email Id to sent you password reset instructions.</string> + <string name="sign_out">Sign out</string> </resources> |