├── .gitignore ├── HelloBubbles ├── bin │ └── classes │ │ └── com │ │ └── warting │ │ └── bubbles │ │ └── .gitignore ├── assets │ └── screenshot.png ├── libs │ └── loremipsum-1.0.jar ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ ├── ic_launcher.png │ │ ├── bubble_green.9.png │ │ └── bubble_yellow.9.png │ ├── values │ │ └── strings.xml │ └── layout │ │ ├── listitem_discuss.xml │ │ └── activity_discuss.xml ├── src │ └── com │ │ └── warting │ │ └── bubbles │ │ ├── OneComment.java │ │ ├── DiscussArrayAdapter.java │ │ └── HelloBubblesActivity.java ├── .classpath ├── project.properties ├── AndroidManifest.xml ├── proguard-project.txt └── .project └── Design ├── bubble.9.psd └── bubble_odd.9.psd /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | bin 3 | gen 4 | -------------------------------------------------------------------------------- /HelloBubbles/bin/classes/com/warting/bubbles/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | gen 3 | -------------------------------------------------------------------------------- /Design/bubble.9.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/Design/bubble.9.psd -------------------------------------------------------------------------------- /Design/bubble_odd.9.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/Design/bubble_odd.9.psd -------------------------------------------------------------------------------- /HelloBubbles/assets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/assets/screenshot.png -------------------------------------------------------------------------------- /HelloBubbles/libs/loremipsum-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/libs/loremipsum-1.0.jar -------------------------------------------------------------------------------- /HelloBubbles/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /HelloBubbles/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /HelloBubbles/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /HelloBubbles/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /HelloBubbles/res/drawable-xhdpi/bubble_green.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/res/drawable-xhdpi/bubble_green.9.png -------------------------------------------------------------------------------- /HelloBubbles/res/drawable-xhdpi/bubble_yellow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warting/AndroidChatBubbles/HEAD/HelloBubbles/res/drawable-xhdpi/bubble_yellow.9.png -------------------------------------------------------------------------------- /HelloBubbles/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello World, HelloBubblesActivity! 5 | HelloBubbles 6 | 7 | -------------------------------------------------------------------------------- /HelloBubbles/src/com/warting/bubbles/OneComment.java: -------------------------------------------------------------------------------- 1 | package com.warting.bubbles; 2 | 3 | public class OneComment { 4 | public boolean left; 5 | public String comment; 6 | 7 | public OneComment(boolean left, String comment) { 8 | super(); 9 | this.left = left; 10 | this.comment = comment; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /HelloBubbles/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /HelloBubbles/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-15 15 | -------------------------------------------------------------------------------- /HelloBubbles/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HelloBubbles/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /HelloBubbles/res/layout/listitem_discuss.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HelloBubbles/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelloBubbles 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /HelloBubbles/res/layout/activity_discuss.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 15 | 22 | 23 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /HelloBubbles/src/com/warting/bubbles/DiscussArrayAdapter.java: -------------------------------------------------------------------------------- 1 | package com.warting.bubbles; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import android.content.Context; 7 | import android.graphics.Bitmap; 8 | import android.graphics.BitmapFactory; 9 | import android.view.Gravity; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.ArrayAdapter; 14 | import android.widget.LinearLayout; 15 | import android.widget.TextView; 16 | 17 | public class DiscussArrayAdapter extends ArrayAdapter { 18 | 19 | private TextView countryName; 20 | private List countries = new ArrayList(); 21 | private LinearLayout wrapper; 22 | 23 | @Override 24 | public void add(OneComment object) { 25 | countries.add(object); 26 | super.add(object); 27 | } 28 | 29 | public DiscussArrayAdapter(Context context, int textViewResourceId) { 30 | super(context, textViewResourceId); 31 | } 32 | 33 | public int getCount() { 34 | return this.countries.size(); 35 | } 36 | 37 | public OneComment getItem(int index) { 38 | return this.countries.get(index); 39 | } 40 | 41 | public View getView(int position, View convertView, ViewGroup parent) { 42 | View row = convertView; 43 | if (row == null) { 44 | LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 45 | row = inflater.inflate(R.layout.listitem_discuss, parent, false); 46 | } 47 | 48 | wrapper = (LinearLayout) row.findViewById(R.id.wrapper); 49 | 50 | OneComment coment = getItem(position); 51 | 52 | countryName = (TextView) row.findViewById(R.id.comment); 53 | 54 | countryName.setText(coment.comment); 55 | 56 | countryName.setBackgroundResource(coment.left ? R.drawable.bubble_yellow : R.drawable.bubble_green); 57 | wrapper.setGravity(coment.left ? Gravity.LEFT : Gravity.RIGHT); 58 | 59 | return row; 60 | } 61 | 62 | public Bitmap decodeToBitmap(byte[] decodedByte) { 63 | return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length); 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /HelloBubbles/src/com/warting/bubbles/HelloBubblesActivity.java: -------------------------------------------------------------------------------- 1 | package com.warting.bubbles; 2 | 3 | import java.util.Random; 4 | 5 | import android.app.Activity; 6 | import android.os.Bundle; 7 | import android.view.KeyEvent; 8 | import android.view.View; 9 | import android.view.View.OnKeyListener; 10 | import android.widget.EditText; 11 | import android.widget.ListView; 12 | import android.widget.Toast; 13 | import de.svenjacobs.loremipsum.LoremIpsum; 14 | 15 | public class HelloBubblesActivity extends Activity { 16 | private com.warting.bubbles.DiscussArrayAdapter adapter; 17 | private ListView lv; 18 | private LoremIpsum ipsum; 19 | private EditText editText1; 20 | private static Random random; 21 | 22 | @Override 23 | public void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_discuss); 26 | random = new Random(); 27 | ipsum = new LoremIpsum(); 28 | 29 | lv = (ListView) findViewById(R.id.listView1); 30 | 31 | adapter = new DiscussArrayAdapter(getApplicationContext(), R.layout.listitem_discuss); 32 | 33 | lv.setAdapter(adapter); 34 | 35 | editText1 = (EditText) findViewById(R.id.editText1); 36 | editText1.setOnKeyListener(new OnKeyListener() { 37 | public boolean onKey(View v, int keyCode, KeyEvent event) { 38 | // If the event is a key-down event on the "enter" button 39 | if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { 40 | // Perform action on key press 41 | adapter.add(new OneComment(false, editText1.getText().toString())); 42 | editText1.setText(""); 43 | return true; 44 | } 45 | return false; 46 | } 47 | }); 48 | 49 | addItems(); 50 | } 51 | 52 | private void addItems() { 53 | adapter.add(new OneComment(true, "Hello bubbles!")); 54 | 55 | for (int i = 0; i < 4; i++) { 56 | boolean left = getRandomInteger(0, 1) == 0 ? true : false; 57 | int word = getRandomInteger(1, 10); 58 | int start = getRandomInteger(1, 40); 59 | String words = ipsum.getWords(word, start); 60 | 61 | adapter.add(new OneComment(left, words)); 62 | } 63 | } 64 | 65 | private static int getRandomInteger(int aStart, int aEnd) { 66 | if (aStart > aEnd) { 67 | throw new IllegalArgumentException("Start cannot exceed End."); 68 | } 69 | long range = (long) aEnd - (long) aStart + 1; 70 | long fraction = (long) (range * random.nextDouble()); 71 | int randomNumber = (int) (fraction + aStart); 72 | return randomNumber; 73 | } 74 | 75 | } --------------------------------------------------------------------------------