IT'S CHRISTMAS ALREADY!

This commit is contained in:
iNPUTmice 2014-09-10 17:59:57 +02:00
parent a6d4a9cda1
commit 31f11070e3
25 changed files with 205 additions and 41 deletions

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg3621"
version="1.1"
inkscape:version="0.48.4 r9939"
width="96"
height="96"
sodipodi:docname="ic_action_send_now.svg"
inkscape:export-filename="/home/daniel/workspace/Conversations/res/drawable-xxhdpi/ic_action_send_now_online.png"
inkscape:export-xdpi="154.28572"
inkscape:export-ydpi="154.28572">
<metadata
id="metadata3627">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3625" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1916"
inkscape:window-height="1161"
id="namedview3623"
showgrid="true"
showguides="true"
inkscape:zoom="1"
inkscape:cx="47.28873"
inkscape:cy="43.262706"
inkscape:window-x="0"
inkscape:window-y="18"
inkscape:window-maximized="0"
inkscape:current-layer="svg3621">
<inkscape:grid
type="xygrid"
id="grid3631" />
</sodipodi:namedview>
<path
style="fill:#e51c28;fill-opacity:0.627451;stroke:none"
d="M 20.012575,21.028577 76,49 20.012575,77.028577 26,52 58.012575,49.028577 26,46 z"
id="path3633"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc"
inkscape:export-filename="/home/daniel/workspace/Conversations/res/drawable-mdpi/ic_action_send_now_dnd.png"
inkscape:export-xdpi="51.42857"
inkscape:export-ydpi="51.42857" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 759 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -58,7 +58,7 @@
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="?android:selectableItemBackground"
android:src="@drawable/ic_action_send_now" />
android:src="@drawable/ic_action_send_now_offline" />
</RelativeLayout>
<RelativeLayout

View File

@ -254,4 +254,6 @@
<string name="pref_expert_options_summary">Please be very careful with those</string>
<string name="pref_use_larger_font">Increase font size</string>
<string name="pref_use_larger_font_summary">Use larger font sizes across the entire app</string>
<string name="pref_use_send_button_to_indicate_status">Send button indicates status</string>
<string name="pref_use_send_button_to_indicate_status_summary">Colorize send button to indicate a contacs status</string>
</resources>

View File

@ -69,6 +69,11 @@
android:key="use_larger_font"
android:title="@string/pref_use_larger_font"
android:summary="@string/pref_use_larger_font_summary"/>
<CheckBoxPreference
android:key="send_button_status"
android:defaultValue="false"
android:title="@string/pref_use_send_button_to_indicate_status"
android:summary="@string/pref_use_send_button_to_indicate_status_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_advanced_options" >
<PreferenceScreen

View File

