Skip to content

Commit

Permalink
Finished UI mockups for login page, register page, and user profile (#78
Browse files Browse the repository at this point in the history
)

* Finished UI mockups for login page, register page, and user profile

* Pushing this commit because Owen is a soy boy

* Changed main startup activity

* switch to 1 XML (light mode) for login/register (#82)

* Very rough draft of user profile/login/logout

* Added unique username check

* Updated to use authentication and encryption

* moving off branch

* Added user authentication with unique usernames

* Finished

* Added javadocs

* Added bug fixes from Lukas

* Added Owen's changes

---------

Co-authored-by: Owen Cooke <90405643+owencooke@users.noreply.github.com>
  • Loading branch information
antonio2uofa and owencooke authored Dec 2, 2023
1 parent fb00691 commit 3bc765c
Show file tree
Hide file tree
Showing 25 changed files with 1,096 additions and 17 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ android {
}

dependencies {
implementation(platform("com.google.firebase:firebase-bom:32.4.0"))
// Import the BoM for the Firebase platform
implementation(platform("com.google.firebase:firebase-bom:32.6.0"))
// implementation(platform("com.google.firebase:firebase-bom:32.4.0"))
implementation("com.google.firebase:firebase-firestore")
implementation("com.google.firebase:firebase-storage")
implementation("com.firebaseui:firebase-ui-storage:7.2.0")
Expand All @@ -57,5 +59,6 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.4.0")
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
implementation("com.google.firebase:firebase-auth")
compileOnly(files("${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.example.househomey;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.clearText;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.hasErrorText;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

import androidx.test.core.app.ActivityScenario;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SignInFragmentTest {
private ActivityScenario<SignInActivity> activityScenario;

@Before
public void setUp() {
// Launch the activity before each test
activityScenario = ActivityScenario.launch(SignInActivity.class);
}

@Test
public void testUsername() {
onView(withId(R.id.signin_username)).perform(typeText("antonio2"));
onView(withId(R.id.signin_username)).perform(clearText());
onView(withId(R.id.signin_username)).check(matches(hasErrorText("username cannot be empty")));
onView(withId(R.id.signin_username)).perform(typeText("antonio2$"));
onView(withId(R.id.signin_username)).check(matches(hasErrorText("only alphanumeric, underscore, or period")));
}

@Test
public void testPassword() {
onView(withId(R.id.signin_password)).perform(typeText("123456"));
onView(withId(R.id.signin_password)).perform(clearText());
onView(withId(R.id.signin_password)).check(matches(hasErrorText("password cannot be empty")));
}

@Test
public void testLogin() {

}

@After
public void tearDown() {
activityScenario.close();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.example.househomey;

public class SignUpFragmentTest {
}
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
android:name=".MainActivity"
android:windowSoftInputMode="adjustPan"
android:exported="true">
</activity>
<activity android:name=".SignInActivity"
android:windowSoftInputMode="adjustPan"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/househomey/HomeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
args.putString("currentSortName",currentSortName);
args.putSerializable("idMap", (Serializable) itemIdMap);
selectStateFragment.setArguments(args);
navigateToFragmentPage(getContext(), selectStateFragment);
navigateToFragmentPage(getContext(), selectStateFragment, R.id.fragmentContainer);
});

View filterButton = rootView.findViewById(R.id.filter_dropdown_button);
Expand Down
23 changes: 13 additions & 10 deletions app/src/main/java/com/example/househomey/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import static com.example.househomey.utils.FragmentUtils.navigateToFragmentPage;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import com.example.househomey.form.AddItemFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
Expand All @@ -32,17 +35,15 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Handle the test user data
Bundle userData = getIntent().getBundleExtra("userData");
if (userData != null) {
String username = userData.getString("username");
user = new User(username);
FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
if (currentUser != null) {
user = new User(currentUser.getDisplayName());
} else {
// create or login a user, for now just assume...
user = new User("john_doe");
Intent intent = new Intent(this, SignInActivity.class);
this.startActivity(intent);
}


// Init home fragment
navigateToFragmentPage(this, new HomeFragment());

Expand All @@ -57,8 +58,10 @@ protected void onCreate(Bundle savedInstanceState) {
// Go to Add Item page
fragment = new AddItemFragment();
} else {
// TODO: Go to Profile Page
fragment = new HomeFragment();
Bundle name = new Bundle();
name.putString("username", user.getUsername());
fragment = new UserProfileFragment();
fragment.setArguments(name);
}
navigateToFragmentPage(this, fragment);
return true;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/househomey/SelectFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
outgoing_args.putString("currentSortName",currentSortName);
outgoing_args.putBoolean("sortOrder", sortOrder);
homeFragment.setArguments(outgoing_args);
navigateToFragmentPage(getContext(),homeFragment);
navigateToFragmentPage(getContext(), homeFragment);
});

final Button deleteButton = rootView.findViewById(R.id.action_delete);
Expand Down Expand Up @@ -184,7 +184,7 @@ public void onOKPressed(ArrayList<Item> selectedItems){
outgoing_args.putString("currentSortName",currentSortName);
outgoing_args.putBoolean("sortOrder", sortOrder);
homeFragment.setArguments(outgoing_args);
navigateToFragmentPage(getContext(),homeFragment);
navigateToFragmentPage(getContext(), homeFragment);
}

/**
Expand Down
55 changes: 55 additions & 0 deletions app/src/main/java/com/example/househomey/SignInActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.example.househomey;

import static com.example.househomey.utils.FragmentUtils.navigateToFragmentPage;
import static com.google.firebase.appcheck.internal.util.Logger.TAG;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;

import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
* SignInActivity of the application, handles setting up the sign in page
* @author Antonio Lech Martin-Ozimek
*/
public class SignInActivity extends AppCompatActivity {

/**
* This launches the SignInActivity which is the basis for both the SignInFragment
* and the SignUpFragment. Once the user has signed in we exit this activity.
*
* @param savedInstanceState A Bundle containing the activity's previously frozen state, or null
* if there was none.
*/
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signin);
navigateToFragmentPage(this, new SignInFragment(), R.id.fragmentContainerSignIn);

}
}
Loading

0 comments on commit 3bc765c

Please sign in to comment.