Added address of car feature
fixed some lint problems Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:contentDescription="@string/my_location"
|
||||
android:src="@drawable/my_location_action_bar" />
|
||||
|
||||
<ImageButton
|
||||
@@ -19,6 +20,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:contentDescription="@string/mark_car"
|
||||
android:src="@drawable/mark_my_location_action_bar" />
|
||||
|
||||
<ImageButton
|
||||
@@ -27,6 +29,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:contentDescription="@string/show_both"
|
||||
android:src="@drawable/car_action_bar" />
|
||||
|
||||
<ImageButton
|
||||
@@ -35,6 +38,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:contentDescription="@string/parking_timer"
|
||||
android:src="@drawable/time_action_bar" />
|
||||
|
||||
<ImageButton
|
||||
@@ -43,6 +47,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:contentDescription="@string/directions"
|
||||
android:src="@drawable/nav_action_bar" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -8,13 +8,15 @@
|
||||
android:id="@+id/tvAddress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true" />
|
||||
android:layout_alignParentTop="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/tvAddress"
|
||||
android:gravity="top" />
|
||||
android:gravity="top"
|
||||
android:hint="@string/store_your_notes_here" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -59,7 +59,7 @@
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="7dip"
|
||||
android:layout_marginTop="10dip"
|
||||
android:paddingLeft="7px" />
|
||||
android:paddingLeft="7dip" />
|
||||
|
||||
<!-- textview to hold text after the checkbox "Notify me" -->
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
android:id="@+id/tvNotify1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25px"
|
||||
android:layout_marginTop="25dip"
|
||||
android:layout_toRightOf="@id/chNotify"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/notify_me"
|
||||
@@ -92,7 +92,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="7dip"
|
||||
android:layout_marginTop="17px"
|
||||
android:layout_marginTop="17dip"
|
||||
android:layout_toRightOf="@id/etNotify"
|
||||
android:text="@string/before"
|
||||
android:textStyle="bold" />
|
||||
@@ -112,7 +112,7 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/btSetTimer"
|
||||
android:layout_width="130px"
|
||||
android:layout_width="130dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
@@ -121,7 +121,7 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/btRemoveTimer"
|
||||
android:layout_width="130px"
|
||||
android:layout_width="130dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
|
||||
@@ -101,8 +101,8 @@
|
||||
<string name="eulaagreement"><insert eula here></string>
|
||||
<string name="feature_in_fmc_full_description">This feature is only available in the full version. Do you want to purchase the full version now?</string>
|
||||
<string name="default_location">Car</string>
|
||||
<string name="deleteing">Deleteing...</string>
|
||||
<string name="calculating">Calculating...</string>
|
||||
<string name="deleteing">Deleteing…</string>
|
||||
<string name="calculating">Calculating…</string>
|
||||
<string name="map_mode">Map Mode</string>
|
||||
<string name="version_info">Version Information</string>
|
||||
<string name="saved">Saved</string>
|
||||
@@ -110,5 +110,6 @@
|
||||
<string name="settings">Settings</string>
|
||||
<string name="directions_empty_msg">Your directions will appear here. Please select the Navigation Icon in the lower right of the map to use navigation.</string>
|
||||
<string name="nav_only_in_full">The Navigation feature is used to display walking directions to your car. This fetaure is only available in the full version of Find My Car. Please visit the Android Market to purchase Find My Car. </string>
|
||||
<string name="store_your_notes_here">You can store your notes here…</string>
|
||||
|
||||
</resources>
|
||||
@@ -17,6 +17,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -37,6 +38,7 @@ import com.TwentyCodes.android.FindMyCarLib.debug.Debug;
|
||||
import com.TwentyCodes.android.SkyHook.SkyHookRegistration;
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
import com.TwentyCodes.android.location.OnDirectionSelectedListener;
|
||||
import com.TwentyCodes.android.location.ReverseGeocoder;
|
||||
import com.TwentyCodes.android.overlays.DirectionsOverlay;
|
||||
import com.google.ads.AdRequest;
|
||||
import com.google.ads.AdView;
|
||||
@@ -198,7 +200,43 @@ public class Main extends FragmentActivity implements RegistrationCallback, MapF
|
||||
Log.d(TAG,"successfully registered new user");
|
||||
mSettings.edit().putBoolean(Settings.IS_REGISTERED, true).commit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* called when a car is deleted
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.FindMyCarLib.UI.fragments.MapFragment.MapFragmentListener#onCarDeleted()
|
||||
*/
|
||||
@Override
|
||||
public void onCarDeleted() {
|
||||
mNotes.delete();
|
||||
mDirectionsFragment.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* called when a new car is marked
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.FindMyCarLib.UI.fragments.MapFragment.MapFragmentListener#onCarMarked(com.google.android.maps.GeoPoint)
|
||||
*/
|
||||
@Override
|
||||
public void onCarMarked(final GeoPoint point) {
|
||||
new Thread( new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
Location location = new Location("location");
|
||||
location.setLatitude(point.getLatitudeE6() /1e6);
|
||||
location.setLongitude(point.getLongitudeE6() /1e6);
|
||||
|
||||
final String address = ReverseGeocoder.getAddressFromLocation(location);
|
||||
runOnUiThread( new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
mNotes.setAddressText(address);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -296,6 +334,39 @@ public class Main extends FragmentActivity implements RegistrationCallback, MapF
|
||||
mPager.setPagingEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* called when directions are displayed
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.FindMyCarLib.UI.fragments.MapFragment.MapFragmentListener#onDirectionsDisplayed(java.util.ArrayList, java.util.ArrayList, java.util.ArrayList, java.util.ArrayList, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void onDirectionsDisplayed(final DirectionsOverlay directions) {
|
||||
this.runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
mDirectionsFragment.setDirections(directions);
|
||||
mPager.setCurrentItem(2);
|
||||
|
||||
mPager.setCurrentItem(0);
|
||||
mIndicator.setCurrentItem(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* called when a direction is selected
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.location.DirectionsListFragment.OnDirectionSelectedListener#onDirectionSelected(com.google.android.maps.GeoPoint)
|
||||
*/
|
||||
@Override
|
||||
public void onDirectionSelected(GeoPoint point) {
|
||||
if(mMap != null) {
|
||||
mMap.panToGeoPoint(point, true);
|
||||
mPager.setCurrentItem(1);
|
||||
mIndicator.setCurrentItem(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -509,47 +580,5 @@ public class Main extends FragmentActivity implements RegistrationCallback, MapF
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* called when a car is deleted
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.FindMyCarLib.UI.fragments.MapFragment.MapFragmentListener#onCarDeleted()
|
||||
*/
|
||||
@Override
|
||||
public void onCarDeleted() {
|
||||
mNotes.delete();
|
||||
mDirectionsFragment.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* called when directions are displayed
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.FindMyCarLib.UI.fragments.MapFragment.MapFragmentListener#onDirectionsDisplayed(java.util.ArrayList, java.util.ArrayList, java.util.ArrayList, java.util.ArrayList, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void onDirectionsDisplayed(final DirectionsOverlay directions) {
|
||||
this.runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
mDirectionsFragment.setDirections(directions);
|
||||
mPager.setCurrentItem(2);
|
||||
|
||||
mPager.setCurrentItem(0);
|
||||
mIndicator.setCurrentItem(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* called when a direction is selected
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.location.DirectionsListFragment.OnDirectionSelectedListener#onDirectionSelected(com.google.android.maps.GeoPoint)
|
||||
*/
|
||||
@Override
|
||||
public void onDirectionSelected(GeoPoint point) {
|
||||
if(mMap != null) {
|
||||
mMap.panToGeoPoint(point, true);
|
||||
mPager.setCurrentItem(1);
|
||||
mIndicator.setCurrentItem(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,13 @@ public class MapFragment extends Fragment implements GeoPointLocationListener, O
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void onCarDeleted();
|
||||
|
||||
/**
|
||||
* Called when a new Car is marked
|
||||
* @param point
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void onCarMarked(GeoPoint point);
|
||||
|
||||
/**
|
||||
* Called when there are new directions being displayed to the user
|
||||
@@ -221,7 +228,7 @@ public class MapFragment extends Fragment implements GeoPointLocationListener, O
|
||||
|
||||
setCar(user);
|
||||
|
||||
// TODO get address
|
||||
mListener.onCarMarked(user);
|
||||
|
||||
} else {
|
||||
Toast.makeText(getActivity(), R.string.no_gps_signal,
|
||||
@@ -593,9 +600,9 @@ public class MapFragment extends Fragment implements GeoPointLocationListener, O
|
||||
*/
|
||||
if (!panToGeoPoint(mMap.getUserLocation(), true)) {
|
||||
Toast.makeText(getActivity(), R.string.no_gps_signal, Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,35 @@ public class NotesFragment extends Fragment {
|
||||
private SharedPreferences mSettings;
|
||||
private TextView mAddress;
|
||||
|
||||
/**
|
||||
* deletes the note
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void delete() {
|
||||
if(mText != null)
|
||||
mText.setText("");
|
||||
if(mAddress != null)
|
||||
mAddress.setText("");
|
||||
if(mSettings != null)
|
||||
mSettings.edit().remove(Settings.NOTE).remove(Settings.ADDRESS).commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
|
||||
* android.view.ViewGroup, android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.notes, container, false);
|
||||
mSettings = getActivity().getSharedPreferences(Settings.SETTINGS, 0);
|
||||
mText = (EditText) view.findViewById(R.id.editText);
|
||||
mAddress = (TextView) view.findViewById(R.id.tvAddress);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.support.v4.app.Fragment#onPause()
|
||||
@@ -34,7 +63,7 @@ public class NotesFragment extends Fragment {
|
||||
@Override
|
||||
public void onPause() {
|
||||
mSettings.edit().putString(Settings.NOTE, mText.getText().toString()).commit();
|
||||
// Toast.makeText(getActivity(), R.string.saved, Toast.LENGTH_LONG).show();
|
||||
mSettings.edit().putString(Settings.ADDRESS, mAddress.getText().toString()).commit();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@@ -56,32 +85,12 @@ public class NotesFragment extends Fragment {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
|
||||
* android.view.ViewGroup, android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.notes, container, false);
|
||||
mSettings = getActivity().getSharedPreferences(Settings.SETTINGS, 0);
|
||||
mText = (EditText) view.findViewById(R.id.editText);
|
||||
mAddress = (TextView) view.findViewById(R.id.tvAddress);
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes the note
|
||||
* Sets the address text
|
||||
* @param text
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void delete() {
|
||||
if(mText != null)
|
||||
mText.setText("");
|
||||
if(mAddress != null)
|
||||
mAddress.setText("");
|
||||
if(mSettings != null)
|
||||
mSettings.edit().remove(Settings.NOTE).remove(Settings.ADDRESS).commit();
|
||||
public void setAddressText(String text) {
|
||||
this.mAddress.setText(text);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user