Merge pull request #28 from ClaytonWWilson/aaron-branch

Aaron branch
This commit is contained in:
DreamCoder23 2020-10-03 13:28:52 -07:00 committed by GitHub
commit 27f22a9724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 261 additions and 204 deletions

View File

@ -34,7 +34,7 @@
<activity android:name="com.example.listify.ui.LoginPage" /> <activity android:name="com.example.listify.ui.LoginPage" />
<activity android:name="com.example.listify.ui.ForgotPasswordPage" /> <activity android:name="com.example.listify.ui.ForgotPasswordPage" />
<activity android:name="com.example.listify.ui.ResetPasswordPage" /> <activity android:name="com.example.listify.ui.ResetPasswordPage" />
<activity android:name="com.example.listify.ui.CodePage" /> <activity android:name="com.example.listify.List" />
</application> </application>
</manifest> </manifest>

View File

@ -1,8 +1,76 @@
package com.example.listify; package com.example.listify;
public class List { import android.content.Context;
String name; import android.os.Bundle;
List(String name) { import android.view.LayoutInflater;
this.name = name; import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class List extends AppCompatActivity {
ListView listView;
String listName = "Sample List";
String[] pNames = {"Half-gallon organic whole milk"};
String[] pStores = {"Kroger"};
String[] pPrices = {"$5.00"};
int[] pImages = {R.drawable.milk};
//List(String name) {
// listName = name;
//}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
listView = findViewById(R.id.listView);
MyAdapter myAdapter = new MyAdapter(this, pNames, pStores, pPrices, pImages);
listView.setAdapter(myAdapter);
}
class MyAdapter extends ArrayAdapter<String> {
Context context;
String[] pNames;
String[] pStores;
String[] pPrices;
int[] pImages;
MyAdapter (Context c, String[] names, String[] stores, String[] prices, int[] images) {
super(c, R.layout.listproduct, R.id.productView, names);
context = c;
pNames = names;
pStores = stores;
pPrices = prices;
pImages = images;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View listproduct = layoutInflater.inflate(R.layout.listproduct, parent,false);
ImageView image = listproduct.findViewById(R.id.imageView);
TextView name = listproduct.findViewById(R.id.productView);
TextView store = listproduct.findViewById(R.id.storeView);
TextView price = listproduct.findViewById(R.id.priceView);
image.setImageResource(pImages[position]);
name.setText(pNames[position]);
store.setText(pStores[position]);
price.setText(pPrices[position]);
return listproduct;
}
} }
} }

View File

