diff --git a/Listify/.idea/codeStyles/Project.xml b/Listify/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/Listify/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/Listify/.idea/gradle.xml b/Listify/.idea/gradle.xml index 7b5f1f4..5cd135a 100644 --- a/Listify/.idea/gradle.xml +++ b/Listify/.idea/gradle.xml @@ -1,13 +1,19 @@ + diff --git a/Listify/.idea/jarRepositories.xml b/Listify/.idea/jarRepositories.xml new file mode 100644 index 0000000..0380d8d --- /dev/null +++ b/Listify/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Listify/app/src/main/AndroidManifest.xml b/Listify/app/src/main/AndroidManifest.xml index 3c75eac..96ca568 100644 --- a/Listify/app/src/main/AndroidManifest.xml +++ b/Listify/app/src/main/AndroidManifest.xml @@ -10,16 +10,27 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> + - + + + + + + + \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/First2Fragment.java b/Listify/app/src/main/java/com/example/listify/First2Fragment.java new file mode 100644 index 0000000..3ca48ef --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/First2Fragment.java @@ -0,0 +1,34 @@ +package com.example.listify; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class First2Fragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_first2, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(First2Fragment.this) + .navigate(R.id.action_First2Fragment_to_Second2Fragment); + } + }); + } +} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/FirstFragment.java b/Listify/app/src/main/java/com/example/listify/FirstFragment.java new file mode 100644 index 0000000..653c343 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/FirstFragment.java @@ -0,0 +1,34 @@ +package com.example.listify; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class FirstFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_first, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(FirstFragment.this) + .navigate(R.id.action_FirstFragment_to_SecondFragment); + } + }); + } +} \ No newline at end of file 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 a24c00a..c0838dd 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -1,5 +1,7 @@ package com.example.listify; +import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -21,9 +23,9 @@ import androidx.navigation.ui.NavigationUI; import androidx.drawerlayout.widget.DrawerLayout; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import android.widget.ImageButton; public class MainActivity extends AppCompatActivity { - private AppBarConfiguration mAppBarConfiguration; @Override @@ -52,14 +54,14 @@ public class MainActivity extends AppCompatActivity { 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 @@ -71,19 +73,33 @@ 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); + + } + }); } - @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() { NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); - return NavigationUI.navigateUp(navController, mAppBarConfiguration) - || super.onSupportNavigateUp(); + return NavigationUI.navigateUp(navController, mAppBarConfiguration) || super.onSupportNavigateUp(); } } \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/SearchResults.java b/Listify/app/src/main/java/com/example/listify/SearchResults.java new file mode 100644 index 0000000..8b2fa83 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/SearchResults.java @@ -0,0 +1,82 @@ +package com.example.listify; +import android.media.Image; +import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.SearchView; + +public class SearchResults extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_search_results); + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + // Back button closes this activity and returns to previous activity (MainActivity) + ImageButton backButton = (ImageButton) findViewById(R.id.backToHomeButton); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + overridePendingTransition(R.anim.enter_from_right, R.anim.exit_from_right); + } + }); + + // Set the search bar to be active and focused + final SearchView searchView = (SearchView) findViewById(R.id.searchBar); + searchView.setIconified(false); + + // There's no easy way to find the close button on the search bar, so this is the way I'm + // doing it + int searchCloseButtonId = searchView.getContext().getResources().getIdentifier("android:id/search_close_btn", null, null); + ImageView closeButton = (ImageView) searchView.findViewById(searchCloseButtonId); + closeButton.setOnClickListener(new View.OnClickListener() { + // Override default close behavior to only clear the search text and the query + @Override + public void onClick(View v) { + // Finding the edit text of the search bar. Same as the method above + int searchTextId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); + EditText searchText = (EditText) searchView.findViewById(searchTextId); + searchText.setText(""); + searchView.setQuery("", false); + } + }); + + // Handle searches + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String query) { + doSearch(query); + // TODO: Display the search results listview + return false; + } + + @Override + public boolean onQueryTextChange(String newText) { + return false; + } + }); + + } + + // Override default phone back button to add animation + @Override + public void onBackPressed() { + super.onBackPressed(); + overridePendingTransition(R.anim.enter_from_right, R.anim.exit_from_right); + } + + // TODO: This function will handle the search operation with the database and return + // a listview to caller to be displayed + private ListView doSearch(String query) { + System.out.println(query); + return null; + } +} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/Second2Fragment.java b/Listify/app/src/main/java/com/example/listify/Second2Fragment.java new file mode 100644 index 0000000..6e17432 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/Second2Fragment.java @@ -0,0 +1,34 @@ +package com.example.listify; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class Second2Fragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_second2, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(Second2Fragment.this) + .navigate(R.id.action_Second2Fragment_to_First2Fragment); + } + }); + } +} \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/SecondFragment.java b/Listify/app/src/main/java/com/example/listify/SecondFragment.java new file mode 100644 index 0000000..609a036 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/SecondFragment.java @@ -0,0 +1,34 @@ +package com.example.listify; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.navigation.fragment.NavHostFragment; + +public class SecondFragment extends Fragment { + + @Override + public View onCreateView( + LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState + ) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_second, container, false); + } + + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NavHostFragment.findNavController(SecondFragment.this) + .navigate(R.id.action_SecondFragment_to_FirstFragment); + } + }); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..81d8fd9 --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/ui/LoginPage.java @@ -0,0 +1,30 @@ +package com.example.listify.ui; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import com.example.listify.MainActivity; +import com.example.listify.R; + +import androidx.appcompat.app.AppCompatActivity; + +public class LoginPage extends AppCompatActivity { + private Button button; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + + button = (Button) findViewById(R.id.button3); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(LoginPage.this, MainActivity.class); + startActivity(intent); + } + }); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..a2ff5de --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/ui/SignupPage.java @@ -0,0 +1,29 @@ +package com.example.listify.ui; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import com.example.listify.R; + +import androidx.appcompat.app.AppCompatActivity; + +public class SignupPage extends AppCompatActivity { + private Button button; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_signup); + + button = (Button) findViewById(R.id.button2); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(SignupPage.this, com.example.listify.ui.LoginPage.class); + startActivity(intent); + } + }); + } +} \ No newline at end of file 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 1937ed3..c530fb9 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 @@ -1,11 +1,12 @@ package com.example.listify.ui.home; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.TextView; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; @@ -15,19 +16,16 @@ import androidx.lifecycle.ViewModelProviders; import com.example.listify.R; public class HomeFragment extends Fragment { + private Button toLoginPage; - private HomeViewModel homeViewModel; - - public View onCreateView(@NonNull LayoutInflater inflater, - ViewGroup container, Bundle savedInstanceState) { - homeViewModel = - ViewModelProviders.of(this).get(HomeViewModel.class); + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_home, container, false); - final TextView textView = root.findViewById(R.id.text_home); - homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { + toLoginPage = (Button) root.findViewById(R.id.button1); + toLoginPage.setOnClickListener(new View.OnClickListener() { @Override - public void onChanged(@Nullable String s) { - textView.setText(s); + public void onClick(View v) { + Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ui.SignupPage.class); + startActivity(intent); } }); return root; diff --git a/Listify/app/src/main/res/anim/enter_from_left.xml b/Listify/app/src/main/res/anim/enter_from_left.xml new file mode 100644 index 0000000..0840bbb --- /dev/null +++ b/Listify/app/src/main/res/anim/enter_from_left.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/Listify/app/src/main/res/anim/enter_from_right.xml b/Listify/app/src/main/res/anim/enter_from_right.xml new file mode 100644 index 0000000..d974522 --- /dev/null +++ b/Listify/app/src/main/res/anim/enter_from_right.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/Listify/app/src/main/res/anim/exit_from_left.xml b/Listify/app/src/main/res/anim/exit_from_left.xml new file mode 100644 index 0000000..f58d54d --- /dev/null +++ b/Listify/app/src/main/res/anim/exit_from_left.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/Listify/app/src/main/res/anim/exit_from_right.xml b/Listify/app/src/main/res/anim/exit_from_right.xml new file mode 100644 index 0000000..2134fe7 --- /dev/null +++ b/Listify/app/src/main/res/anim/exit_from_right.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/Listify/app/src/main/res/drawable/lisitfy_logo.png b/Listify/app/src/main/res/drawable/lisitfy_logo.png new file mode 100644 index 0000000..4f26616 Binary files /dev/null and b/Listify/app/src/main/res/drawable/lisitfy_logo.png differ diff --git a/Listify/app/src/main/res/layout/activity_login.xml b/Listify/app/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..91491c2 --- /dev/null +++ b/Listify/app/src/main/res/layout/activity_login.xml @@ -0,0 +1,63 @@ + + + +