Preparings to allow user set all settings for google places.

master
Tomasz Półgrabia 2016-10-06 20:37:54 +02:00
parent 1c7c2f95c9
commit d9b55bceab
7 changed files with 274 additions and 5 deletions

View File

@ -14,13 +14,11 @@ public class AppConstants {
public static final String PREF_GPS_UPDATE_FREQ = "pref_gps_update_freq"; public static final String PREF_GPS_UPDATE_FREQ = "pref_gps_update_freq";
public static final String PREF_GPS_DISTANCE_FREQ = "pref_gps_distance_freq"; public static final String PREF_GPS_DISTANCE_FREQ = "pref_gps_distance_freq";
public static final String PHOTO_BACKSTACK = "PHOTO_BACKSTACK"; public static final String PHOTO_BACKSTACK = "PHOTO_BACKSTACK";
static final int HOME_FRAGMENT_ID = 0;
static final int WIKI_FRAGMENT_ID = 1;
static final String FRAG_ID = "FRAG_ID"; static final String FRAG_ID = "FRAG_ID";
static final int SETTINGS_ID_INTENT_REQUEST_ID = 2; static final int SETTINGS_ID_INTENT_REQUEST_ID = 2;
static final String PHOTO_INFO = "PHOTO_INFO"; static final String PHOTO_INFO = "PHOTO_INFO";
static final String SAVED_CONFIG_KEY = "SAVED_CONFIG_KEY"; static final String SAVED_CONFIG_KEY = "SAVED_CONFIG_KEY";
public static final String GOOGLE_API_KEY = "AIzaSyBAJoK-pu_qnQ0U8EGjM1Zkz_g8oJV4w2g"; public static final String GOOGLE_API_KEY = "AIzaSyBAJoK-pu_qnQ0U8EGjM1Zkz_g8oJV4w2g";
public static final String DEF_WIKI_COUNTRY_CODE = "en"; public static final String DEF_WIKI_COUNTRY_CODE = "en";
public static final Double DEF_PLACES_RADIUS = 10000.0; public static final Double DEF_PLACES_RADIUS = 5000.0;
} }

View File

