Commit 4863d05c authored by Pearl Jen Santos's avatar Pearl Jen Santos

modified search layout; attempted a custom navdrawer still untested

parent d69e7087
......@@ -5,8 +5,8 @@
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.4" />
<option name="gradleJvm" value="1.7" />
<option name="gradleHome" value="D:\Program Files\Android Studio1\gradle\gradle-2.4" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
......
......@@ -37,11 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<<<<<<< HEAD
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
=======
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
>>>>>>> 9b5c6a49183da47d424d4355d44a6b8a6daec4f1
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -71,8 +71,10 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
......@@ -90,9 +92,10 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="parse-android-1.10.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="design-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -22,4 +22,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.1.0'
}
......@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
......@@ -42,7 +43,8 @@ public class ActionBarAttempt extends AppCompatActivity {
private CharSequence mDrawerTitle;
private CharSequence mTitle;
private String[] options;
private int[] optionIcons = {R.mipmap.ic_search, R.mipmap.ic_search, R.mipmap.ic_search, R.mipmap.ic_settings, R.mipmap.ic_logout};;
private NavigationView nvDrawer;
// private int[] optionIcons = {R.mipmap.ic_search, R.mipmap.ic_search, R.mipmap.ic_search, R.mipmap.ic_settings, R.mipmap.ic_logout};;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -62,6 +64,8 @@ public class ActionBarAttempt extends AppCompatActivity {
mTitle = mDrawerTitle = "About";
options = getResources().getStringArray(R.array.options);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
nvDrawer = (NavigationView) findViewById(R.id.left_drawer);
setupDrawerContent(nvDrawer);
//mDrawerList = (ListView) findViewById(R.id.left_drawer);
......@@ -96,9 +100,72 @@ public class ActionBarAttempt extends AppCompatActivity {
// mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
selectItem(0);
// if (savedInstanceState == null) {
// selectItem(0);
// }
}
private void setupDrawerContent(NavigationView navigationView){
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener(){
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
selectDrawerItem(menuItem);
return true;
}
}
);
}
public void selectDrawerItem(MenuItem menuItem){
Fragment fragment = null;
Class fragmentClass;
switch(menuItem.getItemId()){
case R.id.search:
fragmentClass = SearchFragment.class;
break;
case R.id.schedules:
fragmentClass = Schedules.class;
break;
case R.id.editProfile:
fragmentClass = ChangeInfoFragment.class;
break;
case R.id.viewPastTrips:
fragmentClass = PastTrips.class;
break;
case R.id.settings:
//settings
fragmentClass = Help.class;
break;
case R.id.logout:
//logout
fragmentClass = Help.class;
break;
default:
fragmentClass = SearchFragment.class;
break;
}
try{
fragment = (Fragment) fragmentClass.newInstance();
}catch(Exception e){
e.printStackTrace();
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
// update selected item and title, then close the drawer
menuItem.setChecked(true);
setTitle(menuItem.getTitle());
mDrawerLayout.closeDrawers();
}
@Override
......@@ -113,8 +180,8 @@ public class ActionBarAttempt extends AppCompatActivity {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// If the nav drawer is open, hide action items related to the content view
boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
menu.findItem(R.id.action_search).setVisible(!drawerOpen);
// boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
// menu.findItem(R.id.action_search).setVisible(!drawerOpen);
return super.onPrepareOptionsMenu(menu);
}
......@@ -159,58 +226,58 @@ public class ActionBarAttempt extends AppCompatActivity {
return super.onOptionsItemSelected(item);
}
/* The click listner for ListView in the navigation drawer */
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
}
}
private void selectItem(int position) {
// update the main content by replacing fragments
Fragment fragment = null;
Bundle args = new Bundle();
switch(position){
case 0:
fragment = new SearchFragment();
break;
case 1:
fragment = new Schedules();
break;
case 2:
fragment = new ChangeInfoFragment();
break;
case 3:
fragment = new PastTrips();
break;
case 4:
//settings
fragment = new Help();
break;
case 5:
//logout
fragment = new Help();
break;
default:
break;
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
setTitle(options[position]);
mDrawerLayout.closeDrawer(mDrawerList);
}
// /* The click listner for ListView in the navigation drawer */
// private class DrawerItemClickListener implements ListView.OnItemClickListener {
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// selectItem(position);
// }
// }
@Override
public void setTitle(CharSequence title) {
mTitle = title;
getSupportActionBar().setTitle(mTitle);
}
// private void selectItem(int position) {
// // update the main content by replacing fragments
// Fragment fragment = null;
// Bundle args = new Bundle();
//
// switch(position){
// case 0:
// fragment = new SearchFragment();
// break;
// case 1:
// fragment = new Schedules();
// break;
// case 2:
// fragment = new ChangeInfoFragment();
// break;
// case 3:
// fragment = new PastTrips();
// break;
// case 4:
// //settings
// fragment = new Help();
// break;
// case 5:
// //logout
// fragment = new Help();
// break;
// default:
// break;
// }
//
// FragmentManager fragmentManager = getSupportFragmentManager();
// fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
//
// // update selected item and title, then close the drawer
// mDrawerList.setItemChecked(position, true);
// setTitle(options[position]);
// mDrawerLayout.closeDrawer(mDrawerList);
// }
//
// @Override
// public void setTitle(CharSequence title) {
// mTitle = title;
// getSupportActionBar().setTitle(mTitle);
// }
/**
* When using the ActionBarDrawerToggle, you must call it during
......@@ -221,14 +288,14 @@ public class ActionBarAttempt extends AppCompatActivity {
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
//mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Pass any configuration change to the drawer toggls
mDrawerToggle.onConfigurationChanged(newConfig);
//mDrawerToggle.onConfigurationChanged(newConfig);
}
......
package com.example.pearlsantos.project;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.SharedPreferences;
import android.support.v4.app.DialogFragment;
......@@ -7,37 +8,37 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.DigitalClock;
import android.widget.Spinner;
import android.widget.TextView;
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import java.util.ArrayList;
import java.util.List;
import java.util.Calendar;
/**
* A placeholder fragment containing a simple view.
*/
public class SearchFragment extends Fragment {
SharedPreferences time;
public SearchFragment() {
private TextView clk;
private TimePicker timePicker;
private int selectedHour;
private int selectedMinute;
static final int TIME_DIALOG_ID = 999;
public SearchFragment() {
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle SavedInstance) {
View rootView = inflater.inflate(R.layout.fragment_search, container, false);
DigitalClock clk = (DigitalClock) rootView.findViewById(R.id.digitalClock);
clk = (TextView) rootView.findViewById(R.id.digitalClock);
//String time = hour + ":" + minute;
clk.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
......@@ -46,57 +47,6 @@ public class SearchFragment extends Fragment {
}
});
time = getContext().getSharedPreferences("bus", getContext().MODE_PRIVATE);
String hour = time.getString("hourOfDay", "");
String minute = time.getString("minute", "");
TextView from = (TextView) rootView.findViewById(R.id.fromSearch);
String fromSearch = from.toString().trim();
TextView to = (TextView) rootView.findViewById(R.id.toSearch);
String toSearch = to.toString().trim();
List<String> busCompanies = new ArrayList<>();
busCompanies.add("None");
Spinner s = (Spinner) rootView.findViewById(R.id.busLiners);
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getContext(),
android.R.layout.simple_spinner_item, busCompanies);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(dataAdapter);
String bC = s.getSelectedItem().toString().trim();
ParseQuery<ParseObject> query = ParseQuery.getQuery("Schedule");
query.orderByAscending("departure");
query.whereContains("startingTerminal", fromSearch);
query.whereContains("destination", toSearch);
query.whereContains("busCompany", bC);
query.whereContains("departure", hour);
query.whereContains("arrival", minute);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> bC, ParseException e) {
if (e == null) {
Log.d("score", "Retrieved " + bC.size() + " scores");
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
});
//
// String date = "2014-11-25 14:30";
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:MM");
// Date testDate = null;
// try {
// testDate = sdf.parse(date);
// }catch(Exception ex){
// ex.printStackTrace();
// }
// SimpleDateFormat formatter = new SimpleDateFormat("MM dd,yyyy hh:mm a");
// String newFormat = formatter.format(testDate);
// System.out.println(".....Date..."+newFormat);
return rootView;
......@@ -104,6 +54,6 @@ public class SearchFragment extends Fragment {
}
}
}
......@@ -3,7 +3,6 @@ package com.example.pearlsantos.project;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.SharedPreferences;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
......@@ -12,11 +11,11 @@ import android.view.Menu;
import android.view.MenuItem;
import java.util.Calendar;
import java.util.Map;
import java.util.Set;
public class TimePicker extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
int selectedHour;
int selectedMinute;
SharedPreferences time;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
final Calendar c = Calendar.getInstance();
......@@ -29,11 +28,14 @@ public class TimePicker extends DialogFragment implements TimePickerDialog.OnTim
@Override
public void onTimeSet(android.widget.TimePicker view, int hourOfDay, int minute) {
SharedPreferences searchTime = getContext().getSharedPreferences("bus", getContext().MODE_PRIVATE);
SharedPreferences.Editor edit = searchTime.edit();
edit.putString("hourOfDay", Integer.toString(hourOfDay));
edit.putString("minute", Integer.toString(minute));
public void onTimeSet(android.widget.TimePicker view, int hourOfDay, int minuteOfHour) {
selectedHour = hourOfDay;
selectedMinute = minuteOfHour;
SharedPreferences.Editor edit = time.edit();
edit.putString("hourOfDay", Integer.toString(selectedHour));
edit.putString("minuteOfHour", Integer.toString(selectedMinute));
edit.commit();
//hi EJ, I think this is where you put what you want to do with the time the user picks. Just tell me if you need help
//actually, here's one thing you can do, since I kinda forgot how to SharedPreferences
......@@ -41,5 +43,7 @@ public class TimePicker extends DialogFragment implements TimePickerDialog.OnTim
//2) send it to SearchFragment
//3) set the digital clock to the said time
//4) other things you need to do :)
}
}
......@@ -40,14 +40,29 @@
android:id="@+id/fromSearch"
android:layout_marginBottom="5dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="PAPUNTANG"
android:id="@+id/toLabelSearch"
android:layout_marginBottom="5dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/change"
android:src="@mipmap/ic_change"
android:layout_gravity="right" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -77,13 +92,12 @@
android:id="@+id/timeLabel"
android:layout_marginBottom="5dp" />
<DigitalClock
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/digitalClock"
android:onClick="showTimeDialog" />
android:id="@+id/digitalClock" />
<LinearLayout
android:layout_height="wrap_content"
......
......@@ -5,6 +5,10 @@
android:id="@+id/search"
android:icon="@mipmap/ic_search"
android:title="Search"/>
<item
android:id="@+id/schedules"
android:icon="@mipmap/ic_new_profile"
android:title="Edit Profile"/>
<item
android:id="@+id/editProfile"
android:icon="@mipmap/ic_new_profile"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment