SignUpFormFragment.java 5.64 KB
package com.bitstrips.imoji.ui.fragments;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.app.Fragment;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import com.bitstrips.imoji.models.BSUser;
import com.bitstrips.imoji.ui.views.Form;
import com.bitstrips.imoji.ui.views.Form.EmailValidator;
import com.bitstrips.imoji.ui.views.Form.PasswordValidator;
import com.bitstrips.imoji.ui.views.Form.RequiredFieldValidator;
import com.bitstrips.imoji.ui.views.FormField;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SignUpFormFragment
  extends Fragment
{
  FragmentWithValidationContainer a;
  private FormField b;
  private FormField c;
  private FormField d;
  private FormField e;
  
  private void a()
  {
    FragmentWithValidationContainer localFragmentWithValidationContainer = this.a;
    BSUser localBSUser = new BSUser();
    localBSUser.setFirstName(this.b.getText().toString());
    localBSUser.setLastName(this.c.getText().toString());
    localBSUser.setEmail(this.d.getText().toString());
    localBSUser.setPassword(this.e.getText().toString());
    localBSUser.setAppName(getString(2131231162));
    localFragmentWithValidationContainer.doSignUp(localBSUser);
  }
  
  public void onAttach(Activity paramActivity)
  {
    super.onAttach(paramActivity);
    try
    {
      this.a = ((FragmentWithValidationContainer)paramActivity);
      return;
    }
    catch (ClassCastException localClassCastException)
    {
      throw new ClassCastException(paramActivity.toString() + " must implement FragmentWithValidationContainer");
    }
  }
  
  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setHasOptionsMenu(true);
  }
  
  public void onCreateOptionsMenu(Menu paramMenu, MenuInflater paramMenuInflater)
  {
    paramMenuInflater.inflate(2131755011, paramMenu);
    paramMenu.getItem(0).setEnabled(false);
    paramMenu.getItem(0).getIcon().setAlpha(125);
    super.onCreateOptionsMenu(paramMenu, paramMenuInflater);
  }
  
  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    paramViewGroup = paramLayoutInflater.inflate(2130903114, paramViewGroup, false);
    this.b = ((FormField)paramViewGroup.findViewById(2131689738));
    this.c = ((FormField)paramViewGroup.findViewById(2131689739));
    this.d = ((FormField)paramViewGroup.findViewById(2131689539));
    this.e = ((FormField)paramViewGroup.findViewById(2131689656));
    paramBundle = (Button)paramViewGroup.findViewById(2131689741);
    this.a.setMainButton(paramBundle);
    this.a.setTitleBasedOnExtras();
    paramLayoutInflater = new Form(getActivity());
    paramLayoutInflater.addField(this.b, new Form.RequiredFieldValidator(this.b, paramLayoutInflater));
    paramLayoutInflater.addField(this.c, new Form.RequiredFieldValidator(this.c, paramLayoutInflater));
    paramLayoutInflater.addField(this.d, new Form.EmailValidator(this.d, paramLayoutInflater));
    paramLayoutInflater.addField(this.e, new Form.PasswordValidator(this.e, paramLayoutInflater));
    FormField localFormField = (FormField)paramViewGroup.findViewById(2131689539);
    paramLayoutInflater = "";
    if (ActivityCompat.checkSelfPermission(getActivity(), "android.permission.GET_ACCOUNTS") == 0)
    {
      Account[] arrayOfAccount = AccountManager.get(getActivity()).getAccounts();
      int j = arrayOfAccount.length;
      int i = 0;
      while (i < j)
      {
        Account localAccount = arrayOfAccount[i];
        if (Patterns.EMAIL_ADDRESS.matcher(localAccount.name).matches()) {
          paramLayoutInflater = localAccount.name;
        }
        i += 1;
      }
      if (!TextUtils.isEmpty(paramLayoutInflater)) {
        localFormField.setText(paramLayoutInflater);
      }
    }
    paramLayoutInflater = (TextView)paramViewGroup.findViewById(2131689740);
    paramLayoutInflater.setText(Html.fromHtml(String.format(getString(2131231034), new Object[] { getString(2131231072), getString(2131231306) })));
    paramLayoutInflater.setLinkTextColor(getResources().getColor(2131624039));
    paramLayoutInflater.setMovementMethod(LinkMovementMethod.getInstance());
    paramBundle.setOnClickListener(new View.OnClickListener()
    {
      public final void onClick(View paramAnonymousView)
      {
        SignUpFormFragment.a(SignUpFormFragment.this);
      }
    });
    getActivity().getWindow().setSoftInputMode(16);
    this.b.requestFocus();
    return paramViewGroup;
  }
  
  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    if (paramMenuItem.getItemId() == 2131689979)
    {
      a();
      return true;
    }
    return super.onOptionsItemSelected(paramMenuItem);
  }
  
  public static abstract interface FragmentWithValidationContainer
  {
    public abstract void doSignUp(BSUser paramBSUser);
    
    public abstract void setMainButton(Button paramButton);
    
    public abstract void setTitleBasedOnExtras();
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/ui/fragments/SignUpFormFragment.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */