Skip to content

Commit

Permalink
Merge pull request #42 from mikeputnam/release/v2.0.0
Browse files Browse the repository at this point in the history
Release/v2.0.0
  • Loading branch information
mikeputnam authored Aug 2, 2016
2 parents bee34a0 + 5d832b9 commit ecef2cb
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 165 deletions.
14 changes: 7 additions & 7 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
compileSdkVersion 24
buildToolsVersion '24.0.1'

defaultConfig {
applicationId "theputnams.net.isitrecyclingweek"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
targetSdkVersion 24
versionCode 2
versionName "v2.0.0"
}
buildTypes {
release {
Expand All @@ -37,10 +37,10 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:19.1.+'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public long getItemId(int position)
@Override
public View getView(int position, View view, ViewGroup viewGroup)
{
// ToDo Should be view holder pattern but there aren't many items so it won't hurt us
// Should be view holder pattern but there aren't many items so it won't hurt us
NavItem nav = mNavItems.get(position);
view = mInflater.inflate(R.layout.nav_item_clickable, null);
((TextView) view.findViewById(R.id.tv_nav_text))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@

public class RecyclingInfoFragment extends Fragment {

@Bind(R.id.recycling_message)
TextView mRecyclingMessage;

@Bind(R.id.recycling_text)
TextView mRecyclingText;

Expand Down Expand Up @@ -81,13 +78,12 @@ public void onStart() {

protected void updateViewData() {
SharedPreferences prefs = getActivity().getSharedPreferences(getString(R.string.pref_settings), Context.MODE_PRIVATE);
final String address = prefs.getString(getString(R.string.pref_address), null);
String address = prefs.getString(getString(R.string.pref_address), null);
String api_base_url = prefs.getString(getString(R.string.pref_api_base_url), null);
String api_path = prefs.getString(getString(R.string.pref_api_path), null);

if (address == null || api_base_url == null || api_path == null) {
// We're in a bad state... have them update settings
//ToDo We cannot handle the multiple api end points at the moment because of how they are pathed combined with the contract values
mRecyclingText.setText(getString(R.string.error_missing_data));
}

Expand All @@ -102,26 +98,33 @@ public void success(CollectionEvent[] collectionEvents, retrofit.client.Response
RecyclingLogicHandler logicHandler = new RecyclingLogicHandler(collectionEvents);
if (logicHandler.isRecyclingWeek()) {
mRecyclingImage.setImageResource(R.drawable.recycling_week_icon);
mRecyclingMessage.setText(getString(R.string.yes));
mRecyclingText.setText(getString(R.string.put_out_the_recycling_bin));
} else {
mRecyclingImage.setImageResource(R.drawable.garbage_week_icon);
mRecyclingMessage.setText(getString(R.string.nope));
mRecyclingText.setText(getString(R.string.garbage_bin_only));
}
String recyclingTimeFrame = String.format(getString(R.string.pickup_in_n_days), logicHandler.getPickUpDays());
String recyclingTimeFrame;
if (logicHandler.getPickUpDays() == 0) {
recyclingTimeFrame = getString(R.string.pickup_today);
} else if (logicHandler.getPickUpDays() == 1) {
recyclingTimeFrame = getString(R.string.pickup_tomorrow);
} else {
recyclingTimeFrame = String.format(getString(R.string.pickup_in_n_days), logicHandler.getPickUpDays());
}
mRecyclingTimeFrame.setText(recyclingTimeFrame);
String timeStamp = new SimpleDateFormat("yyyy-MM-dd h:mm a").format(Calendar.getInstance().getTime());
mRecyclingAddress.setText(address);
SharedPreferences inner_prefs = getActivity().getSharedPreferences(getString(R.string.pref_settings), Context.MODE_PRIVATE);
mRecyclingAddress.setText(inner_prefs.getString(getString(R.string.pref_address), null));
mRecyclingAsof.setText(String.format("As of %1$s", timeStamp));
} else {
mRecyclingText.setText(getText(R.string.cannot_find_address));
SharedPreferences inner_prefs = getActivity().getSharedPreferences(getString(R.string.pref_settings), Context.MODE_PRIVATE);
mRecyclingAddress.setText(inner_prefs.getString(getString(R.string.pref_address), null));
}
}

@Override
public void failure(RetrofitError error) {
//ToDo set up some sort of error logging for the app
Toast.makeText(getActivity(), R.string.error_internal_server_error, Toast.LENGTH_LONG).show();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.mobsandgeeks.saripaar.ValidationError;
Expand All @@ -51,6 +52,18 @@
*/
public class SettingsFragment extends Fragment implements Validator.ValidationListener {

@Bind(R.id.label_street_address)
TextView mLabelStreetAddress;

@Bind(R.id.label_city)
TextView mLabelCity;

@Bind(R.id.label_state)
TextView mLabelState;

@Bind(R.id.label_zip)
TextView mLabelZip;

@Bind(R.id.zip_code)
@NotEmpty
EditText mZipCode;
Expand All @@ -62,9 +75,13 @@ public class SettingsFragment extends Fragment implements Validator.ValidationLi
@NotEmpty
EditText mStreetAddress;

@Bind(R.id.city_state)
@Bind(R.id.city)
@NotEmpty
EditText mCityState;
EditText mCity;

@Bind(R.id.state)
@NotEmpty
EditText mState;

Validator mValidator;

Expand All @@ -80,6 +97,12 @@ public void onClick(View view) {
mValidator.validate();
}
});

mLabelStreetAddress.setText(getString(R.string.label_street_address));
mLabelCity.setText(getString(R.string.label_city));
mLabelState.setText(getString(R.string.label_state));
mLabelZip.setText(getString(R.string.label_zip));

return searchView;
}

Expand All @@ -91,12 +114,12 @@ public void success(APIContract[] apiContracts, retrofit.client.Response respons

if (apiContracts.length > 0) {
StringBuilder address = new StringBuilder(mStreetAddress.getText().toString());
address.append(" " + mCityState.getText().toString());
address.append(" " + mCity.getText().toString());
address.append(" " + mState.getText().toString());
address.append(" " + mZipCode.getText().toString());

SharedPreferences.Editor editor = getActivity().getSharedPreferences(getString(R.string.pref_settings), Context.MODE_PRIVATE).edit();

// ToDo Replace this with an ORM
// Save the address in prefs
editor.putString(getString(R.string.pref_address), address.toString());
// Save the api url in prefs
Expand All @@ -121,7 +144,6 @@ public void success(APIContract[] apiContracts, retrofit.client.Response respons

@Override
public void failure(RetrofitError error) {
//ToDo set up some sort of error logging for the app
Toast.makeText(getActivity(), R.string.error_internal_server_error, Toast.LENGTH_LONG).show();
}
});
Expand Down
23 changes: 0 additions & 23 deletions mobile/src/main/res/layout/activity_garbageandorrecycle.xml

This file was deleted.

30 changes: 0 additions & 30 deletions mobile/src/main/res/layout/activity_search_result.xml

This file was deleted.

10 changes: 1 addition & 9 deletions mobile/src/main/res/layout/fragment_recycling_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/recycling_message"
android:textSize="30sp"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"/>

<TextView
android:id="@+id/recycling_text"
android:textSize="20sp"
android:textSize="25sp"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
35 changes: 31 additions & 4 deletions mobile/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,53 @@
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<TextView
android:id="@+id/label_street_address"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/street_address"
android:hint="@string/street_address_hint"
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/label_city"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/city_state"
android:hint="@string/city_state_hint"
android:id="@+id/city"
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/label_state"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/state"
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/label_zip"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/zip_code"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/zip_hint"
android:layout_marginBottom="5dp"
android:maxLength="50"/>

Expand Down
60 changes: 0 additions & 60 deletions mobile/src/main/res/layout/primary_linear_layout.xml

This file was deleted.

Loading

0 comments on commit ecef2cb

Please sign in to comment.