Android Open Source - steamchat Steam Account






From Project

Back to project page steamchat.

License

The source code is released under:

Apache License

If you think the Android project steamchat 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.kevelbreh.steamchat.account;
//  w w w  .  jav a 2s . com
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.os.Bundle;

import com.kevelbreh.steamchat.SteamChat;

public class SteamAccount {

    public static final String ACCOUNT_TYPE = "com.kevelbreh.steamchat";

    private Context mContext;

    private Account mAccount;

    private Bundle mData;

    public SteamAccount(Context context) {
        mContext = context;
        mAccount = getAccount(context);
    }

    public SteamAccount(Context context, Bundle data) {
        mContext = context;
        mAccount = getAccount(context);
        mData = data;
    }

    // To be removed.
    public void setData(Bundle data) {
        mData = data;
    }

    /**
     * Set the user's username of their steam account from the temp meta we've saved in the bundled
     * data object.
     */
    public void setCredentials() {
        AccountManager manager = AccountManager.get(mContext);
        mAccount = getAccount(mContext);

        if (mAccount == null && mData != null) {
            final String username = mData.getString("username", null);
            mAccount = new Account(username, ACCOUNT_TYPE);
            manager.addAccountExplicitly(mAccount, null, Bundle.EMPTY);
            manager.setUserData(mAccount, "username", username);
      SteamChat.debug(this, "Created new steam account.");
        }

        mData = null;
    }

    public Bundle getData() {
        return mData;
    }

    /**
     * @return whether the user has an account or not.
     */
    public boolean hasAccount() {
        return !(mAccount == null);
    }

    /**
     * @return whether the user has an account or not.
     */
    public boolean hasAccountIntent() {
        return !(mData == null);
    }

    /**
     * @return the user's steam username.
     */
    public String getUsername() {
        return (mAccount == null) ? null : AccountManager.get(mContext)
                .getUserData(mAccount, "username");
    }

    /**
     * @return the user's steam password.
     */
    public String getPassword() {
        return (mAccount == null) ? null : AccountManager.get(mContext)
                .getPassword(mAccount);
    }

    /**
     * Get some meta from the account
     * @param key meta key
     * @return meta value
     */
    public String getExtra(String key) {
        if (mAccount == null) return null;
        AccountManager manager = AccountManager.get(mContext);
        return manager.getUserData(mAccount, key);
    }

    /**
     * Set some extra data on the user's account.
     * @param key of the meta.
     * @param value of the meta
     */
    public void setExtra(String key, String value) {
        if (mAccount == null) return;
        AccountManager manager = AccountManager.get(mContext);
        manager.setUserData(mAccount, key, value);
    }

    /**
     * Get the user's Steam account. If one is not found then return null.
     * @param context of the application.
     * @return the steam account on this device.
     */
    public static Account getAccount(Context context) {
        AccountManager manager = AccountManager.get(context);
        Account[] accounts = manager.getAccountsByType(ACCOUNT_TYPE);
        return (accounts.length == 0) ? null : accounts[0];
    }

  /**
   * Delete the user's {@link android.accounts.Account} for the steam application.
   * @param context of the application.
   */
  public static void delete(Context context) {
    AccountManager manager = AccountManager.get(context);
    Account account = getAccount(context);
    if (account != null) {
      manager.removeAccount(getAccount(context), null, null);
    }
  }
}




Java Source Code List

