vpaliy / android-login Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Could you add a licence to your code to clarify the usage of it?
when i click on sign in textView on login fragment then Logcat is showing warning
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
finishComposingText on inactive InputConnection
and the page is not switching. problem might be i use textUtils
private Boolean validate() {
//for email validation
Pattern pattern;
Matcher matcher;
final String EMAIL_PATTERN="^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
pattern=Pattern.compile(EMAIL_PATTERN);
matcher=pattern.matcher(email_id.getText().toString());
if (TextUtils.isEmpty(email_id.getText())) {
email_id.setError("Please enter username");
email_id.requestFocus();
}else if (TextUtils.isEmpty(password.getText())) {
password.setError("Please enter your password");
password.requestFocus();
}else if (TextUtils.isEmpty(confirmPassword.getText().toString())) {
confirmPassword.setError("Please enter your password");
confirmPassword.requestFocus();
}else if(!password.getText().equals(confirmPassword.getText()) ){
//Passward and confirm password is not same
Toast.makeText(getContext(),"Confirm Password should be same as Password", Toast.LENGTH_SHORT).show();
} else if(!matcher.matches()){
//email is validate
Toast.makeText(getContext(),"Please Enter a Valid Email address like [email protected] ", Toast.LENGTH_SHORT).show();
} else{
return true;
}
return false;
}
on button click event. so please tell me what else i can do so that this error is removed and fragment will move smoothly . I am attaching signup fragment code with this question.
`package in.branmark.websitedemo;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import com.transitionseverywhere.ChangeBounds;
import com.transitionseverywhere.Transition;
import com.transitionseverywhere.TransitionManager;
import com.transitionseverywhere.TransitionSet;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.support.annotation.Nullable;
import android.annotation.TargetApi;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import butterknife.BindViews;
import butterknife.ButterKnife;
public class SignUpFragment extends AuthFragment{
@BindViews(value = {R.id.email_input_edit,
R.id.password_input_edit,
R.id.confirm_password_edit})
protected List<TextInputEditText> views;
VerticalTextView signin;
TextInputEditText email_id;
TextInputEditText password;
TextInputEditText confirmPassword;
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if(views!=null){
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.color_sign_up));
caption.setText(getString(R.string.sign_up_label));
for(TextInputEditText editText:views){
if(editText.getId()==R.id.password_input_edit){
final TextInputLayout inputLayout= ButterKnife.findById(view,R.id.password_input);
final TextInputLayout confirmLayout=ButterKnife.findById(view,R.id.confirm_password);
Typeface boldTypeface = Typeface.defaultFromStyle(Typeface.BOLD);
inputLayout.setTypeface(boldTypeface);
confirmLayout.setTypeface(boldTypeface);
editText.addTextChangedListener(new TextWatcherAdapter(){
@Override
public void afterTextChanged(Editable editable) {
inputLayout.setPasswordVisibilityToggleEnabled(editable.length()>0);
}
});
}
editText.setOnFocusChangeListener((temp,hasFocus)->{
if(!hasFocus){
boolean isEnabled=editText.getText().length()>0;
editText.setSelected(isEnabled);
}
});
}
caption.setVerticalText(true);
foldStuff();
caption.setTranslationX(getTextPadding());
signin = view.findViewById(R.id.caption);
email_id=view.findViewById(R.id.email_input_edit);
password=view.findViewById(R.id.password_input_edit);
confirmPassword=view.findViewById(R.id.confirm_password_edit);
//check if password is equal to confirm password
//password.getText().toString()==confirmPassword.getText().toString()
signin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (validate()) {
JSONObject postData = new JSONObject();
try {
postData.put("uid", email_id.getText().toString());
postData.put("pass", password.getText().toString());
new SendDeviceDetails().execute("http://cp.foxymark.com/test-a.php", postData.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
}
}
private Boolean validate() {
//for email validation
Pattern pattern;
Matcher matcher;
final String EMAIL_PATTERN="^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
pattern=Pattern.compile(EMAIL_PATTERN);
matcher=pattern.matcher(email_id.getText().toString());
if (TextUtils.isEmpty(email_id.getText())) {
email_id.setError("Please enter username");
email_id.requestFocus();
}else if (TextUtils.isEmpty(password.getText())) {
password.setError("Please enter your password");
password.requestFocus();
}else if (TextUtils.isEmpty(confirmPassword.getText().toString())) {
confirmPassword.setError("Please enter your password");
confirmPassword.requestFocus();
}else if(!password.getText().equals(confirmPassword.getText()) ){
//Passward and confirm password is not same
Toast.makeText(getContext(),"Confirm Password should be same as Password", Toast.LENGTH_SHORT).show();
} else if(!matcher.matches()){
//email is validate
Toast.makeText(getContext(),"Please Enter a Valid Email address like [email protected] ", Toast.LENGTH_SHORT).show();
} else{
return true;
}
return false;
}
@Override
public int authLayout() {
return R.layout.fragment_sign_up;
}
@Override
public void clearFocus() {
for(View view:views) view.clearFocus();
}
@Override
public void fold() {
lock=false;
Rotate transition = new Rotate();
transition.setEndAngle(-90f);
transition.addTarget(caption);
TransitionSet set=new TransitionSet();
set.setDuration(getResources().getInteger(R.integer.duration));
ChangeBounds changeBounds=new ChangeBounds();
set.addTransition(changeBounds);
set.addTransition(transition);
TextSizeTransition sizeTransition=new TextSizeTransition();
sizeTransition.addTarget(caption);
set.addTransition(sizeTransition);
set.setOrdering(TransitionSet.ORDERING_TOGETHER);
set.addListener(new Transition.TransitionListenerAdapter(){
@Override
public void onTransitionEnd(Transition transition) {
super.onTransitionEnd(transition);
caption.setTranslationX(getTextPadding());
caption.setRotation(0);
caption.setVerticalText(true);
caption.requestLayout();
}
});
TransitionManager.beginDelayedTransition(parent,set);
foldStuff();
caption.setTranslationX(-caption.getWidth()/8+getTextPadding());
}
private void foldStuff(){
caption.setTextSize(TypedValue.COMPLEX_UNIT_PX,caption.getTextSize()/2f);
caption.setTextColor(Color.WHITE);
ConstraintLayout.LayoutParams params=getParams();
params.rightToRight=ConstraintLayout.LayoutParams.UNSET;
params.verticalBias=0.5f;
caption.setLayoutParams(params);
}
private float getTextPadding(){
return getResources().getDimension(R.dimen.folded_label_padding)/2.1f;
}
private class SendDeviceDetails extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String data = "";
HttpURLConnection httpURLConnection = null;
try {
httpURLConnection = (HttpURLConnection) new URL(params[0]).openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
OutputStream os = httpURLConnection.getOutputStream();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
String pd = URLEncoder.encode("uid", "UTF-8") + "=" + URLEncoder.encode(email_id.getText().toString(), "UTF-8") + "&" +
URLEncoder.encode("pass", "UTF-8") + "=" + URLEncoder.encode(password.getText().toString(), "UTF-8");
bw.write(pd);
bw.flush();
bw.close();
InputStream in = httpURLConnection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(in);
int inputStreamData = inputStreamReader.read();
while (inputStreamData != -1) {
char current = (char) inputStreamData;
inputStreamData = inputStreamReader.read();
data += current;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
return data;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
Log.e("TAG", result); // this is expecting a response code to be sent from your server upon receiving the POST data
}
}
@Override
public void onPause() {
// hide the keyboard in order to avoid getTextBeforeCursor on inactive InputConnection
InputMethodManager inputMethodManager = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(email_id.getWindowToken(), 0);
inputMethodManager.hideSoftInputFromWindow(password.getWindowToken(), 0);
inputMethodManager.hideSoftInputFromWindow(confirmPassword.getWindowToken(), 0);
super.onPause();
}
}
`
Please help me out. and thanks in advance.
I don't really know the dependency that's causing this error after i cloned this repository and tried running this app
There is still one weird issue left:
When you first start the app, if you push anywhere on the app except on the edit Text or the switch screen textview) there is a weird animation happening that will only happen once (try to click on the background or on the LOG IN button before clicking anything else)
I think the because the lock is initially at false.
I tried to debug it, but I still don't understand how the lock value is false only when you click the caption and try when you click anything else (I've put a breakpoint on any value change on the lock, and I still don't understand how it's changing its value without hitting that breakpoint)
I cloned this repo and started building it for the first time which resulted in an error of not being able to find the method jackOptions
.
I found a similar StackOverflow post and removed the jackOptions in the gradle files.
https://stackoverflow.com/questions/38944593/android-studio-error-when-add-java8-support
Afterwards it was able to build correctly.
Is it okay if I create a PR to fix this?
Hey really cool project, but I feel like there are 2 key point that could be improved:
When you click on the vertical text to switch the view, if you click anywhere fast enough, the animation will stop midway and the views will just be stuck somewhere in the middle (it doesn't crash the app, and it easy to get the view back to normal, but still)
I think it would be better if not only the vertical text was clickable but the whole side
What do you think ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.