diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e701d7f..153e0a7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme.NoActionBar"> + diff --git a/app/src/main/java/com/community/pocket/data/model/ForumContent.java b/app/src/main/java/com/community/pocket/data/model/ForumContent.java new file mode 100644 index 0000000..e496f9b --- /dev/null +++ b/app/src/main/java/com/community/pocket/data/model/ForumContent.java @@ -0,0 +1,67 @@ +package com.community.pocket.data.model; + +/** + * 论坛楼层数据 + */ +public class ForumContent { + //头像 + private String headImg; + //用户名 + private String username; + //信用分 + private Integer score; + //发帖时间 + private Long time; + //楼层 + private Integer tower; + //帖子正文 + private String content; + + public String getHeadImg() { + return headImg; + } + + public void setHeadImg(String headImg) { + this.headImg = headImg; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } + + public Integer getTower() { + return tower; + } + + public void setTower(Integer tower) { + this.tower = tower; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/app/src/main/java/com/community/pocket/ui/main/TestMainFragment.java b/app/src/main/java/com/community/pocket/ui/main/TestMainFragment.java index aa43cf8..0b8fb26 100644 --- a/app/src/main/java/com/community/pocket/ui/main/TestMainFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/TestMainFragment.java @@ -25,11 +25,11 @@ public abstract class TestMainFragment extends BaseFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - //文本框打印类信息 + //文本框打印测试信息 View root = super.onCreateView(inflater, container, savedInstanceState); final TextView textView = root.findViewById(viewId()); MutableLiveData mText = new MutableLiveData<>(); - mText.setValue(this.getClass().getName()); + mText.setValue("未完成界面!!!"); mText.observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(@Nullable String s) { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java new file mode 100644 index 0000000..55192f3 --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumDataActivity.java @@ -0,0 +1,88 @@ +package com.community.pocket.ui.main.ui.forum; + +import android.os.Bundle; +import android.text.format.DateFormat; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.constraintlayout.widget.ConstraintLayout; + +import com.community.pocket.R; +import com.community.pocket.ui.BaseActivity; + +import org.xutils.view.annotation.ContentView; +import org.xutils.view.annotation.Event; +import org.xutils.view.annotation.ViewInject; + +/** + * 帖子详情界面 + */ +@ContentView(R.layout.activity_forum_data) +public class ForumDataActivity extends BaseActivity { + + //第一楼布局 + @ViewInject(R.id.first_layout) + private ConstraintLayout firstLayout; + + //回复楼层布局 + @ViewInject(R.id.reply_layout) + private LinearLayout replyLayout; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + initFirst(); + + createReply(); + } + + /** + * 初始化第一楼数据 + * TODO 测试数据 + */ + private void initFirst() { + setData(firstLayout); + } + + /** + * 返回 + */ + @Event(value = R.id.back) + private void back(View view) { + finish(); + } + + /** + * 创建楼层数据 + */ + private void createReply() { + for (int i = 0; i < 10; i++) { + View view = View.inflate(this, R.layout.forum_data_content, null); + ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewGroup.MarginLayoutParams marginLayoutParams = new ViewGroup.MarginLayoutParams(layoutParams); + marginLayoutParams.setMargins(0, 50, 0, 0); + setData(view); + view.setLayoutParams(marginLayoutParams); + replyLayout.addView(view); + } + } + + /** + * 设置楼层布局 + */ + private void setData(View view) { + TextView name = view.findViewById(R.id.name); + name.setText("我是笨蛋"); + TextView score = view.findViewById(R.id.score); + score.setText("22"); + TextView time = view.findViewById(R.id.time); + time.setText(DateFormat.format(getString(R.string.dateformat), System.currentTimeMillis())); + TextView tower = view.findViewById(R.id.tower); + tower.setText(getString(R.string.tower, 1)); + TextView content = view.findViewById(R.id.content); + content.setText("我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋我是笨蛋"); + } +} diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java index b1e1320..a5e82e2 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java @@ -1,10 +1,11 @@ package com.community.pocket.ui.main.ui.forum; -import android.annotation.SuppressLint; +import android.content.Intent; import android.os.Bundle; import android.text.format.DateFormat; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; @@ -34,11 +35,11 @@ public abstract class ForumPost extends BaseFragment { } /** - * 加载最新帖子 + * 加载帖子数据 + * TODO 测试数据 */ - @SuppressLint("SetTextI18n") private void loadPost(View view) { - //TODO 测试数据 + for (int i = 0; i < 10; i++) { View childView = View.inflate(getContext(), R.layout.post, null); TextView title = childView.findViewById(R.id.post_title); @@ -58,6 +59,17 @@ public abstract class ForumPost extends BaseFragment { ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layoutParams.setMargins(0, 0, 0, 50); childView.setLayoutParams(layoutParams); + + + //打开帖子 + Button button = childView.findViewById(R.id.showAll); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getContext(), ForumDataActivity.class)); + } + }); + layout.addView(childView); } } diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java index fa11df0..4865bdd 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java @@ -1,5 +1,6 @@ package com.community.pocket.ui.main.ui.info; +import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.view.View; @@ -12,12 +13,14 @@ import androidx.annotation.RequiresApi; import com.community.pocket.R; import com.community.pocket.ui.BaseFragment; +import com.community.pocket.ui.login.LoginActivity; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import org.xutils.view.annotation.ContentView; +import org.xutils.view.annotation.Event; import org.xutils.view.annotation.ViewInject; import java.util.ArrayList; @@ -67,6 +70,15 @@ public class InfoFragment extends BaseFragment { loadChart(); } + /** + * 注销登录 + */ + @RequiresApi(api = Build.VERSION_CODES.KITKAT) + @Event(value = R.id.logout) + private void logout(View view) { + startActivity(new Intent(view.getContext(), LoginActivity.class)); + } + //加载图表数据 private void loadChart() { LineData lineData = new LineData(); diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java index 9967597..5cd4a99 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java @@ -111,9 +111,9 @@ public abstract class VisitorMyVisitor extends BaseFragment { @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)); + TextView textView = view.findViewById(R.id.content); + textView.setText(text); + textView.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(); diff --git a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep1.java b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep1.java index 2bcea1b..89c864a 100644 --- a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep1.java +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep1.java @@ -1,8 +1,10 @@ package com.community.pocket.ui.resetpwd; import android.content.Intent; +import android.os.Build; import android.view.View; +import androidx.annotation.RequiresApi; import androidx.navigation.fragment.NavHostFragment; import com.community.pocket.R; @@ -12,6 +14,8 @@ import com.community.pocket.ui.login.LoginActivity; import org.xutils.view.annotation.ContentView; import org.xutils.view.annotation.Event; +import java.util.Objects; + /** * 重置密码第一步,输入账号邮箱 */ @@ -25,8 +29,10 @@ public class ResetPwdStep1 extends BaseFragment { } //返回登陆 + @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Event(value = R.id.back) private void back(View view) { startActivity(new Intent(getContext(), LoginActivity.class)); + Objects.requireNonNull(getActivity()).finish(); } } diff --git a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep3.java b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep3.java index 81d9632..1d3387e 100644 --- a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep3.java +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep3.java @@ -1,9 +1,12 @@ package com.community.pocket.ui.resetpwd; import android.content.Intent; +import android.os.Build; import android.view.View; import android.widget.Toast; +import androidx.annotation.RequiresApi; + import com.community.pocket.R; import com.community.pocket.ui.BaseFragment; import com.community.pocket.ui.login.LoginActivity; @@ -11,6 +14,8 @@ import com.community.pocket.ui.login.LoginActivity; import org.xutils.view.annotation.ContentView; import org.xutils.view.annotation.Event; +import java.util.Objects; + /** * 重置密码第三步,输入密码 */ @@ -22,8 +27,10 @@ public class ResetPwdStep3 extends BaseFragment { Toast.makeText(getContext(), R.string.action_reset_password, Toast.LENGTH_SHORT).show(); } + @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Event(value = R.id.back) private void back(View v) { startActivity(new Intent(getContext(), LoginActivity.class)); + Objects.requireNonNull(getActivity()).finish(); } } diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index b545546..540d2c4 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -5,103 +5,101 @@ android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".ui.login.LoginActivity"> - + - + app:layout_constraintTop_toBottomOf="@id/titlebar" + tools:layout_constraintStart_toStartOf="parent"> - + android:autofillHints="@string/AUTOFILL_HINT_USERNAME" + android:hint="@string/prompt_user" + android:inputType="text" + android:selectAllOnFocus="true" + app:layout_constraintEnd_toStartOf="@id/login_to_resetPwd" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:layout_constraintEnd_toStartOf="@id/login_to_resetPwd" /> - + + android:layout_marginTop="8dp" + android:autofillHints="@string/AUTOFILL_HINT_PASSWORD" + android:hint="@string/prompt_password" + android:imeActionLabel="@string/action_sign_in_short" + android:imeOptions="actionDone" + android:inputType="textPassword" + android:selectAllOnFocus="true" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/username" /> -