增加访客预约界面

0515
panqihua 4 years ago
parent 4e92a2d41d
commit 9c7b29c63b
  1. 69
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ShowWordCount.java
  2. 35
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostComplainFragment.java
  3. 62
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java
  4. 70
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorAppointmentFragment.java
  5. 6
      app/src/main/res/layout/main/layout/forum/layout/forum_hot_fragment.xml
  6. 34
      app/src/main/res/layout/main/layout/forum/layout/forum_post_complain_fragment.xml
  7. 2
      app/src/main/res/layout/main/layout/forum/layout/forum_post_content.xml
  8. 4
      app/src/main/res/layout/main/layout/info_fragment.xml
  9. 70
      app/src/main/res/layout/main/layout/visitor/layout/visitor_appointment_fragment.xml
  10. 2
      app/src/main/res/values-en-rUS/dimens.xml
  11. 4
      app/src/main/res/values-en-rUS/strings.xml
  12. 2
      app/src/main/res/values-zh-rCN/dimens.xml
  13. 4
      app/src/main/res/values-zh-rCN/strings.xml
  14. 2
      app/src/main/res/values/dimens.xml
  15. 4
      app/src/main/res/values/strings.xml

@ -0,0 +1,69 @@
package com.community.pocket.ui.main.ui.forum;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.IdRes;
import com.community.pocket.R;
/**
* 提示正文输入字数
*/
public class ShowWordCount {
@IdRes
private int[] ids;
private View view;
private EditText postContent;
public ShowWordCount(int[] ids, int contentId, View view) {
this.ids = ids;
this.view = view;
this.postContent = view.findViewById(contentId);
}
/**
* 设置计数
*/
private void setCount() {
String text = view.getContext().getString(R.string.post_content_count, postContent.length(), view.getContext().getResources().getInteger(R.integer.post_content));
for (int id : ids) {
TextView textView = view.findViewById(id);
textView.setText(Html.fromHtml(text));
}
}
/**
* 提示正文字数
*/
public void showCount() {
setCount();
postContent.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
setCount();
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
}

@ -1,27 +1,30 @@
package com.community.pocket.ui.main.ui.forum.post;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.community.pocket.R;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import java.util.Objects;
/**
* 投诉贴
*/
@ContentView(R.layout.forum_post_complain_fragment)
public class ForumPostComplainFragment extends ForumPostContent {
/**
* 显示投诉人
*/
@ViewInject(R.id.show_name)
private TextView showName;
/**
* 检索投诉人
@ -29,6 +32,26 @@ public class ForumPostComplainFragment extends ForumPostContent {
@ViewInject(R.id.search_name)
private AutoCompleteTextView searchName;
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initSearch();
}
/**
* 搜索框
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void initSearch() {
//TODO 设置数据源数组
String[] arrays = {"abc", "abcde", "aef2", "fff", "asdfa"};
// 设置适配器
ArrayAdapter<String> adapter = new ArrayAdapter<>(Objects.requireNonNull(this.getContext()), android.R.layout.simple_list_item_1, arrays);
// 将适配器与当前AutoCompleteTextView控件绑定
searchName.setAdapter(adapter);
}
/**
* 发帖操作

@ -5,12 +5,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
@ -21,8 +16,7 @@ import androidx.navigation.Navigation;
import com.community.pocket.R;
import com.community.pocket.ui.BaseFragment;
import org.xutils.view.annotation.ViewInject;
import com.community.pocket.ui.main.ui.forum.ShowWordCount;
import java.util.Objects;
@ -31,24 +25,6 @@ import java.util.Objects;
*/
abstract class ForumPostContent extends BaseFragment {
/**
* 发送正文
*/
@ViewInject(R.id.post_content)
private EditText postContent;
/**
* 字符记数
*/
@ViewInject(R.id.show_count)
private TextView showCount;
/**
* 字符记数
*/
@ViewInject(R.id.show_count_top)
private TextView showCountTop;
/**
* 导航
@ -68,7 +44,8 @@ abstract class ForumPostContent extends BaseFragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
showCount();
ShowWordCount showWordCount = new ShowWordCount(new int[]{R.id.show_count, R.id.show_count_top}, R.id.post_content, view);
showWordCount.showCount();
initPostCtrl();
}
@ -91,41 +68,10 @@ abstract class ForumPostContent extends BaseFragment {
}
}
/**
* 设置计数
*/
private void setCount() {
String text = getString(R.string.post_content_count, postContent.length(), getResources().getInteger(R.integer.post_content));
showCount.setText(Html.fromHtml(text));
showCountTop.setText(Html.fromHtml(text));
}
/**
* 提示正文字数
* 导航触发器
*/
private void showCount() {
setCount();
postContent.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
setCount();
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
private static class MyHandler extends Handler {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)

@ -1,18 +1,80 @@
package com.community.pocket.ui.main.ui.visitor;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.community.pocket.R;
import com.community.pocket.ui.main.TestMainFragment;
import com.community.pocket.ui.BaseFragment;
import com.community.pocket.ui.main.ui.forum.ShowWordCount;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import java.util.Objects;
/**
* 访客预约界面
*/
@ContentView(R.layout.visitor_appointment_fragment)
public class VisitorAppointmentFragment extends TestMainFragment {
public class VisitorAppointmentFragment extends BaseFragment {
//搜索预约住户
@ViewInject(R.id.appointment)
private AutoCompleteTextView appointment;
@ViewInject(R.id.choose_time)
private Spinner spinner;
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected int viewId() {
return R.id.text_apppointment;
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ShowWordCount showWordCount = new ShowWordCount(new int[]{R.id.show_word_top, R.id.show_word_bottom}, R.id.notes, view);
showWordCount.showCount();
initSearch();
initChooseTime();
}
/**
* 搜索框
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void initSearch() {
//TODO 设置数据源数组
String[] arrays = {"abc", "abcde", "aef2", "fff", "asdfa"};
// 设置适配器
ArrayAdapter<String> adapter = new ArrayAdapter<>(Objects.requireNonNull(this.getContext()), android.R.layout.simple_list_item_1, arrays);
// 将适配器与当前AutoCompleteTextView控件绑定
appointment.setAdapter(adapter);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void initChooseTime() {
//TODO 设置数据源数组
String[] arrays = {"abc", "efg", "aef2", "fff", "asdfa"};
// 设置适配器
ArrayAdapter<String> adapter = new ArrayAdapter<>(Objects.requireNonNull(this.getContext()), android.R.layout.simple_list_item_1, arrays);
spinner.setAdapter(adapter);
}
/**
* 提交预约信息
*/
@Event(value = R.id.submit)
private void submit(View view) {
Toast.makeText(view.getContext(), R.string.submit_appointment, Toast.LENGTH_SHORT).show();
}
}

@ -20,7 +20,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/active_user"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
@ -42,7 +42,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/hot_topic"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">
@ -64,7 +64,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/hot_events"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_height="@dimen/size_200"
android:layout_marginTop="@dimen/size_50"
android:background="@drawable/border">

@ -10,41 +10,29 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/show_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/prompt_complain_name" />
<AutoCompleteTextView
android:id="@+id/search_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="@string/search_complain_name" />
</LinearLayout>
<AutoCompleteTextView
android:id="@+id/search_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/search_complain_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="@+id/post_content_layout"
layout="@layout/forum_post_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/search_layout"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@id/search_name"
tools:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/post_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/post"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/post_content_layout" />

@ -17,7 +17,7 @@
<EditText
android:id="@+id/post_content"
android:layout_width="0dp"
android:layout_height="300dp"
android:layout_height="@dimen/size_300"
android:background="@drawable/border"
android:ems="15"
android:gravity="start|top"

@ -23,8 +23,8 @@
<ImageView
android:id="@+id/headimg"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_width="@dimen/size_200"
android:layout_height="@dimen/size_200"
android:contentDescription="@string/headimg"
android:src="@drawable/comm_titlebar_progress_circular"
app:layout_constraintStart_toStartOf="parent"

@ -1,13 +1,77 @@
<?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.VisitorAppointmentFragment">
<TextView
android:id="@+id/text_apppointment"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<AutoCompleteTextView
android:id="@+id/appointment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:gravity="center"
android:hint="@string/prompt_appointment"
app:layout_constraintBottom_toTopOf="@+id/choose_time"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/choose_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appointment" />
<TextView
android:id="@+id/show_word_top"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/choose_time" />
<EditText
android:id="@+id/notes"
android:layout_width="0dp"
android:layout_height="@dimen/size_200"
android:background="@drawable/border"
android:ems="15"
android:gravity="start|top"
android:hint="@string/prompt_input_notes"
android:importantForAutofill="no"
android:inputType="textMultiLine"
android:maxLength="@integer/post_content"
android:maxLines="@integer/post_content_maxLines"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/show_word_top" />
<TextView
android:id="@+id/show_word_bottom"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/notes" />
<Button
android:id="@+id/submit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/submit_appointment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/show_word_bottom" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

@ -6,4 +6,6 @@
<dimen name="size_50">50dp</dimen>
<dimen name="size_30">30dp</dimen>
<dimen name="chart_height">200dp</dimen>
<dimen name="size_300">300dp</dimen>
<dimen name="size_200">200dp</dimen>
</resources>

@ -72,4 +72,8 @@
<string name="prompt_complain_name">please input complain name</string>
<string name="post">post</string>
<string name="post_reply">reply:%1d</string>
<string name="prompt_appointment">please input appointment of people</string>
<string name="prompt_choose_time">please choose time</string>
<string name="prompt_input_notes">please input notes</string>
<string name="submit_appointment">submit</string>
</resources>

@ -6,4 +6,6 @@
<dimen name="size_50">50dp</dimen>
<dimen name="size_30">30dp</dimen>
<dimen name="chart_height">200dp</dimen>
<dimen name="size_300">300dp</dimen>
<dimen name="size_200">200dp</dimen>
</resources>

@ -72,4 +72,8 @@
<string name="prompt_complain_name">" 请选择投诉人"</string>
<string name="post">发帖</string>
<string name="post_reply">回复 :%1d</string>
<string name="prompt_appointment">请搜索预约住户</string>
<string name="prompt_choose_time">请预约上门时间</string>
<string name="prompt_input_notes">请输入备注信息</string>
<string name="submit_appointment">" 提交预约"</string>
</resources>

@ -7,4 +7,6 @@
<dimen name="fab_margin">16dp</dimen>
<dimen name="size_30">30dp</dimen>
<dimen name="chart_height">200dp</dimen>
<dimen name="size_300">300dp</dimen>
<dimen name="size_200">200dp</dimen>
</resources>

@ -73,6 +73,10 @@
<string name="prompt_complain_name">please input complain name</string>
<string name="post">post</string>
<string name="post_reply">reply:%1d</string>
<string name="prompt_appointment">please input appointment of people</string>
<string name="prompt_choose_time">please choose time</string>
<string name="prompt_input_notes">please input notes</string>
<string name="submit_appointment">submit</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

Loading…
Cancel
Save