Selaa lähdekoodia

1、完成了长度测量、面积测量、清除测量、坐标获取
2、坐标定位功能中的正则表达式尚未完成,正在修复

不会爬树的猴 1 vuosi sitten
vanhempi
commit
6d265ba941

+ 67 - 0
app/src/main/java/com/cr/common/CrUnitManager.kt

@@ -1,6 +1,8 @@
 package com.cr.common
 
 import android.content.res.Resources
+import java.math.RoundingMode
+import java.text.DecimalFormat
 
 /**
  * 操作系统:MAC系统
@@ -39,5 +41,70 @@ class CrUnitManager {
             val metrics = Resources.getSystem().displayMetrics
             return (px / metrics.density + 0.5f).toInt()
         }
+
+        /**
+         * 长度格式化
+         * @param length Double 长度值
+         * @return String 格式化后的长度值
+         */
+        fun formatLength(length:Double):String{
+            var format = DecimalFormat("#.###")
+            format.roundingMode = RoundingMode.FLOOR
+            return if(length <1000){
+                String.format("%s米",format.format(length))
+            }else{
+                String.format("%s公里",format.format(length/1000))
+            }
+        }
+
+        /**
+         * 面积格式化
+         * @param area Double 面积值
+         * @return String 格式化后的面积值
+         */
+        fun formatArea(area:Double):String{
+            var format = DecimalFormat("#.###")
+            format.roundingMode = RoundingMode.FLOOR
+            return if(area>1000000){
+                String.format("%s平方公里",format.format(area/1000000))
+            }else{
+                String.format("%s平方米",format.format(area))
+            }
+        }
+
+        /**
+         * 查询包含的数据量
+         * @param obj Iterable<T> 集合
+         * @return Int 数据数量
+         */
+        fun <T> querySizeByIterable(obj:Iterable<T>):Int{
+            var count:Int = 0;
+            var it = obj.iterator()
+            while (it.hasNext()){
+                it.next()
+                count ++
+            }
+            return count
+        }
+
+        /**
+         * 检验经度数值是否符合要求
+         * @param longitude String 经度值
+         * @return Boolean 是否符合要求
+         */
+        fun checkLongitude(longitude:String):Boolean{
+            var regex = Regex("^[\\-\\+]?(0(\\.\\d{1,10})?|([1-9](\\d)?)(\\.\\d{1,10})?|1[0-7]\\d{1}(\\.\\d{1,10})?|180\\.0{1,10})\$")
+            return regex.matches(longitude)
+        }
+
+        /**
+         * 检查纬度值是否符合要求
+         * @param latitude String 纬度值
+         * @return Boolean 是否符合要求
+         */
+        fun checkLatitude(latitude:String):Boolean{
+            var regex = Regex("^[\\-\\+]?((0|([1-8]\\d?))(\\.\\d{1,10})?|90(\\.0{1,10})?)\$")
+            return regex.matches(latitude)
+        }
     }
 }

+ 4 - 4
app/src/main/java/com/cr/cruav/AvMain.kt

@@ -357,22 +357,22 @@ class AvMain : CrActivity(), View.OnClickListener {
 
         // todo: 2023/4/21 面积测量
         override fun onMeasureArea() {
-
+            CrApplication.getEventBus().post(EventMap(MapAction.EventSurveyArea))
         }
 
         // todo: 2023/4/21 清除测量内容
         override fun onMeasureClear() {
-
+            CrApplication.getEventBus().post(EventMap(MapAction.EventSurveyClear))
         }
 
         // todo: 2023/4/21 获取经纬度位置
         override fun onGetLocation() {
-
+            CrApplication.getEventBus().post(EventMap(MapAction.MapTapGetLocation))
         }
 
         // todo: 2023/4/21 地图定位
         override fun onToLocation() {
-
+            CrApplication.getEventBus().post(EventMap(MapAction.EventInputLocationToMap))
         }
 
     }

+ 239 - 0
app/src/main/java/com/cr/dialog/DialogInput.kt

