Skip to content

Commit

Permalink
Add message to allow user to login manually in the enter email screen. (
Browse files Browse the repository at this point in the history
  • Loading branch information
notandyvee authored Sep 16, 2024
2 parents bd79e42 + f1a36ae commit 1c149f9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ package com.automattic.simplenote.authentication

import android.app.Activity
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.text.Html
import android.text.method.LinkMovementMethod
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import com.automattic.simplenote.R
import com.automattic.simplenote.Simplenote
Expand Down Expand Up @@ -101,6 +106,20 @@ class SignInFragment: MagicLinkableFragment() {
"wpcc_button_press_signin_activity"
)
}
val manualLoginTextView = view.findViewById<TextView>(R.id.sign_in_login_manually)
context?.let {
val colorLink = Integer.toHexString(ContextCompat.getColor(it, R.color.text_link) and 16777215)
manualLoginTextView.text = Html.fromHtml(
String.format(
getString(R.string.signin_login_with_email_manually),
"<span style=\"color:#", colorLink, "\">", "</span>"
)
)
}
manualLoginTextView.setOnClickListener {
val email = getEmailEditText()
showLoginWithPassword(activity, email?.text?.toString())
}
return view
}

Expand Down Expand Up @@ -154,6 +173,8 @@ class SignInFragment: MagicLinkableFragment() {
}

companion object {
const val LOGIN_MANUALLY_SUBSTRING = "log in manually"

fun showLoginWithPassword(activity: Activity?, username: String?) {
activity?.let { act ->
val intent = Intent(act, NewCredentialsActivity::class.java)
Expand Down
17 changes: 16 additions & 1 deletion Simplenote/src/main/res/layout/fragment_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,22 @@
android:textAllCaps="true"
android:textColor="@android:color/white" />

<include layout="@layout/authentication_fancy_or" />
<TextView
android:id="@+id/sign_in_login_manually"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="@string/signin_login_with_email_manually"
android:layout_below="@id/button"
android:textSize="15sp"
android:gravity="center_horizontal"
android:layout_marginVertical="10dp"/>

<include layout="@layout/authentication_fancy_or"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/sign_in_login_manually"
android:layout_marginVertical="10dp"
/>

<com.google.android.material.button.MaterialButton
android:id="@+id/button_login_with_wordpress"
Expand Down
2 changes: 2 additions & 0 deletions Simplenote/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,6 @@
<string name="magic_link_confirm_code_enter_pass_label">Enter password</string>
<string name="magic_link_confirm_code_message">We\'ve sent a code to \n%1$s. The code will be valid for a few minutes.</string>
<string name="login_with_password_message">Enter the password for the account %1$s</string>

<string name="signin_login_with_email_manually">We\'ll email you a code to log in, or you can %1$s%2$s%3$slog in manually%4$s.</string>
</resources>

0 comments on commit 1c149f9

Please sign in to comment.