From 163e238eef30ad22db013893570bcc864240906d Mon Sep 17 00:00:00 2001 From: panqihua <1029559041@qq.com> Date: Tue, 24 Mar 2020 04:40:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=98=E8=AE=B0=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 7 ++ app/src/main/AndroidManifest.xml | 2 +- .../com/community/pocket/ui/BaseFragment.java | 20 +++++ .../pocket/ui/login/LoginActivity.java | 10 ++- .../pocket/ui/resetpwd/ResetPwdActivity.java | 11 +++ .../pocket/ui/resetpwd/ResetPwdStep1.java | 29 +++++++ .../pocket/ui/resetpwd/ResetPwdStep2.java | 42 ++++++++++ .../pocket/ui/resetpwd/ResetPwdStep3.java | 29 +++++++ app/src/main/res/layout/activity_login.xml | 15 +++- .../res/layout/resetpwd/layout/activity.xml | 14 ++++ .../res/layout/resetpwd/layout/fragment.xml | 19 +++++ .../main/res/layout/resetpwd/layout/step1.xml | 70 ++++++++++++++++ .../main/res/layout/resetpwd/layout/step2.xml | 81 +++++++++++++++++++ .../main/res/layout/resetpwd/layout/step3.xml | 67 +++++++++++++++ app/src/main/res/navigation/nav_reset_pwd.xml | 34 ++++++++ app/src/main/res/values-en-rUS/strings.xml | 5 ++ app/src/main/res/values-zh-rCN/strings.xml | 5 ++ app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 8 ++ app/src/main/res/values/styles.xml | 9 +++ 20 files changed, 472 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/community/pocket/ui/BaseFragment.java create mode 100644 app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdActivity.java create mode 100644 app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep1.java create mode 100644 app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java create mode 100644 app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep3.java create mode 100644 app/src/main/res/layout/resetpwd/layout/activity.xml create mode 100644 app/src/main/res/layout/resetpwd/layout/fragment.xml create mode 100644 app/src/main/res/layout/resetpwd/layout/step1.xml create mode 100644 app/src/main/res/layout/resetpwd/layout/step2.xml create mode 100644 app/src/main/res/layout/resetpwd/layout/step3.xml create mode 100644 app/src/main/res/navigation/nav_reset_pwd.xml diff --git a/app/build.gradle b/app/build.gradle index 5adc89f..debf2a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,6 +20,13 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + sourceSets { + main { + res { + srcDirs 'src/main/res', 'src/main/res/layout/resetpwd', 'src/main/res/layout/resetpwd/layout' + } + } + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fcf330f..4ef0eaf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +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/ui/BaseFragment.java b/app/src/main/java/com/community/pocket/ui/BaseFragment.java new file mode 100644 index 0000000..5c8c5b4 --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/BaseFragment.java @@ -0,0 +1,20 @@ +package com.community.pocket.ui; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import org.xutils.x; + +public abstract class BaseFragment extends Fragment { + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + return x.view().inject(this, inflater, container);//fragment注解 + } +} diff --git a/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java b/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java index 525a69b..cc6d552 100644 --- a/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java +++ b/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java @@ -22,6 +22,7 @@ import androidx.lifecycle.ViewModelProvider; import com.community.pocket.R; import com.community.pocket.ui.BaseActivity; import com.community.pocket.ui.register.RegisterActivity; +import com.community.pocket.ui.resetpwd.ResetPwdActivity; import com.community.pocket.util.PropertiesUtil; import org.xutils.view.annotation.ContentView; @@ -46,7 +47,7 @@ public class LoginActivity extends BaseActivity { private EditText passwordEditText; //登录按钮 - @ViewInject(R.id.login) + @ViewInject(R.id.back) private Button loginButton; //进度条 @@ -123,7 +124,7 @@ public class LoginActivity extends BaseActivity { } //登录按钮触发登录请求操作 - @Event(value = R.id.login) + @Event(value = R.id.back) private void login(View v) { //显示登录请求处理进度 loadingProgressBar.setVisibility(View.VISIBLE); @@ -148,6 +149,11 @@ public class LoginActivity extends BaseActivity { return false; } + @Event(value = R.id.login_to_resetPwd) + private void resetRwd(View v) { + startActivity(new Intent(this, ResetPwdActivity.class)); + } + //登陆成功信息 private void updateUiWithUser(LoggedInUserView model) { String welcome = getString(R.string.welcome) + model.getDisplayName(); diff --git a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdActivity.java b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdActivity.java new file mode 100644 index 0000000..6c839ff --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdActivity.java @@ -0,0 +1,11 @@ +package com.community.pocket.ui.resetpwd; + +import com.community.pocket.R; +import com.community.pocket.ui.BaseActivity; + +import org.xutils.view.annotation.ContentView; + +@ContentView(R.layout.activity) +public class ResetPwdActivity extends BaseActivity { + +} 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 new file mode 100644 index 0000000..ef83c06 --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep1.java @@ -0,0 +1,29 @@ +package com.community.pocket.ui.resetpwd; + +import android.content.Intent; +import android.view.View; + +import androidx.navigation.fragment.NavHostFragment; + +import com.community.pocket.R; +import com.community.pocket.ui.BaseFragment; +import com.community.pocket.ui.login.LoginActivity; + +import org.xutils.view.annotation.ContentView; +import org.xutils.view.annotation.Event; + +@ContentView(R.layout.step1) +public class ResetPwdStep1 extends BaseFragment { + //进入下一步发送验证码 + @Event(value = R.id.next) + private void onClick(View view) { + NavHostFragment.findNavController(ResetPwdStep1.this) + .navigate(R.id.action_First2Fragment_to_Second2Fragment); + } + + //返回登陆 + @Event(value = R.id.back) + private void back(View view) { + startActivity(new Intent(getContext(), LoginActivity.class)); + } +} diff --git a/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java new file mode 100644 index 0000000..fb7758c --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep2.java @@ -0,0 +1,42 @@ +package com.community.pocket.ui.resetpwd; + +import android.view.View; +import android.widget.Toast; + +import androidx.navigation.fragment.NavHostFragment; + +import com.community.pocket.R; +import com.community.pocket.ui.BaseFragment; + +import org.xutils.view.annotation.ContentView; +import org.xutils.view.annotation.Event; + +@ContentView(R.layout.step2) +public class ResetPwdStep2 extends BaseFragment { + + /** + * 返回第一步输入账号邮箱 + */ + @Event(value = R.id.back) + private void onClick(View view) { + NavHostFragment.findNavController(ResetPwdStep2.this) + .navigate(R.id.action_Second2Fragment_to_First2Fragment); + } + + /** + * 进入下一步重置密码 + */ + @Event(value = R.id.next) + private void next(View view) { + NavHostFragment.findNavController(ResetPwdStep2.this) + .navigate(R.id.action_Second2Fragment_to_threeFragment); + } + + /** + * 发送验证码 + */ + @Event(value = R.id.sendcode) + private void sendCode(View view) { + Toast.makeText(getContext(), R.string.action_sendcode, Toast.LENGTH_SHORT).show(); + } +} 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 new file mode 100644 index 0000000..81d9632 --- /dev/null +++ b/app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdStep3.java @@ -0,0 +1,29 @@ +package com.community.pocket.ui.resetpwd; + +import android.content.Intent; +import android.view.View; +import android.widget.Toast; + +import com.community.pocket.R; +import com.community.pocket.ui.BaseFragment; +import com.community.pocket.ui.login.LoginActivity; + +import org.xutils.view.annotation.ContentView; +import org.xutils.view.annotation.Event; + +/** + * 重置密码第三步,输入密码 + */ +@ContentView(R.layout.step3) +public class ResetPwdStep3 extends BaseFragment { + + @Event(value = R.id.reset_pwd) + private void resetPwd(View v) { + Toast.makeText(getContext(), R.string.action_reset_password, Toast.LENGTH_SHORT).show(); + } + + @Event(value = R.id.back) + private void back(View v) { + startActivity(new Intent(getContext(), LoginActivity.class)); + } +} diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 27b1073..b545546 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -35,7 +35,6 @@ android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="8dp" - android:layout_marginEnd="24dp" android:autofillHints="@string/AUTOFILL_HINT_PASSWORD" android:hint="@string/prompt_password" @@ -43,7 +42,7 @@ android:imeOptions="actionDone" android:inputType="textPassword" android:selectAllOnFocus="true" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toStartOf="@+id/login_to_resetPwd" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/username" /> @@ -74,7 +73,7 @@ app:layout_constraintTop_toBottomOf="@+id/password">