-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nizarattack
committed
Mar 20, 2012
1 parent
8f2971c
commit 5a5c1ed
Showing
16 changed files
with
808 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_width="fill_parent" | ||
android:layout_height="fill_parent"> | ||
|
||
<TextView android:id="@+id/chatMessages" | ||
android:layout_height="fill_parent" android:layout_width="fill_parent" | ||
android:clickable="false" android:layout_weight="90" android:background="#FFFFFF" /> | ||
|
||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="horizontal" android:layout_width="fill_parent" | ||
android:gravity="bottom" android:layout_height="wrap_content" | ||
android:layout_weight="10" android:paddingTop="5dp"> | ||
|
||
<Button android:id="@+id/btnSend" android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" android:gravity="center" | ||
android:layout_gravity="center_horizontal" android:text="@string/send" | ||
android:layout_alignParentRight="true" android:layout_marginRight="5dp" /> | ||
|
||
<EditText android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" android:textSize="15dp" | ||
android:gravity="center_vertical|left" android:id="@+id/txfMessage" | ||
android:editable="true" android:layout_marginLeft="5dp" | ||
android:layout_marginRight="5dp" android:layout_toLeftOf="@id/btnSend" /> | ||
|
||
|
||
|
||
</RelativeLayout> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TableLayout android:id="@+id/tableLayout1" | ||
android:layout_width="fill_parent" android:layout_height="fill_parent" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:stretchColumns="1"> | ||
|
||
<TableRow android:layout_marginTop="5dp"> | ||
<ImageView android:layout_height="60dp" android:id="@+id/imgContact" | ||
android:layout_width="60dp"></ImageView> | ||
|
||
<LinearLayout android:id="@+id/linearLayout2" | ||
android:layout_height="60dp" android:layout_width="match_parent" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_marginLeft="10dp"> | ||
<TextView android:text="TextView" android:id="@+id/txtName" | ||
android:layout_width="wrap_content" android:layout_height="wrap_content" | ||
android:textStyle="bold" android:textSize="20dp"></TextView> | ||
<TextView android:text="TextView" android:id="@+id/txtStatus" | ||
android:layout_width="fill_parent" android:layout_height="wrap_content" | ||
android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever"></TextView> | ||
</LinearLayout> | ||
|
||
</TableRow> | ||
|
||
|
||
</TableLayout> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" android:gravity="top" android:background="#FFFFFF"> | ||
|
||
<ImageView android:layout_height="85dp" | ||
android:layout_width="180dp" android:clickable="false" | ||
android:id="@+id/imageHeader" android:src="@drawable/gtalk_logo" | ||
android:scaleType="fitXY"></ImageView> | ||
|
||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" android:gravity="center"> | ||
|
||
<EditText android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" android:textSize="15dp" | ||
android:gravity="center_vertical|left" android:id="@+id/txfUser" android:editable="true" | ||
android:layout_marginLeft="5dp" android:layout_marginRight="5dp" /> | ||
|
||
<EditText android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" android:textSize="15dp" | ||
android:gravity="center_vertical|left" android:id="@+id/txfPassword" | ||
android:editable="true" android:password="true" | ||
android:layout_marginLeft="5dp" android:layout_marginRight="5dp" /> | ||
|
||
<Button android:id="@+id/btnLogin" android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" android:gravity="center" | ||
android:layout_gravity="center_horizontal" android:text="@string/login" /> | ||
</LinearLayout> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:background="#FFFFFF"> | ||
<ImageView android:layout_height="55dp" | ||
android:layout_width="120dp" android:clickable="false" | ||
android:id="@+id/imageHeader" android:src="@drawable/gtalk_logo" | ||
android:scaleType="fitXY"></ImageView> | ||
<ListView android:layout_height="fill_parent" | ||
android:id="@+id/listViewContacts" | ||
android:layout_width="fill_parent" | ||
android:clickable="true" | ||
android:layout_marginTop="10dip" | ||
android:cacheColorHint="#00000000" > | ||
</ListView> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.chatmessenger.android.gmail; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
import org.jivesoftware.smack.ConnectionConfiguration; | ||
import org.jivesoftware.smack.Roster; | ||
import org.jivesoftware.smack.RosterEntry; | ||
import org.jivesoftware.smack.XMPPConnection; | ||
import org.jivesoftware.smack.XMPPException; | ||
import org.jivesoftware.smack.packet.Presence; | ||
|
||
import com.chatmessenger.android.R; | ||
|
||
import android.content.res.Resources; | ||
|
||
public class ConnectionHelper { | ||
|
||
static XMPPConnection conn = new XMPPConnection(new ConnectionConfiguration( | ||
"talk.google.com", 5222, "google.com")); | ||
|
||
static Roster roster; | ||
|
||
public static void connect() throws XMPPException { | ||
conn.connect(); | ||
} | ||
|
||
public static XMPPConnection getConnection() { | ||
return conn; | ||
} | ||
|
||
public static void login(String user, String pass) throws XMPPException { | ||
conn.login(user, pass); | ||
roster = conn.getRoster(); | ||
} | ||
|
||
public static Roster getRoster() { | ||
return roster; | ||
} | ||
|
||
public static ArrayList<Contact> getContactList(Resources res) { | ||
ArrayList<Contact> contactList = new ArrayList<Contact>(); | ||
Collection<RosterEntry> rosterCollection = roster.getEntries(); | ||
Presence presence; | ||
for (RosterEntry re : rosterCollection) { | ||
presence = roster.getPresence(re.getUser()); | ||
if (presence.isAvailable()) { | ||
Contact c = new Contact(); | ||
if(re.getName() == null || re.getName().trim().equals("")) | ||
c.setName(re.getUser()); | ||
else | ||
c.setName(re.getName()); | ||
c.setStatus(presence.getStatus()); | ||
c.setRosterEntry(re); | ||
if (presence.getMode() == null) | ||
c.setImage(res.getDrawable(R.drawable.available)); | ||
else if (presence.getMode().equals(Presence.Mode.chat)) | ||
c.setImage(res.getDrawable(R.drawable.available)); | ||
else if (presence.getMode().equals(Presence.Mode.away) | ||
|| presence.getMode().equals(Presence.Mode.xa)) | ||
c.setImage(res.getDrawable(R.drawable.idle)); | ||
else if (presence.getMode().equals(Presence.Mode.dnd)) | ||
c.setImage(res.getDrawable(R.drawable.busy)); | ||
else | ||
c.setImage(res.getDrawable(R.drawable.available)); | ||
contactList.add(c); | ||
} | ||
} | ||
return contactList; | ||
} | ||
|
||
public static ArrayList<Contact> getContactList() { | ||
ArrayList<Contact> contactList = new ArrayList<Contact>(); | ||
Collection<RosterEntry> rosterCollection = roster.getEntries(); | ||
Presence presence; | ||
for (RosterEntry re : rosterCollection) { | ||
presence = roster.getPresence(re.getUser()); | ||
if (presence.isAvailable()) { | ||
Contact c = new Contact(); | ||
if(re.getName() == null || re.getName().trim().equals("")) | ||
c.setName(re.getUser()); | ||
else | ||
c.setName(re.getName()); | ||
c.setStatus(presence.getStatus()); | ||
c.setRosterEntry(re); | ||
contactList.add(c); | ||
} | ||
} | ||
return contactList; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.chatmessenger.android.gmail; | ||
|
||
import org.jivesoftware.smack.RosterEntry; | ||
|
||
import android.graphics.drawable.Drawable; | ||
|
||
public class Contact { | ||
|
||
private String name; | ||
private String status; | ||
private Drawable image; | ||
private RosterEntry rosterEntry; | ||
|
||
|
||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public String getStatus() { | ||
return status; | ||
} | ||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
public Drawable getImage() { | ||
return image; | ||
} | ||
public void setImage(Drawable image) { | ||
this.image = image; | ||
} | ||
public RosterEntry getRosterEntry() { | ||
return rosterEntry; | ||
} | ||
public void setRosterEntry(RosterEntry rosterEntry) { | ||
this.rosterEntry = rosterEntry; | ||
} | ||
|
||
|
||
} |
46 changes: 46 additions & 0 deletions
46
src/com/chatmessenger/android/gmail/ContactArrayAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.chatmessenger.android.gmail; | ||
|
||
import android.widget.ArrayAdapter; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
import java.util.List; | ||
|
||
import com.chatmessenger.android.R; | ||
|
||
public class ContactArrayAdapter extends ArrayAdapter<Contact> | ||
{ | ||
private int resource; | ||
|
||
public ContactArrayAdapter(Context paramContext, int paramInt, List<Contact> paramList) | ||
{ | ||
super(paramContext, paramInt, paramList); | ||
this.resource = paramInt; | ||
} | ||
|
||
public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) | ||
{ | ||
Contact localContact = (Contact)getItem(paramInt); | ||
LinearLayout localLinearLayout; | ||
localLinearLayout = new LinearLayout(getContext()); | ||
((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(this.resource, localLinearLayout, true); | ||
TextView localTextView1 = (TextView)localLinearLayout.findViewById(R.id.txtName); | ||
TextView localTextView2 = (TextView)localLinearLayout.findViewById(R.id.txtStatus); | ||
ImageView localImageView = (ImageView)localLinearLayout.findViewById(R.id.imgContact); | ||
localTextView1.setText(localContact.getName()); | ||
localTextView2.setText(localContact.getStatus()); | ||
localImageView.setImageDrawable(localContact.getImage()); | ||
return localLinearLayout; | ||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.