@@ -0,0 +1,239 @@
+package com.cr.dialog
+
+import android.app.Dialog
+import android.content.Context
+import android.opengl.Visibility
+import android.view.Gravity
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Button
+import android.widget.LinearLayout
+import android.widget.TextView
+import androidx.core.view.get
+import com.cr.common.CrUnitManager
+import com.cr.cruav.R
+import com.cr.data.CrUtil
+import com.cr.widget.CrEditTextWidget
+import org.w3c.dom.Text
+
+/**
+ * 操作系统:MAC系统
+ * 创建者:王成
+ * 创建日期:2023/6/7 15:42
+ * 描述:输入对话框
+ */
+class DialogInput : Dialog, View.OnClickListener {
+    /**
+     * 对外接口
+     */
+    interface DialogInputListener {
+        /**
+         * 完成
+         * @param valueOne String 值1
+         * @param valueTwo String 值2
+         * @param self DialogInput 对话框本身
+         */
+        fun completion(valueOne:String,valueTwo:String,self:DialogInput)
+
+        /**
+         * 关闭
+         */
+        fun close()
+    }
+
+    // define: 2023/3/31 监听接口
+    private var listener: DialogInputListener? = null
+
+    // define: 2023/3/31 定义控件
+    var btnCompletion: Button? = null  // define: 2023/6/7 完成按钮
+    var btnClose: Button? = null   // define: 2023/6/7 取消按钮
+    var lblTitle: TextView? = null  // define: 2023/6/7 对话框标题
+    var lblOne: TextView? = null  // define: 2023/6/7 第一输入框标题
+    var lblTwo: TextView? = null  // define: 2023/6/7 第二输入框标题
+    var panelOne: LinearLayout? = null  // define: 2023/6/7 第一输入框容器
+    var panelTwo: LinearLayout? = null   // define: 2023/6/7 第二输入框容器
+    var txtOne: CrEditTextWidget? = null  // define: 2023/6/7 第一输入框
+    var txtTwo: CrEditTextWidget? = null  // define: 2023/6/7 第二输入框
+    var self:DialogInput?=null  // define: 2023/6/7 自身引用
+
+    /**
+     * 初始化
+     * @param context Context
+     * @constructor
+     */
+    constructor(context: Context) : this(context, 0)
+
+    /**
+     * 初始化
+     * @param context Context 上下文
+     * @param themeResId Int 主题Id
+     * @constructor
+     */
+    constructor(context: Context, themeResId: Int) : super(context, R.style.Dialog) {
+        init()
+    }
+
+    /**
+     * 初始化
+     * @param context Context 上下文
+     * @param title String 标题
+     * @constructor
+     */
+    constructor(context: Context, title: String) : super(context, R.style.Dialog) {
+        init()
+        lblTitle?.text = title
+    }
+
+    /**
+     * 初始化
+     * @param context Context 上下文
+     * @param title String 主题
+     * @param listener DialogNormalListener 消息监听
+     * @constructor
+     */
+    constructor(
+        context: Context,
+        title: String,
+        listener: DialogInputListener
+    ) : super(context, R.style.Dialog) {
+        init()
+        lblTitle?.text = title
+        this.listener = listener
+    }
+
+    /**
+     * 初始化
+     */
+    private fun init() {
+        self = this
+        setContentView(R.layout.dig_input)
+        window?.setGravity(Gravity.CENTER)
+        window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
+        // todo: 2023/3/31 禁止点击对话框外部关闭
+        setCanceledOnTouchOutside(false)
+        // todo: 2023/3/31 初始化控件
+        btnCompletion = findViewById(R.id.dig_btn_ok)
+        btnClose = findViewById(R.id.dig_btn_cancel)
+        btnCompletion?.setOnClickListener(this)
+        btnClose?.setOnClickListener(this)
+        lblTitle = findViewById(R.id.dig_title)
+        lblOne = findViewById(R.id.dig_lbl_one)
+        lblTwo = findViewById(R.id.dig_lbl_two)
+        panelOne = findViewById(R.id.dig_panel_one)
+        panelTwo = findViewById(R.id.dig_panel_two)
+        txtOne = findViewById(R.id.dig_txt_one)
+        txtTwo = findViewById(R.id.dig_txt_two)
+        // todo: 2023/3/31 默认不显示取消按钮
+        btnClose?.visibility = View.GONE
+    }
+
+    /**
+     * 设置标题
+     * @param title String 标题内容
+     */
+    fun setTitle(title: String) {
+        lblTitle?.text = title
+    }
+
+    /**
+     * 设置标签显示内容
+     * @param strOne String 标签一内容
+     * @param strTow String 标签二内容
+     */
+    fun setLabels(strOne: String,strTow:String) {
+        if(strOne == null){
+            panelOne?.visibility = View.GONE
+        }else{
+            panelOne?.visibility = View.VISIBLE
+            lblOne?.text = strOne
+        }
+        if(strTow == null){
+            panelTwo?.visibility = View.GONE
+        }else{
+            panelTwo?.visibility = View.VISIBLE
+            lblTwo?.text = strTow
+        }
+    }
+
+    /**
+     * 设置输入文本框的提示信息
+     * @param hintOne String 输入框一的提示信息
+     * @param hintTwo String 输入框二的提示信息
+     */
+    fun setHints(hintOne:String,hintTwo:String){
+        txtOne?.setContextHint(hintOne)
+        txtTwo?.setContextHint(hintTwo)
+    }
+
+    /**
+     * 设置输入框图标
+     * @param fontOne String 输入框一图标
+     * @param fontTwo String 输入框二图标
+     */
+    fun setFonts(fontOne:String,fontTwo:String){
+        txtOne?.setFontIcon(fontOne)
+        txtTwo?.setFontIcon(fontTwo)
+    }
+
+    /**
+     * 设置按钮文字
+     * @param okText String 确定按钮文字
+     * @param closeText String 关闭按钮文字
+     */
+    fun setButtonsText(okText: String, closeText: String) {
+        if (okText != null) {
+            btnCompletion?.text = okText
+            btnCompletion?.visibility = View.VISIBLE
+        } else {
+            btnCompletion?.visibility = View.GONE
+        }
+        if (closeText != null) {
+            btnClose?.text = closeText
+            btnClose?.visibility = View.VISIBLE
+        } else {
+            btnClose?.visibility = View.GONE
+        }
+    }
+
+    /**
+     * 设置
+     * @param okVisible Boolean 确定按钮是否显示
+     * @param closeVisible Boolean 取消按钮是否显示
+     */
+    fun setButtonsVisible(okVisible: Boolean, closeVisible: Boolean) {
+        btnCompletion?.visibility = if (okVisible) View.VISIBLE else View.GONE
+        btnClose?.visibility = if (closeVisible) View.VISIBLE else View.GONE
+    }
+
+    /**
+     * 设置监听
+     * @param listener DialogInputListener
+     */
+    fun setListener(listener: DialogInputListener) {
+        this.listener = listener
+    }
+
+    /**
+     * 覆写点击事件
+     * @param p0 View
+     */
+    override fun onClick(p0: View?) {
+        when (p0?.id) {
+            R.id.dig_btn_ok -> {
+                if(panelOne?.visibility == View.VISIBLE && (txtOne!!.getContent() == null || txtOne!!.getContent() == "")){
+                    CrUtil.showMessage("请输入内容!")
+                    return
+                }
+                if(panelTwo?.visibility == View.VISIBLE && (txtTwo!!.getContent() == null || txtTwo!!.getContent() == "")){
+                    CrUtil.showMessage("请输入内容!")
+                    return
+                }
+                listener?.completion(txtOne!!.getContent(),txtTwo!!.getContent(),self!!)
+            }
+            R.id.dig_btn_cancel -> {
+                dismiss()
+                listener?.close()
+            }
+        }
+    }
+}

