From ea660e4c3a34edfa7bda0415f3b3124f0e435218 Mon Sep 17 00:00:00 2001 From: Aaron Sun Date: Tue, 10 Nov 2020 19:54:32 -0800 Subject: [PATCH] Cleaned up the code of the previous 3 commits --- .../com/example/listify/MainActivity.java | 32 ++----------------- .../ProfileFragment.java} | 8 ++--- ...{app_bar_lists.xml => app_bar_profile.xml} | 0 ...ragment_lists.xml => fragment_profile.xml} | 0 .../main/res/menu/activity_main_drawer.xml | 2 +- .../main/res/navigation/mobile_navigation.xml | 6 ++-- 6 files changed, 11 insertions(+), 37 deletions(-) rename Listify/app/src/main/java/com/example/listify/ui/{lists/ListsFragment.java => profile/ProfileFragment.java} (95%) rename Listify/app/src/main/res/layout/{app_bar_lists.xml => app_bar_profile.xml} (100%) rename Listify/app/src/main/res/layout/{fragment_lists.xml => fragment_profile.xml} (100%) 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 b2edf0a..881ce02 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -67,7 +67,6 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF startActivity(intent); } - //------------------------------Auth Testing---------------------------------------------// boolean testAuth = false; @@ -89,14 +88,10 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF } } } - //NOTE: deleteUser is slightly unusual in that it requires a Requestor. See below for building one - //authManager.deleteUser(requestor); - - //------------------------------------------------------------------------------------------// + //----------------------------------API Testing---------------------------------------------// boolean testAPI = false; - //----------------------------------API Testing---------------------------------------------// if (testAPI) { AuthManager authManager = new AuthManager(); @@ -114,10 +109,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey")); - - //The name is the only part of this that is used, the rest is generated by the Lambda. List testList = new List(-1, "New List", "user filled by lambda", Instant.now().toEpochMilli()); - //Everything except addedDate is used for ItemEntry ListEntry entry = new ListEntry(1, 4, Math.abs(new Random().nextInt()), Instant.now().toEpochMilli(),false); SynchronousReceiver idReceiver = new SynchronousReceiver<>(); @@ -148,37 +140,26 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF receiverError.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(); - } - });*/ 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. mAppBarConfiguration = new AppBarConfiguration.Builder( - R.id.nav_home, R.id.nav_lists) + R.id.nav_home, R.id.nav_profile) .setDrawerLayout(drawer) .build(); 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); @@ -186,13 +167,6 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF }); } - /*@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); diff --git a/Listify/app/src/main/java/com/example/listify/ui/lists/ListsFragment.java b/Listify/app/src/main/java/com/example/listify/ui/profile/ProfileFragment.java similarity index 95% rename from Listify/app/src/main/java/com/example/listify/ui/lists/ListsFragment.java rename to Listify/app/src/main/java/com/example/listify/ui/profile/ProfileFragment.java index 2bb11bc..7996ec7 100644 --- a/Listify/app/src/main/java/com/example/listify/ui/lists/ListsFragment.java +++ b/Listify/app/src/main/java/com/example/listify/ui/profile/ProfileFragment.java @@ -1,4 +1,4 @@ -package com.example.listify.ui.lists; +package com.example.listify.ui.profile; import android.app.AlertDialog; import android.content.DialogInterface; @@ -24,11 +24,11 @@ import java.util.Properties; import static com.example.listify.MainActivity.am; -public class ListsFragment extends Fragment { +public class ProfileFragment extends Fragment { private Button toDeleteAccountPage; public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View root = inflater.inflate(R.layout.fragment_lists, container, false); + View root = inflater.inflate(R.layout.fragment_profile, container, false); toDeleteAccountPage = (Button) root.findViewById(R.id.button); toDeleteAccountPage.setOnClickListener(new View.OnClickListener() { @@ -75,4 +75,4 @@ public class ListsFragment extends Fragment { return root; } -} \ No newline at end of file +} diff --git a/Listify/app/src/main/res/layout/app_bar_lists.xml b/Listify/app/src/main/res/layout/app_bar_profile.xml similarity index 100% rename from Listify/app/src/main/res/layout/app_bar_lists.xml rename to Listify/app/src/main/res/layout/app_bar_profile.xml diff --git a/Listify/app/src/main/res/layout/fragment_lists.xml b/Listify/app/src/main/res/layout/fragment_profile.xml similarity index 100% rename from Listify/app/src/main/res/layout/fragment_lists.xml rename to Listify/app/src/main/res/layout/fragment_profile.xml diff --git a/Listify/app/src/main/res/menu/activity_main_drawer.xml b/Listify/app/src/main/res/menu/activity_main_drawer.xml index 26a2072..d573500 100644 --- a/Listify/app/src/main/res/menu/activity_main_drawer.xml +++ b/Listify/app/src/main/res/menu/activity_main_drawer.xml @@ -17,7 +17,7 @@ diff --git a/Listify/app/src/main/res/navigation/mobile_navigation.xml b/Listify/app/src/main/res/navigation/mobile_navigation.xml index 274deba..cb76e14 100644 --- a/Listify/app/src/main/res/navigation/mobile_navigation.xml +++ b/Listify/app/src/main/res/navigation/mobile_navigation.xml @@ -24,8 +24,8 @@ tools:layout="@layout/fragment_slideshow" /> + tools:layout="@layout/fragment_profile" /> \ No newline at end of file