diff --git a/Listify/app/src/main/AndroidManifest.xml b/Listify/app/src/main/AndroidManifest.xml index d6e08aa..9de69e3 100644 --- a/Listify/app/src/main/AndroidManifest.xml +++ b/Listify/app/src/main/AndroidManifest.xml @@ -34,7 +34,7 @@ - + \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/List.java b/Listify/app/src/main/java/com/example/listify/List.java index 3a828b1..ae251ea 100644 --- a/Listify/app/src/main/java/com/example/listify/List.java +++ b/Listify/app/src/main/java/com/example/listify/List.java @@ -1,8 +1,76 @@ package com.example.listify; -public class List { - String name; - List(String name) { - this.name = name; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +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 { + 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; + } } } diff --git a/Listify/app/src/main/java/com/example/listify/MainActivity.java b/Listify/app/src/main/java/com/example/listify/MainActivity.java index 8260ed5..0549e08 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -27,12 +27,13 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); //------------------------------Auth Testing---------------------------------------------// - AuthManager authManager = new AuthManager(); + /*AuthManager authManager = new AuthManager(); try { authManager.signIn("merzn@purdue.edu", "Password123"); Log.i("Authentication", authManager.getAuthSession().toString()); 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()); try { authManager.startSignUp("merzn@purdue.edu", "Password123"); @@ -40,46 +41,40 @@ public class MainActivity extends AppCompatActivity { } catch (AuthException signUpError) { Log.e("Authentication", "SignUp error: " + signUpError.getMessage()); } - } - - - - //------------------------------------------------------------------------------------------// + }*/ //----------------------------------API Testing---------------------------------------------// - Properties configs = new Properties(); + + /*Properties configs = new Properties(); try { 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"); try { requestor.postObject(testList); - } catch (JSONException e) { - e.printStackTrace(); } - - //------------------------------------------------------------------------------------------// - + catch (JSONException e) { + e.printStackTrace(); + }*/ setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); -// FloatingActionButton fab = findViewById(R.id.fab); -// fab.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) -// .setAction("Action", null).show(); -// } -// }); + /*FloatingActionButton fab = findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show(); + } + });*/ DrawerLayout drawer = findViewById(R.id.drawer_layout); NavigationView navigationView = findViewById(R.id.nav_view); - // Passing each menu ID as a set of Ids because each - // menu should be considered as top level destinations. + // Passing each menu ID as a set of Ids because each menu should be considered as top level destinations. mAppBarConfiguration = new AppBarConfiguration.Builder( R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow) .setDrawerLayout(drawer) @@ -87,14 +82,12 @@ public class MainActivity extends AppCompatActivity { NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration); NavigationUI.setupWithNavController(navigationView, navController); - // Handle search button click ImageButton searchButton = (ImageButton) findViewById(R.id.searchButton); searchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, SearchResults.class); - // Send user to SearchResults activity startActivity(intent); overridePendingTransition(R.anim.enter_from_left, R.anim.exit_from_left); @@ -103,13 +96,12 @@ public class MainActivity extends AppCompatActivity { }); } -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// // Inflate the menu; this adds items to the action bar if it is present. -// getMenuInflater().inflate(R.menu.main, menu); -// return true; -// } - + /*@Override + public boolean onCreateOptionsMenu(Menu menu) { + //Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main, menu); + return true; + }*/ @Override public boolean onSupportNavigateUp() { diff --git a/Listify/app/src/main/java/com/example/listify/ui/LoginPage.java b/Listify/app/src/main/java/com/example/listify/ui/LoginPage.java index 3be1966..04682b0 100644 --- a/Listify/app/src/main/java/com/example/listify/ui/LoginPage.java +++ b/Listify/app/src/main/java/com/example/listify/ui/LoginPage.java @@ -55,8 +55,8 @@ public class LoginPage extends AppCompatActivity { try { authManager.signIn(email, password); - //Intent intent = new Intent(LoginPage.this, LoginPage.class); - //startActivity(intent); + Intent intent = new Intent(LoginPage.this, MainActivity.class); + startActivity(intent); } catch(Exception ex) { //Display "Incorrect email or password" message diff --git a/Listify/app/src/main/java/com/example/listify/ui/SignupPage.java b/Listify/app/src/main/java/com/example/listify/ui/SignupPage.java index cc56bc5..ac9aa3c 100644 --- a/Listify/app/src/main/java/com/example/listify/ui/SignupPage.java +++ b/Listify/app/src/main/java/com/example/listify/ui/SignupPage.java @@ -68,8 +68,8 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog else { try { authManager.confirmSignUp(code); - //Intent intent = new Intent(SignupPage.this, MainActivity.class); - //startActivity(intent); + Intent intent = new Intent(SignupPage.this, MainActivity.class); + startActivity(intent); } catch (Exception e) { //Remove user from database diff --git a/Listify/app/src/main/java/com/example/listify/ui/home/HomeFragment.java b/Listify/app/src/main/java/com/example/listify/ui/home/HomeFragment.java index 46dcb73..2bb4814 100644 --- a/Listify/app/src/main/java/com/example/listify/ui/home/HomeFragment.java +++ b/Listify/app/src/main/java/com/example/listify/ui/home/HomeFragment.java @@ -14,17 +14,29 @@ import com.example.listify.R; public class HomeFragment extends Fragment { private Button toLoginPage; + private Button toListPage; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_home, container, false); + toLoginPage = (Button) root.findViewById(R.id.button1); toLoginPage.setOnClickListener(new View.OnClickListener() { @Override 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); } }); + + 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; } } \ No newline at end of file diff --git a/Listify/app/src/main/res/drawable/milk.png b/Listify/app/src/main/res/drawable/milk.png new file mode 100644 index 0000000..5ebd687 Binary files /dev/null and b/Listify/app/src/main/res/drawable/milk.png differ diff --git a/Listify/app/src/main/res/drawable/placeholder.png b/Listify/app/src/main/res/drawable/placeholder.png new file mode 100644 index 0000000..9db0c3a Binary files /dev/null and b/Listify/app/src/main/res/drawable/placeholder.png differ diff --git a/Listify/app/src/main/res/layout/activity_list.xml b/Listify/app/src/main/res/layout/activity_list.xml new file mode 100644 index 0000000..65c12f4 --- /dev/null +++ b/Listify/app/src/main/res/layout/activity_list.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/Listify/app/src/main/res/layout/format_list.xml b/Listify/app/src/main/res/layout/format_list.xml deleted file mode 100644 index 8e2ba7b..0000000 --- a/Listify/app/src/main/res/layout/format_list.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Listify/app/src/main/res/layout/fragment_home.xml b/Listify/app/src/main/res/layout/fragment_home.xml index ac1b34e..054c57e 100644 --- a/Listify/app/src/main/res/layout/fragment_home.xml +++ b/Listify/app/src/main/res/layout/fragment_home.xml @@ -10,32 +10,39 @@ android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginEnd="1dp" - android:layout_marginRight="1dp" - android:layout_marginTop="29dp" - android:text="Button" - app:layout_constraintEnd_toEndOf="@+id/switch2" - app:layout_constraintTop_toBottomOf="@+id/switch2" /> + android:layout_marginBottom="25dp" + android:layout_marginStart="1dp" + android:text="Log in" + app:layout_constraintBottom_toTopOf="@+id/button2" + app:layout_constraintStart_toStartOf="@+id/button2" /> - + android:layout_marginBottom="148dp" + android:text="List" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/Listify/app/src/main/res/layout/listproduct.xml b/Listify/app/src/main/res/layout/listproduct.xml new file mode 100644 index 0000000..a4d65fe --- /dev/null +++ b/Listify/app/src/main/res/layout/listproduct.xml @@ -0,0 +1,106 @@ + + + + + + +