Android Open Source - pokerCCF Startup Fragment






From Project

Back to project page pokerCCF.

License

The source code is released under:

Copyright (c) 2011-2014, Intel Corporation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redist...

If you think the Android project pokerCCF listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.intel.startup;
// w  w w .  j av a  2s.co  m
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.intel.inproclib.R;
import com.intel.startup.NewUnbox.UnboxFragmentEnum;
import com.intel.stc.lib.StcLib;
import com.intel.stc.utility.StcConstants;
import com.intel.stc.utility.d;
import com.intel.stclibcc.StcLibCC;

public class StartupFragment extends NewUnboxFragment implements OnClickListener
{
  /********************** Constants ********************************************/
  public final static String   tag             = "Unboxing";
  public final static String  className          = "InProc - " + StartupFragment.class.getSimpleName();
  
  /********************** Local Variables ********************************************/
  Button mCreateAccountButton;
  Button mSignInButton;
  Button mSkipSignInButton;
  
  private String      clientID            = "UW1zLA6yCWaqErsllAAK1kC1yJQQWldZ";
  private String      redirectURL            = "http://www.intel.com/robots.txt";
  
  boolean createAccountBtnClicked = false;
  
  /*********************************************************************/
  /**** Android Activity Life Cycle ************************************/
  /*********************************************************************/
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
  {
    Log.v("Unboxing", "StartupFragment: OnCreateView - Begin");
    
    View vStartupFragmentView = inflater.inflate(R.layout.frag_unboxing_startup, null);
    
    mCreateAccountButton = (Button)vStartupFragmentView.findViewById(R.id.create_account_button);
    mCreateAccountButton.setOnClickListener(this);
    
    mSignInButton = (Button)vStartupFragmentView.findViewById(R.id.sign_in_button);
    mSignInButton.setOnClickListener(this);  
    
    mSkipSignInButton = (Button) vStartupFragmentView.findViewById(R.id.skip_sign_in_button);
    
    if(newActivity.registerButtonClicked == false)
    {
      // User clicked 'Sign in' button on the first startup page and not 'Register' button in Profile.
      mSkipSignInButton.setOnClickListener(this);
    }
    else
    {
      // User clicked 'Register' button in Profile. Do not show 'Skip Sign In' button.
      mSkipSignInButton.setVisibility(View.GONE);
    }
    
    Log.v("Unboxing", "StartupFragment: OnCreateView - End");
    
    return vStartupFragmentView;
  }
  
  /*********************************************************************/
  /**** Android Callbacks **********************************************/
  /*********************************************************************/  
  @Override
  public void onClick(View startupView)
  {    
    final int buttonId = startupView.getId();
    
    if(buttonId == R.id.create_account_button)
    {      
      d.print(tag, className, "onClick", "User clicked 'Create Account' button.");
      
      File file = new File(Environment.getExternalStorageDirectory(), "/Intel/cloudsettings.xml");
      if(file.exists())
      {
        try
        {      
          XmlPullParserFactory xppfact = XmlPullParserFactory.newInstance();
          xppfact.setNamespaceAware(true);
          XmlPullParser xpp = xppfact.newPullParser();
          
          FileInputStream fis = new FileInputStream(file);
          xpp.setInput(new InputStreamReader(fis));
          int eventType;
          while ((eventType = xpp.next()) != XmlPullParser.END_DOCUMENT)
          {
            if (eventType == XmlPullParser.START_TAG)
            {
              String name = xpp.getName();
              if(name.compareTo("ClientId") == 0)
              {
                clientID = xpp.nextText();
              }
              if(name.compareTo("RedirectURI") == 0)
              {
                redirectURL = xpp.nextText();
              }
            }
          }
        }
        catch(IOException e)
        {
          Log.v("StartupFragment:onStartCommand",e.getMessage());
        }
        catch(XmlPullParserException e)
        {
          Log.v("StartupFragment:onStartCommand",e.getMessage());
        }
      }
      
      // start executing 'Create Account' flow. Currently 'Create new account 'and 'Sign In' flows are the same.
      Intent i = new Intent(newActivity, CloudAuthorizationActivity.class);
      i.putExtra(newActivity.CREATE_ACCOUNT_BUTTON_CLICKED, true);
      i.putExtra("clientID", clientID);
      i.putExtra("redirectURL", redirectURL);
      i.putExtra("appId", StcLibCC.id.appId.toString());
      
      newActivity.startActivityForResult(i, NewUnbox.STARTED_CLOUD);
    }
    else if(buttonId == R.id.sign_in_button)
    {      
      d.print(tag, className, "onClick", "User clicked 'Sign In' button.");

      File file = new File(Environment.getExternalStorageDirectory(), "/Intel/cloudsettings.xml");
      if(file.exists())
      {
        try
        {      
          XmlPullParserFactory xppfact = XmlPullParserFactory.newInstance();
          xppfact.setNamespaceAware(true);
          XmlPullParser xpp = xppfact.newPullParser();
          
          FileInputStream fis = new FileInputStream(file);
          xpp.setInput(new InputStreamReader(fis));
          int eventType;
          while ((eventType = xpp.next()) != XmlPullParser.END_DOCUMENT)
          {
            if (eventType == XmlPullParser.START_TAG)
            {
              String name = xpp.getName();
              if(name.compareTo("ClientId") == 0)
              {
                clientID = xpp.nextText();
              }
              if(name.compareTo("RedirectURI") == 0)
              {
                redirectURL = xpp.nextText();
              }
            }
          }
        }
        catch(IOException e)
        {
          Log.v("StartupFragment:onStartCommand",e.getMessage());
        }
        catch(XmlPullParserException e)
        {
          Log.v("StartupFragment:onStartCommand",e.getMessage());
        }
      }
      
      // start executing 'Sing In' flow
      Intent i = new Intent(newActivity, CloudAuthorizationActivity.class);
      i.putExtra("clientID", clientID);
      i.putExtra("redirectURL", redirectURL);
      i.putExtra("appId", StcLibCC.id.appId.toString());
      
      newActivity.startActivityForResult(i, NewUnbox.STARTED_CLOUD);
    }
    else if(buttonId == R.id.skip_sign_in_button)
    {
      Log.v("Unboxing", "StartupFragment: OnClick - User clicked 'Skip Sign In' button.");
      
      // start executing 'Skip Sign In' flow
      if (newActivity != null)
      {  
        d.print(tag, className, "onClick", "Switching to 'UserName' view.");
        UnboxFragmentEnum.username.addOrReplaceFragment(newActivity);
      }        
    }    
  }
    
