Prepare Bashgid to unite with networkutils lib
This commit is contained in:
parent
322a651dd6
commit
1db623b8d6
@ -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
|
||||
|
@ -2,13 +2,28 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="fishrungames.bashgid"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-feature
|
||||
android:glEsVersion="0x00020000"
|
||||
android:required="true"/>
|
||||
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="11"
|
||||
android:targetSdkVersion="21" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<!-- The following two permissions are not required to use
|
||||
Google Maps Android API v2, but are recommended. -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@ -26,6 +41,15 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<meta-data android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.maps.v2.API_KEY"
|
||||
android:value="AIzaSyAN67lwiJpFHprBo7VOio4jAdSzIIOY4s8"/>
|
||||
|
||||
|
||||
|
||||
</application>
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -13,3 +13,4 @@
|
||||
# Project target.
|
||||
target=android-21
|
||||
android.library.reference.1=..\\HorizontalListViewLibrary
|
||||
android.library.reference.2=../google-play-services_lib
|
||||
|
20
android/res/layout/fragment_map_page.xml
Normal file
20
android/res/layout/fragment_map_page.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bkg1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="0dp"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingTop="0dp"
|
||||
tools:context="fishrungames.bashgid.MapHolderFragment" >
|
||||
|
||||
<fragment
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
class="com.google.android.gms.maps.SupportMapFragment" />
|
||||
|
||||
|
||||
</LinearLayout>
|
20
android/res/layout/fragment_osm_map_page.xml
Normal file
20
android/res/layout/fragment_osm_map_page.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bkg1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="0dp"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingTop="0dp"
|
||||
tools:context="fishrungames.bashgid.MapHolderFragment" >
|
||||
|
||||
<org.osmdroid.views.MapView
|
||||
android:id="@+id/mapview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tilesource="Mapnik"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
19
android/res/layout/fragment_streetview_page.xml
Normal file
19
android/res/layout/fragment_streetview_page.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bkg1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="0dp"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingTop="0dp"
|
||||
tools:context="fishrungames.bashgid.StreetViewHolderFragment" >
|
||||
|
||||
<fragment
|
||||
android:name="com.google.android.gms.maps.SupportStreetViewPanoramaFragment"
|
||||
android:id="@+id/streetviewpanorama"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</LinearLayout>
|
@ -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();
|
||||
|
||||
|
@ -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) {
|
||||
|
||||
|
||||
|
72
android/src/fishrungames/bashgid/MapHolderFragment.java
Normal file
72
android/src/fishrungames/bashgid/MapHolderFragment.java
Normal file
@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
||||
|
||||
|
26
android/src/fishrungames/bashgid/OsmMapHolderFragment.java
Normal file
26
android/src/fishrungames/bashgid/OsmMapHolderFragment.java
Normal file
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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) {
|
||||
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
41
android/src/fishrungames/bashgid/core/LocationHolder.java
Normal file
41
android/src/fishrungames/bashgid/core/LocationHolder.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user