Skip to content

Commit

Permalink
Implemented the majority of the mobile mockups provided in Issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Crymzix committed Apr 1, 2015
1 parent c7aab98 commit 934e448
Show file tree
Hide file tree
Showing 47 changed files with 463 additions and 183 deletions.
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<orderEntry type="library" exported="" name="picasso-2.5.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="acra-4.5.0" level="project" />
<orderEntry type="library" exported="" name="android-observablescrollview-1.5.0" level="project" />
<orderEntry type="library" exported="" name="library-1.0.13" level="project" />
</component>
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dependencies {
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile files('libs/acra-4.5.0.jar')
}
Binary file added app/libs/acra-4.5.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:supportsRtl="true">
android:name=".MainApplication">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
Expand Down
Binary file added app/src/main/assets/fonts/DroidSerif-Regular.ttf
Binary file not shown.
Binary file added app/src/main/assets/fonts/LFT_Etica_Bold.otf
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/assets/fonts/LFT_Etica_Book.otf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/assets/fonts/LFT_Etica_Italic.otf
Binary file not shown.
Binary file added app/src/main/assets/fonts/LFT_Etica_Light.otf
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/assets/fonts/LFT_Etica_Reg.otf
Binary file not shown.
Binary file added app/src/main/assets/fonts/LFT_Etica_Semibold.otf
Binary file not shown.
Binary file not shown.
116 changes: 116 additions & 0 deletions app/src/main/java/ca/ubc/ubyssey/DateUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package ca.ubc.ubyssey;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
* Utility class for managing dates
*
* Created by Chris Li on 3/31/2015.
*/
public class DateUtils {

public static Date getFormattedDate(String date) {

TimeZone timezone = TimeZone.getTimeZone("America/Los_Angeles");
Calendar cal = Calendar.getInstance(timezone);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
sdf.setCalendar(cal);
try {
cal.setTime(sdf.parse(date));
} catch (ParseException e) {
e.printStackTrace();
}
Date formattedDate = cal.getTime();

return formattedDate;
}

public static String dayToString(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayOf = cal.get(Calendar.DAY_OF_WEEK);
int weekOf = cal.get(Calendar.WEEK_OF_MONTH);
SimpleDateFormat time = new SimpleDateFormat("h:mm a");
String currentTime = time.format(cal.getTime());
Calendar curr = Calendar.getInstance();
int currDay = curr.get(Calendar.DAY_OF_WEEK);
int currWeek = curr.get(Calendar.WEEK_OF_MONTH);
if (weekOf == currWeek) {
if (dayOf == currDay) {
return "Today" + " " + currentTime;
} else if (dayOf == Calendar.SUNDAY) {
return "Sunday" + " " + currentTime;
} else if (dayOf == Calendar.MONDAY) {
return "Monday" + " " + currentTime;
} else if (dayOf == Calendar.TUESDAY) {
return "Tuesday" + " " + currentTime;
} else if (dayOf == Calendar.WEDNESDAY) {
return "Wednesday" + " " + currentTime;
} else if (dayOf == Calendar.THURSDAY) {
return "Thursday" + " " + currentTime;
} else if (dayOf == Calendar.FRIDAY) {
return "Friday" + " " + currentTime;
} else {
return "Saturday" + " " + currentTime;
}
} else {
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
int year = cal.get(Calendar.YEAR);
return getMonth(month) + " " + day + ", " + year;
}
}

public static String getMonth(int month){
String monthString = "";
switch(month){
case 0:
monthString = "January";
break;
case 1:
monthString = "February";
break;
case 2:
monthString = "March";
break;
case 3:
monthString = "April";
break;
case 4:
monthString = "May";
break;
case 5:
monthString = "June";
break;
case 6:
monthString = "July";
break;
case 7:
monthString = "August";
break;
case 8:
monthString = "September";
break;
case 9:
monthString = "October";
break;
case 10:
monthString = "November";
break;
case 11:
monthString = "December";
break;
}

return monthString;
}

public static String getProperDateString(String date){
return dayToString(getFormattedDate(date));
}

}
8 changes: 6 additions & 2 deletions app/src/main/java/ca/ubc/ubyssey/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import ca.ubc.ubyssey.main.HomeFragment;

