package com.ljuwon.mychat;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import org.apache.commons.lang.StringUtils;

import java.util.Random;

/**
 * Created by 주원 on 2017-01-19.
 */
public class LoginActivity extends AppCompatActivity {

    Toolbar toolbar;
    Button login_bt;
    EditText nick_et;
    EditText profile_et;
    String user_name, image_url;
    StringUtils StringUtils;
    SharedPreferences pref;

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);

        pref = getSharedPreferences("pref", Activity.MODE_PRIVATE);

        toolbar = (Toolbar) findViewById(R.id.chat_toolbar);
        setSupportActionBar(toolbar);

        ActionBar ab = getSupportActionBar();
        if (null != ab) {
            ab.setDisplayHomeAsUpEnabled(true);
        }

        login_bt = (Button)findViewById(R.id.login_bt);
        nick_et = (EditText)findViewById(R.id.nick_et);
        profile_et = (EditText)findViewById(R.id.profile_et);

        if(!StringUtils.isBlank(pref.getString("username", "")))
            nick_et.setText(pref.getString("username", ""));

        if(!StringUtils.isBlank(pref.getString("profile", "")))
            profile_et.setText(pref.getString("profile", ""));

        login_bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                if(StringUtils.isBlank(nick_et.getText().toString())) {
                    user_name = "유저" + new Random().nextInt(10000);
                    image_url = profile_et.getText().toString();
                    if (StringUtils.isBlank(profile_et.getText().toString()))
                        image_url = "https://search.pstatic.net/sunny/?src=https%3A%2F%2Fcdn1.iconfinder.com%2Fdata%2Ficons%2Fcrimes-and-justice%2F100%2F14-512.png&type=b400";
                }
                else {
                    user_name = nick_et.getText().toString();
                    image_url = profile_et.getText().toString();
                    if(StringUtils.isBlank(profile_et.getText().toString()))
                        image_url = "https://search.pstatic.net/sunny/?src=https%3A%2F%2Fcdn1.iconfinder.com%2Fdata%2Ficons%2Fcrimes-and-justice%2F100%2F14-512.png&type=b400";
                }

                intent.putExtra("nickname", user_name);
                intent.putExtra("profile_url", image_url);

                SharedPreferences.Editor editor = pref.edit();
                editor.putString("username", user_name);
                editor.putString("profile", image_url);
                editor.commit();

                nick_et.setText(user_name);
                profile_et.setText(image_url);
                startActivity(intent);
            }
        });

    }

}

@@ -487,16 +487,46 @@
 itText;%0D
+%0Aimport android.widget.Toast;%0D
 %0A%0D%0Aimpor
@@ -2571,24 +2571,298 @@
     else %7B%0D%0A
+                    if(nick_et.getText().toString().length() %3E 20) %7B%0D%0A                        Toast.makeText(LoginActivity.this, %22%EB%8B%89%EB%84%A4%EC%9E%84%EC%9D%80 %EC%B5%9C%EB%8C%80 20%EA%B8%80%EC%9E%90%EA%B9%8C%EC%A7%80 %EC%A0%81%EC%9D%84 %EC%88%98 %EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4%22, Toast.LENGTH_SHORT).show();%0D%0A                        return;%0D%0A                    %7D%0D%0A                    else %7B%0D%0A    
             
@@ -2904,32 +2904,36 @@
 ().toString();%0D%0A
+    
                 
@@ -2974,32 +2974,36 @@
 ().toString();%0D%0A
+    
                 
@@ -3000,32 +3000,33 @@
               if
+ 
 (StringUtils.isB
@@ -3057,32 +3057,36 @@
 ).toString()))%0D%0A
+    
                 
@@ -3238,32 +3238,55 @@
 ng&type=b400%22;%0D%0A
+                    %7D%0D%0A
                 

Add Nickname max