@ -109,6 +109,7 @@ public class XmppConnectionService extends Service {
private OnAccountUpdate mOnAccountUpdate = null;
private int accountChangedListenerCount = 0;
private OnRosterUpdate mOnRosterUpdate = null;
private int rosterChangedListenerCount = 0;
public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() {
@Override
@ -997,12 +998,16 @@ public class XmppConnectionService extends Service {
switchToForeground();
}
this.mOnRosterUpdate = listener;
this.rosterChangedListenerCount++;
}
public void removeOnRosterUpdateListener() {
this.mOnRosterUpdate = null;
if (checkListeners()) {
switchToBackground();
this.rosterChangedListenerCount--;
if (this.rosterChangedListenerCount == 0) {
this.mOnRosterUpdate = null;
if (checkListeners()) {
switchToBackground();
}
}
}

View File

@ -7,7 +7,9 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
import eu.siacs.conversations.ui.adapter.ConversationAdapter;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.UIHelper;
@ -39,7 +41,8 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.Toast;
public class ConversationActivity extends XmppActivity {
public class ConversationActivity extends XmppActivity implements
OnAccountUpdate, OnConversationUpdate, OnRosterUpdate {
public static final String VIEW_CONVERSATION = "viewConversation";
public static final String CONVERSATION = "conversationUuid";
@ -67,34 +70,6 @@ public class ConversationActivity extends XmppActivity {
private boolean paneShouldBeOpen = true;
private ArrayAdapter<Conversation> listAdapter;
private OnConversationUpdate onConvChanged = new OnConversationUpdate() {
@Override
public void onConversationUpdate() {
runOnUiThread(new Runnable() {
@Override
public void run() {
updateConversationList();
if (paneShouldBeOpen) {
if (conversationList.size() >= 1) {
swapConversationFragment();
} else {
startActivity(new Intent(getApplicationContext(),
StartConversationActivity.class));
finish();
}
}
ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
.findFragmentByTag("conversation");
if (selectedFragment != null) {
selectedFragment.updateMessages();
}
}
});
}
};
protected ConversationActivity activity = this;
private Toast prepareImageToast;
@ -602,7 +577,7 @@ public class ConversationActivity extends XmppActivity {
this.onBackendConnected();
}
if (conversationList.size() >= 1) {
onConvChanged.onConversationUpdate();
this.onConversationUpdate();
}
}
@ -610,6 +585,8 @@ public class ConversationActivity extends XmppActivity {
protected void onStop() {
if (xmppConnectionServiceBound) {
xmppConnectionService.removeOnConversationListChangedListener();
xmppConnectionService.removeOnAccountListChangedListener();
xmppConnectionService.removeOnRosterUpdateListener();
}
super.onStop();
}
@ -672,8 +649,9 @@ public class ConversationActivity extends XmppActivity {
public void registerListener() {
if (xmppConnectionServiceBound) {
xmppConnectionService
.setOnConversationListChangedListener(this.onConvChanged);
xmppConnectionService.setOnConversationListChangedListener(this);
xmppConnectionService.setOnAccountListChangedListener(this);
xmppConnectionService.setOnRosterUpdateListener(this);
}
}
@ -806,7 +784,65 @@ public class ConversationActivity extends XmppActivity {
}
public boolean forceEncryption() {
return PreferenceManager.getDefaultSharedPreferences(
getApplicationContext()).getBoolean("force_encryption", false);
return getPreferences().getBoolean("force_encryption", false);
}
public boolean useSendButtonToIndicateStatus() {
return getPreferences().getBoolean("send_button_status", false);
}
@Override
public void onAccountUpdate() {
final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
.findFragmentByTag("conversation");
if (fragment != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
fragment.updateMessages();
}
});
}
}
@Override
public void onConversationUpdate() {
runOnUiThread(new Runnable() {
@Override
public void run() {
updateConversationList();
if (paneShouldBeOpen) {
if (conversationList.size() >= 1) {
swapConversationFragment();
} else {
startActivity(new Intent(getApplicationContext(),
StartConversationActivity.class));
finish();
}
}
ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
.findFragmentByTag("conversation");
if (selectedFragment != null) {
selectedFragment.updateMessages();
}
}
});
}
@Override
public void onRosterUpdate() {
final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
.findFragmentByTag("conversation");
if (fragment != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
fragment.updateMessages();
}
});
}
}
}

View File

@ -12,6 +12,7 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.EditMessage.OnEnterPressed;
import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected;
@ -61,6 +62,7 @@ public class ConversationFragment extends Fragment {
protected String queuedPqpMessage = null;
private EditMessage mEditMessage;
private ImageButton mSendButton;
private String pastedText = null;
private RelativeLayout snackbar;
private TextView snackbarMessage;
@ -255,9 +257,8 @@ public class ConversationFragment extends Fragment {
}
});
ImageButton sendButton = (ImageButton) view
.findViewById(R.id.textSendButton);
sendButton.setOnClickListener(this.mSendButtonListener);
mSendButton = (ImageButton) view.findViewById(R.id.textSendButton);
mSendButton.setOnClickListener(this.mSendButtonListener);
snackbar = (RelativeLayout) view.findViewById(R.id.snackbar);
snackbarMessage = (TextView) view.findViewById(R.id.snackbar_message);
@ -485,6 +486,7 @@ public class ConversationFragment extends Fragment {
activity.getConversationList(), null, false);
activity.updateConversationList();
}
this.updateSendButton();
}
}
@ -497,6 +499,51 @@ public class ConversationFragment extends Fragment {
updateChatMsgHint();
}
public void updateSendButton() {
Conversation c = this.conversation;
if (activity.useSendButtonToIndicateStatus() && c != null
&& c.getAccount().getStatus() == Account.STATUS_ONLINE) {
if (c.getMode() == Conversation.MODE_SINGLE) {
switch (c.getContact().getMostAvailableStatus()) {
case Presences.ONLINE:
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_online);
break;
case Presences.AWAY:
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_away);
break;
case Presences.XA:
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_away);
break;
case Presences.DND:
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_dnd);
break;
default:
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_offline);
break;
}
} else if (c.getMode() == Conversation.MODE_MULTI) {
if (c.getMucOptions().online()) {
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_online);
} else {
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_offline);
}
} else {
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_offline);
}
} else {
this.mSendButton
.setImageResource(R.drawable.ic_action_send_now_offline);
}
}
protected void updateStatusMessages() {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
for (int i = this.messageList.size() - 1; i >= 0; --i) {