  @Override
  public void onBackPressed()
  {
    if (newActivity != null)
    {      
      d.print(tag, className, "onBackPressed", "User clicked 'Back' button. Cancelling unboxing and exiting application.");
      newActivity.setFailFinish();;
    }
  }
  
}




Java Source Code List

com.intel.friend.invitation.FriendInvitationBase.java
com.intel.friend.invitation.FriendInvitationError.java
com.intel.friend.invitation.FriendInvitationMessage.java
com.intel.friend.invitation.FriendInvitationService.java
com.intel.friend.invitation.FriendReceiveInvitationActivity.java
com.intel.friend.invitation.FriendReceiveInvitationState.java
com.intel.friend.invitation.FriendSendInvitationActivity.java
com.intel.friend.invitation.FriendSendInvitationState.java
com.intel.friend.invitation.IDataStreamEventListener.java
com.intel.friend.invitation.IFriendInvitationEventListener.java
com.intel.friend.invitation.ReadEngine.java
com.intel.friend.invitation.SendInvitationDialogFragment.java
com.intel.friend.invitation.WriteEngine.java
com.intel.inproclib.user_details.UpdateUserDetailsActivity.java
com.intel.inproclib.user_details.UserSettingsFragment.java
com.intel.inproclib.utility.ImageViewNoLayoutRefresh.java
com.intel.inproclib.utility.InProcConstants.java
com.intel.inproclib.utility.InProc_ImageManager_Assets.java
com.intel.inproclib.utility.InProc_ListViewImageManager_FileSystem.java
com.intel.inproclib.utility.InProc_ListViewImageManager.java
com.intel.inproclib.utility.MaxLengthTextWatcher.java
com.intel.inproclib.utility.NoNewlineEditText.java
com.intel.startup.AvatarFragment.java
com.intel.startup.AvatarPickerFragment.java
com.intel.startup.CloudAuthorizationActivity.java
com.intel.startup.DeviceNameFragment.java
com.intel.startup.NewUnboxFragment.java
com.intel.startup.NewUnbox.java
com.intel.startup.StartupFragment.java
com.intel.startup.UserNameFragment.java
com.intel.ux.ImageUtilities.java
com.intel.ux.StcSessionListAdapter.java
lo.wolo.pokerccf.AbstractServiceUsingActivity.java
lo.wolo.pokerccf.CCFManager.java
lo.wolo.pokerccf.ChatAdapter.java
lo.wolo.pokerccf.Constants.java
lo.wolo.pokerccf.DiscoveryNodeActivity.java
lo.wolo.pokerccf.IServiceIOListener.java
lo.wolo.pokerccf.ISimpleDiscoveryListener.java
lo.wolo.pokerccf.MultiConnectRegisterApp.java
lo.wolo.pokerccf.NodeListAdapter.java
lo.wolo.pokerccf.NodeWrapper.java
lo.wolo.pokerccf.ReadEngine.java
lo.wolo.pokerccf.RemoteUser.java
lo.wolo.pokerccf.ServerController.java
lo.wolo.pokerccf.SessionAdapter.java
lo.wolo.pokerccf.WriteEngine.java
lo.wolo.pokerengine.Card.java
lo.wolo.pokerengine.ClientCCF.java
lo.wolo.pokerengine.Client.java
lo.wolo.pokerengine.Deck.java
lo.wolo.pokerengine.HandEvaluator.java
lo.wolo.pokerengine.HandValueType.java
lo.wolo.pokerengine.HandValue.java
lo.wolo.pokerengine.Hand.java
lo.wolo.pokerengine.Player.java
lo.wolo.pokerengine.Pot.java
lo.wolo.pokerengine.TableType.java
lo.wolo.pokerengine.Table.java
lo.wolo.pokerengine.actions.Action.java
lo.wolo.pokerengine.actions.AllInAction.java
lo.wolo.pokerengine.actions.BetAction.java
lo.wolo.pokerengine.actions.BigBlindAction.java
lo.wolo.pokerengine.actions.CallAction.java
lo.wolo.pokerengine.actions.CheckAction.java
lo.wolo.pokerengine.actions.ContinueAction.java
lo.wolo.pokerengine.actions.FoldAction.java
lo.wolo.pokerengine.actions.RaiseAction.java
lo.wolo.pokerengine.actions.SmallBlindAction.java
lo.wolo.pokerengine.bots.BasicBot.java
lo.wolo.pokerengine.bots.Bot.java
lo.wolo.pokerengine.bots.DummyBot.java
lo.wolo.pokerengine.util.PokerUtils.java