@ -229,6 +229,7 @@ public class HomeFragment extends Fragment {
@Subscribe @Subscribe
public void refresh(RefreshEvent refreshEvent) { public void refresh(RefreshEvent refreshEvent) {
lg.debug("Refreshing event...");
lg.trace("Fetch panoramio photos"); lg.trace("Fetch panoramio photos");
final FragmentActivity activity = getActivity(); final FragmentActivity activity = getActivity();
if (activity == null) { if (activity == null) {

View File

@ -10,6 +10,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -96,6 +97,11 @@ public class PlacesFragment extends Fragment {
return; return;
} }
Toast.makeText(getActivity(),
String.format("Location changed: %.3f,%.3f",
location.getLatitude(), location.getLongitude()),
Toast.LENGTH_SHORT).show();
places = null; places = null;
nextPageToken = null; nextPageToken = null;
noMoreResults = false; noMoreResults = false;
@ -208,8 +214,13 @@ public class PlacesFragment extends Fragment {
private void fetchNearbyPlacesAndPresent(Location location) { private void fetchNearbyPlacesAndPresent(Location location) {
if (!semaphore.tryAcquire()) { if (!semaphore.tryAcquire()) {
// running // running
lg.debug("Active fetching nearby, quitting...");
return; return;
} }
Toast.makeText(getActivity(),
String.format("Fetching nearby places %.3f,%.3f", location.getLatitude(), location.getLongitude()),
Toast.LENGTH_SHORT).show();
GooglePlacesRequest request = new GooglePlacesRequest(); GooglePlacesRequest request = new GooglePlacesRequest();
request.setLocation(location); request.setLocation(location);
@ -222,10 +233,12 @@ public class PlacesFragment extends Fragment {
if (!semaphore.tryAcquire()) { if (!semaphore.tryAcquire()) {
// running // running
lg.debug("Active fetching nearby, quitting...");
return; return;
} }
if (noMoreResults) { if (noMoreResults) {
lg.debug("There is no results, quitting...");
semaphore.release(); semaphore.release();
return; return;
} }
@ -311,6 +324,9 @@ public class PlacesFragment extends Fragment {
@Subscribe @Subscribe
public void refresh(RefreshEvent event) { public void refresh(RefreshEvent event) {
lg.debug("Refreshing event...");
Toast.makeText(getActivity(), "Refreshing event google places", Toast.LENGTH_SHORT).show();
pageId = 0L;
places = null; places = null;
nextPageToken = null; nextPageToken = null;
noMoreResults = false; noMoreResults = false;

View File

@ -161,6 +161,7 @@ public class WikiLocationsFragment extends Fragment {
@Subscribe @Subscribe
public void refresh(RefreshEvent event) { public void refresh(RefreshEvent event) {
lg.debug("Refreshing event...");
appObjects.clear(); appObjects.clear();
fetchWikiLocations(); fetchWikiLocations();
} }

View File

@ -54,4 +54,235 @@
<string name="upload_date_label">Upload date:</string> <string name="upload_date_label">Upload date:</string>
<string name="location_label">Location:</string> <string name="location_label">Location:</string>
<string name="panoramio_url">Panoramio url:</string> <string name="panoramio_url">Panoramio url:</string>
<string-array name="google_places_categories">
<item>accounting</item>
<item>airport</item>
<item>amusement_park</item>
<item>aquarium</item>
<item>art_gallery</item>
<item>atm</item>
<item>bakery</item>
<item>bank</item>
<item>bar</item>
<item>beauty_salon</item>
<item>bicycle_store</item>
<item>book_store</item>
<item>bowling_alley</item>
<item>bus_station</item>
<item>cafe</item>
<item>campground</item>
<item>car_dealer</item>
<item>car_rental</item>
<item>car_repair</item>
<item>car_wash</item>
<item>casino</item>
<item>cemetery</item>
<item>church</item>
<item>city_hall</item>
<item>clothing_store</item>
<item>convenience_store</item>
<item>courthouse</item>
<item>dentist</item>
<item>department_store</item>
<item>doctor</item>
<item>electrician</item>
<item>electronics_store</item>
<item>embassy</item>
<item>fire_station</item>
<item>florist</item>
<item>funeral_home</item>
<item>furniture_store</item>
<item>gas_station</item>
<item>gym</item>
<item>hair_care</item>
<item>hardware_store</item>
<item>hindu_temple</item>
<item>home_goods_store</item>
<item>hospital</item>
<item>insurance_agency</item>
<item>jewelry_store</item>
<item>laundry</item>
<item>lawyer</item>
<item>library</item>
<item>liquor_store</item>
<item>local_government_office</item>
<item>locksmith</item>
<item>lodging</item>
<item>meal_delivery</item>
<item>meal_takeaway</item>
<item>mosque</item>
<item>movie_rental</item>
<item>movie_theater</item>
<item>moving_company</item>
<item>museum</item>
<item>night_club</item>
<item>painter</item>
<item>park</item>
<item>parking</item>
<item>pet_store</item>
<item>pharmacy</item>
<item>physiotherapist</item>
<item>plumber</item>
<item>police</item>
<item>post_office</item>
<item>real_estate_agency</item>
<item>restaurant</item>
<item>roofing_contractor</item>
<item>rv_park</item>
<item>school</item>
<item>shoe_store</item>
<item>shopping_mall</item>
<item>spa</item>
<item>stadium</item>
<item>storage</item>
<item>store</item>
<item>subway_station</item>
<item>synagogue</item>
<item>taxi_stand</item>
<item>train_station</item>
<item>transit_station</item>
<item>travel_agency</item>
<item>university</item>
<item>veterinary_care</item>
<item>zoo</item>
</string-array>
<string-array name="def_google_places_categories">
<item>airport</item>
<item>amusement_park</item>
<item>aquarium</item>
<item>art_gallery</item>
<item>bar</item>
<item>beauty_salon</item>
<item>bowling_alley</item>
<item>cafe</item>
<item>campground</item>
<item>casino</item>
<item>cemetery</item>
<item>church</item>
<item>city_hall</item>
<item>clothing_store</item>
<item>department_store</item>
<item>embassy</item>
<item>gym</item>
<item>hair_care</item>
<item>hindu_temple</item>
<item>jewelry_store</item>
<item>liquor_store</item>
<item>meal_delivery</item>
<item>meal_takeaway</item>
<item>mosque</item>
<item>museum</item>
<item>night_club</item>
<item>park</item>
<item>restaurant</item>
<item>rv_park</item>
<item>shoe_store</item>
<item>shopping_mall</item>
<item>spa</item>
<item>stadium</item>
<item>store</item>
<item>subway_station</item>
<item>synagogue</item>
<item>taxi_stand</item>
<item>train_station</item>
<item>transit_station</item>
<item>travel_agency</item>
<item>university</item>
<item>zoo</item>
</string-array>
<string-array name="google_places_category_labels">
<item>Accounting</item>
<item>Airport</item>
<item>Amusement park</item>
<item>Aquarium</item>
<item>Art gallery</item>
<item>ATM</item>
<item>Bakery</item>
<item>Bank</item>
<item>Bar</item>
<item>Beauty salon</item>
<item>Bicycle store</item>
<item>Book store</item>
<item>Bowling alley</item>
<item>Bus station</item>
<item>Cafe</item>
<item>Campground</item>
<item>Car dealer</item>
<item>Car rental</item>
<item>Car repair</item>
<item>Car wash</item>
<item>Casino</item>
<item>Cemetery</item>
<item>Church</item>
<item>City hall</item>
<item>Clothing store</item>
<item>Convenience store</item>
<item>Courthouse</item>
<item>Dentist</item>
<item>Department store</item>
<item>Doctor</item>
<item>Electrician</item>
<item>Electronics store</item>
<item>Embassy</item>
<item>Fire station</item>
<item>Florist</item>
<item>Funeral home</item>
<item>Furniture store</item>
<item>Gas station</item>
<item>Gym</item>
<item>Hair care</item>
<item>Hardware store</item>
<item>Hindu temple</item>
<item>Home goods store</item>
<item>Hospital</item>
<item>Insurance agency</item>
<item>Jewelry store</item>
<item>Laundry</item>
<item>Lawyer</item>
<item>Library</item>
<item>Liquor store</item>
<item>Local government office</item>
<item>Locksmith</item>
<item>Lodging</item>
<item>Meal delivery</item>
<item>Meal takeaway</item>
<item>Mosque</item>
<item>Movie rental</item>
<item>Movie theater</item>
<item>Moving company</item>
<item>Museum</item>
<item>Night club</item>
<item>Painter</item>
<item>Park</item>
<item>Parking</item>
<item>Pet store</item>
<item>Pharmacy</item>
<item>Physiotherapist</item>
<item>Plumber</item>
<item>Police</item>
<item>Post office</item>
<item>Real estate agency</item>
<item>Restaurant</item>
<item>Roofing contractor</item>
<item>Rv park</item>
<item>School</item>
<item>Shoe store</item>
<item>Shopping mall</item>
<item>SPA</item>
<item>Stadium</item>
<item>Storage</item>
<item>Store</item>
<item>Subway station</item>
<item>Synagogue</item>
<item>Taxi stand</item>
<item>Train station</item>
<item>Transit station</item>
<item>Travel agency</item>
<item>University</item>
<item>Veterinary care</item>
<item>Zoo</item>
</string-array>
</resources> </resources>

View File

@ -67,6 +67,30 @@
android:inputType="numberDecimal" /> android:inputType="numberDecimal" />
</PreferenceCategory>
<PreferenceCategory
android:title="Google places search settings"
android:key="pref_gplaces_settings">
<EditTextPreference
android:key="pref_gplaces_radius"
android:title="Google places search radius"
android:summary="Google places search radius in kilometer"
android:defaultValue="10.0"
android:inputType="numberDecimal" />
<MultiSelectListPreference
android:key="pref_gplaces_categories"
android:defaultValue="@array/def_google_places_categories"
android:title="Google places categories"
android:summary="Categories of places which are included in the search results"
android:entries="@array/google_places_category_labels"
android:entryValues="@array/google_places_categories">
</MultiSelectListPreference>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory

View File

@ -4,8 +4,6 @@ package pl.tpolgrabia.googleutils.constants;
* Created by tpolgrabia on 02.10.16. * Created by tpolgrabia on 02.10.16.
*/ */
public class GooglePlacesConstants { public class GooglePlacesConstants {
public static final String GOOGLE_PLACES_BASEURL = "https://maps.googleapis.com/maps/api/place/";
public static final Long PHOTO_MAX_WIDTH = 512L;
public static final String GOOGLE_MAPS_PLACES_API_BASEURL = "https://maps.googleapis.com/maps/api/place/"; public static final String GOOGLE_MAPS_PLACES_API_BASEURL = "https://maps.googleapis.com/maps/api/place/";
public static final String PLACES_SEARCH_TYPE = "museum"; public static final String PLACES_SEARCH_TYPE = "museum";
public static final String GOOGLE_PLACES_CACHE_FILE = "places_state.dat"; public static final String GOOGLE_PLACES_CACHE_FILE = "places_state.dat";