@ -27,12 +27,13 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
//------------------------------Auth Testing---------------------------------------------// //------------------------------Auth Testing---------------------------------------------//
AuthManager authManager = new AuthManager(); /*AuthManager authManager = new AuthManager();
try { try {
authManager.signIn("merzn@purdue.edu", "Password123"); authManager.signIn("merzn@purdue.edu", "Password123");
Log.i("Authentication", authManager.getAuthSession().toString()); Log.i("Authentication", authManager.getAuthSession().toString());
Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken()); Log.i("Token", authManager.getAuthSession().getUserPoolTokens().getValue().getIdToken());
} catch (AuthException e) { }
catch (AuthException e) {
Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage()); Log.i("Authentication", "Login failed. User probably needs to register. Exact error: " + e.getMessage());
try { try {
authManager.startSignUp("merzn@purdue.edu", "Password123"); authManager.startSignUp("merzn@purdue.edu", "Password123");
@ -40,46 +41,40 @@ public class MainActivity extends AppCompatActivity {
} catch (AuthException signUpError) { } catch (AuthException signUpError) {
Log.e("Authentication", "SignUp error: " + signUpError.getMessage()); Log.e("Authentication", "SignUp error: " + signUpError.getMessage());
} }
} }*/
//------------------------------------------------------------------------------------------//
//----------------------------------API Testing---------------------------------------------// //----------------------------------API Testing---------------------------------------------//
Properties configs = new Properties();
/*Properties configs = new Properties();
try { try {
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json"); configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
} catch (IOException|JSONException e) {
e.printStackTrace();
} }
catch (IOException|JSONException e) {
e.printStackTrace();
}*/
Requestor requestor = new Requestor(this, authManager,configs.getProperty("apiKey")); /*Requestor requestor = new Requestor(this, authManager,configs.getProperty("apiKey"));
List testList = new List("IAmATestList"); List testList = new List("IAmATestList");
try { try {
requestor.postObject(testList); requestor.postObject(testList);
} catch (JSONException e) {
e.printStackTrace();
} }
catch (JSONException e) {
//------------------------------------------------------------------------------------------// e.printStackTrace();
}*/
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
// FloatingActionButton fab = findViewById(R.id.fab); /*FloatingActionButton fab = findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
// @Override @Override
// public void onClick(View view) { public void onClick(View view) {
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
// .setAction("Action", null).show(); }
// } });*/
// });
DrawerLayout drawer = findViewById(R.id.drawer_layout); DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view); NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each // Passing each menu ID as a set of Ids because each menu should be considered as top level destinations.
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder( mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow) R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow)
.setDrawerLayout(drawer) .setDrawerLayout(drawer)
@ -87,14 +82,12 @@ public class MainActivity extends AppCompatActivity {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration); NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController); NavigationUI.setupWithNavController(navigationView, navController);
// Handle search button click // Handle search button click
ImageButton searchButton = (ImageButton) findViewById(R.id.searchButton); ImageButton searchButton = (ImageButton) findViewById(R.id.searchButton);
searchButton.setOnClickListener(new View.OnClickListener() { searchButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, SearchResults.class); Intent intent = new Intent(MainActivity.this, SearchResults.class);
// Send user to SearchResults activity // Send user to SearchResults activity
startActivity(intent); startActivity(intent);
overridePendingTransition(R.anim.enter_from_left, R.anim.exit_from_left); overridePendingTransition(R.anim.enter_from_left, R.anim.exit_from_left);
@ -103,13 +96,12 @@ public class MainActivity extends AppCompatActivity {
}); });
} }
// @Override /*@Override
// public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present. //Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu); getMenuInflater().inflate(R.menu.main, menu);
// return true; return true;
// } }*/
@Override @Override
public boolean onSupportNavigateUp() { public boolean onSupportNavigateUp() {

View File

@ -55,8 +55,8 @@ public class LoginPage extends AppCompatActivity {
try { try {
authManager.signIn(email, password); authManager.signIn(email, password);
//Intent intent = new Intent(LoginPage.this, LoginPage.class); Intent intent = new Intent(LoginPage.this, MainActivity.class);
//startActivity(intent); startActivity(intent);
} }
catch(Exception ex) { catch(Exception ex) {
//Display "Incorrect email or password" message //Display "Incorrect email or password" message

View File

@ -68,8 +68,8 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
else { else {
try { try {
authManager.confirmSignUp(code); authManager.confirmSignUp(code);
//Intent intent = new Intent(SignupPage.this, MainActivity.class); Intent intent = new Intent(SignupPage.this, MainActivity.class);
//startActivity(intent); startActivity(intent);
} }
catch (Exception e) { catch (Exception e) {
//Remove user from database //Remove user from database

View File

@ -14,17 +14,29 @@ import com.example.listify.R;
public class HomeFragment extends Fragment { public class HomeFragment extends Fragment {
private Button toLoginPage; private Button toLoginPage;
private Button toListPage;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_home, container, false); View root = inflater.inflate(R.layout.fragment_home, container, false);
toLoginPage = (Button) root.findViewById(R.id.button1); toLoginPage = (Button) root.findViewById(R.id.button1);
toLoginPage.setOnClickListener(new View.OnClickListener() { toLoginPage.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ui.SignupPage.class); Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ui.LoginPage.class);
startActivity(intent); startActivity(intent);
} }
}); });
toListPage = (Button) root.findViewById(R.id.button2);
toListPage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.List.class);
startActivity(intent);
}
});
return root; return root;
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView">
</ListView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,142 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="28dp"
android:text="List Name"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="@+id/cardView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="85dp"
app:cardElevation="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="400px"
android:padding="10dp">
<ImageView
android:id="@+id/imageView1"
android:layout_width="400px"
android:layout_height="wrap_content"
android:src="@drawable/lisitfy_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/productView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="30dp"
android:layout_marginBottom="100dp"
android:text="Product Name"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView1"
android:textSize="20sp"/>
<TextView
android:id="@+id/priceView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="30dp"
android:layout_marginBottom="90dp"
android:text="Price"
app:layout_constraintTop_toBottomOf="@+id/productView1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView1"
android:textSize="15sp"/>
<TextView
android:id="@+id/storeView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="30dp"
android:layout_marginBottom="80dp"
android:text="Store Address"
app:layout_constraintTop_toBottomOf="@+id/priceView1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView1"
android:textSize="15sp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:cardElevation="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardView1">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="400px"
android:padding="10dp">
<ImageView
android:id="@+id/imageView2"
android:layout_width="400px"
android:layout_height="wrap_content"
android:src="@drawable/lisitfy_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/productView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="30dp"
android:layout_marginBottom="100dp"
android:text="Product Name"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView2"
android:textSize="20sp"/>
<TextView
android:id="@+id/priceView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="30dp"
android:layout_marginBottom="90dp"
android:text="Price"
app:layout_constraintTop_toBottomOf="@+id/productView2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView2"
android:textSize="15sp"/>
<TextView
android:id="@+id/storeView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="30dp"
android:layout_marginBottom="80dp"
android:text="Store Address"
app:layout_constraintTop_toBottomOf="@+id/priceView2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView2"
android:textSize="15sp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -10,32 +10,39 @@
android:id="@+id/button1" android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="1dp" android:layout_marginBottom="25dp"
android:layout_marginRight="1dp" android:layout_marginStart="1dp"
android:layout_marginTop="29dp" android:text="Log in"
android:text="Button" app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintEnd_toEndOf="@+id/switch2" app:layout_constraintStart_toStartOf="@+id/button2" />
app:layout_constraintTop_toBottomOf="@+id/switch2" />
<Switch <Button
android:id="@+id/switch2" android:id="@+id/button2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="19dp" android:layout_marginBottom="148dp"
android:layout_marginRight="19dp" android:text="List"
android:layout_marginTop="31dp" app:layout_constraintBottom_toBottomOf="parent"
android:text="Target" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toEndOf="@+id/textView4" app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintTop_toBottomOf="@+id/textView4" />
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="29dp"
android:text="Kroger"
app:layout_constraintBottom_toTopOf="@+id/button1"
app:layout_constraintStart_toStartOf="@+id/button1" />
<TextView <TextView
android:id="@+id/textView4" android:id="@+id/textView4"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="31dp"
android:text="Search these stores:" android:text="Search these stores:"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@+id/switch1"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="wrap_content"
android:layout_height="400px"
android:padding="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/buttonIncr"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="25dp"
android:text="+"
android:textSize="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/storeView" />
<Button
android:id="@+id/buttonDecr"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="75dp"
android:text="-"
android:textSize="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/storeView" />
<Button
android:id="@+id/buttonDel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="150dp"
android:text="Remove"
android:textSize="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/storeView" />
<ImageView
android:id="@+id/imageView"
android:layout_width="400px"
android:layout_height="wrap_content"
android:src="@drawable/placeholder"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/productView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="100dp"
android:padding="30dp"
android:text="Product Name"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/storeView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="90dp"
android:padding="30dp"
android:text="Store"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/productView" />
<TextView
android:id="@+id/priceView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="80dp"
android:padding="30dp"
android:text="Price"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/storeView" />
<TextView
android:id="@+id/textViewQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/buttonDecr"
app:layout_constraintStart_toEndOf="@+id/buttonIncr"
app:layout_constraintTop_toBottomOf="@+id/storeView" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>