Expand All @@ -36,26 +38,28 @@ public class MainActivity extends ActionBarActivity
*/
private NavigationDrawerFragment mNavigationDrawerFragment;


private Toolbar mToolbar;

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);

mNavigationDrawerFragment = (NavigationDrawerFragment)
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);

mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);

RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.main_layout);
// Set up the drawer.
mNavigationDrawerFragment.setUp(
R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout),
mToolbar);
mToolbar,
mainLayout);
}

@Override
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/ca/ubc/ubyssey/MainApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ca.ubc.ubyssey;

import android.app.Application;

import org.acra.ACRA;
import org.acra.annotation.ReportsCrashes;

/**
* Application class, where long-running tasks should be instantiated
*
* Created by Chris Li on 3/20/2015.
*/
@ReportsCrashes(formKey = "", // will not be used
mailTo = "[email protected]")
public class MainApplication extends Application{

@Override
public void onCreate() {
super.onCreate();
//TODO: Remove ACRA library as soon the application becomes public
ACRA.init(this);
}
}
21 changes: 15 additions & 6 deletions app/src/main/java/ca/ubc/ubyssey/NavigationDrawerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.List;
import java.util.Map;

import ca.ubc.ubyssey.models.DrawerItem;


/**
* Adapter for the navigator drawer list view
Expand All @@ -21,10 +23,10 @@ public class NavigationDrawerAdapter extends BaseAdapter {


private Context mContext;
private List<AbstractMap.SimpleEntry<String, Integer>> mMenuItems;
private List<DrawerItem> mMenuItems;
private LayoutInflater mLayoutInflater = null;

public NavigationDrawerAdapter(Context context, List<AbstractMap.SimpleEntry<String, Integer>> menuItems) {
public NavigationDrawerAdapter(Context context, List<DrawerItem> menuItems) {
mContext = context;
mMenuItems = menuItems;
mLayoutInflater = LayoutInflater.from(context);
Expand All @@ -48,14 +50,21 @@ public long getItemId(int position) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {

DrawerItem menuItem = mMenuItems.get(position);
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.drawer_list_item, parent, false);
}
if (menuItem.isSection()) {
convertView = mLayoutInflater.inflate(R.layout.drawer_list_section_item, parent, false);
convertView.setOnClickListener(null);
convertView.setOnLongClickListener(null);
convertView.setLongClickable(false);

Map.Entry<String, Integer> menuItem = mMenuItems.get(position);
} else {
convertView = mLayoutInflater.inflate(R.layout.drawer_list_item, parent, false);
}
}

TextView menuTextView = (TextView) convertView.findViewById(R.id.menu_item_text);
menuTextView.setText(menuItem.getKey());
menuTextView.setText(menuItem.getTitle());

return convertView;
}
Expand Down
62 changes: 39 additions & 23 deletions app/src/main/java/ca/ubc/ubyssey/NavigationDrawerFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
Expand All @@ -16,13 +17,17 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.RelativeLayout;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;

import ca.ubc.ubyssey.models.DrawerItem;

/**
* Fragment used for managing interactions for and presentation of a navigation drawer.
* See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction">
Expand Down Expand Up @@ -97,31 +102,39 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
R.layout.fragment_navigation_drawer, container, false);
mDrawerListView = (ListView) view.findViewById(R.id.menu_listview);

View addTopic = inflater.inflate(R.layout.add_topic_button, null);
mDrawerListView.addFooterView(addTopic, null, false);

mDrawerAdapter = new NavigationDrawerAdapter(getActivity(), createMenuItems());
mDrawerListView.setAdapter(mDrawerAdapter);
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
AbstractMap.SimpleEntry<String, Integer> menuItem = (AbstractMap.SimpleEntry<String, Integer>) mDrawerAdapter.getItem(position);
mCallbacks.onNavigationDrawerItemSelected(menuItem.getValue());
mDrawerLayout.closeDrawer(mFragmentContainerView);
DrawerItem menuItem = (DrawerItem) mDrawerAdapter.getItem(position);
if (menuItem != null) {
mCallbacks.onNavigationDrawerItemSelected(menuItem.getTag());
mDrawerLayout.closeDrawer(mFragmentContainerView);
}
}
});
return view;
}

private List<AbstractMap.SimpleEntry<String, Integer>> createMenuItems() {

ArrayList<AbstractMap.SimpleEntry<String, Integer>> menuItems = new ArrayList<>();
menuItems.add(new AbstractMap.SimpleEntry<>("Home", MainActivity.HOME_ITEM));
menuItems.add(new AbstractMap.SimpleEntry<>("Culture", MainActivity.CULTURE_ITEM));
menuItems.add(new AbstractMap.SimpleEntry<>("Opinion", MainActivity.OPINION_ITEM));
menuItems.add(new AbstractMap.SimpleEntry<>("Features", MainActivity.FEATURES_ITEM));
menuItems.add(new AbstractMap.SimpleEntry<>("Data", MainActivity.DATA_ITEM));
menuItems.add(new AbstractMap.SimpleEntry<>("Sports", MainActivity.SPORTS_ITEM));
menuItems.add(new AbstractMap.SimpleEntry<>("Video", MainActivity.VIDEO_ITEM));
menuItems.add(new AbstractMap.SimpleEntry<>("Blog", MainActivity.BLOG_ITEM));
private List<DrawerItem> createMenuItems() {

ArrayList<DrawerItem> menuItems = new ArrayList<>();
menuItems.add(new DrawerItem(true, "Sections"));
menuItems.add(new DrawerItem("Home", MainActivity.HOME_ITEM));
menuItems.add(new DrawerItem("Culture", MainActivity.CULTURE_ITEM));
menuItems.add(new DrawerItem("Opinion", MainActivity.OPINION_ITEM));
menuItems.add(new DrawerItem("Features", MainActivity.FEATURES_ITEM));
menuItems.add(new DrawerItem("Data", MainActivity.DATA_ITEM));
menuItems.add(new DrawerItem("Sports", MainActivity.SPORTS_ITEM));
menuItems.add(new DrawerItem("Video", MainActivity.VIDEO_ITEM));
menuItems.add(new DrawerItem("Blog", MainActivity.BLOG_ITEM));
menuItems.add(new DrawerItem(true, "Saved Topics"));

return menuItems;
}

Expand All @@ -131,19 +144,14 @@ public boolean isDrawerOpen() {

/**
* Users of this fragment must call this method to set up the navigation drawer interactions.
*
* @param fragmentId The android:id of this fragment in its activity's layout.
* @param fragmentId The android:id of this fragment in its activity's layout.
* @param drawerLayout The DrawerLayout containing this fragment's UI.
* @param mainLayout
*/
public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbar toolbar) {
public void setUp(int fragmentId, DrawerLayout drawerLayout, Toolbar toolbar, final RelativeLayout mainLayout) {
mFragmentContainerView = getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;

// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener


mDrawerLayout.setScrimColor(Color.TRANSPARENT);
// ActionBarDrawerToggle ties together the the proper interactions
// between the navigation drawer and the action bar app icon.
mDrawerToggle = new ActionBarDrawerToggle(
Expand Down Expand Up @@ -181,6 +189,14 @@ public void onDrawerOpened(View drawerView) {

getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
}

@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
mainLayout.setTranslationX(slideOffset * drawerView.getWidth());
mDrawerLayout.bringChildToFront(drawerView);
mDrawerLayout.requestLayout();
}
};

// If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
Expand Down
Loading

0 comments on commit 934e448

Please sign in to comment.