diff --git a/README.md b/README.md index d592795..96e4825 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -解放军信息工程导线助手 +上海项目 diff --git a/app/build.gradle b/app/build.gradle index 2f3415d..9d2a9be 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -172,5 +172,7 @@ dependencies { implementation "com.github.zagum:Android-SwitchIcon:1.4.0"//必须的 implementation 'io.github.inflationx:calligraphy3:3.1.1' // implementation 'io.github.inflationx:viewpump:2.0.3' + implementation 'com.gyf.immersionbar:immersionbar:3.0.0-beta05' + } \ No newline at end of file diff --git a/app/libs/base-release.aar b/app/libs/base-release.aar index 9983d9a..4ccdb07 100644 Binary files a/app/libs/base-release.aar and b/app/libs/base-release.aar differ diff --git a/app/libs/device-release.aar b/app/libs/device-release.aar index b76455e..30e0fb6 100644 Binary files a/app/libs/device-release.aar and b/app/libs/device-release.aar differ diff --git a/app/libs/device-ui-release.aar b/app/libs/device-ui-release.aar index ae93585..285e475 100644 Binary files a/app/libs/device-ui-release.aar and b/app/libs/device-ui-release.aar differ diff --git a/app/libs/fastBle-release.aar b/app/libs/fastBle-release.aar new file mode 100644 index 0000000..e2d32a9 Binary files /dev/null and b/app/libs/fastBle-release.aar differ diff --git a/app/libs/fastjson-release.aar b/app/libs/fastjson-release.aar new file mode 100644 index 0000000..354f7e5 Binary files /dev/null and b/app/libs/fastjson-release.aar differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5a723a2..4bb1330 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -46,7 +46,7 @@ android:required="false" /> @@ -56,48 +56,75 @@ + + + + + + diff --git a/app/src/main/java/com/project/survey/App.java b/app/src/main/java/com/project/survey/App.java index 41ba619..c86ed48 100644 --- a/app/src/main/java/com/project/survey/App.java +++ b/app/src/main/java/com/project/survey/App.java @@ -17,6 +17,8 @@ public class App extends Application { private static App app; + public boolean isThemeDark; + @Override public void onCreate() { customChannel = AppChannel.CUSTOM_CONTROL_PRO;//AppChannel.CUSTOM_PUBLIC; @@ -31,7 +33,7 @@ public class App extends Application { } }); - + initThemeDark(); Utils.init(this); } @@ -44,8 +46,8 @@ public class App extends Application { .dark(false); Colorful.init(this); - Colorful.config(this).primaryColor(Colorful.ThemeColor.BROWN).apply(); - Colorful.config(this).accentColor(Colorful.ThemeColor.BROWN).apply(); +// Colorful.config(this).primaryColor(Colorful.ThemeColor.BROWN).apply(); +// Colorful.config(this).accentColor(Colorful.ThemeColor.BROWN).apply(); } diff --git a/app/src/main/java/com/project/survey/activity/approval/ApprovalActivity.kt b/app/src/main/java/com/project/survey/activity/approval/ApprovalActivity.kt deleted file mode 100644 index d1c0550..0000000 --- a/app/src/main/java/com/project/survey/activity/approval/ApprovalActivity.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.project.survey.activity.approval - -import com.project.survey.activity.base.BaseBindingActivity -import com.project.survey.databinding.ActivityApprovalBinding - -/** - * 待处理,已处理,已发起 - */ -class ApprovalActivity : BaseBindingActivity() { - override fun getBinding(): ActivityApprovalBinding { - return ActivityApprovalBinding.inflate(layoutInflater) - } - - override fun initView() { - TODO("Not yet implemented") - } - - override fun initData() { - TODO("Not yet implemented") - } -} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/adapter/ApprovalInitatedAdapter.java b/app/src/main/java/com/project/survey/adapter/ApprovalInitatedAdapter.java new file mode 100644 index 0000000..d1697d2 --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/ApprovalInitatedAdapter.java @@ -0,0 +1,33 @@ +package com.project.survey.adapter; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; + +import com.project.survey.adapter.base.BaseAdapter; +import com.project.survey.adapter.viewholder.ApprovalInitatedListViewHolder; +import com.project.survey.databinding.ItemApprovalInitatedListBinding; +import com.project.survey.model.ApprovalBean; + +/** + * 流程审批 已发起 + */ +public class ApprovalInitatedAdapter extends BaseAdapter { + + public ApprovalInitatedAdapter(Context context) { + super(context); + } + + @NonNull + @Override + public ApprovalInitatedListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ApprovalInitatedListViewHolder(ItemApprovalInitatedListBinding.inflate(getInflater(), parent, false)); + } + + @Override + protected void onBindViewHolderDo(ApprovalInitatedListViewHolder holder, int position) { + ApprovalBean bean = mDataList.get(position); + + } +} diff --git a/app/src/main/java/com/project/survey/adapter/ApprovalWaitAdapter.java b/app/src/main/java/com/project/survey/adapter/ApprovalWaitAdapter.java new file mode 100644 index 0000000..56c4b61 --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/ApprovalWaitAdapter.java @@ -0,0 +1,43 @@ +package com.project.survey.adapter; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; + +import com.project.survey.ui.approval.ApprovalActivity; +import com.project.survey.adapter.base.BaseAdapter; +import com.project.survey.adapter.viewholder.ApprovalWaitListViewHolder; +import com.project.survey.databinding.ItemApprovalWaitListBinding; +import com.project.survey.model.ApprovalBean; + +/** + * 流程审批 等待审批 + */ +public class ApprovalWaitAdapter extends BaseAdapter { + + private final String type; + + public ApprovalWaitAdapter(Context context, String type) { + super(context); + this.type = type; + } + + @NonNull + @Override + public ApprovalWaitListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ApprovalWaitListViewHolder(ItemApprovalWaitListBinding.inflate(getInflater(), parent, false)); + } + + @Override + protected void onBindViewHolderDo(ApprovalWaitListViewHolder holder, int position) { + ApprovalBean bean = mDataList.get(position); + + if (ApprovalActivity.TYPE_PROCESSED.equals(type)) { + holder.mBinding.ivAgree.setVisibility(View.VISIBLE); + } + + + } +} diff --git a/app/src/main/java/com/project/survey/adapter/ControlNetFirstListAdapter.java b/app/src/main/java/com/project/survey/adapter/ControlNetFirstListAdapter.java new file mode 100644 index 0000000..3d53073 --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/ControlNetFirstListAdapter.java @@ -0,0 +1,33 @@ +package com.project.survey.adapter; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; + +import com.project.survey.adapter.base.BaseAdapter; +import com.project.survey.adapter.viewholder.ControlNetFirstListViewHolder; +import com.project.survey.databinding.ItemControlNetFirstListBinding; +import com.project.survey.model.ControlNetListBean; + +/** + * 首级控制网列表 + */ +public class ControlNetFirstListAdapter extends BaseAdapter { + + public ControlNetFirstListAdapter(Context context) { + super(context); + } + + @NonNull + @Override + public ControlNetFirstListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ControlNetFirstListViewHolder(ItemControlNetFirstListBinding.inflate(getInflater(), parent, false)); + } + + @Override + protected void onBindViewHolderDo(ControlNetFirstListViewHolder holder, int position) { + + + } +} diff --git a/app/src/main/java/com/project/survey/adapter/ControlNetSpeciaListAdapter.java b/app/src/main/java/com/project/survey/adapter/ControlNetSpeciaListAdapter.java new file mode 100644 index 0000000..b1f815a --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/ControlNetSpeciaListAdapter.java @@ -0,0 +1,33 @@ +package com.project.survey.adapter; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; + +import com.project.survey.adapter.base.BaseAdapter; +import com.project.survey.adapter.viewholder.ControlNetSpecialListViewHolder; +import com.project.survey.databinding.ItemControlNetSpecialListBinding; +import com.project.survey.model.ControlNetListBean; + +/** + * 专用控制网列表 + */ +public class ControlNetSpeciaListAdapter extends BaseAdapter { + + public ControlNetSpeciaListAdapter(Context context) { + super(context); + } + + @NonNull + @Override + public ControlNetSpecialListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ControlNetSpecialListViewHolder(ItemControlNetSpecialListBinding.inflate(getInflater(), parent, false)); + } + + @Override + protected void onBindViewHolderDo(ControlNetSpecialListViewHolder holder, int position) { + + + } +} diff --git a/app/src/main/java/com/project/survey/adapter/LoftingListAdapter.java b/app/src/main/java/com/project/survey/adapter/LoftingListAdapter.java new file mode 100644 index 0000000..3557d8d --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/LoftingListAdapter.java @@ -0,0 +1,34 @@ +package com.project.survey.adapter; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; + +import com.project.survey.adapter.base.BaseAdapter; +import com.project.survey.adapter.viewholder.LoftingListViewHolder; +import com.project.survey.databinding.ItemLoftingListBinding; +import com.project.survey.model.LoftingListBean; + +/** + * 放样列表 + */ +public class LoftingListAdapter extends BaseAdapter { + + + public LoftingListAdapter(Context context) { + super(context); + } + + @NonNull + @Override + public LoftingListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new LoftingListViewHolder(ItemLoftingListBinding.inflate(getInflater(), parent, false)); + } + + @Override + protected void onBindViewHolderDo(LoftingListViewHolder holder, int position) { + + + } +} diff --git a/app/src/main/java/com/project/survey/adapter/PointMeasureListAdapter.java b/app/src/main/java/com/project/survey/adapter/PointMeasureListAdapter.java new file mode 100644 index 0000000..4581f9a --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/PointMeasureListAdapter.java @@ -0,0 +1,36 @@ +package com.project.survey.adapter; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; + +import com.project.survey.adapter.base.BaseAdapter; +import com.project.survey.adapter.viewholder.PointMeasureListViewHolder; +import com.project.survey.databinding.ItemPointMeasureListBinding; +import com.project.survey.model.PointMeasureListBean; + +/** + * 点测量列表 + */ +public class PointMeasureListAdapter extends BaseAdapter { + + private final String type; + + public PointMeasureListAdapter(Context context, String type) { + super(context); + this.type = type; + } + + @NonNull + @Override + public PointMeasureListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new PointMeasureListViewHolder(ItemPointMeasureListBinding.inflate(getInflater(), parent, false)); + } + + @Override + protected void onBindViewHolderDo(PointMeasureListViewHolder holder, int position) { + + + } +} diff --git a/app/src/main/java/com/project/survey/adapter/viewholder/ApprovalInitatedListViewHolder.java b/app/src/main/java/com/project/survey/adapter/viewholder/ApprovalInitatedListViewHolder.java new file mode 100644 index 0000000..3c9413a --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/viewholder/ApprovalInitatedListViewHolder.java @@ -0,0 +1,18 @@ +package com.project.survey.adapter.viewholder; + +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.databinding.ItemApprovalInitatedListBinding; +import com.project.survey.databinding.ItemApprovalWaitListBinding; + +/** + * 流程审批的 已发起 + */ +public class ApprovalInitatedListViewHolder extends RecyclerView.ViewHolder { + public final ItemApprovalInitatedListBinding mBinding; + + public ApprovalInitatedListViewHolder(ItemApprovalInitatedListBinding binding) { + super(binding.getRoot()); + mBinding = binding; + } +} diff --git a/app/src/main/java/com/project/survey/adapter/viewholder/ApprovalWaitListViewHolder.java b/app/src/main/java/com/project/survey/adapter/viewholder/ApprovalWaitListViewHolder.java new file mode 100644 index 0000000..22ac2ec --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/viewholder/ApprovalWaitListViewHolder.java @@ -0,0 +1,18 @@ +package com.project.survey.adapter.viewholder; + +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.databinding.ItemApprovalWaitListBinding; +import com.project.survey.databinding.ItemProjectListBinding; + +/** + * 流程审批的 + */ +public class ApprovalWaitListViewHolder extends RecyclerView.ViewHolder { + public final ItemApprovalWaitListBinding mBinding; + + public ApprovalWaitListViewHolder(ItemApprovalWaitListBinding binding) { + super(binding.getRoot()); + mBinding = binding; + } +} diff --git a/app/src/main/java/com/project/survey/adapter/viewholder/ControlNetFirstListViewHolder.java b/app/src/main/java/com/project/survey/adapter/viewholder/ControlNetFirstListViewHolder.java new file mode 100644 index 0000000..db736aa --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/viewholder/ControlNetFirstListViewHolder.java @@ -0,0 +1,17 @@ +package com.project.survey.adapter.viewholder; + +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.databinding.ItemControlNetFirstListBinding; + +/** + * 首级控制网 + */ +public class ControlNetFirstListViewHolder extends RecyclerView.ViewHolder { + public final ItemControlNetFirstListBinding mBinding; + + public ControlNetFirstListViewHolder(ItemControlNetFirstListBinding binding) { + super(binding.getRoot()); + mBinding = binding; + } +} diff --git a/app/src/main/java/com/project/survey/adapter/viewholder/ControlNetSpecialListViewHolder.java b/app/src/main/java/com/project/survey/adapter/viewholder/ControlNetSpecialListViewHolder.java new file mode 100644 index 0000000..98ef630 --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/viewholder/ControlNetSpecialListViewHolder.java @@ -0,0 +1,18 @@ +package com.project.survey.adapter.viewholder; + +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.databinding.ItemControlNetFirstListBinding; +import com.project.survey.databinding.ItemControlNetSpecialListBinding; + +/** + * 专用控制网 + */ +public class ControlNetSpecialListViewHolder extends RecyclerView.ViewHolder { + public final ItemControlNetSpecialListBinding mBinding; + + public ControlNetSpecialListViewHolder(ItemControlNetSpecialListBinding binding) { + super(binding.getRoot()); + mBinding = binding; + } +} diff --git a/app/src/main/java/com/project/survey/adapter/viewholder/LoftingListViewHolder.java b/app/src/main/java/com/project/survey/adapter/viewholder/LoftingListViewHolder.java new file mode 100644 index 0000000..ddf2a28 --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/viewholder/LoftingListViewHolder.java @@ -0,0 +1,17 @@ +package com.project.survey.adapter.viewholder; + +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.databinding.ItemLoftingListBinding; + +/** + * 放样 + */ +public class LoftingListViewHolder extends RecyclerView.ViewHolder { + public final ItemLoftingListBinding mBinding; + + public LoftingListViewHolder(ItemLoftingListBinding binding) { + super(binding.getRoot()); + mBinding = binding; + } +} diff --git a/app/src/main/java/com/project/survey/adapter/viewholder/PointMeasureListViewHolder.java b/app/src/main/java/com/project/survey/adapter/viewholder/PointMeasureListViewHolder.java new file mode 100644 index 0000000..0922ed1 --- /dev/null +++ b/app/src/main/java/com/project/survey/adapter/viewholder/PointMeasureListViewHolder.java @@ -0,0 +1,18 @@ +package com.project.survey.adapter.viewholder; + +import androidx.recyclerview.widget.RecyclerView; + +import com.project.survey.databinding.ItemApprovalWaitListBinding; +import com.project.survey.databinding.ItemPointMeasureListBinding; + +/** + * 点测量的 + */ +public class PointMeasureListViewHolder extends RecyclerView.ViewHolder { + public final ItemPointMeasureListBinding mBinding; + + public PointMeasureListViewHolder(ItemPointMeasureListBinding binding) { + super(binding.getRoot()); + mBinding = binding; + } +} diff --git a/app/src/main/java/com/project/survey/dialog/BubblePopWindow.java b/app/src/main/java/com/project/survey/dialog/BubblePopWindow.java new file mode 100644 index 0000000..8f6601a --- /dev/null +++ b/app/src/main/java/com/project/survey/dialog/BubblePopWindow.java @@ -0,0 +1,195 @@ +package com.project.survey.dialog; + +import android.content.Context; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.PopupWindow; + +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; + +import com.bingce.AppChannel; +import com.project.survey.R; +import com.project.survey.databinding.LayoutBubblePopwindowBinding; + +import java.util.Collections; +import java.util.List; + + +public class BubblePopWindow extends PopupWindow { + + private OnHelpDocClickListener onHelpDocClickListener; + private OnTiltSwitchClickListener onTiltSwitchClickListener; + private OnRedrawClickListener onRedrawClickListener; + + private LayoutBubblePopwindowBinding binding; + + public BubblePopWindow(Context context, boolean isCADCustomView) { + this(context, isCADCustomView, Collections.emptyList()); + } + + public BubblePopWindow(Context context, List menuItems) { + this(context, false, menuItems); + } + + public BubblePopWindow(Context context, boolean isCADCustomView, List menuItems) { + super(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + //这里要注意设置setOutsideTouchable之前要设置 setBackgroundDrawable() + //否则点击外部无法关闭pop + setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + setOutsideTouchable(true); + //获取焦点设置为true 这样再次点击菜单时 就隐藏菜单 + setFocusable(true); + + binding = LayoutBubblePopwindowBinding.inflate(LayoutInflater.from(context)); + setContentView(binding.getRoot()); + + binding.llSoftwareSetup.setOnClickListener(v -> { + dismiss(); +// SoftwareSetupActivity.start(context); + }); + + binding.llHelpDocument.setOnClickListener(v -> { + dismiss(); + onHelpDocClickListener.onHelpClick(); + }); + + binding.llTiltSwitch.setOnClickListener(v -> { + dismiss(); + onTiltSwitchClickListener.onTiltSwitchClick(); + }); + + if (isCADCustomView) { + binding.llCadRedraw.setVisibility(View.VISIBLE); + } else { + binding.llCadRedraw.setVisibility(View.GONE); + } + + binding.llCadRedraw.setOnClickListener(v -> { + dismiss(); + onRedrawClickListener.onCadRedrawClicked(); + }); + + if (AppChannel.customChannel == AppChannel.CUSTOM_FJD || + AppChannel.customChannel == AppChannel.CUSTOM_COMNAV) { + binding.llHelpDocument.setVisibility(View.GONE); + } + + if (menuItems != null) { + if (!menuItems.isEmpty()) { + binding.llMenu1.setVisibility(View.VISIBLE); + binding.ivMenu1.setImageResource(menuItems.get(0).iconRes); + binding.tvMenu1.setText(menuItems.get(0).title); + binding.llMenu1.setOnClickListener(v -> { + dismiss(); + menuItems.get(0).action.run(); + }); + } + if (menuItems.size() > 1) { + binding.llMenu2.setVisibility(View.VISIBLE); + binding.ivMenu2.setImageResource(menuItems.get(1).iconRes); + binding.tvMenu2.setText(menuItems.get(1).title); + binding.llMenu2.setOnClickListener(v -> { + dismiss(); + menuItems.get(1).action.run(); + }); + } + if (menuItems.size() > 2) { + binding.llMenu3.setVisibility(View.VISIBLE); + binding.ivMenu3.setImageResource(menuItems.get(2).iconRes); + binding.tvMenu3.setText(menuItems.get(2).title); + binding.llMenu3.setOnClickListener(v -> { + dismiss(); + menuItems.get(2).action.run(); + }); + } + if (menuItems.size() > 3) { + binding.llMenu4.setVisibility(View.VISIBLE); + binding.ivMenu4.setImageResource(menuItems.get(3).iconRes); + binding.tvMenu4.setText(menuItems.get(3).title); + binding.llMenu4.setOnClickListener(v -> { + dismiss(); + menuItems.get(3).action.run(); + }); + } + if (menuItems.size() > 4) { + binding.llMenu5.setVisibility(View.VISIBLE); + binding.ivMenu5.setImageResource(menuItems.get(4).iconRes); + binding.tvMenu5.setText(menuItems.get(4).title); + binding.llMenu5.setOnClickListener(v -> { + dismiss(); + menuItems.get(4).action.run(); + }); + } + if (menuItems.size() > 5) { + binding.llMenu6.setVisibility(View.VISIBLE); + binding.ivMenu6.setImageResource(menuItems.get(5).iconRes); + binding.tvMenu6.setText(menuItems.get(5).title); + binding.llMenu6.setOnClickListener(v -> { + dismiss(); + menuItems.get(5).action.run(); + }); + } + if (menuItems.size() > 6) { + binding.llMenu7.setVisibility(View.VISIBLE); + binding.ivMenu7.setImageResource(menuItems.get(6).iconRes); + binding.tvMenu7.setText(menuItems.get(6).title); + binding.llMenu7.setOnClickListener(v -> { + dismiss(); + menuItems.get(6).action.run(); + }); + } + } + + //设置窗口进入和退出的动画 + setAnimationStyle(R.style.popWindowStyle); + } + + public interface OnHelpDocClickListener { + void onHelpClick(); + } + + public void setOnHelpDocClickListener(OnHelpDocClickListener onHelpDocClickListener) { + this.onHelpDocClickListener = onHelpDocClickListener; + } + + public void setHideHelpDoc(boolean isHide) { + binding.llHelpDocument.setVisibility(isHide ? View.GONE : View.VISIBLE); + } + + public interface OnTiltSwitchClickListener { + void onTiltSwitchClick(); + } + + public void setOnTiltSwitchClickListener(OnTiltSwitchClickListener onTiltSwitchClickListener) { + this.onTiltSwitchClickListener = onTiltSwitchClickListener; + } + + public void setHideTiltSwitch(boolean isHide) { + binding.llTiltSwitch.setVisibility(isHide ? View.GONE : View.VISIBLE); + } + + public interface OnRedrawClickListener { + void onCadRedrawClicked(); + } + + public void setOnRedrawClickListener(OnRedrawClickListener onRedrawClickListener) { + this.onRedrawClickListener = onRedrawClickListener; + } + + public static class CustomMenuItem { + public final @DrawableRes int iconRes; + public final String title; + public final Runnable action; + + + public CustomMenuItem(@DrawableRes int iconRes, @NonNull String title, @NonNull Runnable action) { + this.iconRes = iconRes; + this.title = title; + this.action = action; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/fragment/home/HomeFragment.kt b/app/src/main/java/com/project/survey/fragment/home/HomeFragment.kt deleted file mode 100644 index 1bfd077..0000000 --- a/app/src/main/java/com/project/survey/fragment/home/HomeFragment.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.project.survey.fragment.home - -import android.view.LayoutInflater -import android.view.ViewGroup -import com.project.survey.databinding.FragmentHomeBinding -import com.project.survey.fragment.base.BaseFragmentBinding - -class HomeFragment : BaseFragmentBinding() { - override fun getViewBinding( - inflater: LayoutInflater, - container: ViewGroup? - ): FragmentHomeBinding { - return FragmentHomeBinding.inflate(inflater, container, false) - } - - override fun initView() { - } - - override fun initData() { - } -} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/fragment/home/InstrumentFragment.kt b/app/src/main/java/com/project/survey/fragment/home/InstrumentFragment.kt deleted file mode 100644 index ba9df82..0000000 --- a/app/src/main/java/com/project/survey/fragment/home/InstrumentFragment.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.project.survey.fragment.home - -import android.view.LayoutInflater -import android.view.ViewGroup -import com.project.survey.databinding.FragmentInstrumentBinding -import com.project.survey.fragment.base.BaseFragmentBinding - -class InstrumentFragment : BaseFragmentBinding() { - override fun getViewBinding( - inflater: LayoutInflater, - container: ViewGroup? - ): FragmentInstrumentBinding { - return FragmentInstrumentBinding.inflate(inflater, container, false) - } - - override fun initView() { - } - - override fun initData() { - } -} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/model/ApprovalBean.kt b/app/src/main/java/com/project/survey/model/ApprovalBean.kt new file mode 100644 index 0000000..fd8d297 --- /dev/null +++ b/app/src/main/java/com/project/survey/model/ApprovalBean.kt @@ -0,0 +1,4 @@ +package com.project.survey.model + +class ApprovalBean { +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/model/ControlNetListBean.kt b/app/src/main/java/com/project/survey/model/ControlNetListBean.kt new file mode 100644 index 0000000..e34b282 --- /dev/null +++ b/app/src/main/java/com/project/survey/model/ControlNetListBean.kt @@ -0,0 +1,4 @@ +package com.project.survey.model + +class ControlNetListBean { +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/model/ControlNetVersionBean.kt b/app/src/main/java/com/project/survey/model/ControlNetVersionBean.kt new file mode 100644 index 0000000..686213e --- /dev/null +++ b/app/src/main/java/com/project/survey/model/ControlNetVersionBean.kt @@ -0,0 +1,12 @@ +package com.project.survey.model + +/** + * 控制网版本号 + */ +class ControlNetVersionBean(val version: String) { + + + override fun toString(): String { + return version + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/model/LoftingListBean.kt b/app/src/main/java/com/project/survey/model/LoftingListBean.kt new file mode 100644 index 0000000..f2df5d6 --- /dev/null +++ b/app/src/main/java/com/project/survey/model/LoftingListBean.kt @@ -0,0 +1,4 @@ +package com.project.survey.model + +class LoftingListBean { +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/model/PointMeasureListBean.kt b/app/src/main/java/com/project/survey/model/PointMeasureListBean.kt new file mode 100644 index 0000000..a045a00 --- /dev/null +++ b/app/src/main/java/com/project/survey/model/PointMeasureListBean.kt @@ -0,0 +1,4 @@ +package com.project.survey.model + +class PointMeasureListBean { +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/activity/MainActivity.kt b/app/src/main/java/com/project/survey/ui/MainActivity.kt similarity index 91% rename from app/src/main/java/com/project/survey/activity/MainActivity.kt rename to app/src/main/java/com/project/survey/ui/MainActivity.kt index 6dc8fdb..9206fc5 100644 --- a/app/src/main/java/com/project/survey/activity/MainActivity.kt +++ b/app/src/main/java/com/project/survey/ui/MainActivity.kt @@ -1,4 +1,4 @@ -package com.project.survey.activity +package com.project.survey.ui import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager @@ -8,11 +8,11 @@ import com.bingce.ui.TabEntity import com.flyco.tablayout.listener.CustomTabEntity import com.flyco.tablayout.listener.OnTabSelectListener import com.project.survey.R -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivityMainBinding -import com.project.survey.fragment.home.HomeFragment -import com.project.survey.fragment.home.InstrumentFragment -import com.project.survey.fragment.home.MeFragment +import com.project.survey.ui.home.HomeFragment +import com.project.survey.ui.home.InstrumentFragment +import com.project.survey.ui.home.MeFragment class MainActivity : BaseBindingActivity() { diff --git a/app/src/main/java/com/project/survey/activity/SplashActivity.kt b/app/src/main/java/com/project/survey/ui/SplashActivity.kt similarity index 82% rename from app/src/main/java/com/project/survey/activity/SplashActivity.kt rename to app/src/main/java/com/project/survey/ui/SplashActivity.kt index 1e4dd80..c9d1d62 100644 --- a/app/src/main/java/com/project/survey/activity/SplashActivity.kt +++ b/app/src/main/java/com/project/survey/ui/SplashActivity.kt @@ -1,7 +1,7 @@ -package com.project.survey.activity +package com.project.survey.ui import android.content.Intent -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivitySplashBinding /** diff --git a/app/src/main/java/com/project/survey/ui/approval/ApprovalActivity.kt b/app/src/main/java/com/project/survey/ui/approval/ApprovalActivity.kt new file mode 100644 index 0000000..99ebcc9 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/approval/ApprovalActivity.kt @@ -0,0 +1,52 @@ +package com.project.survey.ui.approval + +import android.content.Context +import android.content.Intent +import com.project.survey.R +import com.project.survey.ui.base.BaseBindingActivity +import com.project.survey.databinding.ActivityApprovalBinding + +/** + * 待处理,已处理,已发起 + */ +class ApprovalActivity : BaseBindingActivity() { + + companion object { + private const val KEY_TYPE = "KEY_TYPE" + const val TYPE_WAIT = "TYPE_WAIT"//待处理 + const val TYPE_PROCESSED = "TYPE_PROCESSED"//已处理 + const val TYPE_INITIATED = "TYPE_INITIATED"//已发起 + + fun launch(context: Context, type: String) { + context.startActivity(Intent(context, ApprovalActivity::class.java).apply { + putExtra(KEY_TYPE, type) + }) + } + } + + override fun getBinding(): ActivityApprovalBinding { + return ActivityApprovalBinding.inflate(layoutInflater) + } + + override fun initView() { + val beginTransaction = supportFragmentManager.beginTransaction() + val fragemnt = when (getType()) { + TYPE_WAIT -> ApprovalWaitFragment() + TYPE_PROCESSED -> ApprovalProcessedFragment() + TYPE_INITIATED -> ApprovalInitiatedFragment() + else -> { + throw IllegalArgumentException("type is error") + } + } + beginTransaction.replace(R.id.container, fragemnt) + beginTransaction.commit() + } + + override fun initData() { + + } + + + private fun getType() = intent.getStringExtra(KEY_TYPE) + +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/approval/ApprovalInitiatedFragment.kt b/app/src/main/java/com/project/survey/ui/approval/ApprovalInitiatedFragment.kt new file mode 100644 index 0000000..0f310d6 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/approval/ApprovalInitiatedFragment.kt @@ -0,0 +1,45 @@ +package com.project.survey.ui.approval + +import android.view.LayoutInflater +import android.view.ViewGroup +import com.project.survey.adapter.ApprovalInitatedAdapter +import com.project.survey.databinding.FragmentApprovalBinding +import com.project.survey.ui.base.BaseFragmentBinding +import com.project.survey.model.ApprovalBean +import com.project.survey.widget.decoration.TransparentDividerDecoration + +/** + * 已发起 + */ +class ApprovalInitiatedFragment : BaseFragmentBinding() { + + private val adapter by lazy { ApprovalInitatedAdapter(requireContext()) } + + override fun getViewBinding( + inflater: LayoutInflater, + container: ViewGroup? + ): FragmentApprovalBinding { + return FragmentApprovalBinding.inflate(inflater, container, false) + } + + override fun initView() { + initAdapter() + } + + override fun initData() { + val dataList = mutableListOf() + for (i in 0 until 3) { + dataList.add(ApprovalBean()) + } + adapter.refreshData(dataList) + } + + private fun initAdapter() { + mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(requireContext())) + adapter.setOnItemClickListener { + + } + mBinding.recyclerView.setAdapter(adapter) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/approval/ApprovalProcessedFragment.kt b/app/src/main/java/com/project/survey/ui/approval/ApprovalProcessedFragment.kt new file mode 100644 index 0000000..148a2e1 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/approval/ApprovalProcessedFragment.kt @@ -0,0 +1,49 @@ +package com.project.survey.ui.approval + +import android.view.LayoutInflater +import android.view.ViewGroup +import com.project.survey.adapter.ApprovalWaitAdapter +import com.project.survey.databinding.FragmentApprovalBinding +import com.project.survey.ui.base.BaseFragmentBinding +import com.project.survey.model.ApprovalBean +import com.project.survey.widget.decoration.TransparentDividerDecoration + +/** + * 已处理 + */ +class ApprovalProcessedFragment : BaseFragmentBinding() { + private val adapter by lazy { + ApprovalWaitAdapter( + requireContext(), + ApprovalActivity.TYPE_PROCESSED + ) + } + + override fun getViewBinding( + inflater: LayoutInflater, + container: ViewGroup? + ): FragmentApprovalBinding { + return FragmentApprovalBinding.inflate(inflater, container, false) + } + + override fun initView() { + initAdapter() + } + + override fun initData() { + val dataList = mutableListOf() + for (i in 0 until 3) { + dataList.add(ApprovalBean()) + } + adapter.refreshData(dataList) + } + + private fun initAdapter() { + mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(requireContext())) + adapter.setOnItemClickListener { + + } + mBinding.recyclerView.setAdapter(adapter) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/approval/ApprovalWaitFragment.kt b/app/src/main/java/com/project/survey/ui/approval/ApprovalWaitFragment.kt new file mode 100644 index 0000000..a6e51b8 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/approval/ApprovalWaitFragment.kt @@ -0,0 +1,50 @@ +package com.project.survey.ui.approval + +import android.view.LayoutInflater +import android.view.ViewGroup +import com.project.survey.adapter.ApprovalWaitAdapter +import com.project.survey.databinding.FragmentApprovalBinding +import com.project.survey.ui.base.BaseFragmentBinding +import com.project.survey.model.ApprovalBean +import com.project.survey.widget.decoration.TransparentDividerDecoration + +/** + * 待处理 + */ +class ApprovalWaitFragment : BaseFragmentBinding() { + + private val adapter by lazy { + ApprovalWaitAdapter( + requireContext(), + ApprovalActivity.TYPE_WAIT + ) + } + + override fun getViewBinding( + inflater: LayoutInflater, + container: ViewGroup? + ): FragmentApprovalBinding { + return FragmentApprovalBinding.inflate(inflater, container, false) + } + + override fun initView() { + initAdapter() + } + + override fun initData() { + val dataList = mutableListOf() + for (i in 0 until 3) { + dataList.add(ApprovalBean()) + } + adapter.refreshData(dataList) + } + + private fun initAdapter() { + mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(requireContext())) + adapter.setOnItemClickListener { + + } + mBinding.recyclerView.setAdapter(adapter) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/activity/base/BaseBindingActivity.kt b/app/src/main/java/com/project/survey/ui/base/BaseBindingActivity.kt similarity index 98% rename from app/src/main/java/com/project/survey/activity/base/BaseBindingActivity.kt rename to app/src/main/java/com/project/survey/ui/base/BaseBindingActivity.kt index 67661ee..974bce1 100644 --- a/app/src/main/java/com/project/survey/activity/base/BaseBindingActivity.kt +++ b/app/src/main/java/com/project/survey/ui/base/BaseBindingActivity.kt @@ -1,4 +1,4 @@ -package com.project.survey.activity.base +package com.project.survey.ui.base import android.os.Bundle import android.view.MenuItem diff --git a/app/src/main/java/com/project/survey/fragment/base/BaseFragmentBinding.java b/app/src/main/java/com/project/survey/ui/base/BaseFragmentBinding.java similarity index 97% rename from app/src/main/java/com/project/survey/fragment/base/BaseFragmentBinding.java rename to app/src/main/java/com/project/survey/ui/base/BaseFragmentBinding.java index 2c1f6ef..1380b3b 100644 --- a/app/src/main/java/com/project/survey/fragment/base/BaseFragmentBinding.java +++ b/app/src/main/java/com/project/survey/ui/base/BaseFragmentBinding.java @@ -1,4 +1,4 @@ -package com.project.survey.fragment.base; +package com.project.survey.ui.base; import android.os.Bundle; import android.view.LayoutInflater; diff --git a/app/src/main/java/com/project/survey/ui/base/BaseSurveyNewActivity.java b/app/src/main/java/com/project/survey/ui/base/BaseSurveyNewActivity.java new file mode 100644 index 0000000..2318cc8 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/base/BaseSurveyNewActivity.java @@ -0,0 +1,625 @@ +package com.project.survey.ui.base; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.KeyEvent; +import android.view.View; +import android.view.WindowManager; + +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; + +import com.bingce.AppChannel; +import com.bingce.constants.KeyEventAction; +import com.bingce.coordlib.model.Blh; +import com.bingce.coordlib.model.Coordinate; +import com.bingce.device.Device; +import com.bingce.device.enums.DeviceTypeEnum; +import com.bingce.device.ui.manager.DeviceConnectManager; +import com.bingce.device.ui.manager.RtkManager; +import com.bingce.device.ui.manager.TsAnglesRefreshManager; +import com.bingce.device.ui.manager.TsBatteryRefreshManager; +import com.bingce.device.ui.manager.TsChangeHrManager; +import com.bingce.device.ui.manager.TsMeasCoordinateManager; +import com.bingce.device.ui.manager.TsMeasSdAnglesManager; +import com.bingce.device.ui.utils.TSSettingDialogUtils; +import com.bingce.rtk.command.RTK; +import com.bingce.rtk.gnss.Gnss; +import com.bingce.surveyor.util.DeviceConnectUtil; +import com.bingce.surveyor.util.SurveyDevicePoleHrHeightUtils; +import com.bingce.totalstation.TsListener; +import com.bingce.utils.PropertiesGet; +import com.project.survey.App; +import com.project.survey.R; +import com.project.survey.dialog.BubblePopWindow; +import com.project.survey.ui.instrument.satellitosis.SatelliteStatusActivity; +import com.project.survey.ui.interfacee.IUIProvider; +import com.project.survey.util.AnimUtil; +import com.project.survey.util.BaseSurveyActivityUtils; +import com.project.survey.util.CountDownUtils; +import com.project.survey.util.DrawableUtils; +import com.project.survey.util.SystemUtils; + +import org.polaric.colorful.Colorful; +import org.polaric.colorful.ColorfulActivity; + +import java.util.List; + +import blankj.utilcode.util.ToastUtils; +import blankj.utilcode.util.Utils; + +public abstract class BaseSurveyNewActivity extends AppCompatActivity implements IUIProvider, Device.IDeviceConnectListener, RtkManager.IRtkListener, + TsListener.MeasCoordinateListener, TsListener.MeasSdAnglesListener, TsListener.AnglesRefreshListener, TsListener.BatteryRefreshListener, TsListener.ChangeHrListener, + CountDownUtils.ICountDownSwitcher { + public final BaseSurveyActivityUtils baseSurveyActivityUtils = new BaseSurveyActivityUtils(this, this, onRootSetBackgroundColor()); + + private final CountDownUtils countDownUtils = new CountDownUtils(() -> this, this); + public final DeviceConnectManager deviceConnectManager = new DeviceConnectManager(this, this); + protected final RtkManager rtkManager = new RtkManager(this, this); + protected final TsMeasCoordinateManager tsMeasCoordinateManager = new TsMeasCoordinateManager(this, this); + protected final TsMeasSdAnglesManager tsMeasSdAnglesManager = new TsMeasSdAnglesManager(this, this); + protected final TsAnglesRefreshManager tsAnglesRefreshManager = new TsAnglesRefreshManager(this, this); + protected final TsBatteryRefreshManager tsBatteryRefreshManager = new TsBatteryRefreshManager(this, this); + protected final TsChangeHrManager tsChangeHrManager = new TsChangeHrManager(this, this); + protected final TSSettingDialogUtils tsSettingDialogUtils = new TSSettingDialogUtils(this); + + final protected void hideSurveyorInfoLayout() { + baseSurveyActivityUtils.activityBaseSurveyBinding.rlSurveyInfo.setVisibility(View.INVISIBLE); + } + + //最右侧的按钮图片点击事件 + protected void onCommonRightClicked(View view) { + } + + public int onRootSetBackgroundColor() { + return -1; + } + + public boolean isUseSystemStyleNavigationBar() { + return false; + } + + public boolean isShowTopBarHrPoleLayout() { + return true; + } + + public int customSystemStyleNavigationBarColor() { + return R.color.theme_gray; + } + + public void setFragmentTitle(int fragmentTitle) { + setStayMainPage(false, getString(fragmentTitle)); + } + + public void setStayMainPage(boolean isStayMainPage) { + setStayMainPage(isStayMainPage, ""); + } + + public void setStayMainPage(boolean isStayMainPage, String fragmentTitle) { + if (isStayMainPage) { + baseSurveyActivityUtils.activityBaseSurveyBinding.rlSurveyInfo.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.rlBack.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.llRoadItemSurveyInfo.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.llTitleBarRightIcon.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.rlMenuSideslip.setVisibility(View.VISIBLE); + } else { + if (!TextUtils.isEmpty(fragmentTitle)) { + baseSurveyActivityUtils.activityBaseSurveyBinding.rlSurveyInfo.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.rlBack.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.llRoadItemSurveyInfo.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.llTitleBarRightIcon.setVisibility(View.GONE); + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.rlSurveyInfo.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.rlBack.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.llRoadItemSurveyInfo.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.llTitleBarRightIcon.setVisibility(View.GONE); + } + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setText(fragmentTitle); + baseSurveyActivityUtils.activityBaseSurveyBinding.rlMenuSideslip.setVisibility(View.GONE); + } + } + + public BubblePopWindow newBubblePopWindow(Context context) { + return new BubblePopWindow(context, false); + } + + private BubblePopWindow defaultMenu = null; + + protected void showMenu() { + if (defaultMenu == null) { + defaultMenu = newBubblePopWindow(this); + defaultMenu.setOnDismissListener(() -> toggleBright()); + defaultMenu.setHideHelpDoc(isHideHelpDoc()); + defaultMenu.setOnHelpDocClickListener(() -> { + onHelpClicked(); + }); + + defaultMenu.setHideTiltSwitch(isHideTiltSwitch()); + defaultMenu.setOnTiltSwitchClickListener(() -> { + onTiltSwitchClick(); + }); + } + defaultMenu.showAsDropDown(baseSurveyActivityUtils.activityBaseSurveyBinding.ivMore, -150, 20); + } + + public boolean isHideHelpDoc() { + return false; + } + + public boolean isHideTiltSwitch() { + return true; + } + + private AnimUtil animUtil; + private float bgAlpha = 1f; + private boolean bright = false; + private static final long DURATION = 400; + private static final float START_ALPHA = 0.6f; + private static final float END_ALPHA = 1f; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Colorful.applyTheme(this); + baseSurveyActivityUtils.onCreate(); + if (((App) Utils.getApp()).isThemeDark) { + baseSurveyActivityUtils.activityBaseSurveyBinding.cutDownProgressbar.setBackgroundColor(ContextCompat.getColor(this, R.color.dark)); + baseSurveyActivityUtils.activityBaseSurveyBinding.baseView.setBackgroundColor(ContextCompat.getColor(this, R.color.dark)); + } + if (!isUseSystemStyleNavigationBar()) { + if (onRootSetBackgroundColor() != -1) { + baseSurveyActivityUtils.activityBaseSurveyBinding.getRoot().setBackgroundColor(getColor(onRootSetBackgroundColor())); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivBack, R.drawable.icon_system_back, R.color.black); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivMore, R.drawable.icon_white_more, R.color.black); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setTextColor(getColor(R.color.black)); + } + } else { + if (customSystemStyleNavigationBarColor() == R.color.theme_gray) { + if (((App) Utils.getApp()).isThemeDark) { + Colorful.ThemeColor primaryColor = Colorful.getThemeDelegate().getPrimaryColor(); + baseSurveyActivityUtils.activityBaseSurveyBinding.getRoot().setBackgroundColor(getColor(primaryColor.getColorRes())); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivBack, R.drawable.icon_system_back, R.color.white); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivMore, R.drawable.icon_white_more, R.color.white); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setTextColor(getColor(R.color.white)); + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.getRoot().setBackgroundColor(getColor(R.color.white)); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivBack, R.drawable.icon_system_back, R.color.black); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivMore, R.drawable.icon_white_more, R.color.black); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setTextColor(getColor(R.color.black)); + } + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.getRoot().setBackgroundColor(getColor(customSystemStyleNavigationBarColor())); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivBack, R.drawable.icon_system_back, R.color.white); + DrawableUtils.tintModifyColorVector(baseSurveyActivityUtils.activityBaseSurveyBinding.ivMore, R.drawable.icon_white_more, R.color.white); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setTextColor(getColor(R.color.white)); + } + } + + baseSurveyActivityUtils.activityBaseSurveyBinding.llPoleHighHr.setVisibility(isShowTopBarHrPoleLayout() ? View.VISIBLE : View.GONE); + + SurveyDevicePoleHrHeightUtils.setDevicePoleHrHigh(this, baseSurveyActivityUtils.activityBaseSurveyBinding.llPoleHighHr, baseSurveyActivityUtils.activityBaseSurveyBinding.ivPoleHighHr, baseSurveyActivityUtils.activityBaseSurveyBinding.tvPoleHighHr, true); + + baseSurveyActivityUtils.activityBaseSurveyBinding.llCommonRight.setOnClickListener(this::onCommonRightClicked); + + baseSurveyActivityUtils.activityBaseSurveyBinding.llIconHomeSatellite.setOnClickListener(v -> { + if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) { + tsSettingDialogUtils.showTotalStationSettingDialog(); + } else { + startActivity(new Intent(this, SatelliteStatusActivity.class)); + } + }); + + baseSurveyActivityUtils.activityBaseSurveyBinding.llRtkStatus.setOnClickListener(v -> { + DeviceConnectUtil.startDeviceConnected(this, baseSurveyActivityUtils.activityBaseSurveyBinding); + }); + + animUtil = new AnimUtil(); + + baseSurveyActivityUtils.activityBaseSurveyBinding.rlMore.setOnClickListener(v -> { + showMenu(); + toggleBright(); + }); + + initViewMap(savedInstanceState); + initView(); + initData(); + } + + @Override + protected void onResume() { + super.onResume(); + //按照设置选项,保持屏幕常亮,放在onResume而不放在onCreate里是因为,用户更改设置后返回主页就要开始常亮了 + SystemUtils.setScreenAlwaysLight(this); + } + + final public void toggleBright() { + // 三个参数分别为:起始值 结束值 时长,那么整个动画回调过来的值就是从0.5f--1f的 + animUtil.setValueAnimator(START_ALPHA, END_ALPHA, DURATION); + animUtil.addUpdateListener(progress -> { + // 此处系统会根据上述三个值,计算每次回调的值是多少,我们根据这个值来改变透明度 + bgAlpha = bright ? progress : (START_ALPHA + END_ALPHA - progress); + backgroundAlpha(bgAlpha); + }); + animUtil.addEndListner(animator -> { + // 在一次动画结束的时候,翻转状态 + bright = !bright; + }); + animUtil.startAnimator(); + } + + final public void backgroundAlpha(float bgAlpha) { + WindowManager.LayoutParams lp = getWindow().getAttributes(); + lp.alpha = bgAlpha; //0.0-1.0 + getWindow().setAttributes(lp); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + } + + protected void initViewMap(Bundle savedInstanceState) { + + } + + /** + * 设置标题 + * + * @param title + */ + final protected void setTitle(String title) { + setTitle(title, null, "", R.color.white); + } + + final protected void setTitle(String title, String rightText) { + setTitle(title, null, rightText, R.color.white); + } + + final protected void setTitle(String title, String rightText, int rightTextColor) { + setTitle(title, null, rightText, rightTextColor); + } + + @Override + public void setTitle(int titleId) { + setTitle(getString(titleId)); + } + + @Override + public void setTitle(CharSequence title) { + setTitle(title.toString()); + } + + final protected void setTitle(String title, Integer rightIcon, String rightText, int rightTextColor) { + if (!TextUtils.isEmpty(title)) { + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setText(title); + baseSurveyActivityUtils.activityBaseSurveyBinding.rlSurveyInfo.setVisibility(View.GONE); + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.rlSurveyInfo.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setText(""); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonTitle.setVisibility(View.GONE); + } + + if (rightIcon == null && TextUtils.isEmpty(rightText)) { + baseSurveyActivityUtils.activityBaseSurveyBinding.llCommonRight.setVisibility(View.GONE); + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.llCommonRight.setVisibility(View.VISIBLE); + } + if (rightIcon != null) { + baseSurveyActivityUtils.activityBaseSurveyBinding.ivCommonRightIcon.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivCommonRightIcon.setImageResource(rightIcon); + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.ivCommonRightIcon.setVisibility(View.GONE); + } + if (!TextUtils.isEmpty(rightText)) { + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonRightText.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonRightText.setText(rightText); + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonRightText.setVisibility(View.GONE); + } + + if (rightTextColor > 0) { + baseSurveyActivityUtils.activityBaseSurveyBinding.tvCommonRightText.setTextColor(getColor(rightTextColor)); + } + } + + protected void setTitleBar(List itemList) { + baseSurveyActivityUtils.activityBaseSurveyBinding.llTitleBarRightIcon.setVisibility(!itemList.isEmpty() ? View.VISIBLE : View.GONE); + if (itemList.size() == 1) { + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon02.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon03.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setImageDrawable(ContextCompat.getDrawable(this, itemList.get(0).iconRes)); + + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setOnClickListener(v -> itemList.get(0).action.run()); + + } else if (itemList.size() == 2) { + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon02.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon03.setVisibility(View.GONE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setImageDrawable(ContextCompat.getDrawable(this, itemList.get(0).iconRes)); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon02.setImageDrawable(ContextCompat.getDrawable(this, itemList.get(1).iconRes)); + + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setOnClickListener(v -> itemList.get(0).action.run()); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon02.setOnClickListener(v -> itemList.get(1).action.run()); + + } else { + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon02.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon03.setVisibility(View.VISIBLE); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setImageDrawable(ContextCompat.getDrawable(this, itemList.get(0).iconRes)); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon02.setImageDrawable(ContextCompat.getDrawable(this, itemList.get(1).iconRes)); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon03.setImageDrawable(ContextCompat.getDrawable(this, itemList.get(2).iconRes)); + + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon01.setOnClickListener(v -> itemList.get(0).action.run()); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon02.setOnClickListener(v -> itemList.get(1).action.run()); + baseSurveyActivityUtils.activityBaseSurveyBinding.ivTitleBarRightIcon03.setOnClickListener(v -> itemList.get(2).action.run()); + + } + } + + public static class CustomMainMenuItem { + public final @DrawableRes int iconRes; + public final Runnable action; + + + public CustomMainMenuItem(@DrawableRes int iconRes, @NonNull Runnable action) { + this.iconRes = iconRes; + this.action = action; + } + } + + @Override + public int getLayoutId() { + return -1; + } + + @Override + public View getContentView() { + return null; + } + + protected abstract void initView(); + + protected abstract void initData(); + + @Override + public boolean isShowTimeStatusBar() { + return true; + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + switch (keyCode) { + case KeyEvent.KEYCODE_VOLUME_UP: + switch (/*((App) Utils.getApp()).*/volumeUpAction()) { + case KeyEventAction.NONE: + return super.onKeyDown(keyCode, event); + case KeyEventAction.CAL: + break; + case KeyEventAction.MEASURE: + performMeasure(); + break; + case KeyEventAction.RECORD: + performRecord(); + break; + case KeyEventAction.LAST: + performLast(); + break; + case KeyEventAction.NEXT: + performNext(); + break; + case KeyEventAction.MEASURE_NOT_SEND: + performMeasureNotSend(); + break; + case KeyEventAction.MEASURE_AND_RECORD: + performMeasureRecord(); + break; + } + return true; + case KeyEvent.KEYCODE_VOLUME_DOWN: + switch (volumeDownAction()) { + case KeyEventAction.NONE: + return super.onKeyDown(keyCode, event); + case KeyEventAction.CAL: + break; + case KeyEventAction.MEASURE: + performMeasure(); + break; + case KeyEventAction.RECORD: + performRecord(); + break; + case KeyEventAction.LAST: + performLast(); + break; + case KeyEventAction.NEXT: + performNext(); + break; + case KeyEventAction.MEASURE_NOT_SEND: + performMeasureNotSend(); + break; + case KeyEventAction.MEASURE_AND_RECORD: + performMeasureRecord(); + break; + } + return true; + case 220://中海达记录快捷键 + if (PropertiesGet.getModel() != null) { + if ((PropertiesGet.getModel().startsWith("iHand") || PropertiesGet.getModel().startsWith("Q3"))) { + performRecord(); + } + } + break; + case 131://丰疆手薄记录快捷键 + if (AppChannel.customChannel == AppChannel.CUSTOM_FJD) { + performRecord(); + } + break; + } + return super.onKeyDown(keyCode, event); + } + + protected int volumeUpAction() { +// return BingCeBaseSurveyPresenter.volumeUpAction(); + return 0; + } + + protected int volumeDownAction() { +// return BingCeBaseSurveyPresenter.volumeDownAction(); + return 0; + } + + protected void performMeasure() { + + } + + protected void performRecord() { + + } + + protected void performMeasureRecord() { + } + + protected void performMeasureNotSend() { + } + + protected void performNext() { + + } + + protected void performLast() { + } + + + protected void onHelpClicked() { + + } + + protected void onTiltSwitchClick() { + if (!Gnss.getInstance().getDevice().isSupportTilt()) { + ToastUtils.showShort(R.string.current_device_not_support_tilt); + } else { + if (Gnss.getInstance().getDevice().isTiltOpen()) { + RTK.getInstance().sendCloseTiltCmd(); + } else { + RTK.getInstance().sendOpenTiltCmd(); + } + } + } + + @Override + final public void setContentView(View view) { + //判断view的背景色 + ColorfulActivity.autoSwitchRootViewBgColor(view); + super.setContentView(view); + } + + @Override + public void onDeviceConnectLost() { + baseSurveyActivityUtils.resetTopStatus(); + } + + @Override + public void onDeviceConnectFailed() { + baseSurveyActivityUtils.resetTopStatus(); + } + + @Override + public void onDeviceConnectNeedOpenBT() { + + } + + @Override + public void onDeviceConnectSucceed() { + + } + + @Override + public void onRtkPositionReceived(double antennaHeight, Blh blh, Blh originalBlh, Coordinate coordinate, double hdop, double vdop, double pdop) { + + } + + @Override + public void onRtkStatusChanged() { + baseSurveyActivityUtils.refreshRtkStatus(); + } + + @Override + public void onRtkError(String errorMsg) { + ToastUtils.showShort(errorMsg); + } + + @Override + public void onRtkPoleHeightChanged() { + + } + + @Override + public void onRtkTiltSwitched(boolean onOff) { + + } + + @Override + public void onSatelliteSkyViewRefresh() { + + } + + @Override + public void onMeasCoordinateSuccess(Coordinate coordinate) { + + } + + @Override + public void onMeasCoordinateFailed(String errorMsg, String original) { + + } + + @Override + public void onMeasSdAnglesSuccess(double originalHa, double originalVa, double sd, double clockwiseHa, double topVa, double hd, double vd) { + baseSurveyActivityUtils.onMeasSdAngleSuccess(originalHa, originalVa, sd, clockwiseHa, topVa, hd, vd); + } + + @Override + public void onMeasSdAnglesFailed(String errorMsg, String original) { + + } + + @Override + public void onAnglesRefresh(double originalHa, double originalVa) { + + } + + @Override + public void onBatteryRefresh(int percent) { + + } + + @Override + public void onChangeHrSuccess(double hr) { + + } + + @Override + public void onChangeHrFailed(String errorMsg) { + + } + + @Override + public boolean isVipCountDownOpen() { + return true; + } + + public interface ISurveyorUIMenuContainer { + BubblePopWindow uiMenu(); + } + + public interface IFragmentBtnHelp { + void onHelpBtnClicked(); + } + + public interface IFragmentBtnTilt { + void onTiltBtnClicked(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/controlnet/ControlNetFirstListActivity.kt b/app/src/main/java/com/project/survey/ui/controlnet/ControlNetFirstListActivity.kt new file mode 100644 index 0000000..13845ba --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/controlnet/ControlNetFirstListActivity.kt @@ -0,0 +1,60 @@ +package com.project.survey.ui.controlnet + +import android.content.Context +import android.content.Intent +import com.project.survey.adapter.ControlNetFirstListAdapter +import com.project.survey.databinding.ActivityControlNetListBinding +import com.project.survey.model.ControlNetListBean +import com.project.survey.model.ControlNetVersionBean +import com.project.survey.ui.base.BaseBindingActivity +import com.project.survey.widget.decoration.TransparentDividerDecoration + +/** + * 首级控制网列表 + */ +class ControlNetFirstListActivity : BaseBindingActivity() { + + private val adapter by lazy { ControlNetFirstListAdapter(this) } + + companion object { + fun launch(context: Context) { + context.startActivity(Intent(context, ControlNetFirstListActivity::class.java)) + } + } + + override fun getBinding(): ActivityControlNetListBinding { + return ActivityControlNetListBinding.inflate(layoutInflater) + } + + override fun initView() { + initVersion() + + + initAdapter() + } + + private fun initVersion() { + val versionList = mutableListOf() + versionList.add(ControlNetVersionBean("版本一")) + versionList.add(ControlNetVersionBean("版本二")) + versionList.add(ControlNetVersionBean("版本三")) + + mBinding.ilSearch.spinner.setItems(versionList) + } + + override fun initData() { + val dataList = mutableListOf() + for (i in 0 until 3) { + dataList.add(ControlNetListBean()) + } + adapter.refreshData(dataList) + } + + private fun initAdapter() { + mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(this)) + adapter.setOnItemClickListener { + + } + mBinding.recyclerView.setAdapter(adapter) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/controlnet/ControlNetSpeciaListActivity.kt b/app/src/main/java/com/project/survey/ui/controlnet/ControlNetSpeciaListActivity.kt new file mode 100644 index 0000000..59753f2 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/controlnet/ControlNetSpeciaListActivity.kt @@ -0,0 +1,57 @@ +package com.project.survey.ui.controlnet + +import android.content.Context +import android.content.Intent +import com.project.survey.adapter.ControlNetSpeciaListAdapter +import com.project.survey.databinding.ActivityControlNetListBinding +import com.project.survey.model.ControlNetListBean +import com.project.survey.model.ControlNetVersionBean +import com.project.survey.ui.base.BaseBindingActivity +import com.project.survey.widget.decoration.TransparentDividerDecoration + +/** + * 专用控制网列表 + */ +class ControlNetSpeciaListActivity : BaseBindingActivity() { + private val adapter by lazy { ControlNetSpeciaListAdapter(this) } + + companion object { + fun launch(context: Context) { + context.startActivity(Intent(context, ControlNetSpeciaListActivity::class.java)) + } + } + + override fun getBinding(): ActivityControlNetListBinding { + return ActivityControlNetListBinding.inflate(layoutInflater) + } + + override fun initView() { + initVersion() + initAdapter() + } + + override fun initData() { + val dataList = mutableListOf() + for (i in 0 until 3) { + dataList.add(ControlNetListBean()) + } + adapter.refreshData(dataList) + } + + private fun initVersion() { + val versionList = mutableListOf() + versionList.add(ControlNetVersionBean("版本一")) + versionList.add(ControlNetVersionBean("版本二")) + versionList.add(ControlNetVersionBean("版本三")) + + mBinding.ilSearch.spinner.setItems(versionList) + } + + private fun initAdapter() { + mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(this)) + adapter.setOnItemClickListener { + + } + mBinding.recyclerView.setAdapter(adapter) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/home/HomeFragment.kt b/app/src/main/java/com/project/survey/ui/home/HomeFragment.kt new file mode 100644 index 0000000..a8ad65f --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/home/HomeFragment.kt @@ -0,0 +1,49 @@ +package com.project.survey.ui.home + +import android.view.LayoutInflater +import android.view.ViewGroup +import com.project.survey.databinding.FragmentHomeBinding +import com.project.survey.ui.approval.ApprovalActivity +import com.project.survey.ui.base.BaseFragmentBinding +import com.project.survey.ui.controlnet.ControlNetFirstListActivity +import com.project.survey.ui.controlnet.ControlNetSpeciaListActivity +import com.project.survey.ui.lofting.LoftingListActivity +import com.project.survey.ui.pointmeasure.PointMeasureListActivity + +class HomeFragment : BaseFragmentBinding() { + override fun getViewBinding( + inflater: LayoutInflater, + container: ViewGroup? + ): FragmentHomeBinding { + return FragmentHomeBinding.inflate(inflater, container, false) + } + + override fun initView() { + mBinding.tvPointMeasure.setOnClickListener { + //点测量 + PointMeasureListActivity.launch(requireContext()) + } + mBinding.tvLofting.setOnClickListener { + //放样 + LoftingListActivity.launch(requireContext()) + } + mBinding.rlApprovalWait.setOnClickListener { + ApprovalActivity.launch(requireContext(), ApprovalActivity.TYPE_WAIT) + } + mBinding.tvApprovalProcessed.setOnClickListener { + ApprovalActivity.launch(requireContext(), ApprovalActivity.TYPE_PROCESSED) + } + mBinding.tvApprovalInitated.setOnClickListener { + ApprovalActivity.launch(requireContext(), ApprovalActivity.TYPE_INITIATED) + } + mBinding.tvControlNetFirst.setOnClickListener { + ControlNetFirstListActivity.launch(requireContext()) + } + mBinding.tvControlNetSpecial.setOnClickListener { + ControlNetSpeciaListActivity.launch(requireContext()) + } + } + + override fun initData() { + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/home/InstrumentFragment.kt b/app/src/main/java/com/project/survey/ui/home/InstrumentFragment.kt new file mode 100644 index 0000000..70bccb1 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/home/InstrumentFragment.kt @@ -0,0 +1,36 @@ +package com.project.survey.ui.home + +import android.content.Intent +import android.view.LayoutInflater +import android.view.ViewGroup +import com.bingce.device.ui.ConnectRtkActivity +import com.bingce.device.ui.ConnectTSActivity +import com.project.survey.databinding.FragmentInstrumentBinding +import com.project.survey.ui.base.BaseFragmentBinding +import com.project.survey.ui.instrument.satellitosis.SatelliteStatusActivity + +class InstrumentFragment : BaseFragmentBinding() { + override fun getViewBinding( + inflater: LayoutInflater, + container: ViewGroup? + ): FragmentInstrumentBinding { + return FragmentInstrumentBinding.inflate(inflater, container, false) + } + + override fun initView() { + mBinding.tvConnectTSActivity.setOnClickListener { + ConnectTSActivity.start(requireContext()) + } + mBinding.tvConnectRtkActivity.setOnClickListener { + ConnectRtkActivity.start(this) + } + mBinding.tvSatelliteStatusActivity.setOnClickListener { + startActivity(Intent(requireContext(), SatelliteStatusActivity::class.java)) + } + + + } + + override fun initData() { + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/fragment/home/MeFragment.kt b/app/src/main/java/com/project/survey/ui/home/MeFragment.kt similarity index 72% rename from app/src/main/java/com/project/survey/fragment/home/MeFragment.kt rename to app/src/main/java/com/project/survey/ui/home/MeFragment.kt index 872bc4c..e341f19 100644 --- a/app/src/main/java/com/project/survey/fragment/home/MeFragment.kt +++ b/app/src/main/java/com/project/survey/ui/home/MeFragment.kt @@ -1,12 +1,12 @@ -package com.project.survey.fragment.home +package com.project.survey.ui.home import android.content.Intent import android.view.LayoutInflater import android.view.ViewGroup -import com.project.survey.activity.login.LoginActivity -import com.project.survey.activity.project.ProjectListActivity import com.project.survey.databinding.FragmentMeBinding -import com.project.survey.fragment.base.BaseFragmentBinding +import com.project.survey.ui.base.BaseFragmentBinding +import com.project.survey.ui.login.LoginActivity +import com.project.survey.ui.project.ProjectListActivity class MeFragment : BaseFragmentBinding() { override fun getViewBinding( @@ -22,7 +22,7 @@ class MeFragment : BaseFragmentBinding() { startActivity(Intent(context, LoginActivity::class.java)) } - mBinding.tvCompany.setOnClickListener { + mBinding.llSwitchProject.setOnClickListener { startActivity(Intent(requireContext(), ProjectListActivity::class.java)) } diff --git a/app/src/main/java/com/project/survey/ui/instrument/satellitosis/SatelliteStatusActivity.java b/app/src/main/java/com/project/survey/ui/instrument/satellitosis/SatelliteStatusActivity.java new file mode 100644 index 0000000..c18f0ae --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/instrument/satellitosis/SatelliteStatusActivity.java @@ -0,0 +1,201 @@ +package com.project.survey.ui.instrument.satellitosis; + +import android.content.Intent; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; + +import com.bingce.device.Device; +import com.bingce.device.ui.databinding.ActivitySatelliteStatusBinding; +import com.bingce.rtk.command.RTK; +import com.bingce.rtk.command.geomax.GeoMaxRTK; +import com.bingce.rtk.enums.SateSystemEnum; +import com.bingce.rtk.model.GnssPosition; +import com.bingce.rtk.parser.nmea0183.SatInfo; +import com.bingce.rtk.parser.nmea0183.SatelliteData; +import com.project.survey.R; +import com.project.survey.ui.base.BaseSurveyNewActivity; + + +public class SatelliteStatusActivity extends BaseSurveyNewActivity { + private ActivitySatelliteStatusBinding binding; + + @Override + public View getContentView() { + binding = ActivitySatelliteStatusBinding.inflate(getLayoutInflater()); + return binding.getRoot(); + } + + @Override + protected void initView() { + } + + @Override + protected void initData() { + onSatelliteSkyViewRefresh(); + } + + + @Override + public void onPause() { + super.onPause(); + if (Device.getInstance().isDeviceConnected()) { + if (RTK.getInstance() instanceof GeoMaxRTK) { + ((GeoMaxRTK) RTK.getInstance()).stopOutputSatelliteInfo(); + } + } + } + + @Override + protected void onResume() { + super.onResume(); + if (Device.getInstance().isDeviceConnected() && RTK.getInstance() instanceof GeoMaxRTK) { + ((GeoMaxRTK) RTK.getInstance()).startOutputSatelliteInfo(); + } + } + + @Override + public void onSatelliteSkyViewRefresh() { + super.onSatelliteSkyViewRefresh(); + binding.activitySatelliteStatusSkyview.update(); + binding.activitySatelliteStatusViewSatelliteNumber.setText(String.format("%s %s", getString(R.string.tracked_satellite_number), GnssPosition.getInstance().getSatTrackNum())); + binding.activitySatelliteStatusSolutionSatelliteNumber.setText(String.format("%s %s", getString(R.string.solution_satellite_number), GnssPosition.getInstance().getSatSolutionNum())); + + StringBuilder systemResult = new StringBuilder(getString(R.string.satellite_system) + "\r\n"); + StringBuilder prnResult = new StringBuilder(getString(R.string.satellite_prn) + "\r\n"); + StringBuilder elevationResult = new StringBuilder(getString(R.string.satellite_elevation) + "\r\n"); + StringBuilder azimuthResult = new StringBuilder(getString(R.string.satellite_azimuth) + "\r\n"); + StringBuilder snrResult = new StringBuilder(getString(R.string.satellite_snr) + "\r\n"); + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.GPS) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "GPS"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.GLONASS) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "GLONASS"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.BDS) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "BDS"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.GALILEO) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "GALILEO"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.QZSS) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "QZSS"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.SBAS) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "SBAS"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.IRNSS) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "IRNSS"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + for (int i = 0; i < SatelliteData.getInstance().getSatInfoArray().size(); i++) { + SatInfo satInfo = SatelliteData.getInstance().getSatInfoArray().get(i); + if (satInfo.getSateSystem() == SateSystemEnum.OTHER) { + if (satInfo.getElevation() <= 0.0) continue; + double snr = satInfo.snrL1B1 != 0 ? satInfo.snrL1B1 : satInfo.snrL2B2 != 0 ? satInfo.snrL2B2 : satInfo.snrL5B3; + String systemName = "OTHER"; + systemResult.append(systemName + "\r\n"); + prnResult.append(satInfo.getPrn() + "\r\n"); + elevationResult.append(satInfo.getElevation() + "\r\n"); + azimuthResult.append(satInfo.getAzimuth() + "\r\n"); + snrResult.append(snr + "\r\n"); + } + } + + binding.activitySatelliteStatusSystem.setText(systemResult.toString()); + binding.activitySatelliteStatusPrn.setText(prnResult.toString()); + binding.activitySatelliteStatusAzimuth.setText(azimuthResult.toString()); + binding.activitySatelliteStatusElevation.setText(elevationResult.toString()); + binding.activitySatelliteStatusSnr.setText(snrResult.toString()); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_activity_satellite_system_switch, 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_satellite_system_switch: + Intent intent = new Intent(this, SatelliteSystemSwitchActivity.class); + startActivity(intent); + break; + } + return super.onOptionsItemSelected(item); + } + +} diff --git a/app/src/main/java/com/project/survey/ui/instrument/satellitosis/SatelliteSystemSwitchActivity.java b/app/src/main/java/com/project/survey/ui/instrument/satellitosis/SatelliteSystemSwitchActivity.java new file mode 100644 index 0000000..6e0666e --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/instrument/satellitosis/SatelliteSystemSwitchActivity.java @@ -0,0 +1,54 @@ +package com.project.survey.ui.instrument.satellitosis; + +import android.os.Bundle; +import android.view.MenuItem; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.bingce.device.Device; +import com.bingce.rtk.command.RtkCommand; +import com.bingce.rtk.gnss.Gnss; +import com.project.survey.R; +import com.project.survey.databinding.ActivitySatelliteSystemSwitchBinding; + +import org.polaric.colorful.ColorfulActivity; + +public class SatelliteSystemSwitchActivity extends ColorfulActivity { + + private ActivitySatelliteSystemSwitchBinding binding; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = ActivitySatelliteSystemSwitchBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + setSupportActionBar(binding.getRoot().findViewById(R.id.toolbar)); + if (getSupportActionBar() != null) + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + binding.switchGps.setChecked(Gnss.getInstance().getGps().isGpsEnable()); + binding.switchGlonass.setChecked(Gnss.getInstance().getGps().isGlonassEnable()); + binding.switchBeidou.setChecked(Gnss.getInstance().getGps().isBeidouEnable()); + binding.switchGalileo.setChecked(Gnss.getInstance().getGps().isGalileoEnable()); + binding.switchQzss.setChecked(Gnss.getInstance().getGps().isQzssEnable()); + binding.switchSbas.setChecked(Gnss.getInstance().getGps().isSbasEnable()); + binding.btnApply.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Device.getInstance().rtkSendCommand(RtkCommand.getInstance().setSatelliteSystem(true)); + } + }); + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + break; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/com/project/survey/ui/interfacee/IUIProvider.java b/app/src/main/java/com/project/survey/ui/interfacee/IUIProvider.java new file mode 100644 index 0000000..2d86b9c --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/interfacee/IUIProvider.java @@ -0,0 +1,11 @@ +package com.project.survey.ui.interfacee; + +import android.view.View; + +public interface IUIProvider { + int getLayoutId(); + + View getContentView(); + + boolean isShowTimeStatusBar(); +} diff --git a/app/src/main/java/com/project/survey/ui/lofting/LoftingListActivity.kt b/app/src/main/java/com/project/survey/ui/lofting/LoftingListActivity.kt new file mode 100644 index 0000000..3add398 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/lofting/LoftingListActivity.kt @@ -0,0 +1,46 @@ +package com.project.survey.ui.lofting + +import android.content.Context +import android.content.Intent +import com.project.survey.adapter.LoftingListAdapter +import com.project.survey.databinding.ActivityLoftingListBinding +import com.project.survey.model.LoftingListBean +import com.project.survey.ui.base.BaseBindingActivity +import com.project.survey.widget.decoration.TransparentDividerDecoration + +class LoftingListActivity : BaseBindingActivity() { + + private val adapter by lazy { LoftingListAdapter(this) } + + companion object { + fun launch(context: Context) { + context.startActivity(Intent(context, LoftingListActivity::class.java)) + } + } + + override fun getBinding(): ActivityLoftingListBinding { + return ActivityLoftingListBinding.inflate(layoutInflater) + } + + override fun initView() { + initAdapter() + + + } + + private fun initAdapter() { + mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(this)) + adapter.setOnItemClickListener { + + } + mBinding.recyclerView.setAdapter(adapter) + } + + override fun initData() { + val dataList = mutableListOf() + for (i in 0 until 3) { + dataList.add(LoftingListBean()) + } + adapter.refreshData(dataList) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/activity/login/ForgetPwdActivity.kt b/app/src/main/java/com/project/survey/ui/login/ForgetPwdActivity.kt similarity index 87% rename from app/src/main/java/com/project/survey/activity/login/ForgetPwdActivity.kt rename to app/src/main/java/com/project/survey/ui/login/ForgetPwdActivity.kt index f364bce..98bad79 100644 --- a/app/src/main/java/com/project/survey/activity/login/ForgetPwdActivity.kt +++ b/app/src/main/java/com/project/survey/ui/login/ForgetPwdActivity.kt @@ -1,8 +1,8 @@ -package com.project.survey.activity.login +package com.project.survey.ui.login import android.content.Intent import androidx.core.widget.addTextChangedListener -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivityForgetPwdBinding /** diff --git a/app/src/main/java/com/project/survey/activity/login/ForgetPwdInputCodeActivity.kt b/app/src/main/java/com/project/survey/ui/login/ForgetPwdInputCodeActivity.kt similarity index 85% rename from app/src/main/java/com/project/survey/activity/login/ForgetPwdInputCodeActivity.kt rename to app/src/main/java/com/project/survey/ui/login/ForgetPwdInputCodeActivity.kt index cb09a06..d2eb90a 100644 --- a/app/src/main/java/com/project/survey/activity/login/ForgetPwdInputCodeActivity.kt +++ b/app/src/main/java/com/project/survey/ui/login/ForgetPwdInputCodeActivity.kt @@ -1,7 +1,7 @@ -package com.project.survey.activity.login +package com.project.survey.ui.login import android.content.Intent -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivityForgetPwdInputCodeBinding /** diff --git a/app/src/main/java/com/project/survey/activity/login/LoginActivity.kt b/app/src/main/java/com/project/survey/ui/login/LoginActivity.kt similarity index 95% rename from app/src/main/java/com/project/survey/activity/login/LoginActivity.kt rename to app/src/main/java/com/project/survey/ui/login/LoginActivity.kt index dc93057..df9e7b2 100644 --- a/app/src/main/java/com/project/survey/activity/login/LoginActivity.kt +++ b/app/src/main/java/com/project/survey/ui/login/LoginActivity.kt @@ -1,9 +1,9 @@ -package com.project.survey.activity.login +package com.project.survey.ui.login import android.content.Intent import android.view.View import com.project.survey.R -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivityLoginBinding import com.project.survey.util.Tools diff --git a/app/src/main/java/com/project/survey/activity/login/LoginInputCodeActivity.kt b/app/src/main/java/com/project/survey/ui/login/LoginInputCodeActivity.kt similarity index 82% rename from app/src/main/java/com/project/survey/activity/login/LoginInputCodeActivity.kt rename to app/src/main/java/com/project/survey/ui/login/LoginInputCodeActivity.kt index f4c44f7..344f378 100644 --- a/app/src/main/java/com/project/survey/activity/login/LoginInputCodeActivity.kt +++ b/app/src/main/java/com/project/survey/ui/login/LoginInputCodeActivity.kt @@ -1,7 +1,7 @@ -package com.project.survey.activity.login +package com.project.survey.ui.login import android.util.Log -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivityLoginInputCodeBinding class LoginInputCodeActivity : BaseBindingActivity() { diff --git a/app/src/main/java/com/project/survey/activity/login/SetNewPwdActivity.kt b/app/src/main/java/com/project/survey/ui/login/SetNewPwdActivity.kt similarity index 78% rename from app/src/main/java/com/project/survey/activity/login/SetNewPwdActivity.kt rename to app/src/main/java/com/project/survey/ui/login/SetNewPwdActivity.kt index c511a11..ef9d2f4 100644 --- a/app/src/main/java/com/project/survey/activity/login/SetNewPwdActivity.kt +++ b/app/src/main/java/com/project/survey/ui/login/SetNewPwdActivity.kt @@ -1,6 +1,6 @@ -package com.project.survey.activity.login +package com.project.survey.ui.login -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivitySetNewPwdBinding /** diff --git a/app/src/main/java/com/project/survey/ui/pointmeasure/PointMeasureListActivity.kt b/app/src/main/java/com/project/survey/ui/pointmeasure/PointMeasureListActivity.kt new file mode 100644 index 0000000..c7e9153 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/pointmeasure/PointMeasureListActivity.kt @@ -0,0 +1,78 @@ +package com.project.survey.ui.pointmeasure + +import android.content.Context +import android.content.Intent +import android.view.View +import androidx.core.os.bundleOf +import com.project.survey.R +import com.project.survey.databinding.ActivityPointMeasureListBinding +import com.project.survey.ui.base.BaseBindingActivity + +/** + * 点测量列表 + */ +class PointMeasureListActivity : BaseBindingActivity() { + + companion object { + const val KEY_TYPE = "KEY_TYPE" + const val TYPE_ALL = "TYPE_ALL"//全部 + const val TYPE_SURVEY_PLAN = "TYPE_SURVEY_PLAN"//测量计划 + const val TYPE_PROJECT_MEASURE = "TYPE_PROJECT_MEASURE"//工程计量 + + fun launch(context: Context) { + context.startActivity(Intent(context, PointMeasureListActivity::class.java)) + } + } + + override fun getBinding(): ActivityPointMeasureListBinding { + return ActivityPointMeasureListBinding.inflate(layoutInflater) + } + + override fun initView() { + initListener() + + + } + + private fun initListener() { + mBinding.tvAll.setOnClickListener { + loadFirstPage() + } + mBinding.tvSurveyPlan.setOnClickListener { + setBtnSelected(mBinding.tvSurveyPlan) + switchFragment(TYPE_SURVEY_PLAN) + } + mBinding.tvProjectMeasured.setOnClickListener { + setBtnSelected(mBinding.tvProjectMeasured) + switchFragment(TYPE_PROJECT_MEASURE) + } + } + + private fun switchFragment(type: String) { + val frament = PointMeasureListFragment() + frament.arguments = bundleOf(KEY_TYPE to type) + + val transaction = supportFragmentManager.beginTransaction() + transaction.replace(R.id.container, frament) + transaction.commit() + } + + override fun initData() { + loadFirstPage() + } + + + private fun loadFirstPage() { + setBtnSelected(mBinding.tvAll) + switchFragment(TYPE_ALL) + } + + private fun setBtnSelected(view: View) { + mBinding.tvAll.isSelected = false + mBinding.tvSurveyPlan.isSelected = false + mBinding.tvProjectMeasured.isSelected = false + + view.isSelected = true + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/ui/pointmeasure/PointMeasureListFragment.kt b/app/src/main/java/com/project/survey/ui/pointmeasure/PointMeasureListFragment.kt new file mode 100644 index 0000000..f8c94e0 --- /dev/null +++ b/app/src/main/java/com/project/survey/ui/pointmeasure/PointMeasureListFragment.kt @@ -0,0 +1,49 @@ +package com.project.survey.ui.pointmeasure + +import android.view.LayoutInflater +import android.view.ViewGroup +import com.project.survey.adapter.PointMeasureListAdapter +import com.project.survey.databinding.FragmentPointMeasureListBinding +import com.project.survey.model.PointMeasureListBean +import com.project.survey.ui.base.BaseFragmentBinding +import com.project.survey.widget.decoration.TransparentDividerDecoration + +class PointMeasureListFragment : BaseFragmentBinding() { + + private val adapter by lazy { + PointMeasureListAdapter( + requireContext(), + getType() + ) + } + + override fun getViewBinding( + inflater: LayoutInflater, + container: ViewGroup? + ): FragmentPointMeasureListBinding { + return FragmentPointMeasureListBinding.inflate(inflater, container, false) + } + + override fun initView() { + initAdapter() + + } + + private fun initAdapter() { + mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(requireContext())) + adapter.setOnItemClickListener { + + } + mBinding.recyclerView.setAdapter(adapter) + } + + override fun initData() { + val dataList = mutableListOf() + for (i in 0 until 3) { + dataList.add(PointMeasureListBean()) + } + adapter.refreshData(dataList) + } + + private fun getType() = getArgumentString(PointMeasureListActivity.KEY_TYPE) +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/activity/project/ProjectListActivity.kt b/app/src/main/java/com/project/survey/ui/project/ProjectListActivity.kt similarity index 92% rename from app/src/main/java/com/project/survey/activity/project/ProjectListActivity.kt rename to app/src/main/java/com/project/survey/ui/project/ProjectListActivity.kt index 7d9ef39..c9f393e 100644 --- a/app/src/main/java/com/project/survey/activity/project/ProjectListActivity.kt +++ b/app/src/main/java/com/project/survey/ui/project/ProjectListActivity.kt @@ -1,10 +1,10 @@ -package com.project.survey.activity.project +package com.project.survey.ui.project import androidx.fragment.app.Fragment import com.bingce.ui.TabEntity import com.flyco.tablayout.listener.CustomTabEntity import com.project.survey.R -import com.project.survey.activity.base.BaseBindingActivity +import com.project.survey.ui.base.BaseBindingActivity import com.project.survey.databinding.ActivityProjectListBinding class ProjectListActivity : BaseBindingActivity() { diff --git a/app/src/main/java/com/project/survey/activity/project/ProjectListFragment.kt b/app/src/main/java/com/project/survey/ui/project/ProjectListFragment.kt similarity index 94% rename from app/src/main/java/com/project/survey/activity/project/ProjectListFragment.kt rename to app/src/main/java/com/project/survey/ui/project/ProjectListFragment.kt index acbefd6..4e1fcef 100644 --- a/app/src/main/java/com/project/survey/activity/project/ProjectListFragment.kt +++ b/app/src/main/java/com/project/survey/ui/project/ProjectListFragment.kt @@ -1,4 +1,4 @@ -package com.project.survey.activity.project +package com.project.survey.ui.project import android.view.LayoutInflater import android.view.ViewGroup @@ -6,7 +6,7 @@ import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import com.project.survey.adapter.ProjectListAdapter import com.project.survey.databinding.FragmentProjectListBinding -import com.project.survey.fragment.base.BaseFragmentBinding +import com.project.survey.ui.base.BaseFragmentBinding import com.project.survey.model.ProjectBean import com.project.survey.widget.decoration.HorDividerDecoration diff --git a/app/src/main/java/com/project/survey/util/AnimUtil.java b/app/src/main/java/com/project/survey/util/AnimUtil.java new file mode 100644 index 0000000..f523aa5 --- /dev/null +++ b/app/src/main/java/com/project/survey/util/AnimUtil.java @@ -0,0 +1,103 @@ +package com.project.survey.util; + +import android.animation.Animator; +import android.animation.ValueAnimator; +import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; + +/** + * 动画工具类 + * UpdateListener: 动画过程中通过添加此监听来回调数据 + * EndListener: 动画结束的时候通过此监听器来做一些处理 + */ +public class AnimUtil { + + private ValueAnimator valueAnimator; + private UpdateListener updateListener; + private EndListener endListener; + private long duration; + private float start; + private float end; + private Interpolator interpolator = new LinearInterpolator(); + + public AnimUtil() { + duration = 1000; //默认动画时常1s + start = 0.0f; + end = 1.0f; + interpolator = new LinearInterpolator();// 匀速的插值器 + } + + + public void setDuration(int timeLength) { + duration = timeLength; + } + + public void setValueAnimator(float start, float end, long duration) { + + this.start = start; + this.end = end; + this.duration = duration; + + } + + public void setInterpolator(Interpolator interpolator) { + this.interpolator = interpolator; + } + + public void startAnimator() { + if (valueAnimator != null){ + valueAnimator = null; + } + valueAnimator = ValueAnimator.ofFloat(start, end); + valueAnimator.setDuration(duration); + valueAnimator.setInterpolator(interpolator); + valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + + if (updateListener == null) { + return; + } + + float cur = (float) valueAnimator.getAnimatedValue(); + updateListener.progress(cur); + } + }); + valueAnimator.addListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animator) {} + @Override + public void onAnimationEnd(Animator animator) { + if(endListener == null){ + return; + } + endListener.endUpdate(animator); + } + @Override + public void onAnimationCancel(Animator animator) {} + + @Override + public void onAnimationRepeat(Animator animator) {} + }); + valueAnimator.start(); + } + + public void addUpdateListener(UpdateListener updateListener) { + + this.updateListener = updateListener; + } + + public void addEndListner(EndListener endListener){ + this.endListener = endListener; + } + + public interface EndListener { + void endUpdate(Animator animator); + } + + public interface UpdateListener { + + void progress(float progress); + } + +} diff --git a/app/src/main/java/com/project/survey/util/BaseSurveyActivityUtils.java b/app/src/main/java/com/project/survey/util/BaseSurveyActivityUtils.java new file mode 100644 index 0000000..d0bc728 --- /dev/null +++ b/app/src/main/java/com/project/survey/util/BaseSurveyActivityUtils.java @@ -0,0 +1,199 @@ +package com.project.survey.util; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; + +import com.bingce.autounit.TextFactory; +import com.bingce.device.Device; +import com.bingce.device.enums.DeviceTypeEnum; +import com.bingce.rtk.enums.WorkModeEnum; +import com.bingce.rtk.gnss.Gnss; +import com.bingce.rtk.model.GnssPosition; +import com.bingce.surveyorBase.databinding.ActivityBaseSurveyNewBinding; +import com.bingce.totalstation.TotalStation; +import com.bingce.totalstation.TsConfig; +import com.bingce.totalstation.enums.SetupStationModeEnum; +import com.bingce.utils.Util; +import com.gyf.immersionbar.ImmersionBar; +import com.project.survey.R; +import com.project.survey.ui.interfacee.IUIProvider; + +import java.util.Locale; + +import blankj.utilcode.util.Utils; + +public class BaseSurveyActivityUtils { + public ActivityBaseSurveyNewBinding activityBaseSurveyBinding; + public final AppCompatActivity activity; + private final IUIProvider uiProvider; + private final int onRootSetBackgroundColor; + + public BaseSurveyActivityUtils(AppCompatActivity activity, IUIProvider uiProvider, int onRootSetBackgroundColor) { + this.activity = activity; + this.uiProvider = uiProvider; + this.onRootSetBackgroundColor = onRootSetBackgroundColor; + } + + public void onCreate() { + SystemUtils.SystemVerticalScreen(activity); + activityBaseSurveyBinding = ActivityBaseSurveyNewBinding.inflate(activity.getLayoutInflater()); + activity.setContentView(activityBaseSurveyBinding.getRoot()); + int layoutId = uiProvider.getLayoutId(); + View contentView = uiProvider.getContentView(); + if (contentView == null && layoutId > 0) { + contentView = LayoutInflater.from(activity).inflate(layoutId, activityBaseSurveyBinding.baseView, false); + } + if (contentView != null) { + activityBaseSurveyBinding.baseView.addView(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + } + + if (onRootSetBackgroundColor == -1) { + if (!uiProvider.isShowTimeStatusBar()) { + ImmersionBar.with(activity).fitsSystemWindows(true).statusBarDarkFont(false).init(); + } else { + ImmersionBar.with(activity).fitsSystemWindows(true).statusBarDarkFont(true).init(); + } + } else { + ImmersionBar.with(activity).fitsSystemWindows(true).statusBarDarkFont(true).init(); + } + + activityBaseSurveyBinding.rlBack.setOnClickListener(v -> { + activity.onBackPressed(); + }); + + resetTopStatus(); + } + + public void resetTopStatus() { + if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) { + if (TsConfig.getInstance().getSetupStationMethod().getMode() == SetupStationModeEnum.ON_TOTAL_STATION) { + activityBaseSurveyBinding.tvSolutionState.setVisibility(View.GONE); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.GONE); + activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.GONE); + activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.GONE); + activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.GONE); + activityBaseSurveyBinding.tvPowerNum.setVisibility(View.GONE); + } else { + activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvPowerNum.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.pivPowerIcon.setProgress(0); + activityBaseSurveyBinding.pivPowerIcon.setTextSize(0); + activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", Util.radianToDmsString(0, 0, true))); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", Util.radianToDmsString(0, 0, true))); + activityBaseSurveyBinding.tvRtkStatusHrms.setText(String.format("Hd %s", Util.formatDouble2String(0, 3))); + activityBaseSurveyBinding.tvRtkStatusVrms.setText(String.format("Sd %s", Util.formatDouble2String(0, 3))); + } + activityBaseSurveyBinding.tvPoleHighHr.setText("0.000m"); + activityBaseSurveyBinding.ivPoleHighHr.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.icon_hr_high_white)); + activityBaseSurveyBinding.ivRtkStatusSatellite.setImageDrawable(ContextCompat.getDrawable(activity, R.mipmap.icon_edm_np)); + activityBaseSurveyBinding.tvRtkStatusSatellite.setText(R.string.laser); + } else { + activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvPowerNum.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvSolutionState.setText(""); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(""); + activityBaseSurveyBinding.tvRtkStatusHrms.setText(Utils.getApp().getString(com.bingce.surveyorBase.R.string.no_data)); + activityBaseSurveyBinding.tvRtkStatusVrms.setText(Utils.getApp().getString(com.bingce.surveyorBase.R.string.no_delay)); + activityBaseSurveyBinding.tvPoleHighHr.setText("0.000m"); + activityBaseSurveyBinding.tvPowerNum.setText("0%"); + activityBaseSurveyBinding.ivPoleHighHr.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.icon_pole_high_white)); + activityBaseSurveyBinding.ivRtkStatusSatellite.setImageDrawable(ContextCompat.getDrawable(activity, R.mipmap.icon_home_satellite)); + activityBaseSurveyBinding.tvRtkStatusSatellite.setText(String.format("%s %s/%s", Utils.getApp().getString(com.bingce.surveyorBase.R.string.satellite), 0, 0)); + activityBaseSurveyBinding.pivPowerIcon.setProgress(0); + activityBaseSurveyBinding.pivPowerIcon.setTextSize(0); + } + } + + public void refreshRtkStatus() { + if (Device.getInstance().deviceType != DeviceTypeEnum.DEVICE_TYPE_RTK) + return; + if (!Device.getInstance().isDeviceConnected()) { + activityBaseSurveyBinding.llRtkStatus.setVisibility(View.GONE); + return; + } + if (Gnss.getInstance().getDevice().getWorkMode() == WorkModeEnum.STATIC) { + activityBaseSurveyBinding.tvSolutionState.setText(R.string.static_mode); + } else { + activityBaseSurveyBinding.tvSolutionState.setText(GnssPosition.getInstance().getSolutionState()); + } + switch (Gnss.getInstance().getDevice().getWorkMode()) { + case ROVER: + case BASE: + if (Gnss.getInstance().getDevice().getWorkMode() == WorkModeEnum.BASE) { + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.GONE); + } else { + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE); + } + activityBaseSurveyBinding.tvRtkStatusHrms.setText(TextFactory.distanceFormatDouble2String("H: ", GnssPosition.getInstance().getHrms(), 3)); + activityBaseSurveyBinding.tvRtkStatusVrms.setText(TextFactory.distanceFormatDouble2String("V: ", GnssPosition.getInstance().getVrms(), 3)); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format(Locale.US, "%s%s", "延迟" + " ", GnssPosition.getInstance().getDiffAge())); + activityBaseSurveyBinding.tvRtkStatusSatellite.setText(String.format(Locale.US, "%s %s/%s", activity.getString(R.string.satellite), GnssPosition.getInstance().getSatSolutionNum(), GnssPosition.getInstance().getSatTrackNum())); + break; + case STATIC: + activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.GONE); + activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.GONE); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.GONE); + activityBaseSurveyBinding.tvRtkStatusSatellite.setVisibility(View.GONE); + break; + } + if (Gnss.getInstance().getDevice().getPowerLevel2() >= 0) { + int title_num = Gnss.getInstance().getDevice().getPowerLevel() + Gnss.getInstance().getDevice().getPowerLevel2(); + activityBaseSurveyBinding.pivPowerIcon.setProgress(Math.round(title_num / 2f)); + activityBaseSurveyBinding.tvPowerNum.setText(Math.round(title_num / 2f) + "%"); + } else if (Gnss.getInstance().getDevice().getPowerLevel() >= 0) { + activityBaseSurveyBinding.pivPowerIcon.setProgress(Gnss.getInstance().getDevice().getPowerLevel()); + activityBaseSurveyBinding.tvPowerNum.setText(Gnss.getInstance().getDevice().getPowerLevel() + "%"); + } + activityBaseSurveyBinding.pivPowerIcon.setTextSize(0); + } + + public void refreshHaVa(double originalHa, double originalVa) { + activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE); + if (TotalStation.getInstance().getOriginalHa() >= 0) { + activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", Util.radianToDmsString(originalHa, 0, true))); + } else { + activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", activity.getString(R.string.tilt_over))); + } + if (TotalStation.getInstance().getOriginalVa() >= 0) { + activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", Util.radianToDmsString(originalVa, 0, true))); + } else { + activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", activity.getString(R.string.tilt_over))); + } + } + + public void onMeasSdAngleSuccess(double originalHa, double originalVa, double sd, double clockwiseHa, double topVa, double hd, double vd) { + activityBaseSurveyBinding.tvSolutionState.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusHrms.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvRtkStatusVrms.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.pivPowerIcon.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvPowerNum.setVisibility(View.VISIBLE); + activityBaseSurveyBinding.tvSolutionState.setText(String.format("Ha %s", Util.radianToDmsString(originalHa, 0, true))); + activityBaseSurveyBinding.tvRtkStatusDiffAge.setText(String.format("Va %s", Util.radianToDmsString(originalVa, 0, true))); + activityBaseSurveyBinding.tvRtkStatusHrms.setText(String.format("Hd %s", Util.formatDouble2String(hd, 3))); + activityBaseSurveyBinding.tvRtkStatusVrms.setText(String.format("Sd %s", Util.formatDouble2String(sd, 3))); + } + + public void refreshBatteryLevel(double percent) { + if (percent >= 0) { + int title_num = TotalStation.getInstance().getPowerLevel() + TotalStation.getInstance().getPowerLevel2(); + activityBaseSurveyBinding.pivPowerIcon.setProgress(Math.round(title_num / 2f)); + activityBaseSurveyBinding.tvPowerNum.setText(String.format(Locale.US, "%d%%", Math.round(title_num / 2f))); + } else { + activityBaseSurveyBinding.pivPowerIcon.setTextSize(0); + } + } +} diff --git a/app/src/main/java/com/project/survey/util/CountDownUtils.java b/app/src/main/java/com/project/survey/util/CountDownUtils.java new file mode 100644 index 0000000..e255285 --- /dev/null +++ b/app/src/main/java/com/project/survey/util/CountDownUtils.java @@ -0,0 +1,110 @@ +package com.project.survey.util; + +import android.graphics.Color; +import android.util.Log; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleEventObserver; +import androidx.lifecycle.LifecycleOwner; + +import com.bingce.event.CountDownEvent; +import com.bingce.utils.ActivityProviderUtils; +import com.bingce.utils.ColorUtil; +import com.bingce.utils.IProvider; +import com.bingce.utils.SdkUtils; +import com.bingce.utils.VipManager; +import com.daimajia.numberprogressbar.NumberProgressBar; +import com.project.survey.R; +import com.project.survey.ui.base.BaseSurveyNewActivity; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import blankj.utilcode.util.Utils; + +public class CountDownUtils extends ActivityProviderUtils { + public interface ICountDownSwitcher { + //是否启动倒计时 + boolean isVipCountDownOpen(); + } + + private final ICountDownSwitcher mSwitcher; + + public CountDownUtils(IProvider activityIProvider) { + this(activityIProvider, () -> true); + } + + public CountDownUtils(IProvider activityIProvider, ICountDownSwitcher switcher) { + super(activityIProvider); + activity().getLifecycle().addObserver(new LifecycleEventObserver() { + @Override + public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) { + switch (event) { + case ON_CREATE: + EventBus.getDefault().register(CountDownUtils.this); + break; + case ON_DESTROY: + EventBus.getDefault().unregister(CountDownUtils.this); + break; + } + } + }); + mSwitcher = switcher; + } + + public void refresh(CountDownEvent event) { + if (mSwitcher != null && !mSwitcher.isVipCountDownOpen()) return; + Log.d("CountDownUtils", "vipinfo refresh:" + "needRefresh:" + event.isNeedRefresh()); + if (activity() instanceof BaseSurveyNewActivity) { + NumberProgressBar cutDownProgressBar = ((BaseSurveyNewActivity) activity()).baseSurveyActivityUtils.activityBaseSurveyBinding.cutDownProgressbar; + if (!SdkUtils.isRegCodeValidate() && SdkUtils.isVipValidate()) { + cutDownProgressBar.setVisibility(View.VISIBLE); + int maxProgress = (int) (SdkUtils.availableTimeMax() / 60 / 1000L); + cutDownProgressBar.setMax(maxProgress); + int progress = Math.max((int) (SdkUtils.availableTime() / 60 / 1000L), 0);//可用时间可能小于0 + cutDownProgressBar.setProgress(progress); + if (progress < 60) { + cutDownProgressBar.setPrefix(getString(R.string.remaining_offline_time) + progress + getString(R.string.minute) + " "); + } else { + cutDownProgressBar.setPrefix(getString(R.string.remaining_offline_time) + progress / 60 + getString(R.string.hour) + progress % 60 + getString(R.string.minute) + " "); + } + if (event.isNeedRefresh()) { +// VipManager.getInstance().surveyorSdkRefresh(activity(), ((App) Utils.getApp()).registerCodeV2, null); + } + if (progress == 240 || progress == 180 || progress == 120 || progress == 60 || (progress > 0 && progress < 60 && progress % 10 == 0)) { + new AlertDialog.Builder(/*this*/activity()) + .setTitle(R.string.warning) + .setMessage(getString(R.string.remaining_offline_time) + progress + getString(R.string.minute) + "," + getString(R.string.the_network_reboot_software_can_reset_the_remaining_time_offline)) + .setPositiveButton(R.string.i_know, null) + .show(); + } + if (progress > 240) {//离线时间大于4小时,主题色显示 + cutDownProgressBar.setProgressTextColor(ColorUtil.getColorPrimary(/*this*/activity())); + cutDownProgressBar.setReachedBarColor(ColorUtil.getColorPrimary(/*this*/activity())); + cutDownProgressBar.setUnreachedBarColor(ColorUtil.getColorPrimary(/*this*/activity())); + } else if (progress > 120) {//离线时间2-5小时间显示橙色警告 + cutDownProgressBar.setProgressTextColor(ContextCompat.getColor(/*this*/activity(), R.color.md_orange_800)); + cutDownProgressBar.setReachedBarColor(ContextCompat.getColor(/*this*/activity(), R.color.md_orange_800)); + cutDownProgressBar.setUnreachedBarColor(ContextCompat.getColor(/*this*/activity(), R.color.md_orange_800)); + } else {//离线时间小于2小时红色警告 + cutDownProgressBar.setProgressTextColor(Color.RED); + cutDownProgressBar.setReachedBarColor(Color.RED); + cutDownProgressBar.setUnreachedBarColor(Color.RED); + } + } else { + cutDownProgressBar.setVisibility(View.GONE); + } + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onMessageEvent(CountDownEvent event) { + refresh(event); + } +} diff --git a/app/src/main/java/com/project/survey/util/DisplayUtils.java b/app/src/main/java/com/project/survey/util/DisplayUtils.java new file mode 100644 index 0000000..afc557d --- /dev/null +++ b/app/src/main/java/com/project/survey/util/DisplayUtils.java @@ -0,0 +1,41 @@ +package com.project.survey.util; + +import blankj.utilcode.util.Utils; + +public class DisplayUtils { + /** + * dp 转成 px + * @return + */ + public static int dip2px(float dpVale) { + final float scale = (Utils.getApp()).getResources().getDisplayMetrics().density; + return (int) (dpVale * scale + 0.5f); + } + + /** + * px 转 dp + * @return + */ + public static int px2dip(float pxValue) { + final float scale = (Utils.getApp()).getResources().getDisplayMetrics().density; + return (int) (pxValue / scale + 0.5f); + } + + /** + * px 转 sp + * @return + */ + public static int px2sp(float pxValue) { + final float fontScale = (Utils.getApp()).getResources().getDisplayMetrics().scaledDensity; + return (int) (pxValue / fontScale + 0.5F); + } + + /** + * sp 转 px + * @return + */ + public static int sp2px(float spValue) { + final float fontScale = (Utils.getApp()).getResources().getDisplayMetrics().scaledDensity; + return (int) (spValue * fontScale + 0.5F); + } +} diff --git a/app/src/main/java/com/project/survey/util/DrawableUtils.java b/app/src/main/java/com/project/survey/util/DrawableUtils.java index e8512bd..ab407f3 100644 --- a/app/src/main/java/com/project/survey/util/DrawableUtils.java +++ b/app/src/main/java/com/project/survey/util/DrawableUtils.java @@ -1,640 +1,201 @@ -/* - * Copyright (C) 2019 xuexiangjys(xuexiangjys@163.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package com.project.survey.util; -import android.content.Context; +import static blankj.utilcode.util.ResourceUtils.getDrawable; + +import android.annotation.SuppressLint; import android.content.res.ColorStateList; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.ColorFilter; -import android.graphics.LightingColorFilter; -import android.graphics.Matrix; -import android.graphics.Paint; -import android.graphics.PixelFormat; -import android.graphics.Rect; -import android.graphics.RectF; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.LayerDrawable; -import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.StateListDrawable; import android.view.View; -import android.webkit.WebView; import android.widget.ImageView; -import android.widget.ScrollView; +import android.widget.TextView; -import androidx.annotation.ColorInt; -import androidx.annotation.DrawableRes; -import androidx.annotation.FloatRange; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.content.res.AppCompatResources; import androidx.core.graphics.drawable.DrawableCompat; -import androidx.core.widget.NestedScrollView; - -import java.security.InvalidParameterException; -/** - * Drawable工具类 - * - * @author xuexiang - * @since 2019/1/3 下午3:47 - */ -public final class DrawableUtils { - - private DrawableUtils() { - throw new UnsupportedOperationException("u can't instantiate me..."); - } +import com.project.survey.R; - private static final String TAG = DrawableUtils.class.getSimpleName(); +import blankj.utilcode.util.Utils; +public class DrawableUtils { /** - * 节省每次创建时产生的开销,但要注意多线程操作synchronized - */ - private static final Canvas CANVAS = new Canvas(); - - /** - * 从一个view创建Bitmap。 - * 注意点:绘制之前要清掉 View 的焦点,因为焦点可能会改变一个 View 的 UI 状态。 - * 来源:https://github.com/tyrantgit/ExplosionField + * 对目标Drawable 进行着色 * - * @param view 传入一个 View,会获取这个 View 的内容创建 Bitmap。 - * @param scale 缩放比例,对创建的 Bitmap 进行缩放,数值支持从 0 到 1。 - */ - public static Bitmap createBitmapFromView(View view, float scale) { - if (view instanceof ImageView) { - Drawable drawable = ((ImageView) view).getDrawable(); - if (drawable != null && drawable instanceof BitmapDrawable) { - return ((BitmapDrawable) drawable).getBitmap(); - } - } - view.clearFocus(); - int viewHeight = 0; - if (view instanceof ScrollView) { - for (int i = 0; i < ((ScrollView) view).getChildCount(); i++) { - viewHeight += ((ScrollView) view).getChildAt(i).getHeight(); - } - } else if (view instanceof NestedScrollView) { - for (int i = 0; i < ((NestedScrollView) view).getChildCount(); i++) { - viewHeight += ((NestedScrollView) view).getChildAt(i).getHeight(); - } - } else { - viewHeight = view.getHeight(); - } - - Bitmap bitmap = createBitmapSafely((int) (view.getWidth() * scale), - (int) (viewHeight * scale), Bitmap.Config.ARGB_8888, 1); - if (bitmap != null) { - synchronized (CANVAS) { - Canvas canvas = CANVAS; - canvas.setBitmap(bitmap); - canvas.save(); - // 防止 View 上面有些区域空白导致最终 Bitmap 上有些区域变黑 - canvas.drawColor(Color.WHITE); - canvas.scale(scale, scale); - view.draw(canvas); - canvas.restore(); - canvas.setBitmap(null); - } - } - return bitmap; - } - - - public static Bitmap createBitmapFromWebView(WebView view) { - return createBitmapFromWebView(view, 1f); - } - - public static Bitmap createBitmapFromWebView(WebView view, float scale) { - view.clearFocus(); - int viewHeight = (int) (view.getContentHeight() * view.getScale()); - Bitmap bitmap = createBitmapSafely((int) (view.getWidth() * scale), (int) (viewHeight * scale), Bitmap.Config.ARGB_8888, 1); - - int unitHeight = view.getHeight(); - int bottom = viewHeight; - - if (bitmap != null) { - synchronized (CANVAS) { - Canvas canvas = CANVAS; - canvas.setBitmap(bitmap); - // 防止 View 上面有些区域空白导致最终 Bitmap 上有些区域变黑 - canvas.drawColor(Color.WHITE); - canvas.scale(scale, scale); - while (bottom > 0) { - if (bottom < unitHeight) { - bottom = 0; - } else { - bottom -= unitHeight; - } - canvas.save(); - canvas.clipRect(0, bottom, canvas.getWidth(), bottom + unitHeight); - view.scrollTo(0, bottom); - view.draw(canvas); - canvas.restore(); - } - canvas.setBitmap(null); - } - } - return bitmap; - } - - - public static Bitmap createBitmapFromView(View view) { - return createBitmapFromView(view, 1f); - } - - /** - * 从一个view创建Bitmap。把view的区域截掉leftCrop/topCrop/rightCrop/bottomCrop + * @param drawable 目标Drawable + * @param color 着色的颜色值 + * @return 着色处理后的Drawable */ - public static Bitmap createBitmapFromView(View view, int leftCrop, int topCrop, int rightCrop, int bottomCrop) { - Bitmap originBitmap = DrawableUtils.createBitmapFromView(view); - if (originBitmap == null) { - return null; - } - Bitmap cutBitmap = createBitmapSafely(view.getWidth() - rightCrop - leftCrop, view.getHeight() - topCrop - bottomCrop, Bitmap.Config.ARGB_8888, 1); - if (cutBitmap == null) { - return null; - } - Canvas canvas = new Canvas(cutBitmap); - Rect src = new Rect(leftCrop, topCrop, view.getWidth() - rightCrop, view.getHeight() - bottomCrop); - Rect dest = new Rect(0, 0, view.getWidth() - rightCrop - leftCrop, view.getHeight() - topCrop - bottomCrop); - // 防止 View 上面有些区域空白导致最终 Bitmap 上有些区域变黑 - canvas.drawColor(Color.WHITE); - canvas.drawBitmap(originBitmap, src, dest, null); - originBitmap.recycle(); - return cutBitmap; + public static Drawable tintModifyColorDrawable(@NonNull Drawable drawable, int color) { + Drawable wrappedDrawable = DrawableCompat.wrap(drawable); + DrawableCompat.setTint(wrappedDrawable, color); + return wrappedDrawable; } /** - * 安全的创建bitmap。 - * 如果新建 Bitmap 时产生了 OOM,可以主动进行一次 GC - System.gc(),然后再次尝试创建。 + * 对目标Drawable 进行着色 * - * @param width Bitmap 宽度。 - * @param height Bitmap 高度。 - * @param config 传入一个 Bitmap.Config。 - * @param retryCount 创建 Bitmap 时产生 OOM 后,主动重试的次数。 - * @return 返回创建的 Bitmap。 + * @param drawable 目标(int) Drawable + * @param color 着色的颜色值 + * @return 着色处理后的Drawable */ - public static Bitmap createBitmapSafely(int width, int height, Bitmap.Config config, int retryCount) { - //width and height must be > 0 - if (width <= 0 || height <= 0) { - return null; - } - try { - return Bitmap.createBitmap(width, height, config); - } catch (OutOfMemoryError e) { - e.printStackTrace(); - if (retryCount > 0) { - System.gc(); - return createBitmapSafely(width, height, config, retryCount - 1); - } - return null; - } + public static Drawable tintModifyColorDrawable(@NonNull int drawable, int color) { + Drawable wrappedDrawable = DrawableCompat.wrap(getDrawable(drawable)); + DrawableCompat.setTint(wrappedDrawable, (Utils.getApp()).getResources().getColor(color)); + return wrappedDrawable; } - - /** - * 安全的创建bitmap。 - * 如果新建 Bitmap 时产生了 OOM,可以主动进行一次 GC - System.gc(),然后再次尝试创建。 + * 对目标Drawable 进行着色 * - * @param source 原图片 - * @param x 源中第一个像素的x坐标 - * @param y 源中第一个像素的y坐标 - * @param width 一行像素点的数量 - * @param height 行数 - * @param retryCount 创建 Bitmap 时产生 OOM 后,主动重试的次数。 - * @return 返回创建的 Bitmap。 + * @param drawable 目标Drawable + * @param colors 着色值 + * @return 着色处理后的Drawable */ - public static Bitmap createBitmapSafely(@NonNull Bitmap source, int x, int y, int width, int height, int retryCount) { - if (x < 0 || y < 0 || width <= 0 || height <= 0) { - return null; - } - try { - return Bitmap.createBitmap(source, x, y, width, height); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - return null; - } catch (OutOfMemoryError e) { - e.printStackTrace(); - if (retryCount > 0) { - System.gc(); - return createBitmapSafely(source, x, y, width, height, retryCount - 1); - } - return null; - } + public static Drawable tintListDrawable(@NonNull Drawable drawable, ColorStateList colors) { + Drawable wrappedDrawable = DrawableCompat.wrap(drawable); + // 进行着色 + DrawableCompat.setTintList(wrappedDrawable, colors); + return wrappedDrawable; } /** - * 创建一张指定大小的纯色图片,支持圆角 - * - * @param resources Resources对象,用于创建BitmapDrawable - * @param width 图片的宽度 - * @param height 图片的高度 - * @param cornerRadius 图片的圆角,不需要则传0 - * @param filledColor 图片的填充色 - * @return 指定大小的纯色图片 + * 修改矢量图标的颜色 + * @param imageView + * @param icVector */ - public static BitmapDrawable createDrawableWithSize(Resources resources, int width, int height, int cornerRadius, @ColorInt int filledColor) { - Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(output); - - if (filledColor == 0) { - filledColor = Color.TRANSPARENT; - } - if (cornerRadius > 0) { - Paint paint = new Paint(); - paint.setAntiAlias(true); - paint.setStyle(Paint.Style.FILL); - paint.setColor(filledColor); - canvas.drawRoundRect(new RectF(0, 0, width, height), cornerRadius, cornerRadius, paint); - } else { - canvas.drawColor(filledColor); - } - return new BitmapDrawable(resources, output); + public static void tintModifyColorVector(ImageView imageView, int icVector){ + tintModifyColorVector(imageView, icVector, R.color.theme_green); } - /** - * 设置Drawable的颜色 - * 这里不对Drawable进行mutate(),会影响到所有用到这个Drawable的地方,如果要避免,请先自行mutate() - */ - public static ColorFilter setDrawableTintColor(Drawable drawable, @ColorInt int tintColor) { - LightingColorFilter colorFilter = new LightingColorFilter(Color.argb(255, 0, 0, 0), tintColor); - if (drawable != null) { - drawable.setColorFilter(colorFilter); - } - return colorFilter; + public static void tintModifyColorVector(ImageView imageView, int icVector, int color){ + imageView.setImageDrawable(DrawableUtils.tintModifyColorDrawable(icVector, color)); } /** - * 创建一张渐变图片,支持韵脚。 - * - * @param startColor 渐变开始色 - * @param endColor 渐变结束色 - * @param radius 圆角大小 - * @param centerX 渐变中心点 X 轴坐标 - * @param centerY 渐变中心点 Y 轴坐标 - * @return 返回所创建的渐变图片。 + * 设置按压前后矢量图标的状态 + * @param imageView + * @param icVector */ - public static GradientDrawable createCircleGradientDrawable(@ColorInt int startColor, - @ColorInt int endColor, int radius, - @FloatRange(from = 0f, to = 1f) float centerX, - @FloatRange(from = 0f, to = 1f) float centerY) { - GradientDrawable gradientDrawable = new GradientDrawable(); - gradientDrawable.setColors(new int[]{ - startColor, - endColor - }); - gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); - gradientDrawable.setGradientRadius(radius); - gradientDrawable.setGradientCenter(centerX, centerY); - return gradientDrawable; + public static void setClickVectorEffect(ImageView imageView, int icVector){ + setClickVectorEffect(imageView, icVector, (Utils.getApp()).getResources().getColor(R.color.theme_green_press), (Utils.getApp()).getResources().getColor(R.color.theme_green)); } - - /** - * 动态创建带上分隔线或下分隔线的Drawable。 - * - * @param separatorColor 分割线颜色。 - * @param bgColor Drawable 的背景色。 - * @param top true 则分割线为上分割线,false 则为下分割线。 - * @return 返回所创建的 Drawable。 - */ - public static LayerDrawable createItemSeparatorBg(@ColorInt int separatorColor, @ColorInt int bgColor, int separatorHeight, boolean top) { - - ShapeDrawable separator = new ShapeDrawable(); - separator.getPaint().setStyle(Paint.Style.FILL); - separator.getPaint().setColor(separatorColor); - - ShapeDrawable bg = new ShapeDrawable(); - bg.getPaint().setStyle(Paint.Style.FILL); - bg.getPaint().setColor(bgColor); - - Drawable[] layers = {separator, bg}; - LayerDrawable layerDrawable = new LayerDrawable(layers); - - layerDrawable.setLayerInset(1, 0, top ? separatorHeight : 0, 0, top ? 0 : separatorHeight); - return layerDrawable; + public static void setClickVectorEffect(ImageView imageView, int icVector, int pressColor, int normalColor){ + //状态 + int[][] states = new int[2][]; + //按下 + states[0] = new int[] {android.R.attr.state_pressed}; + //默认 + states[1] = new int[] {}; + //状态对应颜色值(按下,默认) + int[] colors = new int[] {pressColor, normalColor}; + ColorStateList colorList = new ColorStateList(states, colors); + imageView.setImageDrawable(tintListDrawable(getDrawable(icVector),colorList)); } - /** - * 创建一张指定大小的圆形图片,并附带文字 - * - * @param resources Resources对象,用于创建BitmapDrawable - * @param size 图片的宽度 - * @param filledColor 图片的填充色 - * @param text 文字 - * @param textSize 文字大小(px) - * @param textColor 文字颜色 - * @return 指定大小的纯色图片 + * 设置按压前后文字的状态 + * @param textView + * 默认按压色白色,默认色为主题色 */ - public static BitmapDrawable createCircleDrawableWithText(Resources resources, int size, @ColorInt int filledColor, String text, float textSize, @ColorInt int textColor) { - if (size <= 0) { - throw new InvalidParameterException("bitmap size must be > 0!"); - } - if (textSize <= 0) { - throw new InvalidParameterException("text size must be > 0!"); - } - Bitmap output = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(output); - canvas.drawColor(Color.TRANSPARENT); - // 画圆 - int radius = size / 2; - Paint paint = new Paint(); - paint.setAntiAlias(true); - paint.setStyle(Paint.Style.FILL); - paint.setColor(filledColor); - canvas.drawCircle(radius, radius, radius, paint); - // 画文字 - paint.setColor(textColor); - paint.setTextSize(textSize); - paint.setTextAlign(Paint.Align.CENTER); - float baseline = radius + getBaselineDistance(paint); - canvas.drawText(text, radius, baseline, paint); - return new BitmapDrawable(resources, output); + public static void setClickTextEffect(TextView textView){ + setClickTextEffect(textView, R.color.theme_green_press, R.color.theme_green); } - /** - * 获取画笔的基线距离 - * - * @param paint 画笔 - * @return 基线距离 - */ - public static float getBaselineDistance(@NonNull Paint paint) { - Paint.FontMetrics fontMetrics = paint.getFontMetrics(); - return (fontMetrics.bottom - fontMetrics.top) / 2 - fontMetrics.bottom; + public static void setClickTextEffect(TextView textView, int pressColor, int normalColor){ + //状态 + int[][] states = new int[2][]; + //按下 + states[0] = new int[] {android.R.attr.state_pressed}; + //默认 + states[1] = new int[] {}; + //状态对应颜色值(按下,默认) + int[] colors = new int[] {(Utils.getApp()).getResources().getColor(pressColor), (Utils.getApp()).getResources().getColor(normalColor)}; + ColorStateList colorList = new ColorStateList(states, colors); + textView.setTextColor(colorList); } - /////////////// StateListDrawable ///////////////////// - /** - * 实体 得到随机色 状态选择器 - * - * @param cornerRadius 圆角半径 - * @return 状态选择器 + * 设置按压前后View的状态 + * @param view */ - public static StateListDrawable getDrawable(int cornerRadius) { - return getDrawable(cornerRadius, ColorUtils.getRandomColor()); - } - /** - * 实体 按下的颜色加深 - * - * @param cornerRadius 圆角半径 - * @param normalColor 正常的颜色 - * @return 状态选择器 - */ + public static final int RADIUS_ALL = 0; + public static final int RADIUS_BOTTOM = RADIUS_ALL + 1; + public static final int RADIUS_LEFT = RADIUS_BOTTOM + 1; + public static final int RADIUS_RIGHT = RADIUS_LEFT + 1; + public static final int RADIUS_TOP = RADIUS_RIGHT + 1; - public static StateListDrawable getDrawable(int cornerRadius, int normalColor) { - return getDrawable(cornerRadius, ColorUtils.darker(normalColor, 0.8F), normalColor); + public static void setClickBackgroundEffect(View view){ + setClickBackgroundEffect(view, R.color.theme_green_press, R.color.theme_green,0, RADIUS_ALL); } - /** - * 实体 状态选择器 - * - * @param cornerRadius 圆角半径 - * @param pressedColor 按下颜色 - * @param normalColor 正常的颜色 - * @return 状态选择器 - */ - public static StateListDrawable getDrawable(int cornerRadius, int pressedColor, int normalColor) { - return getStateListDrawable(getSolidRectDrawable(cornerRadius, pressedColor), getSolidRectDrawable(cornerRadius, normalColor)); + public static void setClickBackgroundEffect(View view, int dpStroke){ + setClickBackgroundEffect(view, R.color.theme_green_press, R.color.theme_green, dpStroke, RADIUS_ALL); } - /** - * 背景选择器 - * - * @param pressedDrawable 按下状态的Drawable - * @param normalDrawable 正常状态的Drawable - * @return 状态选择器 - */ - public static StateListDrawable getStateListDrawable(Drawable pressedDrawable, Drawable normalDrawable) { - StateListDrawable stateListDrawable = new StateListDrawable(); - stateListDrawable.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, pressedDrawable); - stateListDrawable.addState(new int[]{android.R.attr.state_enabled}, normalDrawable); - //设置不能用的状态 - //默认其他状态背景 - GradientDrawable gray = getSolidRectDrawable(10, Color.GRAY); - stateListDrawable.addState(new int[]{}, gray); - return stateListDrawable; + public static void setClickBackgroundEffect(View view, int dpStroke, int radiusPosition){ + setClickBackgroundEffect(view, R.color.theme_green_press, R.color.theme_green, dpStroke, radiusPosition); } - /** - * 得到实心的drawable, 一般作为选中,点中的效果 - * - * @param cornerRadius 圆角半径 - * @param solidColor 实心颜色 - * @return 得到实心效果 - */ - public static GradientDrawable getSolidRectDrawable(int cornerRadius, int solidColor) { - GradientDrawable gradientDrawable = new GradientDrawable(); - // 设置矩形的圆角半径 - gradientDrawable.setCornerRadius(cornerRadius); - // 设置绘画图片色值 - gradientDrawable.setColor(solidColor); - // 绘画的是矩形 - gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); - return gradientDrawable; + public static void setClickBackgroundEffect(View view, int pressColor, int normalColor, int dpStroke){ + setClickBackgroundEffect(view, pressColor, normalColor, dpStroke, RADIUS_ALL); } - /** - * 给drawable上色 - * - * @param drawable 图像 - * @param tint 颜色 - * @return drawable - */ - public static Drawable setTint(final Drawable drawable, @ColorInt int tint) { - if (drawable != null) { - DrawableCompat.setTint(drawable, tint); - } - return drawable; - } + public static void setClickBackgroundEffect(View view, int pressColor, int normalColor, int dpStroke, int radiusPosition){ - /** - * 给drawable上色 - * - * @param drawable 图像 - * @param tint 颜色 - * @return drawable - */ - public static Drawable setTintList(final Drawable drawable, @Nullable ColorStateList tint) { - if (drawable != null) { - DrawableCompat.setTintList(drawable, tint); + int radiusLeftUpValue = 0; + int radiusLeftDownValue = 0; + int radiusRightUpValue = 0; + int radiusRightDownValue = 0; + switch (radiusPosition){ + case RADIUS_ALL: + radiusLeftUpValue = DisplayUtils.dip2px(dpStroke); + radiusLeftDownValue = DisplayUtils.dip2px(dpStroke); + radiusRightUpValue = DisplayUtils.dip2px(dpStroke); + radiusRightDownValue = DisplayUtils.dip2px(dpStroke); + break; + case RADIUS_LEFT: + radiusLeftUpValue = DisplayUtils.dip2px(dpStroke); + radiusLeftDownValue = DisplayUtils.dip2px(dpStroke); + break; + case RADIUS_RIGHT: + radiusRightUpValue = DisplayUtils.dip2px(dpStroke); + radiusRightDownValue = DisplayUtils.dip2px(dpStroke); + break; + case RADIUS_TOP: + radiusLeftUpValue = DisplayUtils.dip2px(dpStroke); + radiusRightUpValue = DisplayUtils.dip2px(dpStroke); + break; + case RADIUS_BOTTOM: + radiusLeftDownValue = DisplayUtils.dip2px(dpStroke); + radiusRightDownValue = DisplayUtils.dip2px(dpStroke); + break; } - return drawable; - } - - /////////////// VectorDrawable ///////////////////// - - @Nullable - public static Drawable getVectorDrawable(Context context, @DrawableRes int resVector) { - try { - return AppCompatResources.getDrawable(context, resVector); - } catch (Exception e) { - return null; - } - } - - public static Bitmap vectorDrawableToBitmap(Context context, @DrawableRes int resVector) { - Drawable drawable = getVectorDrawable(context, resVector); - if (drawable != null) { - return drawable2Bitmap(drawable); - } - return null; - } - - /////////////// VectorDrawable ///////////////////// - - /** - * 获取支持RTL布局的drawable【如果是RTL布局就旋转180度】 - * - * @param src 原drawable - * @return - */ - public static Drawable getSupportRTLDrawable(@NonNull Context context, Drawable src) { - return getSupportRTLDrawable(context, src, false); + Drawable normal,press; + StateListDrawable drawable = new StateListDrawable(); + press = DrawableUtils.setShapeColor((Utils.getApp()).getResources().getColor(pressColor),new float[]{radiusLeftUpValue,radiusLeftUpValue,radiusRightUpValue,radiusRightUpValue,radiusRightDownValue,radiusRightDownValue,radiusLeftDownValue,radiusLeftDownValue}); + normal = DrawableUtils.setShapeColor((Utils.getApp()).getResources().getColor(normalColor),new float[]{radiusLeftUpValue,radiusLeftUpValue,radiusRightUpValue,radiusRightUpValue,radiusRightDownValue,radiusRightDownValue,radiusLeftDownValue,radiusLeftDownValue}); + drawable.addState(new int[]{android.R.attr.state_pressed},press); + drawable.addState(new int[]{-android.R.attr.state_pressed},normal); + view.setBackgroundDrawable(drawable); } /** - * 获取支持RTL布局的drawable【如果是RTL布局就旋转180度】 + * 设置圆角背景 * - * @param context - * @param src 原drawable + * @param + * @param radii new float[] { r0, r0, r1, r1, r2, r2, r3,r3 } + * 设置图片四个角圆形半径:1、2两个参数表示左上角,3、4表示右上角,5、6表示右下角,7、8表示左下角 * @return */ - public static Drawable getSupportRTLDrawable(@NonNull Context context, Drawable src, boolean recycle) { - if (ResUtils.isRtl(context)) { - return rotate(src, 180, 0, 0, recycle); - } - return src; - } - - /** - * Return the rotated drawable. - * - * @param src The source of drawable. - * @param degrees The number of degrees. - * @param px The x coordinate of the pivot point. - * @param py The y coordinate of the pivot point. - * @param recycle True to recycle the source of drawable, false otherwise. - * @return the rotated drawable - */ - public static Drawable rotate(final Drawable src, - final int degrees, - final float px, - final float py, - final boolean recycle) { - return bitmap2Drawable(rotate(drawable2Bitmap(src), degrees, px, py, recycle)); - } - - /** - * Return the rotated bitmap. - * - * @param src The source of bitmap. - * @param degrees The number of degrees. - * @param px The x coordinate of the pivot point. - * @param py The y coordinate of the pivot point. - * @param recycle True to recycle the source of bitmap, false otherwise. - * @return the rotated bitmap - */ - public static Bitmap rotate(final Bitmap src, - final int degrees, - final float px, - final float py, - final boolean recycle) { - if (isEmptyBitmap(src)) { - return null; - } - if (src.isRecycled()) { - return null; - } - if (degrees == 0) { - return src; - } - Matrix matrix = new Matrix(); - matrix.setRotate(degrees, px, py); - Bitmap ret = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); - if (recycle && !src.isRecycled()) { - src.recycle(); - } - return ret; - } - - private static boolean isEmptyBitmap(final Bitmap src) { - return src == null || src.getWidth() == 0 || src.getHeight() == 0; - } - - /** - * 获取图片 - * - * @param context 上下文 - * @param resId 图片资源 - * @return 图片 - */ - public static Bitmap getBitmapByDrawableId(Context context, @DrawableRes int resId) { - return drawable2Bitmap(ResUtils.getDrawable(context, resId)); - } - - /** - * Drawable to bitmap. - * - * @param drawable The drawable. - * @return bitmap - */ - public static Bitmap drawable2Bitmap(final Drawable drawable) { - if (drawable == null) { - return null; - } - if (drawable instanceof BitmapDrawable) { - BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; - if (bitmapDrawable.getBitmap() != null) { - return bitmapDrawable.getBitmap(); - } - } - Bitmap bitmap; - if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { - bitmap = Bitmap.createBitmap(1, 1, - drawable.getOpacity() != PixelFormat.OPAQUE - ? Bitmap.Config.ARGB_8888 - : Bitmap.Config.RGB_565); - } else { - bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), - drawable.getIntrinsicHeight(), - drawable.getOpacity() != PixelFormat.OPAQUE - ? Bitmap.Config.ARGB_8888 - : Bitmap.Config.RGB_565); - } - Canvas canvas = new Canvas(bitmap); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - drawable.draw(canvas); - return bitmap; - } - - /** - * Bitmap to drawable. - * - * @param bitmap The bitmap. - * @return drawable - */ - public static Drawable bitmap2Drawable(final Bitmap bitmap) { - return bitmap == null ? null : new BitmapDrawable(ResUtils.getResources(), bitmap); + @SuppressLint("WrongConstant") + public static GradientDrawable setShapeColor(int color, float[] radii) { + GradientDrawable drawable = new GradientDrawable(); + drawable.setShape(GradientDrawable.RECTANGLE); + drawable.setGradientType(GradientDrawable.RECTANGLE); + drawable.setCornerRadii(radii); + drawable.setColor(color); + return drawable; } } diff --git a/app/src/main/java/com/project/survey/util/SystemUtils.java b/app/src/main/java/com/project/survey/util/SystemUtils.java new file mode 100644 index 0000000..1a3eb4d --- /dev/null +++ b/app/src/main/java/com/project/survey/util/SystemUtils.java @@ -0,0 +1,396 @@ +package com.project.survey.util; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.pm.ActivityInfo; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.WifiManager; +import android.os.Environment; +import android.os.ResultReceiver; +import android.text.TextUtils; +import android.util.Log; +import android.view.Display; +import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.LinearLayout; + +import androidx.preference.PreferenceManager; + +import com.bingce.device.Device; +import com.bingce.device.enums.DeviceTypeEnum; +import com.bingce.log.BCLog; +import com.bingce.totalstation.event.TsUpdateBatteryEvent; +import com.gyf.immersionbar.ImmersionBar; +import com.project.survey.R; + +import org.greenrobot.eventbus.EventBus; + +import java.io.File; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import blankj.utilcode.util.ActivityUtils; +import blankj.utilcode.util.KeyboardUtils; +import blankj.utilcode.util.ToastUtils; +import blankj.utilcode.util.Utils; + +public class SystemUtils { + + /** + * 适配手机底部返回键(例如:小米底部横线返回) + */ + public static void SystemBottomBack(Activity activity) { + //MIUI系统底部返回键适配 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //设置沉浸式状态栏,在MIUI系统中,状态栏背景透明。原生系统中,状态栏背景半透明。 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); //设置沉浸式虚拟键,在MIUI系统中,虚拟键背景透明。原生系统中,虚拟键背景半透明。 + } + + /** + * 适配显示出沉浸式状态栏的高度 + */ + public static void SystemTopStatusBar(Activity activity, View view) { + int hight = ImmersionBar.getStatusBarHeight(activity); + LinearLayout.LayoutParams searchParams = (LinearLayout.LayoutParams) view.getLayoutParams(); + searchParams.topMargin = hight; + view.setLayoutParams(searchParams); + } + + /** + * 禁止App旋转,只能竖屏 + */ + @SuppressLint("SourceLockedOrientationActivity") + public static void SystemVerticalScreen(Activity activity) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } + + /** + * 隐藏软键盘(只适用于Activity,不适用于Fragment) + */ + public static void hideSoftKeyboard() { + Activity act = ActivityUtils.getTopActivity(); + if (act != null) { + if (act.getCurrentFocus() != null) { + InputMethodManager inputMethodManager = (InputMethodManager) act.getSystemService(Activity.INPUT_METHOD_SERVICE); + inputMethodManager.hideSoftInputFromWindow(act.getCurrentFocus().getWindowToken(), 0); + } else { + if (KeyboardUtils.isSoftInputVisible(act)) + KeyboardUtils.toggleSoftInput(); + } + } + } + + /** + * 隐藏软键盘(可用于Activity,Fragment) + * + * @param viewList 需要放的是当前界面所有触发软键盘弹出的控件 + */ + public static void hideSoftKeyboard(List viewList) { + if (viewList == null) return; + InputMethodManager inputMethodManager = (InputMethodManager) (Utils.getApp()).getSystemService(Activity.INPUT_METHOD_SERVICE); + for (View v : viewList) { + inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); + } + } + + /** + * 判断sd卡是否可用 + */ + public static boolean isExternalStorageAvailable() { + return Environment.getExternalStorageState().equals( + Environment.MEDIA_MOUNTED); + } + + /** + * 获取当前时间 + * + * @return + */ + public static String getSimpleDateFormat() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss + //获取当前时间 + Date date = new Date(System.currentTimeMillis()); + return simpleDateFormat.format(date); + } + + /** + * 获取当前时间戳 + * + * @return + */ + public static long getSimpleDateTimeStamp() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss + //获取当前时间 + Date date = new Date(System.currentTimeMillis()); + return date.getTime(); + } + + /** + * 复制 + * + * @param text + */ + public static void copy(String text) { + // 获取系统剪贴板 + ClipboardManager clipboard = (ClipboardManager) (Utils.getApp()).getSystemService(Context.CLIPBOARD_SERVICE); + // 创建一个剪贴数据集,包含一个普通文本数据条目(需要复制的数据),其他的还有 + ClipData clipData = ClipData.newPlainText(null, text); + // 把数据集设置(复制)到剪贴板 + clipboard.setPrimaryClip(clipData); + if (!TextUtils.isEmpty(text)) { + ToastUtils.showShort((Utils.getApp()).getResources().getString(R.string.has_copy_to_clipboard)); + } + } + + /** + * 获取文件创建时间 + * + * @param file + * @return + */ + private static final String mformatType = "yyyy/MM/dd"; + + public static String getFileCreateTime(File file) { + Calendar cal = Calendar.getInstance(); + long time = file.lastModified(); + SimpleDateFormat formatter = new SimpleDateFormat(mformatType); + cal.setTimeInMillis(time); + + // 输出:修改时间[2] 2009-08-17 10:32:38 + return formatter.format(cal.getTime()); + } + + /** + * 生成的UUID + * + * @return + */ + @SuppressLint("MissingPermission") + public static String getUUID() { + UUID uuid = UUID.randomUUID(); + String uniqueId = uuid.toString(); + BCLog.log(log -> log.e("debug", "uuid=" + uniqueId)); + return uniqueId; + } + + /** + * 获取wifi状态 + * + * @return + */ + public static boolean getWifiEnabled() { + WifiManager wm = (WifiManager) (Utils.getApp()).getSystemService(Context.WIFI_SERVICE); + return wm.isWifiEnabled(); + } + + /** + * 开关wifi + * + * @param enabled true:打开 false:关闭 + * @return + */ + public static void setWifiEnabled(boolean enabled) { + WifiManager wm = (WifiManager) (Utils.getApp()).getSystemService(Context.WIFI_SERVICE); + wm.setWifiEnabled(enabled); + } + + /** + * 获取手机数据流量是否打开 + * + * @return + */ + public static boolean getMobileDataEnabled() { + boolean mobileDataEnabled; + ConnectivityManager connectivityManager = (ConnectivityManager) (Utils.getApp()).getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); + if (activeNetworkInfo == null) { + Log.e("mobileData", "没有联网"); + mobileDataEnabled = false; + } else { + if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { + Log.e("mobileData", "连接的网络是移动数据流量"); + mobileDataEnabled = true; + } else { + Log.e("mobileData", "不是移动数据流量"); + mobileDataEnabled = false; + } + } + return mobileDataEnabled; + } + + /** + * 移动网络开关 + * + * @param enabled true:打开 false:关闭 + */ + public static void setMobileDataEnabled(boolean enabled) { + ConnectivityManager conMgr = (ConnectivityManager) (Utils.getApp()).getSystemService(Context.CONNECTIVITY_SERVICE); + Class conMgrClass = null;//ConnectivityManager类 + Field iConMgrField = null;//ConnectivityManager类中的字段 + Object iConMgr = null;//IConnectivityManager类的引用 + Class iConMgrClass = null;//IConnectivityManager类 + Method setMobileDataEnabledMethod = null;//setMobileDataEnabled方法 + try { + //取得ConnectivityManager类 + conMgrClass = Class.forName(conMgr.getClass().getName()); + //取得ConnectivityManager类中的对象mService + iConMgrField = conMgrClass.getDeclaredField("mService"); + //设置mService可访问 + iConMgrField.setAccessible(true); + //取得mService的实例化类IConnectivityManager + iConMgr = iConMgrField.get(conMgr); + //取得IConnectivityManager类 + iConMgrClass = Class.forName(iConMgr.getClass().getName()); + //取得IConnectivityManager类中的setMobileDataEnabled(boolean)方法 + setMobileDataEnabledMethod = iConMgrClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE); + //设置setMobileDataEnabled方法可访问 + setMobileDataEnabledMethod.setAccessible(true); + //调用setMobileDataEnabled方法 + setMobileDataEnabledMethod.invoke(iConMgr, enabled); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + /** + * 获取wifi热点状态 + * + * @return + */ + public static boolean getWifiApEnable() { + WifiManager wifiManager = (WifiManager) (Utils.getApp()).getApplicationContext().getSystemService(Context.WIFI_SERVICE); + if (wifiManager == null) { + return false; + } + try { + Method method = wifiManager.getClass().getDeclaredMethod("isWifiApEnabled"); + method.setAccessible(true); + return (Boolean) method.invoke(wifiManager); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + e.printStackTrace(); + } + return false; + } + + /** + * 网络热点是否打开 + * + * @param enabled + */ + public static void setWifiApEnabled(boolean enabled) { + ConnectivityManager connManager = (ConnectivityManager) (Utils.getApp()).getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); + Field iConnMgrField = null; + try { + iConnMgrField = connManager.getClass().getDeclaredField("mService"); + iConnMgrField.setAccessible(true); + Object iConnMgr = iConnMgrField.get(connManager); + Class iConnMgrClass = Class.forName(iConnMgr.getClass().getName()); + if (enabled) { + Method startTethering = iConnMgrClass.getMethod("startTethering", int.class, ResultReceiver.class, boolean.class); + startTethering.invoke(iConnMgr, 0, null, true); + } else { + Method stopTethering = iConnMgrClass.getMethod("stopTethering", int.class); + stopTethering.invoke(iConnMgr, 0); + } + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + /** + * 获取当前连接蓝牙的名称(没有蓝牙连接,返回为空) + * + * @return + */ + public static String getConnectedBtDeviceName() { + //获取蓝牙适配器 + BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + //得到已匹配的蓝牙设备列表 + Set bondedDevices = bluetoothAdapter.getBondedDevices(); + if (bondedDevices != null && bondedDevices.size() > 0) { + for (BluetoothDevice bondedDevice : bondedDevices) { + try { + //使用反射调用被隐藏的方法 + Method isConnectedMethod = BluetoothDevice.class.getDeclaredMethod("isConnected", (Class[]) null); + isConnectedMethod.setAccessible(true); + boolean isConnected = (boolean) isConnectedMethod.invoke(bondedDevice, (Object[]) null); + if (isConnected) { + return bondedDevice.getName(); + } + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + } + return null; + } + + public static int[] getScreenWidthHeight(Context context) { + Activity activity = (Activity) context; + Display display = activity.getWindowManager().getDefaultDisplay(); + int width = display.getWidth(); + int height = display.getHeight(); + return new int[]{width, height}; + } + + public static String getFileName(String path) { + int start = path.lastIndexOf("/"); + int end = path.lastIndexOf("."); + if (start != -1 && end != -1) { + return path.substring(start + 1, end); + } else { + return null; + } + } + + public static void setScreenAlwaysLight(Context context) { + Activity activity = (Activity) context; + boolean isWakeLock = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("key_is_wake_lock", false); + if (isWakeLock) { + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } + if (Device.getInstance().deviceType == DeviceTypeEnum.DEVICE_TYPE_TS) { + EventBus.getDefault().post(new TsUpdateBatteryEvent()); + } + } +} diff --git a/app/src/main/java/com/project/survey/widget/decoration/TransparentDividerDecoration.kt b/app/src/main/java/com/project/survey/widget/decoration/TransparentDividerDecoration.kt new file mode 100644 index 0000000..c2b0c7f --- /dev/null +++ b/app/src/main/java/com/project/survey/widget/decoration/TransparentDividerDecoration.kt @@ -0,0 +1,11 @@ +package com.project.survey.widget.decoration + +import android.content.Context +import androidx.core.content.ContextCompat +import com.bingce.utils.ScreenUtil +import com.project.survey.R + +class TransparentDividerDecoration(context: Context) : DefaultItemDecoration( + ContextCompat.getColor(context, R.color.transparent), + 1, ScreenUtil.dp2px(context, 12f) +) \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinner.java b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinner.java new file mode 100644 index 0000000..6255902 --- /dev/null +++ b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinner.java @@ -0,0 +1,733 @@ +package com.project.survey.widget.materialspinner; + +import android.animation.ObjectAnimator; +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.graphics.PorterDuff; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.StateListDrawable; +import android.os.Build; +import android.os.Bundle; +import android.os.Parcelable; +import android.util.AttributeSet; +import android.view.Gravity; +import android.view.MotionEvent; +import android.view.View; +import android.view.WindowManager; +import android.widget.AdapterView; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.PopupWindow; + +import androidx.annotation.ColorInt; +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatTextView; + +import com.bingce.utils.ScreenUtil; +import com.project.survey.R; +import com.project.survey.util.ResUtils; +import com.project.survey.util.ThemeUtils; +import com.project.survey.util.Tools; +import com.project.survey.widget.util.Utils; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; + +/** + * 自定义下拉框,使用AppCompatTextView + PopupWindow组合实现 + * + * @author xuexiang + * @since 2018/12/7 下午4:24 + */ +public class MaterialSpinner extends AppCompatTextView { + + private OnNothingSelectedListener mOnNothingSelectedListener; + private OnItemSelectedListener mOnItemSelectedListener; + private OnNoMoreChoiceListener mOnNoMoreChoiceListener; + private MaterialSpinnerBaseAdapter mAdapter; + private PopupWindow mPopupWindow; + private ListView mListView; + private Drawable mArrowDrawable; + private boolean mHideArrow; + private boolean mNothingSelected; + private int mPopupWindowMaxHeight; + private int mPopupWindowHeight; + private int mSelectedIndex; + private int mBackgroundColor; + private int mArrowColor; + private int mArrowColorDisabled; + private int mTextColor; + private boolean mIsInDialog; + private int mDropDownOffset; + + public MaterialSpinner(Context context) { + this(context, null); + } + + public MaterialSpinner(Context context, AttributeSet attrs) { + this(context, attrs, R.attr.MaterialSpinnerStyle); + } + + public MaterialSpinner(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + initAttrs(context, attrs, defStyleAttr); + } + + /** + * 初始化属性 + * + * @param context 上下文 + * @param attrs 属性 + * @param defStyleAttr 默认属性 + */ + private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr) { + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaterialSpinner, defStyleAttr, 0); + int defaultColor = getTextColors().getDefaultColor(); + int popAnimStyle; + Drawable dropDownBg; + int entriesId; + int backgroundSelector; + try { + mBackgroundColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_background_color, Color.TRANSPARENT); + backgroundSelector = typedArray.getResourceId(R.styleable.MaterialSpinner_ms_background_selector, 0); + mTextColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_text_color, defaultColor); + + mArrowDrawable = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.MaterialSpinner_ms_arrow_image); + mArrowColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_arrow_tint, mTextColor); + mHideArrow = typedArray.getBoolean(R.styleable.MaterialSpinner_ms_hide_arrow, false); + mPopupWindowMaxHeight = typedArray.getDimensionPixelSize(R.styleable.MaterialSpinner_ms_dropdown_max_height, 0); + mPopupWindowHeight = typedArray.getLayoutDimension(R.styleable.MaterialSpinner_ms_dropdown_height, WindowManager.LayoutParams.WRAP_CONTENT); + mArrowColorDisabled = ResUtils.lighter(mArrowColor, 0.8f); + entriesId = typedArray.getResourceId(R.styleable.MaterialSpinner_ms_entries, 0); + dropDownBg = ResUtils.getDrawableAttrRes(context, typedArray, R.styleable.MaterialSpinner_ms_dropdown_bg); + mIsInDialog = typedArray.getBoolean(R.styleable.MaterialSpinner_ms_in_dialog, false); + popAnimStyle = typedArray.getResourceId(R.styleable.MaterialSpinner_ms_pop_anim_style, -1); + } finally { + typedArray.recycle(); + } + + mDropDownOffset = ThemeUtils.resolveDimension(getContext(), R.attr.ms_dropdown_offset); + + setGravity(Gravity.CENTER_VERTICAL | Gravity.START); + setClickable(true); + + int leftOrRight = ScreenUtil.dp2px(context, 16); + setPaddingRelative(leftOrRight, 0, leftOrRight, 0); + setBackgroundResource(R.drawable.ms_background_selector); + + if (!mHideArrow) { + if (mArrowDrawable == null) { + mArrowDrawable = ResUtils.getVectorDrawable(getContext(), R.drawable.ms_ic_arrow_up).mutate(); + } + mArrowDrawable.setColorFilter(mArrowColor, PorterDuff.Mode.SRC_IN); + int arrowSize = ThemeUtils.resolveDimension(getContext(), R.attr.ms_arrow_size); + mArrowDrawable.setBounds(0, 0, arrowSize, arrowSize); + setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, mArrowDrawable, null); + } + + mListView = new ListView(context); + mListView.setId(getId()); + mListView.setDivider(new ColorDrawable(Tools.getColor(R.color.hor_line))); + mListView.setDividerHeight(ScreenUtil.dp2px(context, 0.5f)); + mListView.setItemsCanFocus(true); + int padding = ThemeUtils.resolveDimension(getContext(), R.attr.ms_dropdown_offset); + mListView.setPadding(padding, padding, padding, padding); + mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + if (position >= mSelectedIndex && position < mAdapter.getCount()) { + position++; + } + mSelectedIndex = position; + mNothingSelected = false; + Object item = mAdapter.get(position); + mAdapter.notifyItemSelected(position); + setText(item.toString()); + collapse(); + if (mOnItemSelectedListener != null) { + //noinspection unchecked + mOnItemSelectedListener.onItemSelected(MaterialSpinner.this, position, id, item); + } + } + }); + if (entriesId != 0) { + setItems(ResUtils.getStringList(context, entriesId)); + } + + mPopupWindow = new PopupWindow(context); + mPopupWindow.setContentView(mListView); + mPopupWindow.setOutsideTouchable(true); + if (popAnimStyle != -1) { + mPopupWindow.setAnimationStyle(popAnimStyle); + } + mPopupWindow.setFocusable(true); + mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + mPopupWindow.setElevation(16); + } + + if (dropDownBg != null) { + mPopupWindow.setBackgroundDrawable(dropDownBg); + } else { + //ResUtils.getDrawable(getContext(), R.drawable.ms_drop_down_bg) + mPopupWindow.setBackgroundDrawable(new ColorDrawable(Tools.getColor(R.color.bg_content))); + } + // default color is white + if (mBackgroundColor != Color.WHITE) { + setBackgroundColor(mBackgroundColor); + } else if (backgroundSelector != 0) { + setBackgroundResource(backgroundSelector); + } + if (mTextColor != defaultColor) { + setTextColor(mTextColor); + } + + mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { + + @Override + public void onDismiss() { + if (mNothingSelected && mOnNothingSelectedListener != null) { + mOnNothingSelectedListener.onNothingSelected(MaterialSpinner.this); + } + if (!mHideArrow) { + animateArrow(false); + } + } + }); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + mPopupWindow.setHeight(calculatePopupWindowHeight()); + if (mAdapter != null) { + CharSequence currentText = getText(); + String longestItem = currentText.toString(); + for (int i = 0; i < mAdapter.getCount(); i++) { + String itemText = mAdapter.getItemText(i); + if (itemText.length() > longestItem.length()) { + longestItem = itemText; + } + } + setText(longestItem); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + setText(currentText); + } else { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + mPopupWindow.setWidth(getMeasuredWidth()); + } + + @Override + public boolean onTouchEvent(@NonNull MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_UP) { + if (isEnabled() && isClickable()) { + if (!mPopupWindow.isShowing()) { + expand(); + } else { + collapse(); + } + } + } + return super.onTouchEvent(event); + } + + @Override + public void setBackgroundColor(int color) { + mBackgroundColor = color; + Drawable background = getBackground(); + if (background instanceof StateListDrawable) { // pre-L + try { + Method getStateDrawable = StateListDrawable.class.getDeclaredMethod("getStateDrawable", int.class); + if (!getStateDrawable.isAccessible()) { + getStateDrawable.setAccessible(true); + } + int[] colors = {ResUtils.darker(color, 0.85f), color}; + for (int i = 0; i < colors.length; i++) { + ColorDrawable drawable = (ColorDrawable) getStateDrawable.invoke(background, i); + drawable.setColor(colors[i]); + } + } catch (Exception e) { + e.printStackTrace(); + } + } else if (background != null) { // 21+ (RippleDrawable) + background.setColorFilter(color, PorterDuff.Mode.SRC_IN); + } + mPopupWindow.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN); + } + + @Override + public void setTextColor(int color) { + mTextColor = color; + super.setTextColor(color); + } + + @Override + public Parcelable onSaveInstanceState() { + Bundle bundle = new Bundle(); + bundle.putParcelable("state", super.onSaveInstanceState()); + bundle.putInt("selected_index", mSelectedIndex); + if (mPopupWindow != null) { + bundle.putBoolean("is_popup_showing", mPopupWindow.isShowing()); + collapse(); + } else { + bundle.putBoolean("is_popup_showing", false); + } + return bundle; + } + + @Override + public void onRestoreInstanceState(Parcelable savedState) { + if (savedState instanceof Bundle) { + Bundle bundle = (Bundle) savedState; + mSelectedIndex = bundle.getInt("selected_index"); + if (mAdapter != null) { + setText(mAdapter.get(mSelectedIndex).toString()); + mAdapter.notifyItemSelected(mSelectedIndex); + } + if (bundle.getBoolean("is_popup_showing")) { + if (mPopupWindow != null) { + // Post the show request into the looper to avoid bad token exception + post(new Runnable() { + + @Override + public void run() { + expand(); + } + }); + } + } + savedState = bundle.getParcelable("state"); + } + super.onRestoreInstanceState(savedState); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (mArrowDrawable != null) { + mArrowDrawable.setColorFilter(enabled ? mArrowColor : mArrowColorDisabled, PorterDuff.Mode.SRC_IN); + } + } + + /** + * @return the selected item position + */ + public int getSelectedIndex() { + return mSelectedIndex; + } + + /** + * Set the default spinner item using its index + * + * @param position the item's position + */ + public MaterialSpinner setSelectedIndex(int position) { + if (mAdapter != null) { + if (position >= 0 && position <= mAdapter.getCount()) { + mAdapter.notifyItemSelected(position); + mSelectedIndex = position; + setText(mAdapter.get(position).toString()); + } else { + throw new IllegalArgumentException("Position must be lower than adapter count!"); + } + } + return this; + } + + /** + * 设置选中的内容 + * + * @param item 选中的内容 + * @param + */ + public MaterialSpinner setSelectedItem(@NonNull T item) { + if (mAdapter != null && item != null) { + setSelectedIndex(getSpinnerPosition(item, mAdapter.getItems())); + } + return this; + } + + /** + * 获取选中内容在Spinner中的位置 + * + * @param item 选中的内容 + * @param items Spinner中选项的集合 + * @return + */ + public int getSpinnerPosition(T item, List items) { + if (item != null && items != null && items.size() > 0) { + for (int i = 0; i < items.size(); i++) { + if (item.equals(items.get(i))) { + return i; + } + } + } + return 0; + } + + /** + * Register a callback to be invoked when an item in the dropdown is selected. + * + * @param onItemSelectedListener The callback that will run + */ + public MaterialSpinner setOnItemSelectedListener(@Nullable OnItemSelectedListener onItemSelectedListener) { + mOnItemSelectedListener = onItemSelectedListener; + return this; + } + + /** + * Register a callback to be invoked when the {@link PopupWindow} is shown but the user didn't select an item. + * + * @param onNothingSelectedListener the callback that will run + */ + public MaterialSpinner setOnNothingSelectedListener(@Nullable OnNothingSelectedListener onNothingSelectedListener) { + mOnNothingSelectedListener = onNothingSelectedListener; + return this; + } + + /** + * 设置无更多选择的监听 + * + * @param onNoMoreChoiceListener + * @return + */ + public MaterialSpinner setOnNoMoreChoiceListener(OnNoMoreChoiceListener onNoMoreChoiceListener) { + mOnNoMoreChoiceListener = onNoMoreChoiceListener; + return this; + } + + /** + * Set the dropdown items + * + * @param items A list of items + * @param The item type + */ + @SafeVarargs + public final MaterialSpinner setItems(@NonNull T... items) { + setItems(Arrays.asList(items)); + return this; + } + + /** + * Set the dropdown items + * + * @param items A list of items + * @param The item type + */ + public MaterialSpinner setItems(@NonNull List items) { + mAdapter = new MaterialSpinnerAdapter<>(getContext(), items) + .setTextColor(mTextColor).setTextSize(getTextSize()); + setAdapterInternal(mAdapter); + return this; + } + + /** + * Get the list of items in the adapter + * + * @param The item type + * @return A list of items or {@code null} if no items are set. + */ + public List getItems() { + if (mAdapter == null) { + return null; + } + //noinspection unchecked + return mAdapter.getItems(); + } + + /** + * Get the Selected Item in the adapter + * + * @param The item type + * @return A list of items or {@code null} if no items are set. + */ + public T getSelectedItem() { + return mAdapter != null ? (T) mAdapter.get(mSelectedIndex) : null; + } + + /** + * Set a custom adapter for the dropdown items + * + * @param adapter The list adapter + */ + public MaterialSpinner setAdapter(@NonNull ListAdapter adapter) { + mAdapter = new MaterialSpinnerAdapterWrapper(getContext(), adapter) + .setTextColor(mTextColor).setTextSize(getTextSize()); + setAdapterInternal(mAdapter); + return this; + } + + /** + * Set the custom adapter for the dropdown items + * + * @param adapter The adapter + * @param The type + */ + public MaterialSpinner setAdapter(MaterialSpinnerAdapter adapter) { + mAdapter = adapter; + mAdapter.setTextColor(mTextColor); + mAdapter.setTextSize(getTextSize()); + setAdapterInternal(adapter); + return this; + } + + /** + * 获取适配器 + * + * @return + */ + public MaterialSpinnerBaseAdapter getAdapter() { + return mAdapter; + } + + public MaterialSpinner setDropDownBackgroundSelector(@DrawableRes int backgroundSelector) { + if (mAdapter != null) { + mAdapter.setBackgroundSelector(backgroundSelector); + } + return this; + } + + private void setAdapterInternal(@NonNull MaterialSpinnerBaseAdapter adapter) { + mListView.setAdapter(adapter); + if (mSelectedIndex >= adapter.getCount()) { + mSelectedIndex = 0; + } + if (adapter.getCount() >= 0) { + setText(adapter.get(mSelectedIndex).toString()); + } else { + setText(""); + } + } + + /** + * @return 是否有内容可以下拉选择 + */ + private boolean hasMoreChoice() { + return mAdapter != null && mAdapter.getCount() > 0; + } + + /** + * Show the dropdown menu + */ + public void expand() { + if (!hasMoreChoice()) { + if (mOnNoMoreChoiceListener != null) { + mOnNoMoreChoiceListener.OnNoMoreChoice(this); + } + return; + } + + if (!mHideArrow) { + animateArrow(true); + } + mNothingSelected = true; + showPopupWindow(); + } + + /** + * Closes the dropdown menu + */ + public void collapse() { + if (!mHideArrow) { + animateArrow(false); + } + mPopupWindow.dismiss(); + } + + private void showPopupWindow() { + if (mIsInDialog) { + mPopupWindow.showAsDropDown(this); + } else { + mPopupWindow.showAsDropDown(this, 0, calculatePopWindowYOffset(this)); + } + } + + /** + * 计算出来的位置,y方向就在anchorView的上面和下面对齐显示,x方向就是与屏幕右边对齐显示 + * 如果anchorView的位置有变化,就可以适当自己额外加入偏移来修正 + * + * @param anchorView 呼出window的view + * @return window显示的左上角的xOff, yOff坐标 + */ + private int[] calculatePopWindowPos(final View anchorView) { + final int[] windowPos = new int[2]; + final int[] anchorLoc = new int[2]; + // 获取锚点View在屏幕上的左上角坐标位置 + anchorView.getLocationOnScreen(anchorLoc); + final int anchorHeight = anchorView.getHeight(); + // 获取屏幕的高宽 + final int screenHeight = Utils.getScreenHeight(getContext()); + // 计算ListView的高宽 + int listViewHeight = Utils.getListViewHeightBasedOnChildren(mListView); + if (mPopupWindowMaxHeight > 0 && listViewHeight > mPopupWindowMaxHeight) { + listViewHeight = mPopupWindowMaxHeight; + } + // 判断需要向上弹出还是向下弹出显示 + final boolean isNeedShowUp = (screenHeight - anchorLoc[1] - anchorHeight < listViewHeight); + if (isNeedShowUp) { + windowPos[0] = anchorLoc[0]; + windowPos[1] = anchorLoc[1] - listViewHeight - mDropDownOffset; + } else { + windowPos[0] = anchorLoc[0]; + windowPos[1] = anchorLoc[1] + anchorHeight; + } + return windowPos; + } + + /** + * 计算出来的位置,y方向就在anchorView的上面和下面对齐显示,x方向就是与屏幕右边对齐显示 + * 如果anchorView的位置有变化,就可以适当自己额外加入偏移来修正 + * + * @param anchorView 呼出window的view + * @return window显示的左上角的xOff, yOff坐标 + */ + private int calculatePopWindowYOffset(final View anchorView) { + int windowYOffset; + final int[] anchorLoc = new int[2]; + // 获取锚点View在屏幕上的左上角坐标位置 + anchorView.getLocationOnScreen(anchorLoc); + final int anchorHeight = anchorView.getHeight(); + // 获取屏幕的高宽 + final int screenHeight = Utils.getScreenHeight(getContext()); + // 计算ListView的高宽 + int listViewHeight = Utils.getListViewHeightBasedOnChildren(mListView); + if (mPopupWindowMaxHeight > 0 && listViewHeight > mPopupWindowMaxHeight) { + listViewHeight = mPopupWindowMaxHeight; + } + // 判断需要向上弹出还是向下弹出显示 + final boolean isNeedShowUp = (screenHeight - anchorLoc[1] < listViewHeight + anchorHeight); + if (isNeedShowUp) { + windowYOffset = -(listViewHeight + mDropDownOffset + anchorHeight); + } else { + windowYOffset = 0; + } + return windowYOffset; + } + + /** + * Set the tint color for the dropdown arrow + * + * @param color the color value + */ + public void setArrowColor(@ColorInt int color) { + mArrowColor = color; + mArrowColorDisabled = ResUtils.lighter(mArrowColor, 0.8f); + if (mArrowDrawable != null) { + mArrowDrawable.setColorFilter(mArrowColor, PorterDuff.Mode.SRC_IN); + } + } + + private void animateArrow(boolean shouldRotateUp) { + int start = shouldRotateUp ? 0 : 10000; + int end = shouldRotateUp ? 10000 : 0; + ObjectAnimator animator = ObjectAnimator.ofInt(mArrowDrawable, "level", start, end); + animator.start(); + } + + /** + * Set the maximum height of the dropdown menu. + * + * @param height the height in pixels + */ + public void setDropdownMaxHeight(int height) { + mPopupWindowMaxHeight = height; + mPopupWindow.setHeight(calculatePopupWindowHeight()); + } + + /** + * Set the height of the dropdown menu + * + * @param height the height in pixels + */ + public void setDropdownHeight(int height) { + mPopupWindowHeight = height; + mPopupWindow.setHeight(calculatePopupWindowHeight()); + } + + private int calculatePopupWindowHeight() { + if (mAdapter == null) { + return WindowManager.LayoutParams.WRAP_CONTENT; + } + float listViewHeight = mAdapter.getCount() * ThemeUtils.resolveDimension(getContext(), R.attr.ms_item_height_size); + if (mPopupWindowMaxHeight > 0 && listViewHeight > mPopupWindowMaxHeight) { + return mPopupWindowMaxHeight; + } else if (mPopupWindowHeight != WindowManager.LayoutParams.MATCH_PARENT + && mPopupWindowHeight != WindowManager.LayoutParams.WRAP_CONTENT + && mPopupWindowHeight <= listViewHeight) { + return mPopupWindowHeight; + } + return WindowManager.LayoutParams.WRAP_CONTENT; + } + + /** + * Get the {@link PopupWindow}. + * + * @return The {@link PopupWindow} that is displayed when the view has been clicked. + */ + public PopupWindow getPopupWindow() { + return mPopupWindow; + } + + /** + * Get the {@link ListView} that is used in the dropdown menu + * + * @return the ListView shown in the PopupWindow. + */ + public ListView getListView() { + return mListView; + } + + /** + * Interface definition for a callback to be invoked when an item in this view has been selected. + * + * @param Adapter item type + */ + public interface OnItemSelectedListener { + + /** + *

Callback method to be invoked when an item in this view has been selected. This callback is invoked only when + * the newly selected position is different from the previously selected position or if there was no selected + * item.

+ * + * @param view The {@link MaterialSpinner} view + * @param position The position of the view in the adapter + * @param id The row id of the item that is selected + * @param item The selected item + */ + void onItemSelected(MaterialSpinner view, int position, long id, T item); + } + + /** + * Interface definition for a callback to be invoked when the dropdown is dismissed and no item was selected. + */ + public interface OnNothingSelectedListener { + + /** + * Callback method to be invoked when the {@link PopupWindow} is dismissed and no item was selected. + * + * @param spinner the {@link MaterialSpinner} + */ + void onNothingSelected(MaterialSpinner spinner); + } + + /** + * 无更多选择的监听 + */ + public interface OnNoMoreChoiceListener { + /** + * 无更多选择 + * + * @param spinner + */ + void OnNoMoreChoice(MaterialSpinner spinner); + } + +} diff --git a/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerAdapter.java b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerAdapter.java new file mode 100644 index 0000000..7ded4ab --- /dev/null +++ b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerAdapter.java @@ -0,0 +1,56 @@ +package com.project.survey.widget.materialspinner; + +import android.content.Context; + +import java.util.List; + +/** + * Spinner适配器 + * + * @author xuexiang + * @since 2019/1/14 下午10:08 + */ +public class MaterialSpinnerAdapter extends MaterialSpinnerBaseAdapter { + + private final List mItems; + + public MaterialSpinnerAdapter(Context context, List items) { + super(context); + mItems = items; + } + + @Override + public int getCount() { + return mItems != null ? mItems.size() - 1 : 0; + } + + /** + * 获取列表项 + * + * @param position + * @return + */ + @Override + public T getItem(int position) { + if (position >= getSelectedIndex()) { + return mItems.get(position + 1); + } else { + return mItems.get(position); + } + } + + @Override + public T get(int position) { + if (mItems != null && position >= 0 && position <= mItems.size() - 1) { + return mItems.get(position); + } else { + return null; + } + } + + @Override + public List getItems() { + return mItems; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerAdapterWrapper.java b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerAdapterWrapper.java new file mode 100644 index 0000000..72ce056 --- /dev/null +++ b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerAdapterWrapper.java @@ -0,0 +1,52 @@ +package com.project.survey.widget.materialspinner; + +import android.content.Context; +import android.widget.ListAdapter; + +import java.util.ArrayList; +import java.util.List; + +/** + * Spinner适配器代理 + * + * @author xuexiang + * @since 2019/1/14 下午10:16 + */ +final class MaterialSpinnerAdapterWrapper extends MaterialSpinnerBaseAdapter { + + private final ListAdapter listAdapter; + + public MaterialSpinnerAdapterWrapper(Context context, ListAdapter toWrap) { + super(context); + listAdapter = toWrap; + } + + @Override + public int getCount() { + return listAdapter.getCount() - 1; + } + + @Override + public Object getItem(int position) { + if (position >= getSelectedIndex()) { + return listAdapter.getItem(position + 1); + } else { + return listAdapter.getItem(position); + } + } + + @Override + public Object get(int position) { + return listAdapter.getItem(position); + } + + @Override + public List getItems() { + List items = new ArrayList<>(); + for (int i = 0; i < getCount(); i++) { + items.add(getItem(i)); + } + return items; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerBaseAdapter.java b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerBaseAdapter.java new file mode 100644 index 0000000..97ee29a --- /dev/null +++ b/app/src/main/java/com/project/survey/widget/materialspinner/MaterialSpinnerBaseAdapter.java @@ -0,0 +1,115 @@ +package com.project.survey.widget.materialspinner; + +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.util.TypedValue; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import androidx.annotation.ColorInt; +import androidx.annotation.DrawableRes; + + +import com.project.survey.R; + +import java.util.List; + +/** + * 基础Spinner适配器 + * + * @author xuexiang + * @since 2019/1/14 下午10:03 + */ +public abstract class MaterialSpinnerBaseAdapter extends BaseAdapter { + + private final Context context; + private int selectedIndex; + private int textColor; + private float textSize; + private int backgroundSelector; + + public MaterialSpinnerBaseAdapter(Context context) { + this.context = context; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + final TextView textView; + if (convertView == null) { + LayoutInflater inflater = LayoutInflater.from(context); + convertView = inflater.inflate(R.layout.ms_layout_list_item, parent, false); + textView = convertView.findViewById(R.id.tv_tinted_spinner); + textView.setTextColor(textColor); + textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); + if (backgroundSelector != 0) { + textView.setBackgroundResource(backgroundSelector); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + Configuration config = context.getResources().getConfiguration(); + if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { + textView.setTextDirection(View.TEXT_DIRECTION_RTL); + } + } + convertView.setTag(new ViewHolder(textView)); + } else { + textView = ((ViewHolder) convertView.getTag()).textView; + } + textView.setText(getItemText(position)); + return convertView; + } + + public String getItemText(int position) { + return getItem(position).toString(); + } + + public int getSelectedIndex() { + return selectedIndex; + } + + public void notifyItemSelected(int index) { + selectedIndex = index; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public abstract T getItem(int position); + + @Override + public abstract int getCount(); + + public abstract T get(int position); + + public abstract List getItems(); + + public MaterialSpinnerBaseAdapter setTextColor(@ColorInt int textColor) { + this.textColor = textColor; + return this; + } + + public MaterialSpinnerBaseAdapter setTextSize(float textSize) { + this.textSize = textSize; + return this; + } + + public MaterialSpinnerBaseAdapter setBackgroundSelector(@DrawableRes int backgroundSelector) { + this.backgroundSelector = backgroundSelector; + return this; + } + + private static class ViewHolder { + + private TextView textView; + + private ViewHolder(TextView textView) { + this.textView = textView; + } + } +} diff --git a/app/src/main/res/anim/pop_add_hide.xml b/app/src/main/res/anim/pop_add_hide.xml new file mode 100644 index 0000000..a32b521 --- /dev/null +++ b/app/src/main/res/anim/pop_add_hide.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/app/src/main/res/anim/pop_add_show.xml b/app/src/main/res/anim/pop_add_show.xml new file mode 100644 index 0000000..55c918d --- /dev/null +++ b/app/src/main/res/anim/pop_add_show.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/app/src/main/res/color/text_color_selector_blue_black.xml b/app/src/main/res/color/text_color_selector_blue_black.xml new file mode 100644 index 0000000..6b76539 --- /dev/null +++ b/app/src/main/res/color/text_color_selector_blue_black.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_approval_blue_stroke.xml b/app/src/main/res/drawable/bg_approval_blue_stroke.xml new file mode 100644 index 0000000..c547cdf --- /dev/null +++ b/app/src/main/res/drawable/bg_approval_blue_stroke.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_point_measure_selector.xml b/app/src/main/res/drawable/bg_point_measure_selector.xml new file mode 100644 index 0000000..5b05510 --- /dev/null +++ b/app/src/main/res/drawable/bg_point_measure_selector.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_white_round_4.xml b/app/src/main/res/drawable/bg_white_round_4.xml new file mode 100644 index 0000000..e9df9aa --- /dev/null +++ b/app/src/main/res/drawable/bg_white_round_4.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/icon_cad_redraw.xml b/app/src/main/res/drawable/icon_cad_redraw.xml new file mode 100644 index 0000000..66618ec --- /dev/null +++ b/app/src/main/res/drawable/icon_cad_redraw.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/app/src/main/res/drawable/icon_function_switch_off.xml b/app/src/main/res/drawable/icon_function_switch_off.xml new file mode 100644 index 0000000..8e25461 --- /dev/null +++ b/app/src/main/res/drawable/icon_function_switch_off.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/icon_global_settings.xml b/app/src/main/res/drawable/icon_global_settings.xml new file mode 100644 index 0000000..aa7b1a1 --- /dev/null +++ b/app/src/main/res/drawable/icon_global_settings.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/icon_help_document.xml b/app/src/main/res/drawable/icon_help_document.xml new file mode 100644 index 0000000..b4bc421 --- /dev/null +++ b/app/src/main/res/drawable/icon_help_document.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/icon_system_back.xml b/app/src/main/res/drawable/icon_system_back.xml new file mode 100644 index 0000000..8e25e8e --- /dev/null +++ b/app/src/main/res/drawable/icon_system_back.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/app/src/main/res/drawable/icon_video_tutorial.xml b/app/src/main/res/drawable/icon_video_tutorial.xml new file mode 100644 index 0000000..71410ed --- /dev/null +++ b/app/src/main/res/drawable/icon_video_tutorial.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/ms_background_selector.xml b/app/src/main/res/drawable/ms_background_selector.xml new file mode 100644 index 0000000..824d14c --- /dev/null +++ b/app/src/main/res/drawable/ms_background_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ms_drop_down_bg.xml b/app/src/main/res/drawable/ms_drop_down_bg.xml new file mode 100644 index 0000000..0f2c965 --- /dev/null +++ b/app/src/main/res/drawable/ms_drop_down_bg.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ms_ic_arrow_down.xml b/app/src/main/res/drawable/ms_ic_arrow_down.xml new file mode 100644 index 0000000..22e2cdc --- /dev/null +++ b/app/src/main/res/drawable/ms_ic_arrow_down.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ms_ic_arrow_up.xml b/app/src/main/res/drawable/ms_ic_arrow_up.xml new file mode 100644 index 0000000..3151449 --- /dev/null +++ b/app/src/main/res/drawable/ms_ic_arrow_up.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_approval.xml b/app/src/main/res/layout/activity_approval.xml index 77d9ef6..5250350 100644 --- a/app/src/main/res/layout/activity_approval.xml +++ b/app/src/main/res/layout/activity_approval.xml @@ -1,6 +1,16 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_control_net_list.xml b/app/src/main/res/layout/activity_control_net_list.xml new file mode 100644 index 0000000..849a2b1 --- /dev/null +++ b/app/src/main/res/layout/activity_control_net_list.xml @@ -0,0 +1,21 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_lofting_list.xml b/app/src/main/res/layout/activity_lofting_list.xml new file mode 100644 index 0000000..6b8dd37 --- /dev/null +++ b/app/src/main/res/layout/activity_lofting_list.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_point_measure_list.xml b/app/src/main/res/layout/activity_point_measure_list.xml new file mode 100644 index 0000000..5dbef90 --- /dev/null +++ b/app/src/main/res/layout/activity_point_measure_list.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_satellite_system_switch.xml b/app/src/main/res/layout/activity_satellite_system_switch.xml new file mode 100644 index 0000000..3dbb1a3 --- /dev/null +++ b/app/src/main/res/layout/activity_satellite_system_switch.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +