增加访客管理-我的预约和我的访客界面

0515
panqihua 4 years ago
parent 9c7b29c63b
commit d12f84d4f5
  1. 1
      app/build.gradle
  2. 6
      app/src/main/java/com/community/pocket/data/adapter/LocaleAdapter.java
  3. 28
      app/src/main/java/com/community/pocket/data/model/Visitor.java
  4. 19
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java
  5. 25
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyFragment.java
  6. 128
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java
  7. 28
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorReservationFragment.java
  8. 4
      app/src/main/java/com/community/pocket/util/LocaleType.java
  9. 4
      app/src/main/res/layout/main/layout/forum/layout/forum_hot_fragment.xml
  10. 4
      app/src/main/res/layout/main/layout/forum/layout/forum_my_fragment.xml
  11. 4
      app/src/main/res/layout/main/layout/forum/layout/forum_new_fragment.xml
  12. 4
      app/src/main/res/layout/main/layout/forum/layout/forum_notice.xml
  13. 4
      app/src/main/res/layout/main/layout/forum/layout/forum_post_fragment.xml
  14. 4
      app/src/main/res/layout/main/layout/info_fragment.xml
  15. 30
      app/src/main/res/layout/main/layout/visitor/layout/visitor_info.xml
  16. 101
      app/src/main/res/layout/main/layout/visitor/layout/visitor_my_fragment.xml
  17. 13
      app/src/main/res/layout/main/layout/visitor/layout/visitor_reservation_fragment.xml
  18. 2
      app/src/main/res/navigation/visitor_navigation.xml
  19. 12
      app/src/main/res/values-en-rUS/strings.xml
  20. 12
      app/src/main/res/values-zh-rCN/strings.xml
  21. 12
      app/src/main/res/values/strings.xml

@ -52,4 +52,5 @@ dependencies {
implementation 'com.wuhenzhizao:titlebar:1.2.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
}

@ -49,13 +49,15 @@ public class LocaleAdapter extends BaseAdapter {
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
String text = convertView.getResources().getString(LocaleType.getLocale(position).getResId());
String text = convertView.getContext().getString(LocaleType.getLocale(position).getResId());
viewHolder.childName.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
viewHolder.childName.setText(text);
return convertView;
}
private class ViewHolder {
protected static class ViewHolder {
@ViewInject(android.R.id.text1)//加载item的控件
TextView childName;
}

@ -0,0 +1,28 @@
package com.community.pocket.data.model;
/**
* 访客信息
*/
public class Visitor {
private String name;
private long time;
private String notes;
public Visitor(String name, long time, String notes) {
this.name = name;
this.time = time;
this.notes = notes;
}
public String getName() {
return name;
}
public long getTime() {
return time;
}
public String getNotes() {
return notes;
}
}

@ -7,7 +7,6 @@ import android.os.Handler;
import android.os.Message;
import android.view.View;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
@ -50,22 +49,12 @@ abstract class ForumPostContent extends BaseFragment {
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private static void nav(@IdRes int id) {
if (Objects.requireNonNull(nav.getCurrentDestination()).getId() != id) {
nav.navigate(id);
}
}
/**
* 初始化路由控制器
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void initPostCtrl() {
if (nav == null) {
nav = Navigation.findNavController(Objects.requireNonNull(getView()));
}
nav = Navigation.findNavController(Objects.requireNonNull(getView()));
}
@ -79,13 +68,13 @@ abstract class ForumPostContent extends BaseFragment {
public void handleMessage(@NonNull Message msg) {
switch (msg.what) {
case 0:
nav(R.id.forumPostActiveFragment);
nav.navigate(R.id.forumPostActiveFragment);
break;
case 1:
nav(R.id.forumPostTopicFragment);
nav.navigate(R.id.forumPostTopicFragment);
break;
case 2:
nav(R.id.forumPostComplainFragment);
nav.navigate(R.id.forumPostComplainFragment);
break;
}
}

@ -1,18 +1,35 @@
package com.community.pocket.ui.main.ui.visitor;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.community.pocket.R;
import com.community.pocket.ui.main.TestMainFragment;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
/**
* 我的访客界面
*/
@ContentView(R.layout.visitor_my_fragment)
public class VisitorMyFragment extends TestMainFragment {
public class VisitorMyFragment extends VisitorMyVisitor {
@Override
protected int viewId() {
return R.id.text_visitor;
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
name.setText(R.string.visitor_name);
time.setText(R.string.visitor_time);
}
/**
* 查询访客数据
*/
@Event(R.id.query)
private void query(View view) {
Toast.makeText(getContext(), "访客数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show();
}
}

@ -0,0 +1,128 @@
package com.community.pocket.ui.main.ui.visitor;
import android.os.Build;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.gridlayout.widget.GridLayout;
import com.community.pocket.R;
import com.community.pocket.data.model.Visitor;
import com.community.pocket.ui.BaseFragment;
import org.xutils.view.annotation.ViewInject;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public abstract class VisitorMyVisitor extends BaseFragment {
//表格布局
@ViewInject(R.id.table)
private GridLayout gridLayout;
//查询开始时间
@ViewInject(R.id.start_time)
protected EditText startTime;
//查询结束时间
@ViewInject(R.id.end_time)
protected EditText endTime;
//表格列
@ViewInject(R.id.name)
protected TextView name;
@ViewInject(R.id.time)
protected TextView time;
/**
* 显示备注最大长度
*/
private static final int maxLength = 5;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initDataList();
}
/**
* 初始化数据
* TODO 测试数据
*/
private void initDataList() {
List<Visitor> visitors = new ArrayList<>();
for (int i = 0; i < 30; i++) {
Visitor visitor = new Visitor("1231", System.currentTimeMillis(), "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
visitors.add(visitor);
}
for (final Visitor visitor : visitors) {
createTextView(visitor.getName());
createTextView(DateFormat.format(getString(R.string.dateformat), visitor.getTime()));
createTextView(visitor.getNotes().length() <= maxLength ? visitor.getNotes() : visitor.getNotes().substring(0, maxLength));
Button button = new Button(getContext());
button.setText(getString(R.string.show_notes));
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
button.setLayoutParams(layoutParams);
button.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onClick(View v) {
createAlertNotes(visitor.getNotes());
}
});
gridLayout.addView(button);
}
}
/**
* 创建单元格
*/
private void createTextView(CharSequence text) {
TextView textView = new TextView(getContext());
textView.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
textView.setText(text);
textView.setBackground(getResources().getDrawable(R.drawable.border));
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
textView.setLayoutParams(layoutParams);
gridLayout.addView(textView);
}
/**
* 创建显示备注信息弹窗
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void createAlertNotes(String text) {
View view = View.inflate(getContext(), R.layout.visitor_info, null);
EditText editText = view.findViewById(R.id.content);
editText.setText(text);
editText.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
Button button = view.findViewById(R.id.close);
AlertDialog.Builder alert = new AlertDialog.Builder(Objects.requireNonNull(getContext()));
final AlertDialog alertDialog = alert.setTitle(R.string.notes).setView(view).create();
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
alertDialog.show();
}
}

@ -1,18 +1,36 @@
package com.community.pocket.ui.main.ui.visitor;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.community.pocket.R;
import com.community.pocket.ui.main.TestMainFragment;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
/**
* 我的预约界面
*/
@ContentView(R.layout.visitor_reservation_fragment)
public class VisitorReservationFragment extends TestMainFragment {
@ContentView(R.layout.visitor_my_fragment)
public class VisitorReservationFragment extends VisitorMyVisitor {
@Override
protected int viewId() {
return R.id.text_reservation;
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
name.setText(R.string.appointment_name);
time.setText(R.string.appointment_time);
}
/**
* 查询预约数据
*/
@Event(value = R.id.query)
private void query(View view) {
Toast.makeText(getContext(), "预约数据查询" + startTime.getText() + "|" + endTime.getText(), Toast.LENGTH_SHORT).show();
}
}

@ -1,5 +1,7 @@
package com.community.pocket.util;
import androidx.annotation.StringRes;
import com.community.pocket.R;
import java.util.Locale;
@ -29,7 +31,7 @@ public enum LocaleType {
return resId;
}
LocaleType(Locale locale, int type, int resId) {
LocaleType(Locale locale, int type, @StringRes int resId) {
this.locale = locale;
this.type = type;
this.resId = resId;

@ -7,7 +7,7 @@
tools:context=".ui.main.ui.forum.ForumHotFragment">
<ScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
@ -83,5 +83,5 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</FrameLayout>

@ -5,7 +5,7 @@
android:layout_height="match_parent"
tools:context=".ui.main.ui.forum.ForumMyFragment">
<ScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
@ -21,5 +21,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</FrameLayout>

@ -5,7 +5,7 @@
android:layout_height="match_parent"
tools:context=".ui.main.ui.forum.ForumNewFragment">
<ScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
@ -21,5 +21,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</FrameLayout>

@ -16,7 +16,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
<androidx.core.widget.NestedScrollView
android:id="@+id/content"
android:layout_width="0dp"
android:layout_height="100dp"
@ -39,7 +39,7 @@
android:importantForAutofill="no"
android:inputType="none|textMultiLine" />
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
<TextView
android:id="@+id/notice_author"

@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context=".ui.main.ui.forum.post.ForumPostFragment">
<ScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
@ -46,6 +46,6 @@
app:navGraph="@navigation/nav_forum_post_type" />
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</FrameLayout>

@ -7,7 +7,7 @@
android:layout_height="match_parent"
tools:context=".ui.main.ui.info.InfoFragment">
<ScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -147,6 +147,6 @@
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:gravity="start|top"
android:importantForAutofill="no"
android:inputType="textMultiLine"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="LabelFor" />
<Button
android:id="@+id/close"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/action_close"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/content" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,13 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.ui.visitor.VisitorMyFragment">
<TextView
android:id="@+id/text_visitor"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/query_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/start_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="@string/start_time"
android:inputType="textPersonName"
android:importantForAutofill="no" />
<EditText
android:id="@+id/end_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="@string/end_time"
android:inputType="textPersonName"
android:importantForAutofill="no" />
</LinearLayout>
<Button
android:id="@+id/query"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/query"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/query_layout" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/query">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.gridlayout.widget.GridLayout
android:id="@+id/table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:columnCount="4">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
app:layout_columnWeight="1" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="18sp"
app:layout_columnWeight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/notes"
android:textSize="18sp"
app:layout_columnWeight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/action"
android:textSize="18sp"
app:layout_columnWeight="1" />
</androidx.gridlayout.widget.GridLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.ui.visitor.VisitorReservationFragment">
<TextView
android:id="@+id/text_reservation"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

@ -15,7 +15,7 @@
android:id="@+id/visitorReservationFragment"
android:name="com.community.pocket.ui.main.ui.visitor.VisitorReservationFragment"
android:label="visitor_reservation_fragment"
tools:layout="@layout/visitor_reservation_fragment" />
tools:layout="@layout/visitor_my_fragment" />
<fragment
android:id="@+id/visitorMyFragment"
android:name="com.community.pocket.ui.main.ui.visitor.VisitorMyFragment"

@ -76,4 +76,16 @@
<string name="prompt_choose_time">please choose time</string>
<string name="prompt_input_notes">please input notes</string>
<string name="submit_appointment">submit</string>
<string name="show_notes">show all text</string>
<string name="hide_notes">hide notes</string>
<string name="appointment_time">appointment_time</string>
<string name="notes">notes</string>
<string name="visitor_name">visitor name</string>
<string name="visitor_time">visitor time</string>
<string name="action">action</string>
<string name="action_close">close</string>
<string name="start_time">start time</string>
<string name="end_time">end time</string>
<string name="query">query</string>
<string name="appointment_name">appointment name</string>
</resources>

@ -76,4 +76,16 @@
<string name="prompt_choose_time">请预约上门时间</string>
<string name="prompt_input_notes">请输入备注信息</string>
<string name="submit_appointment">" 提交预约"</string>
<string name="show_notes">显示所有备注</string>
<string name="hide_notes">隐藏部分备注</string>
<string name="appointment_time">预约时间</string>
<string name="notes">备注</string>
<string name="visitor_name">访客人</string>
<string name="visitor_time">访客时间</string>
<string name="action">操作</string>
<string name="action_close">关闭</string>
<string name="start_time">开始时间</string>
<string name="end_time">结束时间</string>
<string name="query">查询</string>
<string name="appointment_name">预约人</string>
</resources>

@ -77,6 +77,18 @@
<string name="prompt_choose_time">please choose time</string>
<string name="prompt_input_notes">please input notes</string>
<string name="submit_appointment">submit</string>
<string name="show_notes">show all text</string>
<string name="hide_notes">hide notes</string>
<string name="appointment_time">appointment_time</string>
<string name="notes">notes</string>
<string name="visitor_name">visitor name</string>
<string name="visitor_time">visitor time</string>
<string name="action">action</string>
<string name="action_close">close</string>
<string name="start_time">start time</string>
<string name="end_time">end time</string>
<string name="query">query</string>
<string name="appointment_name">appointment name</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

Loading…
Cancel
Save