Prepare Bashgid to unite with networkutils lib

This commit is contained in:
Vladislav Khorev 2015-01-22 02:48:48 +00:00
parent 322a651dd6
commit 1db623b8d6
16 changed files with 339 additions and 7 deletions

View File

@ -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_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=next_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=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_constant=next_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=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 org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line

View File

@ -4,11 +4,26 @@
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" > android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk <uses-sdk
android:minSdkVersion="11" android:minSdkVersion="11"
android:targetSdkVersion="21" /> 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 <application
android:allowBackup="true" android:allowBackup="true"
@ -27,6 +42,15 @@
</intent-filter> </intent-filter>
</activity> </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> </application>
</manifest> </manifest>

View File

@ -18,3 +18,21 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *; # 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;
}

View File

@ -13,3 +13,4 @@
# Project target. # Project target.
target=android-21 target=android-21
android.library.reference.1=..\\HorizontalListViewLibrary android.library.reference.1=..\\HorizontalListViewLibrary
android.library.reference.2=../google-play-services_lib

View 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>

View 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>

View 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>

View File

@ -26,6 +26,9 @@ 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_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT = "TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT";
public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment"; public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment";
public static final String TAG_TO_MAINFRAGMENT = "MainFragment"; public static final String TAG_TO_MAINFRAGMENT = "MainFragment";
public static final String TAG_TO_MAPFRAGMENT = "MapFragment";
@ -157,6 +160,19 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
mNavigationDrawerFragment.EnableDrawer(); 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(); OpenNewsScreen();
} }
else if (position == 4)
{
OpenMapScreen();
//OpenStreetViewScreen();
}
else if (position == 8) else if (position == 8)
{ {
OpenSettingsScreen(); OpenSettingsScreen();
@ -285,6 +306,14 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
return; return;
} }
if (getSupportFragmentManager().findFragmentByTag(TAG_TO_MAPFRAGMENT) != null)
{
OpenMapScreen();
return;
}
super.onBackPressed(); super.onBackPressed();

View File

@ -1,6 +1,7 @@
package fishrungames.bashgid; package fishrungames.bashgid;
import fishrungames.bashgid.core.LinkContentStorage; import fishrungames.bashgid.core.LinkContentStorage;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -39,6 +40,7 @@ public class MainPageHListViewAdapters {
} }
// create a new ImageView for each item referenced by the Adapter // create a new ImageView for each item referenced by the Adapter
@SuppressLint("InflateParams")
public View getView(int position, View convertView, ViewGroup parent) { 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 // create a new ImageView for each item referenced by the Adapter
@SuppressLint("InflateParams")
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {

View 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);
}
});
}
}

View File

@ -3,11 +3,10 @@ package fishrungames.bashgid;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.app.Activity; import android.app.Activity;
import android.app.SearchManager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.SearchView;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.content.Context; import android.content.Context;

View File

@ -9,6 +9,7 @@ import fishrungames.bashgid.core.NewsManager.NewsRecord;
import fishrungames.bashgid.core.NewsUpdatedCallbackInterface; import fishrungames.bashgid.core.NewsUpdatedCallbackInterface;
import fishrungames.bashgid.core.RemoveCallbackInterface; import fishrungames.bashgid.core.RemoveCallbackInterface;
import fishrungames.bashgid.core.db.NewsDataSource; import fishrungames.bashgid.core.db.NewsDataSource;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -34,7 +35,7 @@ public class NewsListFragment extends Fragment implements NewsUpdatedCallbackInt
RemoveCallbackInterface downloadNewsCanceller = null; RemoveCallbackInterface downloadNewsCanceller = null;
@Override @SuppressLint("InflateParams") @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_news_page, container, false); 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 // create a new ImageView for each item referenced by the Adapter
@SuppressLint("InflateParams")
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {

View 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;
}
}

View File

@ -9,6 +9,7 @@ import fishrungames.bashgid.core.db.NewsDataSource;
import fishrungames.bashgid.core.ImageManager; import fishrungames.bashgid.core.ImageManager;
import fishrungames.bashgid.core.NewsSearchRunnable; import fishrungames.bashgid.core.NewsSearchRunnable;
import fishrungames.bashgid.core.NewsUpdatedCallbackInterface; import fishrungames.bashgid.core.NewsUpdatedCallbackInterface;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -51,7 +52,7 @@ public class SearchFragment extends Fragment implements NewsUpdatedCallbackInter
this.restorePreviousSearch = restorePreviousSearch; this.restorePreviousSearch = restorePreviousSearch;
} }
@Override @SuppressLint("InflateParams") @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_search_page, container, false); 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 // create a new ImageView for each item referenced by the Adapter
@SuppressLint("InflateParams")
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {

View File

@ -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));
}
}

View 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;
}
}
}