+ 5 - 0
app/src/main/java/com/cr/map/MapAction.kt

@@ -151,4 +151,9 @@ enum class MapAction {
      * 停止点击
      */
     EventStopTouch,
+
+    /**
+     * 输入定位位置到地图
+     */
+    EventInputLocationToMap,
 }

+ 12 - 0
app/src/main/java/com/cr/map/MapTouch.kt

@@ -5,11 +5,13 @@ import android.view.MotionEvent
 import com.cr.dialog.DialogNormal
 import com.esri.arcgisruntime.ArcGISRuntimeException
 import com.esri.arcgisruntime.data.Feature
+import com.esri.arcgisruntime.geometry.GeometryEngine
 import com.esri.arcgisruntime.geometry.Point
 import com.esri.arcgisruntime.geometry.SpatialReference
 import com.esri.arcgisruntime.layers.Layer
 import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener
 import com.esri.arcgisruntime.mapping.view.MapView
+import java.text.DecimalFormat
 
 /**
  * 操作系统:MAC系统
@@ -29,6 +31,9 @@ class MapTouch constructor(context: Context, mapView: MapView) :
 
         // todo: 2023/4/19 添加标志
         fun onMarkAppend(mapPoint:Point)
+
+        // todo: 2023/6/7 查询位置返回
+        fun onQueryLocation(location:Point,longitude:String,latitude:String)
     }
 
 
@@ -75,6 +80,13 @@ class MapTouch constructor(context: Context, mapView: MapView) :
                 var mapPoint = mapView?.screenToLocation(android.graphics.Point(e!!.x.toInt(),e.y.toInt()))
                 if(listener != null) listener?.onMarkAppend(mapPoint!!)
             }
+            // todo: 2023/6/7 查询地理位置
+            MapAction.MapTapGetLocation->{
+                var mapPoint = mapView?.screenToLocation(android.graphics.Point(e!!.x.toInt(),e.y.toInt()))
+                var queryPoint = GeometryEngine.project(mapPoint, SpatialReference.create(4326)) as Point
+                var format:DecimalFormat = DecimalFormat("#.######")
+                if(listener != null) listener?.onQueryLocation(mapPoint!!,format.format(queryPoint.x),format.format(queryPoint.y))
+            }
         }
         return true
     }

+ 151 - 10
app/src/main/java/com/cr/pages/FragmentMap.kt

@@ -12,6 +12,7 @@ import com.cr.common.FileManager
 import com.cr.cruav.CrApplication
 import com.cr.cruav.R
 import com.cr.data.CrUtil
+import com.cr.dialog.DialogInput
 import com.cr.dialog.DialogNormal
 import com.cr.map.*
 import com.esri.arcgisruntime.arcgisservices.LabelDefinition
@@ -33,6 +34,7 @@ import com.google.gson.JsonParser
 import com.google.gson.JsonPrimitive
 import com.squareup.otto.Subscribe
 import java.util.concurrent.ExecutionException
+import kotlin.math.abs
 
 /**
  * 操作系统:MAC系统
@@ -113,6 +115,7 @@ class FragmentMap : CrAnimationFragment() {
     private var gLayerAirplaneHomeLocation: GraphicsOverlay? = null // define: 2023/4/13 飞行器返航点位置图层
     private var gLayerAirplaneLine: GraphicsOverlay? = null // define: 2023/4/13 飞行航线图层
     private var gLayerHistoryAirplaneLine: GraphicsOverlay? = null // define: 2023/4/13 历史航线图层
+    private var gLayerTemp:GraphicsOverlay?=null  // define: 2023/6/5 临时展示内容图层
 
     // todo: 2023/4/13 样式相关
     private var symbolAirplaneLine: SimpleLineSymbol? = null // define: 2023/4/13 飞行航线样式
@@ -209,22 +212,60 @@ class FragmentMap : CrAnimationFragment() {
      * 草图编辑工具监听
      */
     private var sketchGeometryChangeListener =
