diff --git a/app/src/main/java/com/project/survey/App.java b/app/src/main/java/com/project/survey/App.java index a8f3b50..5717758 100644 --- a/app/src/main/java/com/project/survey/App.java +++ b/app/src/main/java/com/project/survey/App.java @@ -33,6 +33,10 @@ public class App extends Application { private static App app; public boolean isThemeDark; + /** + * 磁偏角,用于校正指南针 + */ + public float magneticDeclination = 0; public boolean isLandscape() { return false; diff --git a/app/src/main/java/com/project/survey/adapter/CustomRecycleTtemStyleDialogAdapter.java b/app/src/main/java/com/project/survey/adapter/CustomRecycleTtemStyleDialogAdapter.java new file mode 100644 index 0000000..3039119 --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/CustomRecycleTtemStyleDialogAdapter.java @@ -0,0 +1,97 @@ +package com.project.survey.adapter; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.drawable.GradientDrawable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.R; +import com.project.survey.model.TextStyleBean; +import com.project.survey.util.DisplayUtils; + +import java.util.List; + +public class CustomRecycleTtemStyleDialogAdapter extends RecyclerView.Adapter { + + private Context context; + private List list; + private int mposition; + private OnItemClickListener onClickListener; + + public CustomRecycleTtemStyleDialogAdapter(Context context, List list, int selectedIndex) { + this.context = context; + this.list = list; + mposition = selectedIndex; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + ViewHolder holder = new ViewHolder(LayoutInflater.from( + context).inflate(R.layout.layout_checkbox_item, parent, + false)); + return holder; + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, @SuppressLint("RecyclerView") int position) { + + ViewGroup.LayoutParams layoutParams = holder.radio_type.getLayoutParams(); + layoutParams.width = 100; + layoutParams.height = 50; + holder.radio_type.setLayoutParams(layoutParams); + + holder.radio_type.setText(list.get(position).getText()); + + if (list.get(position).getTextSize() > 0) { + holder.radio_type.setTextSize(list.get(position).getTextSize()); + } + if (list.get(position).getTextColor() > 0) { + holder.radio_type.setTextColor(list.get(position).getTextColor()); + } + + GradientDrawable gradientDrawable = new GradientDrawable(); + gradientDrawable.setCornerRadii(new float[]{DisplayUtils.dip2px(3), DisplayUtils.dip2px(3), DisplayUtils.dip2px(3), DisplayUtils.dip2px(3), + DisplayUtils.dip2px(3), DisplayUtils.dip2px(3), DisplayUtils.dip2px(3), DisplayUtils.dip2px(3)}); + gradientDrawable.setColor(list.get(position).getBackground()); + holder.radio_type.setBackgroundDrawable(gradientDrawable); + + if (position == mposition) { + holder.iv_select_choose.setImageResource(R.mipmap.icon_checkbox_select); + } else { + holder.iv_select_choose.setImageResource(R.mipmap.icon_checkbox_unselect); + } + holder.itemView.setOnClickListener(v -> onClickListener.OnItemClick(position)); + } + + @Override + public int getItemCount() { + return list == null ? 0 : list.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + ImageView iv_select_choose; + TextView radio_type; + + public ViewHolder(@NonNull View itemView) { + super(itemView); + iv_select_choose = itemView.findViewById(R.id.iv_select_choose); + radio_type = itemView.findViewById(R.id.radio_type); + } + } + + public interface OnItemClickListener { + void OnItemClick(int position); + } + + public void setOnClickListener(OnItemClickListener onClickListener) { + this.onClickListener = onClickListener; + } +} diff --git a/app/src/main/java/com/project/survey/dialog/CustomRecycleStyleDialog.java b/app/src/main/java/com/project/survey/dialog/CustomRecycleStyleDialog.java new file mode 100644 index 0000000..0b6c810 --- /dev/null +++ b/app/src/main/java/com/project/survey/dialog/CustomRecycleStyleDialog.java @@ -0,0 +1,128 @@ +package com.project.survey.dialog; + +import static androidx.recyclerview.widget.LinearLayoutManager.VERTICAL; + +import android.app.Dialog; +import android.content.Context; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.R; +import com.project.survey.adapter.CustomRecycleTtemStyleDialogAdapter; +import com.project.survey.model.TextStyleBean; + +import java.util.List; + +public class CustomRecycleStyleDialog extends Dialog { + + public CustomRecycleStyleDialog(Context context) { + super(context); + } + + public CustomRecycleStyleDialog(Context context, int theme) { + super(context, theme); + } + + public static class Builder { + private Context context; // 上下文对象 + private String title; // 对话框标题 + private List list; + private String preferenceKey; + private int selectedIndex; + private static OnItemClickListener onItemClickListener; + + public Builder(Context context) { + this.context = context; + } + + /** + * Set the Dialog title from resource + * + * @param title + * @return + */ + public Builder setTitle(int title) { + this.title = (String) context.getText(title); + return this; + } + + /** + * Set the Dialog title from String + * + * @param title + * @return + */ + public Builder setTitle(String title) { + this.title = title; + return this; + } + + public Builder setItemClickListener(OnItemClickListener onItemClickListener){ + this.onItemClickListener = onItemClickListener; + return this; + } + + public Builder setListData(List list, String preferenceKey){ + this.list = list; + this.preferenceKey = preferenceKey; + this.selectedIndex = 0; + return this; + } + + public Builder setListData(List list, String preferenceKey, int selectedIndex){ + this.list = list; + this.preferenceKey = preferenceKey; + this.selectedIndex = selectedIndex; + return this; + } + + public CustomRecycleStyleDialog create() { + LayoutInflater inflater = (LayoutInflater) context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + // instantiate the dialog with the custom Theme + final CustomRecycleStyleDialog dialog = new CustomRecycleStyleDialog(context, + R.style.gif_dialog); + View layout = inflater.inflate(R.layout.layout_recycle_style_dialog, null); + dialog.addContentView(layout, new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); + + RecyclerView recyclerView = layout.findViewById(R.id.recyclerView); + if (list != null && list.size() > 0){ + CustomRecycleTtemStyleDialogAdapter adapter = new CustomRecycleTtemStyleDialogAdapter(context,list,selectedIndex); + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context); + linearLayoutManager.setOrientation(VERTICAL); + recyclerView.setLayoutManager(linearLayoutManager); + recyclerView.setAdapter(adapter); + adapter.setOnClickListener(position -> { + onItemClickListener.OnItemClick(preferenceKey,position,list.get(position)); + dialog.dismiss(); + }); + } + + TextView tv_title = layout.findViewById(R.id.tv_title); + if (title != null || !TextUtils.isEmpty(title)){ + tv_title.setText(title); +// tv_title.getPaint().setFakeBoldText(true); + tv_title.setVisibility(View.VISIBLE); + }else { + tv_title.setVisibility(View.GONE); + } + + TextView tv_cancel = layout.findViewById(R.id.tv_cancel); + tv_cancel.setOnClickListener(v -> dialog.dismiss()); + + dialog.setContentView(layout); + return dialog; + } + } + + public interface OnItemClickListener{ + void OnItemClick(String preferenceKey, int position, TextStyleBean textStyleBean); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/model/TextStyleBean.java b/app/src/main/java/com/project/survey/model/TextStyleBean.java new file mode 100644 index 0000000..c72f503 --- /dev/null +++ b/app/src/main/java/com/project/survey/model/TextStyleBean.java @@ -0,0 +1,62 @@ +package com.project.survey.model; + +import androidx.annotation.ColorInt; + +public class TextStyleBean { + private String text; + private float textSize; + @ColorInt + private int textColor; + + @ColorInt + private int background; + + public TextStyleBean(@ColorInt int background) { + this.background = background; + } + +// public TextStyleBean(String text, float textSize, @ColorInt int textColor, @ColorInt int background) { +// this.text = text; +// this.textSize = textSize; +// this.textColor = textColor; +// this.background = background; +// } + + public TextStyleBean(String text) { + this.text = text; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public float getTextSize() { + return textSize; + } + + public void setTextSize(float textSize) { + this.textSize = textSize; + } + + @ColorInt + public int getTextColor() { + return textColor; + } + +// public void setTextColor(@ColorInt int textColor) { +// this.textColor = textColor; +// } + + @ColorInt + public int getBackground() { + return background; + } + +// public void setBackground(@ColorInt int background) { +// this.background = background; +// } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/instrument/setupstation/ControlPointsNewActivity.java b/app/src/main/java/com/project/survey/ui/instrument/setupstation/ControlPointsNewActivity.java index f741896..3260ee6 100644 --- a/app/src/main/java/com/project/survey/ui/instrument/setupstation/ControlPointsNewActivity.java +++ b/app/src/main/java/com/project/survey/ui/instrument/setupstation/ControlPointsNewActivity.java @@ -937,6 +937,10 @@ public class ControlPointsNewActivity extends ColorfulActivity { intent.getStringExtra(RESULT_REMARK)); } + /** + * isGlobal false 线路控制点 true 工程控制点 + * + */ public static void pickPoint(FragmentActivity activity, boolean isGlobal, @NonNull IPickXyzCallback2 callback) { Intent intent2 = new Intent(activity, ControlPointsNewActivity.class); intent2.putExtra(KEY_IS_SELECT, true); diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java index bf47983..5c96d9a 100644 --- a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingActivity.java @@ -3,10 +3,10 @@ package com.project.survey.ui.lofting.pointlofting; import static com.bingce.surveyor.util.ConstUtils.intentConst.KEY_JOB_ID; import static com.bingce.surveyor.util.ConstUtils.intentConst.KEY_PROJECT_ID; import static com.bingce.surveyor.util.ConstUtils.intentConst.KEY_ROAD_ID; - +import static com.project.survey.util.DrawableUtils.RADIUS_BOTTOM; +import static com.project.survey.util.DrawableUtils.RADIUS_TOP; import android.annotation.SuppressLint; -import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -43,14 +43,12 @@ import com.bingce.logic.bean.StakingPoint; import com.bingce.logic.linestaking.TargetCompassHelper; import com.bingce.road.move.MoveK; import com.bingce.road.move.MoveLeftRight; - import com.bingce.surveyor.agentweb.HelpWebActivity; import com.bingce.surveyor.util.ConstUtils; import com.bingce.surveyor.util.DeviceConnectUtil; import com.bingce.surveyor.util.PreferencesUtil; import com.bingce.surveyor.util.SurveyLimitCheckUtils; import com.bingce.surveyor.util.SurveyRemarksUtils; -import com.bingce.surveyor.util.SurveyToolBarClickListenerUtils; import com.bingce.surveyor.util.SurveyUIUtils; import com.bingce.surveyor.util.dialog.CustomDialog; import com.bingce.surveyor.util.dialog.CustomRecycleDialog; @@ -65,6 +63,10 @@ import com.project.survey.App; import com.project.survey.R; import com.project.survey.databinding.ActivityPointStakingBinding; import com.project.survey.ui.base.BaseSurveyNewActivity; +import com.project.survey.ui.instrument.setupstation.ControlPointsNewActivity; +import com.project.survey.ui.instrument.setupstation.CoordinatePointsLibraryActivity; +import com.project.survey.ui.instrument.setupstation.StakingNewJobActivity; +import com.project.survey.ui.pointmeasure.measure.util.SurveyToolBarClickListenerUtils; import com.project.survey.util.DrawableUtils; import java.util.ArrayList; @@ -81,6 +83,9 @@ import lecho.hellocharts.model.LineChartData; import lecho.hellocharts.model.PointValue; import lecho.hellocharts.renderer.LineChartRenderer; +/** + * 点放样 测量 + */ public class PointStakingActivity extends BaseSurveyNewActivity { private ActivityPointStakingBinding binding; @@ -211,20 +216,18 @@ public class PointStakingActivity extends BaseSurveyNewActivity { stopSoundPool(); switch (index) { case 0: + //放样点库 StakingNewJobActivity.pickPoint(PointStakingActivity.this, (pointId, pointsListIndex, name, x, y, z) -> onPickedPoint(true, pointId, name, x, y, z)); break; - case 1: - ControlPointsNewActivity.pickPoint(PointStakingActivity.this, false, (pointId, name, code, x, y, z, remarks) -> { - onPickedPoint(false, pointId, name, x, y, z); - }); - break; case 2: + //工程全局控制点 ControlPointsNewActivity.pickPoint(PointStakingActivity.this, true, (pointId, name, code, x, y, z, remarks) -> { onPickedPoint(false, pointId, name, x, y, z); }); break; case 3: + //测量点库 CoordinatePointsLibraryActivity.pickPoint(PointStakingActivity.this, (pointId, name, code, x, y, z, b, l, h) -> { onPickedPoint(false, pointId, name, x, y, z); }); @@ -392,9 +395,7 @@ public class PointStakingActivity extends BaseSurveyNewActivity { @Override protected void initData() { - stringListLibraty.add(getString(R.string.staking_point_library)); - stringListLibraty.add(getString(R.string.road_control_point)); stringListLibraty.add(getString(R.string.global_control_point)); stringListLibraty.add(getString(R.string.point_survey_point_library)); diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingSettingActivity.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingSettingActivity.java new file mode 100644 index 0000000..325d08f --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/PointStakingSettingActivity.java @@ -0,0 +1,414 @@ +package com.project.survey.ui.lofting.pointlofting; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.graphics.drawable.GradientDrawable; +import android.view.View; + +import androidx.annotation.ColorInt; + +import com.bingce.device.Device; +import com.bingce.device.enums.DeviceTypeEnum; +import com.bingce.surveyor.util.ConstUtils; +import com.bingce.surveyor.util.PreferencesCadUtil; +import com.bingce.surveyor.util.PreferencesUtil; +import com.bingce.surveyor.util.dialog.CustomRecycleDialog; +import com.bingce.utils.FileUtil; +import com.bingce.utils.IntentUtil; +import com.bingce.utils.Util; +import com.project.survey.R; +import com.project.survey.databinding.ActivityPointStakingSettingBinding; +import com.project.survey.dialog.CustomRecycleStyleDialog; +import com.project.survey.model.TextStyleBean; +import com.project.survey.ui.base.BaseSurveyNewActivity; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import blankj.utilcode.util.ToastUtils; + +public class PointStakingSettingActivity extends BaseSurveyNewActivity { + + private ActivityPointStakingSettingBinding binding; + private int limitHrmsIndex = -1; + private int limitVrmsIndex = -1; + private int limitPdopIndex = -1; + private int limitAgeIndex = -1; + private int limitTipsRangeIndex = -1; + private int limitStakingIndex = -1; + private int limitSmoothPointNumberIndex = -1; + + @Override + public View getContentView() { + binding = ActivityPointStakingSettingBinding.inflate(getLayoutInflater()); + return binding.getRoot(); + } + + @Override + protected void initView() { + if (IntentUtil.boolExtra(getIntent(), KEY_IS_CAD_SETTING) && !Device.getInstance().isDeviceConnected()) { + setTitle(getString(R.string.cad_setting)); + binding.rlStatusLimit.setVisibility(View.GONE); + binding.llHvpd.setVisibility(View.GONE); + binding.llRangeLimit.setVisibility(View.GONE); + binding.llCadSetting.setVisibility(View.VISIBLE); + } else { + if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) { + setTitle(getString(R.string.ts_staking_setting)); + binding.rlStatusLimit.setVisibility(View.GONE); + binding.llHvpd.setVisibility(View.GONE); + binding.rlSmoothPointNumberLimit.setVisibility(View.GONE); + } else { + setTitle(getString(R.string.rtk_staking_setting)); + binding.rlStatusLimit.setVisibility(View.VISIBLE); + binding.llHvpd.setVisibility(View.VISIBLE); + binding.rlSmoothPointNumberLimit.setVisibility(View.VISIBLE); + } + binding.llRangeLimit.setVisibility(View.VISIBLE); + if (IntentUtil.boolExtra(getIntent(), KEY_IS_CAD_SETTING)) { + binding.llCadSetting.setVisibility(View.VISIBLE); + } else { + binding.llCadSetting.setVisibility(View.GONE); + } + } + } + + @Override + protected void initData() { + limitStatus(); + limitHrms(); + limitVrms(); + limitPdop(); + limitAge(); + limitTipsRange(); + limitStaking(); + cadUcsWcsStatus(); + cadUnitLength(); + cadBackground(); + cadCleanCache(); + limitSmoothPointNumber(); + } + + /** + * 状态解 + */ + private void limitStatus() { + List limitStatusList = new ArrayList<>(); + limitStatusList.add(getString(R.string.rtk_state_fixed)); + limitStatusList.add(getString(R.string.rtk_state_diff_3D)); + limitStatusList.add(getString(R.string.rtk_state_float)); + limitStatusList.add(getString(R.string.rtk_state_single)); + binding.tvStatusLimit.setText(limitStatusList.get(PreferencesUtil.getPointStakingStatusLimitIndex())); + binding.rlStatusLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.solution_status_limit, limitStatusList, PreferencesUtil.getPointStakingStatusLimitIndex(), false, (index, itemString) -> { + binding.tvStatusLimit.setText(limitStatusList.get(index)); + PreferencesUtil.putPreference(ConstUtils.preferConst.pointStakingStatusLimit, index); + })); + } + + /** + * Hrms + */ + private void limitHrms() { + List limitHrmsList = new ArrayList<>(); + limitHrmsList.add("0.05"); + limitHrmsList.add("0.10"); + limitHrmsList.add("0.20"); + limitHrmsList.add("0.30"); + for (int i = 0; i < limitHrmsList.size(); i++) { + if (Double.parseDouble(PreferencesUtil.getPointStakingHrmsLimit()) == Double.parseDouble(limitHrmsList.get(i))) { + limitHrmsIndex = i; + } + } + + binding.tvHrmsLimit.setText(PreferencesUtil.getPointStakingHrmsLimit() + getString(R.string.meter)); + binding.rlHrmsLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.hrms_limit, limitHrmsList, limitHrmsIndex, CustomRecycleDialog.Builder.INPUT_TYPE_DECIMAL, true, PreferencesUtil.getPointStakingHrmsLimit(), new CustomRecycleDialog.IClickCallback() { + @Override + public void onItemSelected(int index, String itemString) { + limitHrmsIndex = index; + if (index != -1) { + binding.tvHrmsLimit.setText(limitHrmsList.get(index) + getString(R.string.meter)); + } else { + binding.tvHrmsLimit.setText(itemString + getString(R.string.meter)); + } + PreferencesUtil.putPreference(ConstUtils.preferConst.pointStakingHrmsLimit, itemString); + } + })); + } + + /** + * Vrms + */ + private void limitVrms() { + List limitVrmsList = new ArrayList<>(); + limitVrmsList.add("0.05"); + limitVrmsList.add("0.10"); + limitVrmsList.add("0.20"); + limitVrmsList.add("0.30"); + for (int i = 0; i < limitVrmsList.size(); i++) { + if (Double.parseDouble(PreferencesUtil.getPointStakingVrmsLimit()) == Double.parseDouble(limitVrmsList.get(i))) { + limitVrmsIndex = i; + } + } + + binding.tvVrmsLimit.setText(PreferencesUtil.getPointStakingVrmsLimit() + getString(R.string.meter)); + binding.rlVrmsLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.vrms_limit, limitVrmsList, limitVrmsIndex, CustomRecycleDialog.Builder.INPUT_TYPE_DECIMAL, true, PreferencesUtil.getPointStakingVrmsLimit(), new CustomRecycleDialog.IClickCallback() { + @Override + public void onItemSelected(int index, String itemString) { + limitVrmsIndex = index; + if (index != -1) { + binding.tvVrmsLimit.setText(limitVrmsList.get(index) + getString(R.string.meter)); + } else { + binding.tvVrmsLimit.setText(itemString + getString(R.string.meter)); + } + PreferencesUtil.putPreference(ConstUtils.preferConst.pointStakingVrmsLimit, itemString); + } + })); + } + + /** + * Pdop + */ + private void limitPdop() { + List limitPdopList = new ArrayList<>(); + limitPdopList.add("5.00"); + limitPdopList.add("20.00"); + limitPdopList.add("50.00"); + limitPdopList.add("100.00"); + for (int i = 0; i < limitPdopList.size(); i++) { + if (Double.parseDouble(PreferencesUtil.getPointStakingPdopLimit()) == Double.parseDouble(limitPdopList.get(i))) { + limitPdopIndex = i; + } + } + + binding.tvPdopLimit.setText(PreferencesUtil.getPointStakingPdopLimit()); + binding.rlPdopLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.pdop_limit, limitPdopList, limitPdopIndex, CustomRecycleDialog.Builder.INPUT_TYPE_DECIMAL, true, PreferencesUtil.getPointStakingPdopLimit(), new CustomRecycleDialog.IClickCallback() { + @Override + public void onItemSelected(int index, String itemString) { + limitPdopIndex = index; + if (index != -1) { + binding.tvPdopLimit.setText(limitPdopList.get(index)); + } else { + binding.tvPdopLimit.setText(itemString); + } + PreferencesUtil.putPreference(ConstUtils.preferConst.pointStakingPdopLimit, itemString); + } + })); + } + + private void limitAge() { + List limitAgeList = new ArrayList<>(); + limitAgeList.add("5"); + limitAgeList.add("10"); + limitAgeList.add("15"); + limitAgeList.add("25"); + for (int i = 0; i < limitAgeList.size(); i++) { + if (Double.parseDouble(PreferencesUtil.getPointStakingAgeLimit()) == Double.parseDouble(limitAgeList.get(i))) { + limitAgeIndex = i; + } + } + + binding.tvAgeLimit.setText(PreferencesUtil.getPointStakingAgeLimit() + getString(R.string.sec)); + binding.rlAgeLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.diff_age_limit, limitAgeList, limitAgeIndex, CustomRecycleDialog.Builder.INPUT_TYPE_INTEGER, true, PreferencesUtil.getPointStakingAgeLimit(), new CustomRecycleDialog.IClickCallback() { + @Override + public void onItemSelected(int index, String itemString) { + limitAgeIndex = index; + if (index != -1) { + binding.tvAgeLimit.setText(limitAgeList.get(index) + getString(R.string.sec)); + } else { + binding.tvAgeLimit.setText(itemString + getString(R.string.sec)); + } + PreferencesUtil.putPreference(ConstUtils.preferConst.pointStakingAgeLimit, itemString); + } + })); + } + + public void limitTipsRange() { + List limitTipsRangeList = new ArrayList<>(); + limitTipsRangeList.add("0.20"); + limitTipsRangeList.add("0.50"); + limitTipsRangeList.add("1.00"); + limitTipsRangeList.add("2.00"); + for (int i = 0; i < limitTipsRangeList.size(); i++) { + if (Double.parseDouble(PreferencesUtil.getPointStakingTipsRangeLimit()) == Double.parseDouble(limitTipsRangeList.get(i))) { + limitTipsRangeIndex = i; + } + } + + binding.tvTipsRangeLimit.setText(PreferencesUtil.getPointStakingTipsRangeLimit() + getString(R.string.meter)); + binding.rlTipsRangeLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.tips_range, limitTipsRangeList, limitTipsRangeIndex, CustomRecycleDialog.Builder.INPUT_TYPE_DECIMAL, true, PreferencesUtil.getPointStakingTipsRangeLimit(), new CustomRecycleDialog.IClickCallback() { + @Override + public void onItemSelected(int index, String itemString) { + limitTipsRangeIndex = index; + if (index != -1) { + binding.tvTipsRangeLimit.setText(limitTipsRangeList.get(index) + getString(R.string.meter)); + } else { + binding.tvTipsRangeLimit.setText(itemString + getString(R.string.meter)); + } + PreferencesUtil.putPreference(ConstUtils.preferConst.pointStakingTipsRangeLimit, itemString); + } + })); + } + + private void limitSmoothPointNumber() { + List limitSmoothPointNumberList = new ArrayList<>(); + limitSmoothPointNumberList.add("1"); + limitSmoothPointNumberList.add("2"); + limitSmoothPointNumberList.add("5"); + limitSmoothPointNumberList.add("10"); + for (int i = 0; i < limitSmoothPointNumberList.size(); i++) { + if (PreferencesUtil.getPreferenceInt(ConstUtils.preferConst.rtkStakingSmoothPointsNumber, 1) == Integer.parseInt(limitSmoothPointNumberList.get(i))) { + limitSmoothPointNumberIndex = i; + } + } + binding.tvSmoothPointNumberLimit.setText(String.valueOf(PreferencesUtil.getPreferenceInt(ConstUtils.preferConst.rtkStakingSmoothPointsNumber, 1))); + binding.rlSmoothPointNumberLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.smooth_points_number, limitSmoothPointNumberList, limitSmoothPointNumberIndex, CustomRecycleDialog.Builder.INPUT_TYPE_INTEGER, true, Util.formatDouble2StringDotAuto(PreferencesUtil.getPreferenceInt(ConstUtils.preferConst.rtkStakingSmoothPointsNumber, 1)), new CustomRecycleDialog.IClickCallback() { + @Override + public void onItemSelected(int index, String itemString) { + limitSmoothPointNumberIndex = index; + if (index != -1) { + binding.tvSmoothPointNumberLimit.setText(limitSmoothPointNumberList.get(index)); + PreferencesUtil.putPreference(ConstUtils.preferConst.rtkStakingSmoothPointsNumber, Integer.parseInt(limitSmoothPointNumberList.get(index))); + } else { + binding.tvSmoothPointNumberLimit.setText(itemString); + PreferencesUtil.putPreference(ConstUtils.preferConst.rtkStakingSmoothPointsNumber, Integer.parseInt(itemString)); + } + } + })); + } + + private void limitStaking() { + List limitStakingList = new ArrayList<>(); + limitStakingList.add("0.01"); + limitStakingList.add("0.02"); + limitStakingList.add("0.05"); + limitStakingList.add("0.10"); + for (int i = 0; i < limitStakingList.size(); i++) { + if (Double.parseDouble(PreferencesUtil.getPointStakingLimit()) == Double.parseDouble(limitStakingList.get(i))) { + limitStakingIndex = i; + } + } + + binding.tvStakingLimit.setText(PreferencesUtil.getPointStakingLimit() + getString(R.string.meter)); + binding.rlStakingLimit.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.stakout_difference, limitStakingList, limitStakingIndex, CustomRecycleDialog.Builder.INPUT_TYPE_DECIMAL, true, PreferencesUtil.getPointStakingLimit(), new CustomRecycleDialog.IClickCallback() { + @Override + public void onItemSelected(int index, String itemString) { + limitStakingIndex = index; + if (index != -1) { + binding.tvStakingLimit.setText(limitStakingList.get(index) + getString(R.string.meter)); + } else { + binding.tvStakingLimit.setText(itemString + getString(R.string.meter)); + } + PreferencesUtil.putPreference(ConstUtils.preferConst.pointStakingLimit, itemString); + } + })); + } + + private void cadUcsWcsStatus() { + List ucsWcsStatusList = new ArrayList<>(); + ucsWcsStatusList.add(getString(R.string.user_coordinate_system)); + ucsWcsStatusList.add(getString(R.string.world_coordinate_system)); + binding.tvWcsUcsStatus.setText(ucsWcsStatusList.get(PreferencesCadUtil.getCadUserSetUcsWcsStatus())); + binding.rlSelectCoordinateSystem.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.coordinate_system, ucsWcsStatusList, PreferencesCadUtil.getCadUserSetUcsWcsStatus(), false, (index, itemString) -> { + binding.tvWcsUcsStatus.setText(ucsWcsStatusList.get(index)); + PreferencesCadUtil.putPreference(ConstUtils.preferConst.cadUseSetUcsWcsStatus, index); + })); + } + + private void cadUnitLength() { + List unitLengthList = new ArrayList<>(); + unitLengthList.add(getString(R.string.unit_cad_m)); + unitLengthList.add(getString(R.string.unit_cad_cm)); + unitLengthList.add(getString(R.string.unit_cad_mm)); + binding.tvUnitLength.setText(unitLengthList.get(PreferencesCadUtil.getCadDrawingUnitLength())); + binding.rlSelectUnitLength.setOnClickListener(view -> CustomRecycleDialog.showDialog(PointStakingSettingActivity.this, R.string.unit_length, unitLengthList, PreferencesCadUtil.getCadDrawingUnitLength(), false, (index, itemString) -> { + binding.tvUnitLength.setText(unitLengthList.get(index)); + PreferencesCadUtil.putPreference(ConstUtils.preferConst.cadDrawingUnitLength, index); + })); + } + + private int cadBackgroundColorIndex = 0; + private GradientDrawable mGroupDrawable; + + /** + * cad背景 + */ + private void cadBackground() { + mGroupDrawable = (GradientDrawable) binding.tvSelectColor.getBackground(); + setGroupDrawable(PreferencesCadUtil.getCadBackgroundColorValue()); + List list = new ArrayList<>(); + list.add(new TextStyleBean(Color.BLACK)); + list.add(new TextStyleBean(Color.WHITE)); + if (PreferencesCadUtil.getCadBackgroundColorValue() == Color.BLACK) { + cadBackgroundColorIndex = 0; + } else { + cadBackgroundColorIndex = 1; + } + binding.rlCadBackground.setOnClickListener(v -> { + new CustomRecycleStyleDialog.Builder(this).setTitle(R.string.background_color).setListData(list, "", cadBackgroundColorIndex) + .setItemClickListener((preferenceKey, position, textStyleBean) -> { + cadBackgroundColorIndex = position; + setGroupDrawable(textStyleBean.getBackground()); + PreferencesCadUtil.putPreference(ConstUtils.preferConst.cadBackgroundColor, textStyleBean.getBackground()); + }).create().show(); + }); + } + + private void setGroupDrawable(@ColorInt int color) { + if (color == Color.WHITE) { + //判断为白色是,添加一个边框便于颜色识别(白色和弹框背景色重合了) + mGroupDrawable.setStroke(2, getColor(R.color.color_8a8a8a)); + mGroupDrawable.setColor(color); + } else { + mGroupDrawable.setStroke(1, color); + mGroupDrawable.setColor(color); + } + } + + /** + * cad文件缓存 + */ + private void cadCleanCache() { + File file = new File(FileUtil.getSDPath() + "/SurveyorCAD"); + binding.tvCleanCache.setText(formatSize(file.length())); + binding.rlCleanCache.setOnClickListener(v -> { + if (file.exists()) { + boolean result = FileUtil.deleteDir(file); + if (result) { + ToastUtils.showShort(R.string.clean_over_then_restart_activity); + binding.tvCleanCache.setText("0.0KB"); + } + } else { + ToastUtils.showShort(R.string.clean_over_then_restart_activity); + binding.tvCleanCache.setText("0.0KB"); + } + }); + } + + public static String formatSize(long size) { + String suffix = "KB"; + double fSize = size / 1024; + if (fSize > 1024) { + suffix = "MB"; + fSize /= 1024; + } + if (fSize > 1024) { + suffix = "GB"; + fSize /= 1024; + } + return fSize + suffix; + } + + private static String KEY_IS_CAD_SETTING = "isCADSetting"; + + public static void start(Context context) { + start(context, false); + } + + public static void start(Context context, boolean isCADSetting) { + Intent intent = new Intent(context, PointStakingSettingActivity.class); + intent.putExtra(KEY_IS_CAD_SETTING, isCADSetting); + context.startActivity(intent); + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/RecordsActivity.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/RecordsActivity.java new file mode 100644 index 0000000..23fed22 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/RecordsActivity.java @@ -0,0 +1,364 @@ +package com.project.survey.ui.lofting.pointlofting.record; + + +import android.annotation.SuppressLint; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; +import android.graphics.Color; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.preference.PreferenceManager; + +import com.bingce.AppChannel; +import com.bingce.data.base.user.UserConfig; +import com.bingce.data.sync.utils.LoadCurrentJobIdKt; +import com.bingce.data.sync.utils.LoadCurrentProjectIdKt; +import com.bingce.data.sync.utils.LoadCurrentRoadIdKt; +import com.bingce.data.sync.utils.LoadCurrentWaterPipeIdKt; +import com.bingce.data.sync.utils.LoadUserConfigKt; +import com.bingce.utils.StringUtil; +import com.bingce.utils.ThreadPoolUtil; +import com.hjq.permissions.Permission; +import com.hjq.permissions.XXPermissions; +import com.hjq.shape.view.ShapeTextView; +import com.project.survey.databinding.ActivityRecordsBinding; +import com.project.survey.ui.lofting.pointlofting.record.util.RecordsActivityExportUtils; +import com.project.survey.ui.lofting.pointlofting.record.util.RecordsActivityFilterUtils; + +import org.polaric.colorful.ColorfulActivity; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +import blankj.utilcode.util.ToastUtils; +import blankj.utilcode.util.Utils; + + +public class RecordsActivity extends ColorfulActivity { + private static final String TAG = "RecordsActivity"; + private final static String KEY_TYPE = "type"; + + private boolean isSortByTimeAcs = false;//是否把结果按照时间升序排列 + private TextView tv_top_date_filter; + private ShapeTextView tv_filter_other; + private ShapeTextView tv_filter_time; + private ShapeTextView tv_filter_dcs_type; + private ActivityRecordsBinding binding; + + private int currentTypeFromSpinner; + private final RecordsActivityFilterUtils filterUtils = new RecordsActivityFilterUtils(() -> this, + () -> currentTypeFromSpinner, () -> tv_filter_time, () -> tv_filter_dcs_type); + private final RecordsActivityExportUtils exportUtils = new RecordsActivityExportUtils(() -> this, () -> currentTypeFromSpinner); + private final RecordsActivityClearUtils clearUtils = new RecordsActivityClearUtils(() -> this, () -> currentTypeFromSpinner); + + private final Map recordsUtilsMap = RecordsUtilsFactory.buildUtils(this); + + private final RecordsActivityHeaders headers = new RecordsActivityHeaders(() -> this); + private final RecordsViewModelKt.HolderInActivity holderInActivity = + new RecordsViewModelKt.HolderInActivity(this); + + public static void start(Context context, int type) { + Intent intent = new Intent(context, RecordsActivity.class); + intent.putExtra(KEY_TYPE, type); + context.startActivity(intent); + } + + public static void start(Context context) { + Intent intent = new Intent(context, RecordsActivity.class); + context.startActivity(intent); + } + + @SuppressLint("SourceLockedOrientationActivity") + @Override + protected void onCreate(Bundle savedInstanceState) { + if (((App) getApplication()).isLandscape()) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + } + super.onCreate(savedInstanceState); + binding = ActivityRecordsBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + setSupportActionBar(binding.toolbarWithOneSpinner); + if (getSupportActionBar() != null) + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + tv_top_date_filter = findViewById(R.id.activity_records_top_date_filter); + tv_filter_time = findViewById(R.id.tv_filter_time); + tv_filter_dcs_type = findViewById(R.id.tv_filter_dcs_type); + tv_filter_other = findViewById(R.id.tv_filter_other); + tv_top_date_filter.setText(R.string.record_default_display_one_week); + + if (((App) Utils.getApp()).isThemeDark) { + tv_filter_time.getShapeDrawableBuilder().setSolidColor(Color.GRAY).intoBackground(); + tv_filter_dcs_type.getShapeDrawableBuilder().setSolidColor(Color.GRAY).intoBackground(); + tv_filter_other.getShapeDrawableBuilder().setSolidColor(Color.GRAY).intoBackground(); + } else { + tv_filter_time.getShapeDrawableBuilder().setSolidColor(Color.WHITE).intoBackground(); + tv_filter_dcs_type.getShapeDrawableBuilder().setSolidColor(Color.WHITE).intoBackground(); + tv_filter_other.getShapeDrawableBuilder().setSolidColor(Color.WHITE).intoBackground(); + } + initSpinnerType(); + headers.initHeaders(); + binding.ivOrder.setOnClickListener(view -> { + isSortByTimeAcs = !isSortByTimeAcs; + binding.ivOrder.setImageResource(isSortByTimeAcs ? R.drawable.icon_sort_ascending : R.drawable.icon_sort_descending); + updateRecyclerView(); + }); + binding.tvFilterTime.setOnClickListener(v -> filterUtils.showTimeFilterDialog(this::updateRecyclerView)); + if (currentTypeFromSpinner != RecordTypeConstants.TYPE_TUNNEL_BACK_BREAK && currentTypeFromSpinner != RecordTypeConstants.TYPE_WATER_PIPE_BACK_BREAK) { + filterUtils.resetTcsType(); + } + binding.tvFilterDcsType.setOnClickListener(v -> filterUtils.showTcsTypeDialog(this::updateRecyclerView)); + + + tv_filter_dcs_type.setVisibility((currentTypeFromSpinner != RecordTypeConstants.TYPE_TUNNEL_BACK_BREAK && currentTypeFromSpinner != RecordTypeConstants.TYPE_WATER_PIPE_BACK_BREAK) ? View.GONE : View.VISIBLE); + tv_filter_other.setOnClickListener(v -> { + filterUtils.showFilterDialog(this::updateRecyclerView); + }); + } + + /** + * 切换里程坐标等记录类型 + */ + private void initSpinnerType() { + binding.spinner1.setOnItemSelectedListener(spinnerListener); + + List spinnerTitlesList = new ArrayList<>(); + for (Map.Entry entry : recordsUtilsMap.entrySet()) { + if (entry == null) { + continue; + } + IRecordsUtils recordsUtils = entry.getValue(); + if (recordsUtils == null) { + continue; + } + int type = entry.getKey(); + String name = recordsUtils.name(); + switch (type) { + case RecordTypeConstants.TYPE_CUSTOM_ZHONG_JIAO_ONE: + if (AppChannel.customChannel == AppChannel.CUSTOM_ZJYGJ) { + spinnerTitlesList.add(name); + } + break; + case RecordTypeConstants.TYPE_CUSTOM_TIAN_JING_ONE: + if (AppChannel.customChannel == AppChannel.CUSTOM_CR18SZ) { + spinnerTitlesList.add(name); + } + break; + case RecordTypeConstants.TYPE_CUSTOM_MDM: + if (AppChannel.customChannel == AppChannel.CUSTOM_MONITOR) { + spinnerTitlesList.add(name); + } + break; +// case RecordTypeConstants.TYPE_ROTARY_BRIDGE_6COM: +// if (AppChannel.customChannel == AppChannel.CUSTOM_6_COM) { +// spinnerTitlesList.add(name); +// } +// break; + default: + spinnerTitlesList.add(name); + break; + } + } + + ArrayAdapter mSpinnerAdapter = new ArrayAdapter<>(this, + R.layout.spinner_dropdown_item_my_with_background, android.R.id.text1, + spinnerTitlesList); + binding.spinner1.setAdapter(mSpinnerAdapter); + + //设置默认记录类型 + int type = ((App) getApplication()).lastRecordBrowseType; + Intent intent = getIntent(); + if (intent != null && intent.hasExtra(KEY_TYPE)) { + type = intent.getIntExtra(KEY_TYPE, 0); + } + int lastType = Math.max(type, 0); + + IRecordsUtils utils = recordsUtilsMap.get(lastType); + int index = 0; + if (utils != null) { + String name = utils.name(); + boolean found = false; + for (index = 0; index < spinnerTitlesList.size(); index++) { + if (spinnerTitlesList.get(index).equals(name)) { + found = true; + break; + } + } + if (!found) { + index = 0; + } + } + binding.spinner1.setSelection(index); + } + + //里程计算坐标等类型切换监听器 + AdapterView.OnItemSelectedListener spinnerListener = new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + String typeString = binding.spinner1.getSelectedItem().toString(); + Set> entries = recordsUtilsMap.entrySet(); + for (Map.Entry entry : entries) { + if (entry.getValue().name().equals(typeString)) { + currentTypeFromSpinner = entry.getKey(); + if (currentTypeFromSpinner != RecordTypeConstants.TYPE_TUNNEL_BACK_BREAK && currentTypeFromSpinner != RecordTypeConstants.TYPE_WATER_PIPE_BACK_BREAK) { + filterUtils.resetTcsType(); + tv_filter_dcs_type.setVisibility(View.GONE); + } else { + tv_filter_dcs_type.setVisibility(View.VISIBLE); + } + break; + } + } + + updateRecyclerView(); + ((App) getApplication()).lastRecordBrowseType = currentTypeFromSpinner; + SharedPreferences prefs = + PreferenceManager.getDefaultSharedPreferences(RecordsActivity.this); + SharedPreferences.Editor editor = prefs.edit(); + editor.putInt("lastRecordBrowseType", ((App) getApplication()).lastRecordBrowseType); + editor.apply(); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }; + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_activity_records, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + break; + case R.id.menu_record_sort: + isSortByTimeAcs = !isSortByTimeAcs; + updateRecyclerView(); + break; + case R.id.menu_record_export: + exportUtils.requestStoragePermission(this, exportSuccess()); + break; + case R.id.menu_record_filter: + binding.spinner1.getSelectedItem().toString(); + filterUtils.showFilterDialog(this::updateRecyclerView); + break; + case R.id.menu_record_clear: + clearUtils.showClearDialog(() -> { + ProgressDialog mProgressDialog = new ProgressDialog(this); + mProgressDialog.setMessage(getString(R.string.deleting)); + mProgressDialog.show(); + ThreadPoolUtil.execute(() -> { + IRecordsUtils recordsUtils = recordsUtilsMap.get(currentTypeFromSpinner); + if (recordsUtils != null) { + recordsUtils.clearInWorkerThread(filterUtils.filterParameter(), () -> { + runOnUiThread(mProgressDialog::dismiss); + }); + } + ToastUtils.showShort(R.string.clean_over); + }); + }); + break; + } + return super.onOptionsItemSelected(item); + } + + private void updateRecyclerView() { + ThreadPoolUtil.execute(() -> { + UserConfig userConfig = LoadUserConfigKt.loadUserConfig(); + String projectId = LoadCurrentProjectIdKt.loadCurrentProjectId(true, userConfig); + if (StringUtil.isEmpty(projectId)) { + return; + } + String jobId = LoadCurrentJobIdKt.loadCurrentJobId(projectId, true, userConfig); + if (StringUtil.isEmpty(jobId)) { + return; + } + if (currentTypeFromSpinner == RecordTypeConstants.TYPE_WATER_PIPE_BACK_BREAK){ + String waterPipeId = LoadCurrentWaterPipeIdKt.loadCurrentWaterPipeId(projectId, true, userConfig); + if (StringUtil.isEmpty(waterPipeId)){ + return; + } + runOnUiThread(() -> { + IRecordsUtils recordsUtils = recordsUtilsMap.get(currentTypeFromSpinner); + if (recordsUtils != null) { + recordsUtils.update(binding.recyclerviewRecords, isSortByTimeAcs, + userConfig, + projectId, jobId, waterPipeId, + filterUtils.filterParameter()); + + } + }); + }else { + String roadId = LoadCurrentRoadIdKt.loadCurrentRoadId(projectId, true, userConfig); + if (StringUtil.isEmpty(roadId)) { + return; + } + runOnUiThread(() -> { + IRecordsUtils recordsUtils = recordsUtilsMap.get(currentTypeFromSpinner); + if (recordsUtils != null) { + recordsUtils.update(binding.recyclerviewRecords, isSortByTimeAcs, + userConfig, + projectId, jobId, roadId, + filterUtils.filterParameter()); + + if (RecordTypeConstants.TYPE_MEASURING_TAPE == currentTypeFromSpinner) { + //如果选中的是进尺,尝试加载数据 + holderInActivity.getViewModel().loadMeasuringTapeRecord(userConfig, roadId); + } + } + }); + } + + + }); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == XXPermissions.REQUEST_CODE) { + if (XXPermissions.isGranted(this, Permission.MANAGE_EXTERNAL_STORAGE)) { + exportUtils.requestStoragePermission(this, exportSuccess()); + } else { + ToastUtils.showLong(getString(R.string.no_storage_permission_hint)); + } + } + } + + private RecordsActivityExportUtils.IExportCallback exportSuccess() { + return (name, isExportRtkStatus, isExportHr, exportSuccess) -> { + IRecordsUtils recordsUtils = recordsUtilsMap.get(currentTypeFromSpinner); + if (recordsUtils != null) { + recordsUtils.exportRecord2ExcelAsync(name, isSortByTimeAcs, filterUtils.filterParameter(), headers, isExportRtkStatus, isExportHr, + exportSuccess); + } + }; + } + + public interface IExportSuccess { + void showExportSuccessDialog(File file); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailActivityDbFindUtils.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailActivityDbFindUtils.java new file mode 100644 index 0000000..9a6b738 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailActivityDbFindUtils.java @@ -0,0 +1,4 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +class RecordDetailActivityDbFindUtils { +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailActivityRemarksUtils.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailActivityRemarksUtils.java new file mode 100644 index 0000000..ab68240 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailActivityRemarksUtils.java @@ -0,0 +1,54 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import android.content.Context; +import android.view.View; +import android.widget.EditText; + +import com.afollestad.materialdialogs.MaterialDialog; + +import com.bingce.utils.StringUtil; +import com.project.survey.R; +import com.project.survey.util.CommonUtils; + + +class RecordDetailActivityRemarksUtils { + static void changeRemarks(Context context, String remarks, IOnRemarksChanged remarksChanged) { + MaterialDialog dialog = new MaterialDialog.Builder(context) + .title(R.string.remarks) + .customView(R.layout.dialog_edit_remarks, false) + .onPositive((dialog1, which) -> { + View contentView = dialog1.getCustomView(); + if (contentView == null) { + return; + } + EditText met_remarks = contentView.findViewById(R.id.et_dialog_edit_remarks); + if (met_remarks == null) { + return; + } + String remarks1 = met_remarks.getText().toString(); + if (remarksChanged != null && !StringUtil.isEmpty(remarks1)) { + remarksChanged.onChanged(remarks1); + } + CommonUtils.hideSoftInput(); + }) + .positiveText(context.getString(R.string.save)) + .negativeText(context.getString(R.string.cancel)) + .show(); + + View contentView = dialog.getCustomView(); + if (contentView != null) { + EditText editText = contentView.findViewById(R.id.et_dialog_edit_remarks); + if (editText != null) { + if (StringUtil.isEmpty(remarks)) { + editText.setHint(R.string.empty); + } else { + editText.setText(remarks); + } + } + } + } + + interface IOnRemarksChanged { + void onChanged(String remarks); + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailData.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailData.java new file mode 100644 index 0000000..0e033e4 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordDetailData.java @@ -0,0 +1,25 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import androidx.annotation.Nullable; + +import com.bingce.data.DeviceInfoData; + +import java.util.Date; +import java.util.LinkedHashMap; + +public class RecordDetailData { + public final String recordId; + public final LinkedHashMap keyValueMap; + @Nullable + public final DeviceInfoData deviceInfoData; + public final Date date; + public final String remarks; + + public RecordDetailData(String recordId, LinkedHashMap keyValueMap, @Nullable DeviceInfoData deviceInfoData, Date date, String remarks) { + this.recordId = recordId; + this.keyValueMap = keyValueMap; + this.deviceInfoData = deviceInfoData; + this.date = date; + this.remarks = remarks; + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordItemVH.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordItemVH.java new file mode 100644 index 0000000..04a0005 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordItemVH.java @@ -0,0 +1,36 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import android.graphics.Color; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + + +import com.project.survey.App; +import com.project.survey.databinding.RecyclerviewItemRecordsBinding; + +import blankj.utilcode.util.Utils; + +public class RecordItemVH extends RecyclerView.ViewHolder { + public final RecyclerviewItemRecordsBinding itemBinding; + + public RecordItemVH(@NonNull RecyclerviewItemRecordsBinding binding) { + super(binding.getRoot()); + this.itemBinding = binding; + } + + public void doBinder(RecyclerViewItemData instance) { + itemBinding.recyclerviewItemSwipeRecordTitle1.setText(instance.title1); + itemBinding.recyclerviewItemSwipeRecordTitle2.setText(instance.title2); + itemBinding.recyclerviewItemSwipeRecordBody1.setText(instance.body1); + itemBinding.recyclerviewItemSwipeRecordBody2.setText(instance.body2); + itemBinding.recyclerviewItemSwipeRecordBody3.setText(instance.body3); + itemBinding.recyclerviewItemSwipeRecordBody4.setText(instance.body4); + itemBinding.recyclerviewItemSwipeRecordBody5.setText(instance.body5); + if (((App) Utils.getApp()).isThemeDark) { + itemBinding.sll.getShapeDrawableBuilder().setSolidColor(Color.GRAY).intoBackground(); + }else { + itemBinding.sll.getShapeDrawableBuilder().setSolidColor(Color.WHITE).intoBackground(); + } + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordTypeConstants.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordTypeConstants.java new file mode 100644 index 0000000..ae238c2 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordTypeConstants.java @@ -0,0 +1,25 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +public interface RecordTypeConstants { + int TYPE_K2XYZ = 0; + int TYPE_XYZ2K = TYPE_K2XYZ + 1; + int TYPE_TUNNEL_BACK_BREAK = TYPE_XYZ2K + 1; + int TYPE_LEVEL = TYPE_TUNNEL_BACK_BREAK + 1; + int TYPE_COMMON_SIDE = TYPE_LEVEL + 1; + int TYPE_FREEDOM_SIDE = TYPE_COMMON_SIDE + 1; + int TYPE_POINT_STAKE = TYPE_FREEDOM_SIDE + 1; + int TYPE_SUBWAY_SEGMENT = TYPE_POINT_STAKE + 1; + int TYPE_BRIDGE_STAKING = TYPE_SUBWAY_SEGMENT + 1;//桥梁放样的 + int TYPE_ROTARY_BRIDGE_6COM = TYPE_BRIDGE_STAKING + 1;//6com转体桥 + int TYPE_MEASURING_TAPE = TYPE_ROTARY_BRIDGE_6COM + 1;//进尺 + int TYPE_BRIDGE_STAKING2 = TYPE_MEASURING_TAPE + 1;//桥梁放样2 + int TYPE_ROTARY_BRIDGE_BC = TYPE_BRIDGE_STAKING2 + 1;//bc转体桥 + + int TYPE_WATER_PIPE_BACK_BREAK = TYPE_ROTARY_BRIDGE_BC + 1; + + + //自定义 定制类型 + int TYPE_CUSTOM_ZHONG_JIAO_ONE = 100;//中交一公司 + int TYPE_CUSTOM_TIAN_JING_ONE = TYPE_CUSTOM_ZHONG_JIAO_ONE + 1;//天津项目 + int TYPE_CUSTOM_MDM = TYPE_CUSTOM_TIAN_JING_ONE + 1;//测量数据管理 +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityClearUtils.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityClearUtils.java new file mode 100644 index 0000000..460224f --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityClearUtils.java @@ -0,0 +1,80 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import android.content.Context; +import android.os.CountDownTimer; + +import com.afollestad.materialdialogs.DialogAction; +import com.afollestad.materialdialogs.MaterialDialog; +import com.afollestad.materialdialogs.internal.MDButton; +import com.bingce.utils.ContextProviderUtils; +import com.bingce.utils.IProvider; + +import blankj.utilcode.util.ToastUtils; +import cn.liuyanbing.surveyor.R; + +public class RecordsActivityClearUtils extends ContextProviderUtils { + private MDButton mPositiveAction; + + private final IProvider currentTypeFromSpinner; + + public RecordsActivityClearUtils(IProvider contextIProvider, IProvider currentTypeFromSpinner) { + super(contextIProvider); + this.currentTypeFromSpinner = currentTypeFromSpinner; + } + + void showClearDialog(Runnable clearCallback) { + if (isCloceFunction()) { + ToastUtils.showShort("暂不支持"); + return; + } + MaterialDialog dialog = new MaterialDialog.Builder(context()) + .title(R.string.warning) + .content(R.string.confirm_delete_filter_records) + .positiveText(getString(R.string.clear)) + .negativeText(getString(R.string.cancel)) + .onPositive((dialog1, which) -> { +// ProgressDialog mProgressDialog = new ProgressDialog(context()); +// mProgressDialog.setMessage(getString(R.string.deleting)); +// mProgressDialog.show(); +// ThreadPoolUtil.execute(() -> { +// IRecordsUtils recordsUtils = recordsUtilsMap.get(currentTypeFromSpinner); +// if (recordsUtils != null) { +// recordsUtils.clearInWorkerThread(this, mProgressDialog, filterParameter()); +// } +// ToastUtils.showShort(R.string.clean_over); +// }); + if (clearCallback != null) { + clearCallback.run(); + } + }) + .build(); + + mPositiveAction = dialog.getActionButton(DialogAction.POSITIVE); + mPositiveAction.setEnabled(false); + final CountDownTimer countDownTimer = new CountDownTimer(5000, 1000) { + @Override + public void onTick(long millisUntilFinished) { + mPositiveAction.setText(getString(R.string.clear) + "(" + millisUntilFinished / 1000 + "s)"); + } + + @Override + public void onFinish() { + mPositiveAction.setEnabled(true); + mPositiveAction.setText(R.string.clear); + } + }.start(); + dialog.setOnDismissListener(dialog12 -> countDownTimer.cancel()); + + dialog.show(); + } + + /** + * 是否关闭的功能 + * + * @return + */ + private boolean isCloceFunction() { + return currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_CUSTOM_TIAN_JING_ONE + || currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_CUSTOM_ZHONG_JIAO_ONE; + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityExportUtils.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityExportUtils.java new file mode 100644 index 0000000..34edf9f --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityExportUtils.java @@ -0,0 +1,183 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Color; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.View; +import android.widget.CheckBox; + +import androidx.annotation.NonNull; + +import com.afollestad.materialdialogs.DialogAction; +import com.afollestad.materialdialogs.MaterialDialog; +import com.afollestad.materialdialogs.internal.MDButton; +import com.bingce.file.FileOperator; + +import com.bingce.utils.ContextProviderUtils; +import com.bingce.utils.FileUtil; +import com.bingce.utils.IProvider; +import com.hjq.permissions.OnPermissionCallback; +import com.hjq.permissions.Permission; +import com.hjq.permissions.XXPermissions; +import com.project.survey.R; +import com.rengwuxian.materialedittext.MaterialEditText; + +import java.io.File; +import java.util.List; + +import blankj.utilcode.util.ToastUtils; +import blankj.utilcode.util.Utils; + + +public class RecordsActivityExportUtils extends ContextProviderUtils { + private MDButton mPositiveAction; + private MaterialEditText met_export_name; + private CheckBox checkBoxRtkStatus, checkBoxHr; + private boolean isExportRtkStatus = true, isExportHr = true; + + private final IProvider currentTypeFromSpinner; + + public RecordsActivityExportUtils(IProvider contextIProvider, IProvider currentTypeFromSpinner) { + super(contextIProvider); + this.currentTypeFromSpinner = currentTypeFromSpinner; + } + + void showExportDialog(IExportCallback exportCallback) { + MaterialDialog dialog = new MaterialDialog.Builder(context()) + .title(R.string.export_excel) + .customView(R.layout.dialog_export_record_config, true) + .positiveText(R.string.export_records) + .negativeText(R.string.cancel) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, + @NonNull DialogAction which) { + String name; + if ("".equals(met_export_name.getText().toString().trim())) { + ToastUtils.showShort(R.string.file_name_can_not_empty); + return; + } else { + name = met_export_name.getText().toString().trim(); + } + + if (isIgnoreDeviceExport()) { + isExportRtkStatus = true; + isExportHr = true; + } else { + isExportRtkStatus = checkBoxRtkStatus.isChecked(); + isExportHr = checkBoxHr.isChecked(); + } + +// IRecordsUtils recordsUtils = recordsUtilsMap.get(currentTypeFromSpinner); +// if (recordsUtils != null) { +// recordsUtils.exportRecord2ExcelAsync(RecordsActivity.this, name, filterParameter(), headers, isExportRtkStatus, isExportHr, +// file -> showExportSuccessDialog(file)); +// } + if (exportCallback != null) { + exportCallback.onExport(name, isExportRtkStatus, isExportHr, file -> showExportSuccessDialog(file)); + } + } + }).build(); + + met_export_name = + dialog.getCustomView().findViewById(R.id.dialog_export_record_config_name); + checkBoxRtkStatus = + dialog.getCustomView().findViewById(R.id.dialog_export_record_config_check_rtk_status); + checkBoxHr = dialog.getCustomView().findViewById(R.id.dialog_export_record_config_check_hr); + mPositiveAction = dialog.getActionButton(DialogAction.POSITIVE); + + if (isIgnoreDeviceExport()) { + checkBoxRtkStatus.setVisibility(View.GONE); + checkBoxHr.setVisibility(View.GONE); + } else { + checkBoxRtkStatus.setVisibility(View.VISIBLE); + checkBoxHr.setVisibility(View.VISIBLE); + checkBoxRtkStatus.setChecked(isExportRtkStatus); + checkBoxHr.setChecked(isExportHr); + } + + initMaterialEditTextColor(); + + met_export_name.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable s) { + if (!"".equals(met_export_name.getText().toString().trim())) { + mPositiveAction.setEnabled(true); + } else { + mPositiveAction.setEnabled(false); + } + } + }); + dialog.show(); + mPositiveAction.setEnabled(false); + } + + void showExportSuccessDialog(final File file) { + new MaterialDialog.Builder(context()).title(R.string.export_successful) + .content(R.string.exported_file_save_at_surveyor_exported_files) + .positiveText(R.string.send_to) + .negativeText(R.string.open) + .neutralText(R.string.close) + .onPositive((dialog, which) -> FileOperator.shareFile(context(), file, BuildConfig.APPLICATION_ID)) + .onNegative((dialog, which) -> FileUtil.openFile(context(), file)).show(); + } + + private void initMaterialEditTextColor() { + if (((App) Utils.getApp()).isThemeDark) { + met_export_name.setMetTextColor(Color.WHITE); + met_export_name.setPrimaryColor(Color.LTGRAY); + met_export_name.setFocusFraction(1.0f); + met_export_name.setMetHintTextColor(Color.GRAY); + met_export_name.setUnderlineColor(Color.GRAY); + } + } + + + /** + * 是否忽略导出(包含RTK状态,包含杆高/镜高) + * + * @return true 忽略 + */ + private boolean isIgnoreDeviceExport() { + return currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_LEVEL + || currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_SUBWAY_SEGMENT; + } + + public void requestStoragePermission(Activity activity, IExportCallback exportCallback) { + XXPermissions.with(activity) + .permission(Permission.MANAGE_EXTERNAL_STORAGE) + .request(new OnPermissionCallback() { + @Override + public void onGranted(List permissions, boolean all) { + showExportDialog(exportCallback); + } + + @Override + public void onDenied(List permissions, boolean never) { + if (never) { + ToastUtils.showShort(getString(R.string.manually_grant_read_and_write_permissions_to_files)); + // 如果是被永久拒绝就跳转到应用权限系统设置页面 + XXPermissions.startPermissionActivity(activity, permissions); + } else { + requestStoragePermission(activity, exportCallback); + } + } + }); + } + + public interface IExportCallback { + void onExport(String name, boolean isExportRtkStatus, boolean isExportHr,RecordsActivity.IExportSuccess exportSuccess); + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityFilterParameter.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityFilterParameter.java new file mode 100644 index 0000000..e6c1dee --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityFilterParameter.java @@ -0,0 +1,23 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import java.util.Date; + +public class RecordsActivityFilterParameter { + public final String road; + public final String k; + public final String remarks; + public final Date start; + public final Date end; + public String tcsType; + public RecordsActivityFilterParameter(String road, String k, String remarks, Date start, Date end) { + this.road = road; + this.k = k; + this.remarks = remarks; + this.start = start; + this.end = end; + } + public RecordsActivityFilterParameter(String road, String k, String remarks, Date start, Date end,String tcsType) { + this(road,k,remarks,start,end); + this.tcsType = tcsType; + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityFilterUtils.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityFilterUtils.java new file mode 100644 index 0000000..774c262 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityFilterUtils.java @@ -0,0 +1,429 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import android.content.Context; +import android.graphics.Color; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RadioGroup; +import android.widget.TextView; + +import androidx.appcompat.app.AlertDialog; + +import com.bingce.utils.ContextProviderUtils; +import com.bingce.utils.DateUtils; +import com.bingce.utils.IProvider; +import com.kongzue.dialogx.dialogs.BottomDialog; +import com.kongzue.dialogx.dialogs.BottomMenu; +import com.kongzue.dialogx.interfaces.OnBindView; +import com.kongzue.dialogx.interfaces.OnMenuItemClickListener; +import com.project.survey.R; +import com.rengwuxian.materialedittext.MaterialEditText; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import blankj.utilcode.util.ToastUtils; +import blankj.utilcode.util.Utils; +import cn.aigestudio.datepicker.views.DatePicker; + +public class RecordsActivityFilterUtils extends ContextProviderUtils { + private int lastFilterPosition = 1; + private int lastFilterTcsType = 0; + private Date startDate = DateUtils.reverse2Date(DateUtils.get7DaysStartTime()); + private Date endDate = DateUtils.reverse2Date(DateUtils.getTodayEndTime()); + private MaterialEditText met_roadname_keyword, met_kilometer_keyword, met_remarks_keyword; + private RadioGroup group; + private RadioGroup tcsGroup; + private String roadname_keyword = "", kilometer_keyword = "", remarks_keyword = ""; + private String tcsType; + + private final IProvider currentTypeFromSpinner; + private TextView tv_dialog_date_filter, tv_tcstype_filter; + private final IProvider tv_top_date_filter; + private final IProvider tv_top_dcs_filter; + + public void resetTcsType() { + tcsType = null; + lastFilterTcsType = 0; + tv_top_dcs_filter.value().setVisibility(View.GONE); + } + + public RecordsActivityFilterUtils(IProvider contextIProvider, IProvider currentTypeFromSpinner, IProvider tv_top_date_filter, IProvider tv_top_dcs_filter) { + super(contextIProvider); + this.currentTypeFromSpinner = currentTypeFromSpinner; + this.tv_top_date_filter = tv_top_date_filter; + this.tv_top_dcs_filter = tv_top_dcs_filter; + } + + + private void checkFilterGroup(int checkId, boolean ready2Cal) { + switch (checkId) { + case R.id.dialog_records_filter_radio1: + startDate = DateUtils.reverse2Date(DateUtils.getTodayStartTime()); + endDate = DateUtils.reverse2Date(DateUtils.getTodayEndTime()); +// tv_dialog_date_filter.setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); +// tv_top_date_filter.value().setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); + lastFilterPosition = 0; + break; + case R.id.dialog_records_filter_radio2: + startDate = DateUtils.reverse2Date(DateUtils.get7DaysStartTime()); + endDate = DateUtils.reverse2Date(DateUtils.getTodayEndTime()); +// tv_dialog_date_filter.setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); +// tv_top_date_filter.value().setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); + lastFilterPosition = 1; + break; + case R.id.dialog_records_filter_radio3: + startDate = null; + endDate = null; +// tv_dialog_date_filter.setText(R.string.all); +// tv_top_date_filter.value().setText(R.string.all); + lastFilterPosition = 2; + break; + case R.id.dialog_records_filter_radio4: + if (!ready2Cal) { + showTimePickerDialog(); + } + break; + } + } + + private void checkFilterGroup2(int checkId, boolean ready2Cal) { + switch (checkId) { + case 0: + startDate = DateUtils.reverse2Date(DateUtils.getTodayStartTime()); + endDate = DateUtils.reverse2Date(DateUtils.getTodayEndTime()); +// tv_dialog_date_filter.setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); +// tv_top_date_filter.value().setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); + lastFilterPosition = 0; + break; + case 1: + startDate = DateUtils.reverse2Date(DateUtils.get7DaysStartTime()); + endDate = DateUtils.reverse2Date(DateUtils.getTodayEndTime()); +// tv_dialog_date_filter.setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); +// tv_top_date_filter.value().setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); + lastFilterPosition = 1; + break; + case 2: + startDate = null; + endDate = null; +// tv_dialog_date_filter.setText(R.string.all); +// tv_top_date_filter.value().setText(R.string.all); + lastFilterPosition = 2; + break; + case 3: + if (!ready2Cal) { + showTimePickerDialog(); + } + break; + } + } + + private void checkFilterGroup(int checkId) { + checkFilterGroup(checkId, false); + } + + private String[] timeMenuArr; + private String[] tcsMenuArr; + + public void showTimeFilterDialog(Runnable updateCallback) { + if (timeMenuArr == null || timeMenuArr.length == 0) { + timeMenuArr = new String[]{context().getString(R.string.today), context().getString(R.string.within_seven_days), context().getString(R.string.all), context().getString(R.string.custom_time)}; + } + BottomMenu.build().setMenuList(timeMenuArr) + .setShowSelectedBackgroundTips(true) + .setTitle(R.string.time_filter) + .setOnMenuItemClickListener((dialog, text, index) -> { + tv_top_date_filter.value().setText(timeMenuArr[index]); + checkFilterGroup2(index, false); + if (updateCallback != null) updateCallback.run(); + return false; + }).setCancelButton(R.string.cancel).setSelection(lastFilterPosition).show(); + } + + public void showTcsTypeDialog(Runnable updateCallback) { + if (tcsMenuArr == null || tcsMenuArr.length == 0) { + tcsMenuArr = new String[]{context().getString(R.string.all), context().getString(R.string.kaiwa), context().getString(R.string.chuzhi), context().getString(R.string.erchen)}; + } + BottomMenu.build().setMenuList(tcsMenuArr) + .setShowSelectedBackgroundTips(true) + .setTitle(R.string.type_filter) + .setOnMenuItemClickListener(new OnMenuItemClickListener() { + @Override + public boolean onClick(BottomMenu dialog, CharSequence text, int index) { + lastFilterTcsType = index; + tcsType = index == 0 ? null : tcsMenuArr[index]; + tv_top_dcs_filter.value().setText(tcsMenuArr[index]); + if (updateCallback != null) updateCallback.run(); + return false; + } + }).setCancelButton(R.string.cancel).setSelection(lastFilterTcsType).show(); + } + + public void showFilterDialog(Runnable updateCallback) { + BottomDialog.build(new OnBindView(R.layout.dialog_records_filter) { + @Override + public void onBind(BottomDialog dialog, View v) { + met_roadname_keyword = v.findViewById(R.id.met_dialog_records_filter_roadname_keyword); + met_kilometer_keyword = v.findViewById(R.id.met_dialog_records_filter_kilometer_keyword); + met_remarks_keyword = v.findViewById(R.id.met_dialog_records_filter_remarks_keyword); + if (isWaterPipKeyword()) { + met_roadname_keyword.setHint(R.string.water_pipe_name_keyword); + } + met_roadname_keyword.setText(roadname_keyword); + met_kilometer_keyword.setText(kilometer_keyword); + met_remarks_keyword.setText(remarks_keyword); + if (isHideMetRoadKeyword()) { + if (met_roadname_keyword != null) { + met_roadname_keyword.setVisibility(View.GONE); + } + } + if (isHideMetKilometerKeyword()) { + if (met_kilometer_keyword != null) { + met_kilometer_keyword.setVisibility(View.GONE); + } + } + if (isHideMetRemarksKeyword()) { + if (met_remarks_keyword != null) { + met_remarks_keyword.setVisibility(View.GONE); + } + } + initMaterialEditTextColor2(); + } + }).setTitle(R.string.other_filter).setOkButton(R.string.confirm, (dialog, v) -> { + roadname_keyword = met_roadname_keyword.getText().toString(); + kilometer_keyword = met_kilometer_keyword.getText().toString(); + remarks_keyword = met_remarks_keyword.getText().toString(); + if (updateCallback != null) { + updateCallback.run(); + } + return false; + }).setCancelButton(R.string.cancel).show(); +// MaterialDialog dialog = new MaterialDialog.Builder(context()) +// .title(R.string.filter) +// .customView(R.layout.dialog_records_filter, true) +// .onPositive((dialog1, which) -> { +// roadname_keyword = met_roadname_keyword.getText().toString(); +// kilometer_keyword = met_kilometer_keyword.getText().toString(); +// remarks_keyword = met_remarks_keyword.getText().toString(); +// if (type == RecordTypeConstants.TYPE_TUNNEL_BACK_BREAK){ +// RadioButton crb = tcsGroup.findViewById(tcsGroup.getCheckedRadioButtonId()); +// String crbTxt = crb.getText().toString(); +// lastFilterTcsType = tcsGroup.indexOfChild(crb); +// if (context().getString(R.string.all).equals(crbTxt)){ +// tcsType = null; +// }else { +// tcsType = crbTxt; +// } +// }else { +// tcsType = null; +// } +// //读取设置信息 +// int checkId = group.getCheckedRadioButtonId(); +// checkFilterGroup(checkId, true); +//// updateRecyclerView(); +// if (updateCallback != null) { +// updateCallback.run(); +// } +// }) +// .positiveText(context().getString(R.string.confirm)) +// .negativeText(context().getString(R.string.cancel)).build(); +// +// tv_dialog_date_filter = +// dialog.getCustomView().findViewById(R.id.tv_dialog_records_filter_period_of_time); +// tv_tcstype_filter = dialog.getCustomView().findViewById(R.id.tv_dialog_records_filter_period_of_tcstype); +// tcsGroup = dialog.getCustomView().findViewById(R.id.radiogroup_dialog_records_filter_tcstype); +// group = dialog.getCustomView().findViewById(R.id.radiogroup_dialog_records_filter_time); +// met_roadname_keyword = +// dialog.getCustomView().findViewById(R.id.met_dialog_records_filter_roadname_keyword); +// if (type == RecordTypeConstants.TYPE_TUNNEL_BACK_BREAK){ +// tv_tcstype_filter.setVisibility(View.VISIBLE); +// tcsGroup.setVisibility(View.VISIBLE); +// } +// if (isHideMetRoadKeyword()) { +// if (met_roadname_keyword != null) { +// met_roadname_keyword.setVisibility(View.GONE); +// } +// } +// +// met_kilometer_keyword = +// dialog.getCustomView().findViewById(R.id.met_dialog_records_filter_kilometer_keyword); +// +// if (isHideMetKilometerKeyword()) { +// if (met_kilometer_keyword != null) { +// met_kilometer_keyword.setVisibility(View.GONE); +// } +// } +// +// met_remarks_keyword = +// dialog.getCustomView().findViewById(R.id.met_dialog_records_filter_remarks_keyword); +// +// if (isHideMetRemarksKeyword()) { +// if (met_remarks_keyword != null) { +// met_remarks_keyword.setVisibility(View.GONE); +// } +// } +// +// initMaterialEditTextColor2(); +// +// met_roadname_keyword.setText(roadname_keyword); +// met_kilometer_keyword.setText(kilometer_keyword); +// met_remarks_keyword.setText(remarks_keyword); +// +// switch (lastFilterPosition) { +// case 0: +// ((RadioButton) dialog.getCustomView().findViewById(R.id.dialog_records_filter_radio1)).setChecked(true); +// break; +// case 1: +// ((RadioButton) dialog.getCustomView().findViewById(R.id.dialog_records_filter_radio2)).setChecked(true); +// break; +// case 2: +// ((RadioButton) dialog.getCustomView().findViewById(R.id.dialog_records_filter_radio3)).setChecked(true); +// break; +// case 3: +// ((RadioButton) dialog.getCustomView().findViewById(R.id.dialog_records_filter_radio4)).setChecked(true); +// break; +// } +// ((RadioButton)tcsGroup.getChildAt(lastFilterTcsType)).setChecked(true); +// +// group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { +// @Override +// public void onCheckedChanged(RadioGroup radioGroup, int checkId) { +// checkFilterGroup(checkId); +// } +// }); +// +// dialog.show(); + } + + private void showTimePickerDialog() { + final AlertDialog dialog = new AlertDialog.Builder(context()).create(); + dialog.show(); + + DatePicker datePicker = new DatePicker(context()); + + Calendar calendar = Calendar.getInstance(); + datePicker.setDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1); + datePicker.setOnDateSelectedListener(new DatePicker.OnDateSelectedListener() { + @Override + public void onDateSelected(List date) { + if (date.size() == 0) { + ToastUtils.showShort(R.string.not_choose_date); + return; + } + Date min = new Date(); + Date max = new Date(0); + if (date.size() == 1) { + startDate = + DateUtils.reverse2Date(DateUtils.toDate(DateUtils.reverse2Date(date.get(0))) + " 00:00:00"); + endDate = + DateUtils.reverse2Date(DateUtils.toDate(DateUtils.reverse2Date(date.get(0))) + " 23:59:59"); +// tv_dialog_date_filter.setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); +// tv_top_date_filter.value().setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); + lastFilterPosition = 1; + } else if (date.size() > 1) { + for (int i = 0; i < date.size(); i++) { + if (DateUtils.reverse2Date(date.get(i)).after(max)) + max = DateUtils.reverse2Date(date.get(i)); + if (DateUtils.reverse2Date(date.get(i)).before(min)) + min = DateUtils.reverse2Date(date.get(i)); + } + if (max.after(min)) { + startDate = DateUtils.reverse2Date(DateUtils.toDate(min) + " 00:00:00"); + endDate = DateUtils.reverse2Date(DateUtils.toDate(max) + " 23:59:59"); +// tv_dialog_date_filter.setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); +// tv_top_date_filter.value().setText(DateUtils.toDate(startDate) + "~" + DateUtils.toDate(endDate)); + lastFilterPosition = 1; + } + } + dialog.dismiss(); + } + }); + + ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams + .WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + dialog.getWindow().setContentView(datePicker, params); + dialog.getWindow().setGravity(Gravity.CENTER); + } + + private void initMaterialEditTextColor2() { + if (((App) Utils.getApp()).isThemeDark) { + met_roadname_keyword.setMetTextColor(Color.WHITE); + met_kilometer_keyword.setMetTextColor(Color.WHITE); + met_remarks_keyword.setMetTextColor(Color.WHITE); + + met_roadname_keyword.setPrimaryColor(Color.LTGRAY); + met_kilometer_keyword.setPrimaryColor(Color.LTGRAY); + met_remarks_keyword.setPrimaryColor(Color.LTGRAY); + + met_roadname_keyword.setFocusFraction(1.0f); + met_kilometer_keyword.setFocusFraction(1.0f); + met_remarks_keyword.setFocusFraction(1.0f); + + met_roadname_keyword.setHelperTextColor(Color.GRAY); + met_kilometer_keyword.setHelperTextColor(Color.GRAY); + met_remarks_keyword.setHelperTextColor(Color.GRAY); + + met_roadname_keyword.setMetHintTextColor(Color.GRAY); + met_kilometer_keyword.setMetHintTextColor(Color.GRAY); + met_remarks_keyword.setMetHintTextColor(Color.GRAY); + + met_roadname_keyword.setUnderlineColor(Color.GRAY); + met_kilometer_keyword.setUnderlineColor(Color.GRAY); + met_remarks_keyword.setUnderlineColor(Color.GRAY); + } + } + + public String road() { + return roadname_keyword; + } + + public String k() { + return kilometer_keyword; + } + + public String remarks() { + return remarks_keyword; + } + + public Date start() { + return startDate; + } + + public Date end() { + return endDate; + } + + public RecordsActivityFilterParameter filterParameter() { + return new RecordsActivityFilterParameter(road(), k(), remarks(), start(), end(), tcsType); + } + + /** + * 是否隐藏里程过滤 + * + * @return true 隐藏 + */ + private boolean isHideMetKilometerKeyword() { + return currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_FREEDOM_SIDE + || currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_POINT_STAKE; + } + + /** + * 是否隐藏road过滤 + */ + private boolean isHideMetRoadKeyword() { + return currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_MEASURING_TAPE; + } + + /** + * 是否隐藏remarks过滤 + */ + private boolean isHideMetRemarksKeyword() { + return currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_MEASURING_TAPE; + } + + private boolean isWaterPipKeyword() { + return currentTypeFromSpinner.value() == RecordTypeConstants.TYPE_WATER_PIPE_BACK_BREAK; + } +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityHeaders.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityHeaders.java new file mode 100644 index 0000000..51d7d0d --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityHeaders.java @@ -0,0 +1,83 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +import android.content.Context; + +import com.bingce.utils.ContextProviderUtils; +import com.bingce.utils.IProvider; +import com.project.survey.R; + +public class RecordsActivityHeaders extends ContextProviderUtils { + public String[] mHeaders01, mHeaders02, mHeaders03, mHeaders11, mHeaders12, mHeaders13, + mHeaders21, mHeaders22, mHeaders23, mHeaders24, + mHeaders3, mHeaders41, mHeaders42, mHeaders43, mHeaders51, mHeaders52, mHeaders53, + mHeaders61, mHeaders62, mHeaders63, mHeaders7; + + public String[] mHeadersBridgeStaking; + public String[] mHeadersRotaryBridge; + public String[] mHeadersBridge2Staking; + + public RecordsActivityHeaders(IProvider contextIProvider) { + super(contextIProvider); + } + + void initHeaders() { + initSideCommonHeaders(); + initSideFreedomHeaders(); + initKnowPointSettingOutHeaders(); + } + + private void initSideCommonHeaders() { + mHeaders41 = new String[]{getString(R.string.road_name), getString(R.string.fill_cut), + getString(R.string.side_name), getString(R.string.move_left_right), + getString(R.string.move_up_down), getString(R.string.back_break) + , getString(R.string.move_left_right_to_feature_point), + getString(R.string.move_up_down_to_feature_point), + getString(R.string.measured_x_k), getString(R.string.measured_y_d), + getString(R.string.measured_z), getString(R.string.k) + , getString(R.string.d), getString(R.string.design_h), + getString(R.string.longitudinal_slope), getString(R.string.roadbed_edge_h), + getString(R.string.roadbed_edge_d), getString(R.string.orientation) + , getString(R.string.remarks), getString(R.string.record_time)}; + mHeaders42 = new String[]{getString(R.string.position_type), + getString(R.string.station_type), getString(R.string.satellite) + , "hrms", "vrms", getString(R.string.diff_age), getString(R.string.battery)}; + mHeaders43 = new String[]{getString(R.string.hr)}; + } + + private void initSideFreedomHeaders() { + mHeaders51 = new String[]{getString(R.string.road_name), getString(R.string.begin_x), + getString(R.string.begin_y), getString(R.string.begin_z), + getString(R.string.end_x), getString(R.string.end_y), getString(R.string.end_z) + , getString(R.string.fill_cut), getString(R.string.side_name), + getString(R.string.move_left_right), getString(R.string.move_up_down), + getString(R.string.back_break) + , getString(R.string.move_left_right_to_feature_point), + getString(R.string.move_up_down_to_feature_point), getString(R.string.measured_x) + , getString(R.string.measured_y), getString(R.string.measured_z), + getString(R.string.k) + , getString(R.string.d), getString(R.string.design_h), + getString(R.string.longitudinal_slope), getString(R.string.roadbed_edge_h), + getString(R.string.roadbed_edge_d), getString(R.string.orientation) + , getString(R.string.remarks), getString(R.string.record_time)}; + mHeaders52 = new String[]{getString(R.string.position_type), + getString(R.string.station_type), getString(R.string.satellite) + , "hrms", "vrms", getString(R.string.diff_age), getString(R.string.battery)}; + mHeaders53 = new String[]{getString(R.string.hr)}; + } + + private void initKnowPointSettingOutHeaders() { + mHeaders61 = new String[]{getString(R.string.road_name), getString(R.string.point_name) + , getString(R.string.design_x), getString(R.string.design_y), getString(R.string.design_z) + , getString(R.string.measured_x), getString(R.string.measured_y), getString(R.string.measured_z) + , getString(R.string.distance), getString(R.string.move_up_down) + , getString(R.string.move_k), getString(R.string.move_d) + , getString(R.string.move_west_east), getString(R.string.move_north_south) + , getString(R.string.move_fore_back), getString(R.string.move_left_right) + , getString(R.string.remarks), getString(R.string.record_time)}; + mHeaders62 = new String[]{getString(R.string.position_type), + getString(R.string.station_type), getString(R.string.satellite) + , "hrms", "vrms", getString(R.string.diff_age), getString(R.string.battery)}; + mHeaders63 = new String[]{getString(R.string.hr)}; + } + +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityRecyclerViewUtils.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityRecyclerViewUtils.java new file mode 100644 index 0000000..e285bed --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecordsActivityRecyclerViewUtils.java @@ -0,0 +1,4 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +class RecordsActivityRecyclerViewUtils { +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecyclerViewItemData.java b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecyclerViewItemData.java new file mode 100644 index 0000000..f5ced9a --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/pointlofting/record/util/RecyclerViewItemData.java @@ -0,0 +1,23 @@ +package com.project.survey.ui.lofting.pointlofting.record.util; + +public class RecyclerViewItemData { + final String id; + final String title1; + final String title2; + final String body1; + final String body2; + final String body3; + final String body4; + final String body5; + + public RecyclerViewItemData(String id, String title1, String title2, String body1, String body2, String body3, String body4, String body5) { + this.id = id; + this.title1 = title1; + this.title2 = title2; + this.body1 = body1; + this.body2 = body2; + this.body3 = body3; + this.body4 = body4; + this.body5 = body5; + } +} diff --git a/app/src/main/res/drawable/icon_sort_descending.xml b/app/src/main/res/drawable/icon_sort_descending.xml new file mode 100644 index 0000000..e58e94a --- /dev/null +++ b/app/src/main/res/drawable/icon_sort_descending.xml @@ -0,0 +1,12 @@ + + + diff --git a/app/src/main/res/layout/activity_point_staking_setting.xml b/app/src/main/res/layout/activity_point_staking_setting.xml new file mode 100644 index 0000000..b1145fd --- /dev/null +++ b/app/src/main/res/layout/activity_point_staking_setting.xml @@ -0,0 +1,572 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_records.xml b/app/src/main/res/layout/activity_records.xml new file mode 100644 index 0000000..785c104 --- /dev/null +++ b/app/src/main/res/layout/activity_records.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/dialog_edit_remarks.xml b/app/src/main/res/layout/dialog_edit_remarks.xml new file mode 100644 index 0000000..e42518c --- /dev/null +++ b/app/src/main/res/layout/dialog_edit_remarks.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/app/src/main/res/layout/dialog_export_record_config.xml b/app/src/main/res/layout/dialog_export_record_config.xml new file mode 100644 index 0000000..7d42eeb --- /dev/null +++ b/app/src/main/res/layout/dialog_export_record_config.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_records_filter.xml b/app/src/main/res/layout/dialog_records_filter.xml new file mode 100644 index 0000000..3898eab --- /dev/null +++ b/app/src/main/res/layout/dialog_records_filter.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/layout_checkbox_item.xml b/app/src/main/res/layout/layout_checkbox_item.xml new file mode 100644 index 0000000..92da875 --- /dev/null +++ b/app/src/main/res/layout/layout_checkbox_item.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_recycle_style_dialog.xml b/app/src/main/res/layout/layout_recycle_style_dialog.xml new file mode 100644 index 0000000..f125c54 --- /dev/null +++ b/app/src/main/res/layout/layout_recycle_style_dialog.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/recyclerview_item_records.xml b/app/src/main/res/layout/recyclerview_item_records.xml new file mode 100644 index 0000000..622b594 --- /dev/null +++ b/app/src/main/res/layout/recyclerview_item_records.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/color.xml b/app/src/main/res/values/color.xml index 77bc20e..f9e1047 100644 --- a/app/src/main/res/values/color.xml +++ b/app/src/main/res/values/color.xml @@ -15,6 +15,7 @@ #EBEBEB #00000000 #10000000 + #e5e5e5 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cd53313..7db301e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -263,6 +263,55 @@ 下一点 采集\n记录 实测坐标 - + 提示范围 + CAD设置 + 坐标系统 + 用户坐标系 + 单位长度 + 米(m) + 厘米(cm) + 毫米(mm) + 背景颜色 + 全站仪放样设置 + RTK放样设置 + 世界坐标系 + 清理完成,重启页面后生效 + 请先连接设备(或输入实测点坐标) + 当前设备不支持自动寻点功能 + 请先选择或输入待放样的目标点 + 开始自动寻点... + 时间筛选 + 类型筛选 + 其他筛选 + 左右移动 + 实测X或里程 + 实测Y或偏距 + 状态 + 测站类型 + 起始X + 起始Y + 起始Z + 终点X + 终点Y + 终点Z + 设计X坐标 + 设计Y坐标 + 里程移动 + 内外移动 + 东西移动 + 南北移动 + 前后移动 + 包含杆高/镜高 + 时间区间 + 今天 + 7天内 + 自定义 + 断面类型 + 开挖 + 初支 + 二衬 + 线路名关键词 + 线路名里包含的关键词 + 里程关键词 \ No newline at end of file