e9b52a2e by chiangbt

update 3.26 11.37

1 parent a437ef42
......@@ -28,6 +28,7 @@ dependencies {
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
compile 'com.github.arimorty:floatingsearchview:2.1.1'
compile 'com.amitshekhar.android:android-networking:0.2.0'
compile 'com.github.chyrta:AndroidOnboarder:0.6'
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
......
......@@ -15,16 +15,18 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@style/AppTheme.NoActionBar">
android:name=".BootActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="landscape"> <!-- 禁止屏幕旋转 -->
</activity>
</application>
</manifest>
\ No newline at end of file
......
package com.pashanhoo.landsurvey;
import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.KeyEvent;
import com.chyrta.onboarder.OnboarderActivity;
import com.chyrta.onboarder.OnboarderPage;
import java.util.ArrayList;
import java.util.List;
/**
* Created by chiangbt on 2017/5/8.
*/
public class BootActivity extends OnboarderActivity {
/**
* 需要进行检测的权限数组
*/
protected String[] needPermissions = {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.READ_PHONE_STATE
};
private static final int PERMISSON_REQUESTCODE = 0;
/**
* 判断是否需要检测,防止不停的弹框
*/
private boolean isNeedCheck = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 系统权限检查
if(isNeedCheck){
checkPermissions(needPermissions);
}
// 引导页设置
OnboarderPage onboarderPage1 = new OnboarderPage("Keymap", "服务于智慧城市信息化的产品", R.drawable.planet1);
OnboarderPage onboarderPage2 = new OnboarderPage("国土监测", "移动,无所不知...", R.drawable.planet2);
OnboarderPage onboarderPage3 = new OnboarderPage("江苏爬山虎科技股份有限公司", "中国 江苏 南京/扬州", R.drawable.planet3);
onboarderPage1.setBackgroundColor(R.color.onboarder_bg_1);
onboarderPage2.setBackgroundColor(R.color.onboarder_bg_2);
onboarderPage3.setBackgroundColor(R.color.onboarder_bg_3);
List<OnboarderPage> pages = new ArrayList<>();
pages.add(onboarderPage1);
pages.add(onboarderPage2);
pages.add(onboarderPage3);
for (OnboarderPage page : pages) {
page.setTitleColor(R.color.primary_text);
page.setDescriptionColor(R.color.secondary_text);
}
setSkipButtonTitle("跳过");
setFinishButtonTitle("进入");
setOnboardPagesReady(pages);
}
@Override
public void onSkipButtonPressed() {
super.onSkipButtonPressed();
gotoMainActivity();
}
@Override
public void onFinishButtonPressed() {
gotoMainActivity();
}
private void gotoMainActivity(){
Intent intent = new Intent(BootActivity.this, MainActivity.class);
startActivity(intent);
// 跳转后关闭引导页
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
// Android6的许可检查
private void checkPermissions(String... permissions) {
List<String> needRequestPermissonList = findDeniedPermissions(permissions);
if (null != needRequestPermissonList
&& needRequestPermissonList.size() > 0) {
ActivityCompat.requestPermissions(this,
needRequestPermissonList.toArray(
new String[needRequestPermissonList.size()]),
PERMISSON_REQUESTCODE);
}
}
private List<String> findDeniedPermissions(String[] permissions) {
List<String> needRequestPermissonList = new ArrayList<String>();
for (String perm : permissions) {
if (ContextCompat.checkSelfPermission(this,
perm) != PackageManager.PERMISSION_GRANTED
|| ActivityCompat.shouldShowRequestPermissionRationale(
this, perm)) {
needRequestPermissonList.add(perm);
}
}
return needRequestPermissonList;
}
private boolean verifyPermissions(int[] grantResults) {
for (int result : grantResults) {
if (result != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
return true;
}
@Override
public void onRequestPermissionsResult(int requestCode,
String[] permissions, int[] paramArrayOfInt) {
if (requestCode == PERMISSON_REQUESTCODE) {
if (!verifyPermissions(paramArrayOfInt)) {
showMissingPermissionDialog();
isNeedCheck = false;
}
}
}
/**
* 显示提示信息
*
* @since 2.5.0
*
*/
private void showMissingPermissionDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.notifyTitle);
builder.setMessage(R.string.notifyMsg);
// 拒绝, 退出应用
builder.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.setPositiveButton(R.string.setting,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startAppSettings();
}
});
builder.setCancelable(false);
builder.show();
}
/**
* 启动应用的设置
*
* @since 2.5.0
*
*/
private void startAppSettings() {
Intent intent = new Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + getPackageName()));
startActivity(intent);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
this.finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
......@@ -40,37 +40,48 @@ import org.json.JSONObject;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
// 地图控件
private MapView mapView;
// 地图中的GraphicsLayer对象
private GraphicsLayer graphicsLayer;
// GPS定位器对象
private LocationDisplayManager locationDisplayManager;
// 四个天地图图层对象
private TianDiTuTiledMapServiceLayer t_vec;
private TianDiTuTiledMapServiceLayer t_cva;
private TianDiTuTiledMapServiceLayer t_img;
private TianDiTuTiledMapServiceLayer t_cia;
// mbtiles式天地图数据
private TianDiTuLocalTiledMapServiceLayer t_local;
private String mapType;
// 左下角LGOGO信息
private TextView mapinfoView;
// 浮动查询条
private FloatingSearchView floatingSearchView;
// 当前地图层级
private int curLevel = 0;
// 地图类型名称
private String mapType;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 分别获取控件
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
mapinfoView = (TextView) findViewById(R.id.mapinfo);
floatingSearchView = (FloatingSearchView) findViewById(R.id.floating_search_view);
setSupportActionBar(toolbar);
//初始化-------------------------------------------------------------------
AppInfo.Settings();
//按钮动作-------------------------------------------------------------------
// 放大按钮
FloatingActionButton zoomin = (FloatingActionButton) findViewById(R.id.zoomin);
zoomin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 停止GPS
if (locationDisplayManager != null) {
locationDisplayManager.stop();
}
......@@ -79,6 +90,7 @@ public class MainActivity extends AppCompatActivity {
}
}
});
// 缩小按钮
FloatingActionButton zoomout = (FloatingActionButton) findViewById(R.id.zoomout);
zoomout.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -91,16 +103,19 @@ public class MainActivity extends AppCompatActivity {
}
}
});
// 回到初始页面
FloatingActionButton fullmap = (FloatingActionButton) findViewById(R.id.fullmap);
fullmap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
locationDisplayManager.stop();
graphicsLayer.removeAll();
mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes);
curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes);
mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
}
});
// GPS按钮
FloatingActionButton gps = (FloatingActionButton) findViewById(R.id.gps);
gps.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -118,7 +133,7 @@ public class MainActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.map);
mapView.setEsriLogoVisible(false);
mapView.enableWrapAround(false);
// 添加地图图层
t_vec = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.VEC_C);
mapView.addLayer(t_vec);
t_cva = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.CVA_C);
......@@ -126,7 +141,7 @@ public class MainActivity extends AppCompatActivity {
// 一个本地sqlite数据库,注意其只有8-9级数据,因此在数据层中予以了显示控制
t_local = new TianDiTuLocalTiledMapServiceLayer("my.db", "IMG_C");
mapView.addLayer(t_local);
// 添加地图图层
t_img = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.IMG_C);
t_img.setVisible(false);
mapView.addLayer(t_img);
......@@ -134,18 +149,19 @@ public class MainActivity extends AppCompatActivity {
t_cia.setVisible(false);
mapView.addLayer(t_cia);
mapType = "VEC";
// 添加GraphicsLayer
graphicsLayer = new GraphicsLayer();
mapView.addLayer(graphicsLayer);
// 设置地图的最小和最大分辨率
mapView.setMaxResolution(TDTTileinfo.getRes4490()[1]);
mapView.setMinResolution(TDTTileinfo.getRes4490()[18]);
mapView.setMinResolution(TDTTileinfo.getRes4490()[19]);
// 监听地图状态变化事件
mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
private static final long serialVersionUID = 1L;
@Override
public void onStatusChanged(Object o, STATUS status) {
// 刚刚打开时,将地图缩放到指定位置及层级
if (status == STATUS.INITIALIZED) {
mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes);
curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes);
......@@ -203,19 +219,18 @@ public class MainActivity extends AppCompatActivity {
POISuggestion colorSuggestion = (POISuggestion) searchSuggestion;
Point poipt = new Point(colorSuggestion.getLng(), colorSuggestion.getLat());
mapView.zoomToResolution(poipt, TDTTileinfo.getRes4490()[18]);
mapView.zoomToResolution(poipt, TDTTileinfo.getRes4490()[19]);
graphicsLayer.addGraphic(new Graphic(poipt,
new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16)));
// floatingSearchView.clearSuggestions();
curLevel = TDTTileinfo.getCurrentLevel(mapView.getResolution());
mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
mapinfoView.setText("当前地图级别为:19");
}
@Override
public void onSearchAction(String currentQuery) {
if (currentQuery.length() > 3) {
floatingSearchView.clearSuggestions();
// 查询天地图API
String str = "{\"keyWord\":\"" + currentQuery + "\",\"level\":\"11\",\"mapBound\":\"76.24832,30.1129,156.40458,49.97618\",\"queryType\":\"1\",\"count\":\"10\",\"start\":\"0\",\"queryTerminal\":\"1000\"}";
AndroidNetworking.post("http://map.tianditu.com/query.shtml")
.addBodyParameter("type", "query")
......@@ -225,6 +240,7 @@ public class MainActivity extends AppCompatActivity {
.getAsJSONObject(new JSONObjectRequestListener() {
@Override
public void onResponse(JSONObject response) {
//解析响应结果
JSONArray Jarray = null;
try {
Jarray = response.getJSONArray("pois");
......
......@@ -32,9 +32,8 @@
android:layout_marginBottom="16dp"
app:floatingSearch_searchHint="地名地址检索..."
app:floatingSearch_suggestionsListAnimDuration="250"
app:floatingSearch_showSearchKey="false"
app:floatingSearch_leftActionMode="showSearch"
app:floatingSearch_menu="@menu/menu_main"
app:floatingSearch_showSearchKey="true"
app:floatingSearch_leftActionMode="showHome"
app:floatingSearch_close_search_on_keyboard_dismiss="true"/>
<android.support.v7.widget.LinearLayoutCompat
......
......@@ -3,4 +3,10 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="onboarder_bg_1">#5fa4c4</color>
<color name="onboarder_bg_2">#d4774f</color>
<color name="onboarder_bg_3">#724abc</color>
<color name="primary_text">#FAFAFA</color>
<color name="secondary_text">#E0E0E0</color>
</resources>
......
<resources>
<string name="app_name">土地监察</string>
<string name="action_settings">切换图层</string>
<string name="notifyTitle">提示</string>
<string name="notifyMsg">当前应用缺少必要权限。\n\n请点击\"设置\"-\"权限\"-打开所需权限。</string>
<string name="setting">设置</string>
<string name="cancel">取消</string>
<string name="drawer_item_section_header1">图层控制</string>
<string name="drawer_item_section_header2">版权信息</string>
</resources>
......