-        SketchGeometryChangedListener { p0 -> // todo: 2023/4/21 计算测试
+        SketchGeometryChangedListener { p0 ->
             if(p0!!.geometry.geometryType == GeometryType.POLYLINE){
+                // todo: 2023/6/5 清除已展示内容
+                gLayerTemp?.graphics?.clear()
                 var polyline = p0.geometry as Polyline
                 var pointCollection = PointCollection(SpatialReference.create(3857))
-                for(point in polyline.parts[0].points){
-                    pointCollection.add(point)
-                    if(pointCollection.size >=2){
-                        var polyline = Polyline(pointCollection)
-                        var lineLength = GeometryEngine.length(polyline)
-                        CrUtil.print("长度$lineLength")
+                if(polyline.parts.size >0) {
+                    for(point in polyline.parts[0].points){
+                        pointCollection.add(point)
+                        if(pointCollection.size >=2){
+                            var polyline = Polyline(pointCollection)
+                            // todo: 2023/6/5 计算长度
+                            var lineLength = GeometryEngine.length(polyline)
+                            // todo: 2023/6/5 添加标签
+                            appendMeasureLabel(point,CrUnitManager.formatLength(lineLength))
+                        }
+                    }
+                }
+            }else if(p0!!.geometry.geometryType == GeometryType.POLYGON){
+                // todo: 2023/6/6 清除临时标签
+                gLayerTemp?.graphics?.clear()
+                var polygon = p0.geometry as Polygon
+                if(polygon.parts.size > 0){
+                    if(CrUnitManager.querySizeByIterable(polygon.parts[0].points) >=3){
+                        // todo: 2023/6/6 计算面积
+                        var area = GeometryEngine.area(polygon)
+                        area = abs(area)
+                        // todo: 2023/6/6 添加标签
+                        appendMeasureLabel(polygon.parts[0].startPoint,CrUnitManager.formatArea(area))
                     }
                 }
             }
         }
 
     /**
+     * 添加一个测量标签
+     * @param location Point 位置
+     * @param label String 标签内容
+     */
+    private fun appendMeasureLabel(location:Point,label:String){
+        var tSymbol = TextSymbol();
+        tSymbol.color = Color.rgb(17,46,114)
+        tSymbol.text = label
+        tSymbol.size = 10f
+        tSymbol.haloColor = Color.WHITE
+        tSymbol.haloWidth = 2f
+        tSymbol.fontWeight = TextSymbol.FontWeight.BOLD
+        tSymbol.offsetY = 20f
+        tSymbol.backgroundColor = Color.argb(200,13,49,130)
+        var graphic = Graphic(location,tSymbol)
+        gLayerTemp?.graphics?.add(graphic)
+    }
+
+    /**
      * 设置草图编辑器
      */
     private fun setSketchEditor(){
@@ -263,6 +304,12 @@ class FragmentMap : CrAnimationFragment() {
         override fun onMarkAppend(mapPoint: Point) {
             markAppend(mapPoint)
         }
+
+        // todo: 2023/6/7 查询地理位置回调
+        override fun onQueryLocation(location:Point,longitude: String, latitude: String) {
+//            showInformation(String.format("经度:%s 纬度:%s",longitude,latitude))
+            appendLocation(location,longitude,latitude)
+        }
     }
 
     /**
@@ -425,6 +472,11 @@ class FragmentMap : CrAnimationFragment() {
         // todo: 2023/4/19 初始化动态标志图层
         gLayerIco = GraphicsOverlay()
         appendGraphicOverlay(gLayerIco!!, LAYER_NAME_TEMP_ICO)
+
+        // todo: 2023/6/5 初始化临时展示内容图层
+        gLayerTemp = GraphicsOverlay();
+        mapView?.graphicsOverlays?.add(gLayerTemp)
+
     }
 
     /**
@@ -560,7 +612,6 @@ class FragmentMap : CrAnimationFragment() {
                 ), LayerManager.LayerGroup.LAYER_NAME_DRAW
             )
         }
-
     }
 
     /**
@@ -820,19 +871,40 @@ class FragmentMap : CrAnimationFragment() {
     }
 
     /**
+     * 添加展示获取经纬度位置
+     * @param location Point 地理位置
+     * @param longitude String 经度
+     * @param latitude String 纬度
+     */
+    private fun appendLocation(location:Point,longitude:String,latitude:String){
+        // todo: 2023/6/7 点符号样式
+        var markSymbol:SimpleMarkerSymbol = SimpleMarkerSymbol()
+        markSymbol.color = Color.argb(255,0,0,255)
+        markSymbol.size = 14.0f
+        markSymbol.style = SimpleMarkerSymbol.Style.CIRCLE
+        markSymbol.outline = SimpleLineSymbol(SimpleLineSymbol.Style.SOLID,Color.argb(255,255,255,255),1.0f)
+        // todo: 2023/6/7 创建点符号
+        var graphic = Graphic(location,markSymbol)
+        gLayerTemp?.graphics?.add(graphic)
+        // todo: 2023/6/7 添加标注
+        appendMeasureLabel(location,String.format("经度:%s   纬度:%s",longitude,latitude))
+    }
+
+
+    /**
      * 测量长度
      */
     private fun measureLength(){
         CrUtil.showMessage("地图上点击开始测量!")
         sketchEditor?.let {
             it.stop()
+            it.removeGeometryChangedListener(sketchGeometryChangeListener)
             // todo: 2023/4/21 设置编辑模式
             var model = SketchEditConfiguration()
             model.isAllowPartSelection = false
             model.isContextMenuEnabled = false
             model.isRequireSelectionBeforeDrag = true
             it.start(SketchCreationMode.POLYLINE,model)
-
             it.opacity = 1.0f
             // todo: 2023/4/21 设置监听
             it.addGeometryChangedListener(sketchGeometryChangeListener)
@@ -840,6 +912,47 @@ class FragmentMap : CrAnimationFragment() {
     }
 
     /**
+     * 面积测量
+     */
+    private fun measureArea(){
+        CrUtil.showMessage("地图上点击开始测量!")
+        sketchEditor?.let {
+            it.stop()
+            it.removeGeometryChangedListener(sketchGeometryChangeListener)
+            // todo: 2023/6/6 设置编辑模式
+            var model = SketchEditConfiguration()
+            model.isAllowPartSelection = false
+            model.isContextMenuEnabled = false
+            model.isRequireSelectionBeforeDrag = true
+            it.start(SketchCreationMode.POLYGON,model)
+            it.opacity = 1.0f
+            // todo: 2023/6/6 设置监听
+            it.addGeometryChangedListener(sketchGeometryChangeListener)
+        }
+    }
+
+    /**
+     * 输入坐标定位监听
+     */
+    private var inputLocationToMapListener:DialogInput.DialogInputListener = object:DialogInput.DialogInputListener{
+        // todo: 2023/6/7 点击完成按钮回调
+        override fun completion(valueOne: String, valueTwo: String, self: DialogInput) {
+            if(!CrUnitManager.checkLongitude(valueOne)){
+                CrUtil.showMessage("输入的经度值不符合要求!")
+            }else if (!CrUnitManager.checkLatitude(valueTwo)){
+                CrUtil.showMessage("输入的纬度值不符合要求!")
+            }else{
+                self.dismiss()
+            }
+        }
+
+        // todo: 2023/6/7 点击取消按钮回调
+        override fun close() {
+        }
+
+    }
+
+    /**
      * 显示警告信息
      * @param warning String 警告消息
      */
@@ -937,10 +1050,38 @@ class FragmentMap : CrAnimationFragment() {
             MapAction.EventMarkDelete->{
                 doodleSelectFeature(fLayerMark!!)
             }
-            // todo: 2023/4/21 开始测量
+            // todo: 2023/4/21 长度测量
             MapAction.EventSurveyLength->{
                 measureLength()
             }
+            // todo: 2023/6/6 面积测量
+            MapAction.EventSurveyArea->{
+                measureArea()
+            }
+            // todo: 2023/6/7 初始化测量
+            MapAction.EventSurveyClear->{
+                // todo: 2023/6/7 清理临时标注
+                gLayerTemp?.graphics?.clear()
+                // todo: 2023/6/7 结束编辑
+                sketchEditor?.let {
+                    it.stop()
+                    it.removeGeometryChangedListener(sketchGeometryChangeListener)
+                }
+            }
+            // todo: 2023/6/7 获取地图位置
+            MapAction.MapTapGetLocation->{
+                CrUtil.showMessage("地图上点击查询地理位置")
+                mapTouch?.setAction(MapAction.MapTapGetLocation)
+            }
+            // todo: 2023/6/7 输入坐标定位
+            MapAction.EventInputLocationToMap->{
+                var dialogInput:DialogInput = DialogInput(context!!,"输入位置信息")
+                dialogInput.setButtonsText("确定","关闭")
+                dialogInput.setHints("输入经度,例118.70687","输入纬度,例35.218991")
+                dialogInput.setFonts(getString(R.string.ico_location),getString(R.string.ico_location))
+                dialogInput.setListener(inputLocationToMapListener)
+                dialogInput.show()
+            }
         }
     }
 

+ 1 - 0
app/src/main/java/com/cr/pages/FragmentTools.kt

@@ -123,6 +123,7 @@ class FragmentTools:CrNavigationFragment() ,CrButton.OnClickListener{
                 if(listener != null) listener?.onToLocation()
             }
         }
+        dismiss()
     }
 
     /**

+ 8 - 0
app/src/main/java/com/cr/widget/CrEditTextWidget.kt

@@ -153,6 +153,14 @@ class CrEditTextWidget @JvmOverloads constructor(
     }
 
     /**
+     * 设置提示文字
+     * @param hint String 提示文字
+     */
+    fun setContextHint(hint:String){
+        txtContent?.hint = hint
+    }
+
+    /**
      * 设置字体图标
      * @param icoName String 图标名称
      */

+ 89 - 0
app/src/main/res/layout/dig_input.xml

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center">
+    <LinearLayout
+        android:layout_width="@dimen/cr_180_dp"
+        android:layout_height="wrap_content"
+        android:background="@drawable/shape_back_dialog_normal"
+        android:orientation="vertical"
+        android:padding="@dimen/cr_8_dp">
+        <ImageView
+            android:layout_width="@dimen/cr_24_dp"
+            android:layout_height="@dimen/cr_24_dp"
+            android:src="@drawable/ico_info"
+            android:layout_gravity="center"
+            android:layout_margin="@dimen/common_margin"/>
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/dig_normal_title"
+            android:textSize="@dimen/sp_16"
+            android:gravity="center"
+            android:layout_margin="@dimen/common_margin"
+            android:id="@+id/dig_title"
+            android:textColor="@color/white"/>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:layout_marginBottom="@dimen/cr_8_dp"
+            android:layout_marginTop="@dimen/cr_8_dp">
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:layout_marginBottom="@dimen/cr_8_dp"
+                android:id="@+id/dig_panel_one"
+                android:visibility="visible">
+                <TextView
+                    style="@style/text_label"
+                    android:text="@string/label_longitude"
+                    android:id="@+id/dig_lbl_one"/>
+                <com.cr.widget.CrEditTextWidget
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/dig_txt_one"
+                    app:crIcoColor="@color/white"/>
+            </LinearLayout>
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:id="@+id/dig_panel_two">
+                <TextView
+                    style="@style/text_label"
+                    android:text="@string/label_latitude"
+                    android:id="@+id/dig_lbl_two"/>
+                <com.cr.widget.CrEditTextWidget
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/dig_txt_two"
+                    app:crIcoColor="@color/white"/>
+            </LinearLayout>
+        </LinearLayout>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:gravity="center">
+            <Button
+                style="@style/btn_default"
+                android:background="@drawable/btn_red_selector"
+                android:text="@string/dig_normal_btn_ok"
+                android:id="@+id/dig_btn_ok"
+                android:layout_width="@dimen/cr_40_dp"/>
+            <Button
+                style="@style/btn_default"
+                android:background="@drawable/btn_blue_selector"
+                android:text="@string/dig_normal_btn_close"
+                android:id="@+id/dig_btn_cancel"
+                android:layout_width="@dimen/cr_40_dp"/>
+        </LinearLayout>
+    </LinearLayout>
+</LinearLayout>

+ 6 - 0
app/src/main/res/values/strings.xml

@@ -86,6 +86,7 @@
     <!--对话框-->
     <string name="dig_normal_btn_ok">确定</string>
     <string name="dig_normal_btn_cancel">取消</string>
+    <string name="dig_normal_btn_close">关闭</string>
     <string name="dig_normal_title">操作提示</string>
     <string name="dig_normal_default_message">默认提示信息</string>
 
@@ -108,6 +109,10 @@
     <string name="frag_mark_title_on_select">选择标志</string>
     <string name="frag_mark_title_on_delete">删除标志</string>
 
+    <!--标签相关-->
+    <string name="label_longitude">经度</string>
+    <string name="label_latitude">纬度</string>
+
     <!--工具箱页面相关-->
     <string name="frag_tools_measure_length">长度测量</string>
     <string name="frag_tools_measure_area">面积测量</string>
@@ -127,6 +132,7 @@
     <string name="ico_save">&#xe8bb;</string>
     <string name="ico_remove">&#xec49;</string>
     <string name="ico_delete">&#xe604;</string>
+    <string name="ico_location">&#xe636;</string>
 
 
 </resources>

+ 13 - 0
app/src/main/res/values/themes.xml

@@ -92,10 +92,23 @@
 
     <!--文本框通用样式 必须调用-->
     <style name="text_default">
+        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_height">wrap_content</item>
         <item name="android:includeFontPadding">false</item>
         <item name="android:gravity">center_vertical</item>
     </style>
 
+    <!--通用标签样式-->
+    <style name="text_label" parent="text_default">
+        <item name="android:textColor">@color/white</item>
+        <item name="android:textSize">@dimen/sp_10</item>
+        <item name="android:textStyle">bold</item>
+        <item name="android:gravity">center_vertical</item>
+        <item name="android:layout_gravity">center</item>
+        <item name="android:layout_marginLeft">@dimen/cr_3_dp</item>
+        <item name="android:layout_marginRight">@dimen/cr_3_dp</item>
+    </style>
+
     <!--登录界面相关样式集合-->
     <!--密码和用户名输入框文字样式-->
     <style name="login_txt_style" parent="text_default">