diff --git a/android/.settings/org.eclipse.jdt.core.prefs b/android/.settings/org.eclipse.jdt.core.prefs index 5dbe380..f88a139 100644 --- a/android/.settings/org.eclipse.jdt.core.prefs +++ b/android/.settings/org.eclipse.jdt.core.prefs @@ -43,7 +43,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=nex org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block=next_line org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 1e07e69..08c03cf 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -2,13 +2,28 @@ + android:versionName="1.0" > + + + - + + + + + + + + + + + + + + + + diff --git a/android/proguard-project.txt b/android/proguard-project.txt index f2fe155..f60edd1 100644 --- a/android/proguard-project.txt +++ b/android/proguard-project.txt @@ -18,3 +18,21 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} + + +-keep class * extends java.util.ListResourceBundle { + protected Object[][] getContents(); +} + +-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { + public static final *** NULL; +} + +-keepnames @com.google.android.gms.common.annotation.KeepName class * +-keepclassmembernames class * { + @com.google.android.gms.common.annotation.KeepName *; +} + +-keepnames class * implements android.os.Parcelable { + public static final ** CREATOR; +} diff --git a/android/project.properties b/android/project.properties index 1865458..dbb66c3 100644 --- a/android/project.properties +++ b/android/project.properties @@ -13,3 +13,4 @@ # Project target. target=android-21 android.library.reference.1=..\\HorizontalListViewLibrary +android.library.reference.2=../google-play-services_lib diff --git a/android/res/layout/fragment_map_page.xml b/android/res/layout/fragment_map_page.xml new file mode 100644 index 0000000..9fdb94a --- /dev/null +++ b/android/res/layout/fragment_map_page.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/android/res/layout/fragment_osm_map_page.xml b/android/res/layout/fragment_osm_map_page.xml new file mode 100644 index 0000000..86d34cf --- /dev/null +++ b/android/res/layout/fragment_osm_map_page.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/android/res/layout/fragment_streetview_page.xml b/android/res/layout/fragment_streetview_page.xml new file mode 100644 index 0000000..4bfffcc --- /dev/null +++ b/android/res/layout/fragment_streetview_page.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/android/src/fishrungames/bashgid/MainActivity.java b/android/src/fishrungames/bashgid/MainActivity.java index 8f3141e..685bd50 100644 --- a/android/src/fishrungames/bashgid/MainActivity.java +++ b/android/src/fishrungames/bashgid/MainActivity.java @@ -26,6 +26,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF public static final String TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT = "TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT"; public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment"; public static final String TAG_TO_MAINFRAGMENT = "MainFragment"; + public static final String TAG_TO_MAPFRAGMENT = "MapFragment"; @@ -33,6 +34,8 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF + + static MainActivity instance = null; private NavigationDrawerFragment mNavigationDrawerFragment = null; @@ -157,6 +160,19 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF mNavigationDrawerFragment.EnableDrawer(); } + public void OpenMapScreen() + { + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MapHolderFragment(), TAG_TO_MAINFRAGMENT).commit(); + + mNavigationDrawerFragment.EnableDrawer(); + } + + public void OpenStreetViewScreen(double lat, double lon) + { + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new StreetViewHolderFragment(lat, lon), TAG_TO_MAPFRAGMENT).commit(); + + mNavigationDrawerFragment.EnableDrawer(); + } @@ -240,6 +256,11 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF { OpenNewsScreen(); } + else if (position == 4) + { + OpenMapScreen(); + //OpenStreetViewScreen(); + } else if (position == 8) { OpenSettingsScreen(); @@ -285,7 +306,15 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF return; } + if (getSupportFragmentManager().findFragmentByTag(TAG_TO_MAPFRAGMENT) != null) + { + OpenMapScreen(); + return; + } + + + super.onBackPressed(); diff --git a/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java b/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java index 8b3bbca..de690a2 100644 --- a/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java +++ b/android/src/fishrungames/bashgid/MainPageHListViewAdapters.java @@ -1,6 +1,7 @@ package fishrungames.bashgid; import fishrungames.bashgid.core.LinkContentStorage; +import android.annotation.SuppressLint; import android.content.Context; import android.view.LayoutInflater; import android.view.View; @@ -39,6 +40,7 @@ public class MainPageHListViewAdapters { } // create a new ImageView for each item referenced by the Adapter + @SuppressLint("InflateParams") public View getView(int position, View convertView, ViewGroup parent) { @@ -102,6 +104,7 @@ public static class DarkenElementAdapter extends BaseAdapter { } // create a new ImageView for each item referenced by the Adapter + @SuppressLint("InflateParams") public View getView(int position, View convertView, ViewGroup parent) { diff --git a/android/src/fishrungames/bashgid/MapHolderFragment.java b/android/src/fishrungames/bashgid/MapHolderFragment.java new file mode 100644 index 0000000..d0387a0 --- /dev/null +++ b/android/src/fishrungames/bashgid/MapHolderFragment.java @@ -0,0 +1,72 @@ +package fishrungames.bashgid; + + +import com.google.android.gms.maps.GoogleMap; + +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener; +import com.google.android.gms.maps.OnMapReadyCallback; +import com.google.android.gms.maps.SupportMapFragment; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; +import com.google.android.gms.maps.model.MarkerOptions; + +import fishrungames.bashgid.core.LocationHolder; + +import android.os.Bundle; +import android.support.v4.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +public class MapHolderFragment extends Fragment implements OnMapReadyCallback +{ + + GoogleMap mMap = null; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + View rootView = inflater.inflate(R.layout.fragment_map_page, container, false); + + SupportMapFragment mapFragment = (SupportMapFragment) this.getChildFragmentManager().findFragmentById(R.id.map); + + mapFragment.getMapAsync(this); + + + return rootView; + } + + @Override + public void onMapReady(GoogleMap map) + { + mMap = map; + mMap.setMyLocationEnabled(true); + mMap.getUiSettings().setRotateGesturesEnabled(false); + + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE), LocationHolder.CONST_UFA_ZOOM)); + + + LatLng ufaPanoramas = new LatLng(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE); + /*Marker marker =*/ mMap.addMarker(new MarkerOptions() + .position(ufaPanoramas) + .title("Ufa") + .snippet("City center")); + + + mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() + { + + @Override + public void onInfoWindowClick(Marker marker) + { + MainActivity.getInstance().OpenStreetViewScreen(LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE); + } + + }); + + + } +} diff --git a/android/src/fishrungames/bashgid/NavigationDrawerFragment.java b/android/src/fishrungames/bashgid/NavigationDrawerFragment.java index 00353bd..c92ab09 100644 --- a/android/src/fishrungames/bashgid/NavigationDrawerFragment.java +++ b/android/src/fishrungames/bashgid/NavigationDrawerFragment.java @@ -3,11 +3,10 @@ package fishrungames.bashgid; import android.support.v7.app.ActionBarActivity; import android.app.Activity; -import android.app.SearchManager; + import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBarDrawerToggle; -import android.support.v7.widget.SearchView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.content.Context; diff --git a/android/src/fishrungames/bashgid/NewsListFragment.java b/android/src/fishrungames/bashgid/NewsListFragment.java index 7604665..e45b010 100644 --- a/android/src/fishrungames/bashgid/NewsListFragment.java +++ b/android/src/fishrungames/bashgid/NewsListFragment.java @@ -9,6 +9,7 @@ import fishrungames.bashgid.core.NewsManager.NewsRecord; import fishrungames.bashgid.core.NewsUpdatedCallbackInterface; import fishrungames.bashgid.core.RemoveCallbackInterface; import fishrungames.bashgid.core.db.NewsDataSource; +import android.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -34,7 +35,7 @@ public class NewsListFragment extends Fragment implements NewsUpdatedCallbackInt RemoveCallbackInterface downloadNewsCanceller = null; - @Override + @SuppressLint("InflateParams") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_news_page, container, false); @@ -92,6 +93,7 @@ public class NewsListFragment extends Fragment implements NewsUpdatedCallbackInt } // create a new ImageView for each item referenced by the Adapter + @SuppressLint("InflateParams") public View getView(int position, View convertView, ViewGroup parent) { diff --git a/android/src/fishrungames/bashgid/OsmMapHolderFragment.java b/android/src/fishrungames/bashgid/OsmMapHolderFragment.java new file mode 100644 index 0000000..749d20b --- /dev/null +++ b/android/src/fishrungames/bashgid/OsmMapHolderFragment.java @@ -0,0 +1,26 @@ +package fishrungames.bashgid; + + + +import android.os.Bundle; +import android.support.v4.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +public class OsmMapHolderFragment extends Fragment +{ + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + View rootView = inflater.inflate(R.layout.fragment_osm_map_page, container, false); + + + return rootView; + } + +} diff --git a/android/src/fishrungames/bashgid/SearchFragment.java b/android/src/fishrungames/bashgid/SearchFragment.java index 5600958..7839497 100644 --- a/android/src/fishrungames/bashgid/SearchFragment.java +++ b/android/src/fishrungames/bashgid/SearchFragment.java @@ -9,6 +9,7 @@ import fishrungames.bashgid.core.db.NewsDataSource; import fishrungames.bashgid.core.ImageManager; import fishrungames.bashgid.core.NewsSearchRunnable; import fishrungames.bashgid.core.NewsUpdatedCallbackInterface; +import android.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -51,7 +52,7 @@ public class SearchFragment extends Fragment implements NewsUpdatedCallbackInter this.restorePreviousSearch = restorePreviousSearch; } - @Override + @SuppressLint("InflateParams") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_search_page, container, false); @@ -115,6 +116,7 @@ public class SearchFragment extends Fragment implements NewsUpdatedCallbackInter } // create a new ImageView for each item referenced by the Adapter + @SuppressLint("InflateParams") public View getView(int position, View convertView, ViewGroup parent) { diff --git a/android/src/fishrungames/bashgid/StreetViewHolderFragment.java b/android/src/fishrungames/bashgid/StreetViewHolderFragment.java new file mode 100644 index 0000000..76ac607 --- /dev/null +++ b/android/src/fishrungames/bashgid/StreetViewHolderFragment.java @@ -0,0 +1,56 @@ +package fishrungames.bashgid; + + +import com.google.android.gms.maps.OnStreetViewPanoramaReadyCallback; +import com.google.android.gms.maps.StreetViewPanorama; + +import com.google.android.gms.maps.SupportStreetViewPanoramaFragment; +import com.google.android.gms.maps.model.LatLng; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +public class StreetViewHolderFragment extends Fragment implements OnStreetViewPanoramaReadyCallback +{ + + double lat = 0; + double lon = 0; + + public StreetViewHolderFragment() + { + + } + + public StreetViewHolderFragment(double lat, double lon) + { + this.lat = lat; + this.lon = lon; + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + View rootView = inflater.inflate(R.layout.fragment_streetview_page, container, false); + + SupportStreetViewPanoramaFragment streetViewPanoramaFragment = (SupportStreetViewPanoramaFragment) getChildFragmentManager().findFragmentById(R.id.streetviewpanorama); + + streetViewPanoramaFragment.getStreetViewPanoramaAsync(this); + + + return rootView; + } + + @Override + public void onStreetViewPanoramaReady(StreetViewPanorama svp) + { + svp.setPosition(new LatLng(lat, lon)); + } + +} diff --git a/android/src/fishrungames/bashgid/core/LocationHolder.java b/android/src/fishrungames/bashgid/core/LocationHolder.java new file mode 100644 index 0000000..9da81c4 --- /dev/null +++ b/android/src/fishrungames/bashgid/core/LocationHolder.java @@ -0,0 +1,41 @@ +package fishrungames.bashgid.core; + +import android.content.Context; +import android.location.Location; +import android.location.LocationManager; + +public class LocationHolder +{ + public static Location location; + + public static double CONST_UFA_LATITUDE = 54.726274; + public static double CONST_UFA_LONGITUDE = 55.947622; + public static int CONST_UFA_ZOOM = 10; + + public static void RefreshLocation(Context context) + { + LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); + + boolean isGPSEnabled = locationManager + .isProviderEnabled(LocationManager.GPS_PROVIDER); + + // getting network status + boolean isNetworkEnabled = locationManager + .isProviderEnabled(LocationManager.NETWORK_PROVIDER); + + if (isGPSEnabled) + { + location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); + } + else if (isNetworkEnabled) + { + location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + } + else + { + location = null; + } + } + + +}