com.kevelbreh.steamchat.SteamChat.java
com.kevelbreh.steamchat.account.AuthenticatorService.java
com.kevelbreh.steamchat.account.Authenticator.java
com.kevelbreh.steamchat.account.SteamAccount.java
com.kevelbreh.steamchat.activity.AuthenticationActivity.java
com.kevelbreh.steamchat.activity.ConversationActivity.java
com.kevelbreh.steamchat.activity.FriendsActivity.java
com.kevelbreh.steamchat.activity.InteractionsActivity.java
com.kevelbreh.steamchat.activity.LauncherActivity.java
com.kevelbreh.steamchat.activity.SettingsActivity.java
com.kevelbreh.steamchat.fragment.ConversationFragment.java
com.kevelbreh.steamchat.fragment.FriendsFragment.java
com.kevelbreh.steamchat.fragment.InteractionsFragment.java
com.kevelbreh.steamchat.fragment.SettingsFragment.java
com.kevelbreh.steamchat.provider.SteamProviderUtils.java
com.kevelbreh.steamchat.provider.SteamProvider.java
com.kevelbreh.steamchat.provider.content.InteractionContentItem.java
com.kevelbreh.steamchat.provider.content.PersonaContentItem.java
com.kevelbreh.steamchat.provider.content.UserContentItem.java
com.kevelbreh.steamchat.steam2.SteamConnection.java
com.kevelbreh.steamchat.steam2.SteamEventBus.java
com.kevelbreh.steamchat.steam2.SteamService.java
com.kevelbreh.steamchat.steam2.handler.ConnectionHandler.java
com.kevelbreh.steamchat.steam2.handler.FriendHandler.java
com.kevelbreh.steamchat.steam2.handler.MessageHandler.java
com.kevelbreh.steamchat.steam2.handler.UserHandler.java
com.kevelbreh.steamchat.steam2.packet.Packet.java
com.kevelbreh.steamchat.steam2.packet.ProtoPacket.java
com.kevelbreh.steamchat.steam.SteamClient.java
com.kevelbreh.steamchat.steam.SteamID.java
com.kevelbreh.steamchat.steam.SteamServiceHandler.java
com.kevelbreh.steamchat.steam.SteamService.java
com.kevelbreh.steamchat.steam.handler2.ConnectionHandler.java
com.kevelbreh.steamchat.steam.handler2.FriendHandler.java
com.kevelbreh.steamchat.steam.handler2.Handler.java
com.kevelbreh.steamchat.steam.handler2.UserHandler.java
com.kevelbreh.steamchat.steam.handler.AEventHandler.java
com.kevelbreh.steamchat.steam.handler.AuthenticationHandler.java
com.kevelbreh.steamchat.steam.handler.FriendsHandler.java
com.kevelbreh.steamchat.steam.handler.IEventHandler.java
com.kevelbreh.steamchat.steam.handler.IHandler.java
com.kevelbreh.steamchat.steam.handler.MessageDebugHandler.java
com.kevelbreh.steamchat.steam.language.Language.java
com.kevelbreh.steamchat.steam.language.Message.java
com.kevelbreh.steamchat.steam.network.TCPConnection.java
com.kevelbreh.steamchat.steam.network.packet.ChannelEncryptRequest.java
com.kevelbreh.steamchat.steam.network.packet.ChannelEncryptResponse.java
com.kevelbreh.steamchat.steam.network.packet.ChannelEncryptResult.java
com.kevelbreh.steamchat.steam.network.packet.ClientLogOnResponse.java
com.kevelbreh.steamchat.steam.network.packet.ClientLogOn.java
com.kevelbreh.steamchat.steam.network.packet.HeartBeat.java
com.kevelbreh.steamchat.steam.network.packet.MultiPacket.java
com.kevelbreh.steamchat.steam.network.packet.Packet.java
com.kevelbreh.steamchat.steam.network.packet.ProtoPacket.java
com.kevelbreh.steamchat.steam.proto.DescriptorsProto.java
com.kevelbreh.steamchat.steam.proto.EncryptedAppTicketProto.java
com.kevelbreh.steamchat.steam.proto.SteamMessagesBaseProto.java
com.kevelbreh.steamchat.steam.proto.SteamMessagesClientServerProto.java
com.kevelbreh.steamchat.steam.security.AsnKeyParser.java
com.kevelbreh.steamchat.steam.security.AsnParser.java
com.kevelbreh.steamchat.steam.security.BerDecodeException.java
com.kevelbreh.steamchat.steam.security.Cryptography.java
com.kevelbreh.steamchat.steam.security.NetEncryption.java
com.kevelbreh.steamchat.steam.security.PublicKey.java
com.kevelbreh.steamchat.steam.security.RSA.java
com.kevelbreh.steamchat.steam.util.BinaryReader.java
com.kevelbreh.steamchat.steam.util.BinaryWriter.java
com.kevelbreh.steamchat.steam.util.BitVector64.java
com.kevelbreh.steamchat.steam.util.JenkinsHash.java
com.kevelbreh.steamchat.util.AServiceActivity.java
com.kevelbreh.steamchat.util.Dump.java
com.kevelbreh.steamchat.util.MiscUtils.java
com.kevelbreh.steamchat.widget.adapter.ChatAdapter.java
com.kevelbreh.steamchat.widget.adapter.ConversationAdapter.java
com.kevelbreh.steamchat.widget.adapter.FriendAdapter.java
com.kevelbreh.steamchat.widget.view.AvatarView.java
com.kevelbreh.steamchat.widget.view.FriendInteractionsView.java