-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Slyce-Inc/general-text-item
Added GeneralText and GeneralOption
- Loading branch information
Showing
15 changed files
with
311 additions
and
4 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
6 changes: 6 additions & 0 deletions
6
slyce-messaging/src/main/java/it/slyce/messaging/listeners/OnOptionSelectedListener.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,6 @@ | ||
package it.slyce.messaging.listeners; | ||
|
||
|
||
public interface OnOptionSelectedListener { | ||
void onOptionSelected(int optionSelected); | ||
} |
64 changes: 64 additions & 0 deletions
64
slyce-messaging/src/main/java/it/slyce/messaging/message/GeneralOptionsMessage.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,64 @@ | ||
package it.slyce.messaging.message; | ||
|
||
import android.content.Context; | ||
|
||
import it.slyce.messaging.listeners.OnOptionSelectedListener; | ||
import it.slyce.messaging.message.messageItem.MessageItem; | ||
import it.slyce.messaging.message.messageItem.general.generalOptions.MessageGeneralOptionsItem; | ||
|
||
public class GeneralOptionsMessage extends Message { | ||
private String title; | ||
private String[] options; | ||
private OnOptionSelectedListener onOptionSelectedListener; | ||
private String finalText; | ||
private boolean selected; | ||
|
||
public GeneralOptionsMessage() { | ||
this.selected = false; | ||
} | ||
|
||
public OnOptionSelectedListener getOnOptionSelectedListener() { | ||
return onOptionSelectedListener; | ||
} | ||
|
||
public void setOnOptionSelectedListener(OnOptionSelectedListener onOptionSelectedListener) { | ||
this.onOptionSelectedListener = onOptionSelectedListener; | ||
} | ||
|
||
public String[] getOptions() { | ||
return options; | ||
} | ||
|
||
public void setOptions(String[] options) { | ||
this.options = options; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getFinalText() { | ||
return finalText; | ||
} | ||
|
||
public void setFinalText(String finalText) { | ||
this.finalText = finalText; | ||
} | ||
|
||
@Override | ||
public MessageItem toMessageItem(Context context) { | ||
return new MessageGeneralOptionsItem(this, context); | ||
} | ||
|
||
public void setSelected() { | ||
this.selected = true; | ||
} | ||
|
||
public boolean isSelected() { | ||
return selected; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
slyce-messaging/src/main/java/it/slyce/messaging/message/GeneralTextMessage.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,23 @@ | ||
package it.slyce.messaging.message; | ||
|
||
import android.content.Context; | ||
|
||
import it.slyce.messaging.message.messageItem.MessageItem; | ||
import it.slyce.messaging.message.messageItem.general.generalText.MessageGeneralTextItem; | ||
|
||
public class GeneralTextMessage extends Message { | ||
private String text; | ||
|
||
public void setText(String text) { | ||
this.text = text; | ||
} | ||
|
||
public String getText() { | ||
return this.text; | ||
} | ||
|
||
@Override | ||
public MessageItem toMessageItem(Context context) { | ||
return new MessageGeneralTextItem(this); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,5 +5,6 @@ | |
*/ | ||
public enum MessageSource { | ||
LOCAL_USER, | ||
EXTERNAL_USER | ||
EXTERNAL_USER, | ||
GENERAL | ||
} |
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
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
65 changes: 65 additions & 0 deletions
65
...slyce/messaging/message/messageItem/general/generalOptions/MessageGeneralOptionsItem.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,65 @@ | ||
package it.slyce.messaging.message.messageItem.general.generalOptions; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.graphics.PorterDuff; | ||
import android.support.v4.content.ContextCompat; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import it.slyce.messaging.R; | ||
import it.slyce.messaging.message.GeneralOptionsMessage; | ||
import it.slyce.messaging.message.MessageSource; | ||
import it.slyce.messaging.message.messageItem.MessageItem; | ||
import it.slyce.messaging.message.messageItem.MessageItemType; | ||
import it.slyce.messaging.message.messageItem.MessageViewHolder; | ||
|
||
public class MessageGeneralOptionsItem extends MessageItem { | ||
private Context context; | ||
|
||
public MessageGeneralOptionsItem(GeneralOptionsMessage generalOptionsMessage, Context context) { | ||
super(generalOptionsMessage); | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public void buildMessageItem(MessageViewHolder messageViewHolder) { | ||
final MessageGeneralOptionsViewHolder viewHolder = (MessageGeneralOptionsViewHolder) messageViewHolder; | ||
final GeneralOptionsMessage generalTextMessage = (GeneralOptionsMessage) message; | ||
if (!generalTextMessage.isSelected()) { | ||
viewHolder.titleTextView.setText(generalTextMessage.getTitle()); | ||
viewHolder.optionsLinearLayout.removeAllViews(); | ||
for (int i = 0; i < generalTextMessage.getOptions().length; i++) { | ||
String option = generalTextMessage.getOptions()[i]; | ||
Button button = new Button(context); | ||
button.setText(option); | ||
button.getBackground().setColorFilter(ContextCompat.getColor(context, R.color.background_gray_light), PorterDuff.Mode.MULTIPLY); | ||
button.setTextColor(Color.BLUE); | ||
final int finalI = i; | ||
button.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
viewHolder.titleTextView.setText(generalTextMessage.getFinalText()); | ||
viewHolder.optionsLinearLayout.removeAllViews(); | ||
generalTextMessage.setSelected(); | ||
generalTextMessage.getOnOptionSelectedListener().onOptionSelected(finalI); | ||
} | ||
}); | ||
viewHolder.optionsLinearLayout.addView(button); | ||
} | ||
} else { | ||
viewHolder.titleTextView.setText(generalTextMessage.getFinalText()); | ||
viewHolder.optionsLinearLayout.removeAllViews(); | ||
} | ||
} | ||
|
||
@Override | ||
public MessageItemType getMessageItemType() { | ||
return MessageItemType.GENERAL_OPTIONS; | ||
} | ||
|
||
@Override | ||
public MessageSource getMessageSource() { | ||
return MessageSource.GENERAL; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...messaging/message/messageItem/general/generalOptions/MessageGeneralOptionsViewHolder.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,25 @@ | ||
package it.slyce.messaging.message.messageItem.general.generalOptions; | ||
|
||
import android.view.View; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import it.slyce.messaging.R; | ||
import it.slyce.messaging.message.messageItem.MessageViewHolder; | ||
import it.slyce.messaging.utils.CustomSettings; | ||
|
||
/** | ||
* @Author Matthew Page | ||
* @Date 8/10/16 | ||
*/ | ||
public class MessageGeneralOptionsViewHolder extends MessageViewHolder { | ||
public TextView titleTextView; | ||
public LinearLayout optionsLinearLayout; | ||
|
||
public MessageGeneralOptionsViewHolder(View itemView, CustomSettings customSettings) { | ||
super(itemView, customSettings); | ||
|
||
this.titleTextView = (TextView) itemView.findViewById(R.id.message_general_options_text_view); | ||
this.optionsLinearLayout = (LinearLayout) itemView.findViewById(R.id.message_general_options_options_linear_layout); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...va/it/slyce/messaging/message/messageItem/general/generalText/MessageGeneralTextItem.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,31 @@ | ||
package it.slyce.messaging.message.messageItem.general.generalText; | ||
|
||
import it.slyce.messaging.message.GeneralTextMessage; | ||
import it.slyce.messaging.message.MessageSource; | ||
import it.slyce.messaging.message.messageItem.MessageItem; | ||
import it.slyce.messaging.message.messageItem.MessageItemType; | ||
import it.slyce.messaging.message.messageItem.MessageViewHolder; | ||
|
||
public class MessageGeneralTextItem extends MessageItem { | ||
public MessageGeneralTextItem(GeneralTextMessage message) { | ||
super(message); | ||
} | ||
|
||
@Override | ||
public void buildMessageItem( | ||
MessageViewHolder messageViewHolder) { | ||
MessageGeneralTextViewHolder viewHolder = (MessageGeneralTextViewHolder) messageViewHolder; | ||
GeneralTextMessage generalTextMessage = (GeneralTextMessage) message; | ||
viewHolder.messageTextView.setText(generalTextMessage.getText()); | ||
} | ||
|
||
@Override | ||
public MessageItemType getMessageItemType() { | ||
return MessageItemType.GENERAL_TEXT; | ||
} | ||
|
||
@Override | ||
public MessageSource getMessageSource() { | ||
return MessageSource.GENERAL; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...slyce/messaging/message/messageItem/general/generalText/MessageGeneralTextViewHolder.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,19 @@ | ||
package it.slyce.messaging.message.messageItem.general.generalText; | ||
|
||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import it.slyce.messaging.R; | ||
import it.slyce.messaging.message.messageItem.MessageViewHolder; | ||
import it.slyce.messaging.utils.CustomSettings; | ||
|
||
public class MessageGeneralTextViewHolder extends MessageViewHolder { | ||
public TextView messageTextView; | ||
|
||
public MessageGeneralTextViewHolder(View itemView, CustomSettings customSettings) { | ||
super(itemView, customSettings); | ||
|
||
messageTextView = (TextView) itemView.findViewById(R.id.message_general_text_text_view); | ||
messageTextView.setTextColor(customSettings.timestampColor); | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
...e-messaging/src/main/java/it/slyce/messaging/message/messageItem/spinner/SpinnerItem.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
27 changes: 27 additions & 0 deletions
27
slyce-messaging/src/main/res/layout/item_message_general_options.xml
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"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="50dp" | ||
android:layout_marginLeft="50dp" | ||
android:layout_marginEnd="50dp" | ||
android:layout_marginRight="50dp"> | ||
|
||
<TextView | ||
android:id="@+id/message_general_options_text_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:textAlignment="center"/> | ||
|
||
<LinearLayout | ||
android:id="@+id/message_general_options_options_linear_layout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:orientation="horizontal"> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
18 changes: 18 additions & 0 deletions
18
slyce-messaging/src/main/res/layout/item_message_general_text.xml
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="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="50dp" | ||
android:layout_marginLeft="50dp" | ||
android:layout_marginEnd="50dp" | ||
android:layout_marginRight="50dp"> | ||
|
||
<TextView | ||
android:id="@+id/message_general_text_text_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:textAlignment="center"/> | ||
|
||
</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