mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-12 11:14:20 +00:00
contact selection reactive to dark theme
// FREEBIE
This commit is contained in:
parent
559228af5b
commit
829a92d371
@ -36,6 +36,11 @@
|
|||||||
<attr name="conversation_item_sent_push_background" format="reference" />
|
<attr name="conversation_item_sent_push_background" format="reference" />
|
||||||
<attr name="conversation_item_sent_push_triangle_background" format="reference" />
|
<attr name="conversation_item_sent_push_triangle_background" format="reference" />
|
||||||
|
|
||||||
|
<attr name="contact_selection_push_user" format="reference|color" />
|
||||||
|
<attr name="contact_selection_lay_user" format="reference|color" />
|
||||||
|
<attr name="contact_selection_push_label" format="reference|color" />
|
||||||
|
<attr name="contact_selection_lay_label" format="reference|color" />
|
||||||
|
|
||||||
<attr name="navigation_drawer_background" format="reference|color"/>
|
<attr name="navigation_drawer_background" format="reference|color"/>
|
||||||
<attr name="navigation_drawer_text_color" format="color"/>
|
<attr name="navigation_drawer_text_color" format="color"/>
|
||||||
<attr name="navigation_drawer_icons" format="reference"/>
|
<attr name="navigation_drawer_icons" format="reference"/>
|
||||||
|
@ -19,6 +19,11 @@
|
|||||||
<item name="conversation_received_text_primary_color">#ff111111</item>
|
<item name="conversation_received_text_primary_color">#ff111111</item>
|
||||||
<item name="conversation_received_text_secondary_color">#33000000</item>
|
<item name="conversation_received_text_secondary_color">#33000000</item>
|
||||||
|
|
||||||
|
<item name="contact_selection_push_user">#ff000000</item>
|
||||||
|
<item name="contact_selection_lay_user">#a0000000</item>
|
||||||
|
<item name="contact_selection_push_label">#ff64a926</item>
|
||||||
|
<item name="contact_selection_lay_label">#99000000</item>
|
||||||
|
|
||||||
<item name="conversation_background">#ffdddddd</item>
|
<item name="conversation_background">#ffdddddd</item>
|
||||||
<item name="conversation_editor_background">#eeeeee</item>
|
<item name="conversation_editor_background">#eeeeee</item>
|
||||||
<item name="conversation_editor_text_color">@color/edit_text_light_theme</item>
|
<item name="conversation_editor_text_color">@color/edit_text_light_theme</item>
|
||||||
@ -77,6 +82,11 @@
|
|||||||
<item name="conversation_received_text_primary_color">#ffeeeeee</item>
|
<item name="conversation_received_text_primary_color">#ffeeeeee</item>
|
||||||
<item name="conversation_received_text_secondary_color">#44eeeeee</item>
|
<item name="conversation_received_text_secondary_color">#44eeeeee</item>
|
||||||
|
|
||||||
|
<item name="contact_selection_push_user">#ffdddddd</item>
|
||||||
|
<item name="contact_selection_lay_user">#ffcccccc</item>
|
||||||
|
<item name="contact_selection_push_label">#ff64a926</item>
|
||||||
|
<item name="contact_selection_lay_label">#11ffffff</item>
|
||||||
|
|
||||||
<item name="conversation_item_received_background">@drawable/conversation_item_received_shape_dark</item>
|
<item name="conversation_item_received_background">@drawable/conversation_item_received_shape_dark</item>
|
||||||
<item name="conversation_item_received_triangle_background">@drawable/conversation_item_received_triangle_shape_dark</item>
|
<item name="conversation_item_received_triangle_background">@drawable/conversation_item_received_triangle_shape_dark</item>
|
||||||
<item name="conversation_item_sent_background">@drawable/conversation_item_sent_shape_dark</item>
|
<item name="conversation_item_sent_background">@drawable/conversation_item_sent_shape_dark</item>
|
||||||
|
@ -20,6 +20,7 @@ package org.thoughtcrime.securesms;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.MergeCursor;
|
import android.database.MergeCursor;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -61,9 +62,15 @@ import java.util.List;
|
|||||||
public class PushContactSelectionListFragment extends SherlockListFragment
|
public class PushContactSelectionListFragment extends SherlockListFragment
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor>
|
implements LoaderManager.LoaderCallbacks<Cursor>
|
||||||
{
|
{
|
||||||
|
private final int STYLE_ATTRIBUTES[] = new int[]{R.attr.contact_selection_push_user,
|
||||||
|
R.attr.contact_selection_lay_user,
|
||||||
|
R.attr.contact_selection_push_label,
|
||||||
|
R.attr.contact_selection_lay_label};
|
||||||
|
|
||||||
private final HashMap<Long, ContactData> selectedContacts = new HashMap<Long, ContactData>();
|
private final HashMap<Long, ContactData> selectedContacts = new HashMap<Long, ContactData>();
|
||||||
private static LayoutInflater li;
|
private static LayoutInflater li;
|
||||||
|
private TypedArray drawables;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle icicle) {
|
public void onActivityCreated(Bundle icicle) {
|
||||||
@ -88,8 +95,12 @@ public class PushContactSelectionListFragment extends SherlockListFragment
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_select_all: handleSelectAll(); return true;
|
case R.id.menu_select_all:
|
||||||
case R.id.menu_unselect_all: handleUnselectAll(); return true;
|
handleSelectAll();
|
||||||
|
return true;
|
||||||
|
case R.id.menu_unselect_all:
|
||||||
|
handleUnselectAll();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onOptionsItemSelected(item);
|
super.onOptionsItemSelected(item);
|
||||||
@ -105,7 +116,7 @@ public class PushContactSelectionListFragment extends SherlockListFragment
|
|||||||
|
|
||||||
private void handleUnselectAll() {
|
private void handleUnselectAll() {
|
||||||
selectedContacts.clear();
|
selectedContacts.clear();
|
||||||
((CursorAdapter)getListView().getAdapter()).notifyDataSetChanged();
|
((CursorAdapter) getListView().getAdapter()).notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSelectAll() {
|
private void handleSelectAll() {
|
||||||
@ -119,16 +130,16 @@ public class PushContactSelectionListFragment extends SherlockListFragment
|
|||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
ContactData contactData = ContactAccessor.getInstance().getContactData(getActivity(), cursor);
|
ContactData contactData = ContactAccessor.getInstance().getContactData(getActivity(), cursor);
|
||||||
|
|
||||||
if (contactData.numbers.isEmpty()) continue;
|
if (contactData.numbers.isEmpty()) continue;
|
||||||
else if (contactData.numbers.size() == 1) addSingleNumberContact(contactData);
|
else if (contactData.numbers.size() == 1) addSingleNumberContact(contactData);
|
||||||
else addMultipleNumberContact(contactData, null, null);
|
else addMultipleNumberContact(contactData, null, null);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
((CursorAdapter)getListView().getAdapter()).notifyDataSetChanged();
|
((CursorAdapter) getListView().getAdapter()).notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSingleNumberContact(ContactData contactData) {
|
private void addSingleNumberContact(ContactData contactData) {
|
||||||
@ -162,6 +173,7 @@ public class PushContactSelectionListFragment extends SherlockListFragment
|
|||||||
|
|
||||||
private void initializeResources() {
|
private void initializeResources() {
|
||||||
this.getListView().setFocusable(true);
|
this.getListView().setFocusable(true);
|
||||||
|
this.drawables = getActivity().obtainStyledAttributes(STYLE_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -244,13 +256,13 @@ public class PushContactSelectionListFragment extends SherlockListFragment
|
|||||||
this.pushSupport = pushContactData.pushSupport;
|
this.pushSupport = pushContactData.pushSupport;
|
||||||
|
|
||||||
if (!pushSupport) {
|
if (!pushSupport) {
|
||||||
this.name.setTextColor(0xa0000000);
|
this.name.setTextColor(drawables.getColor(1, 0xff000000));
|
||||||
this.number.setTextColor(0xa0000000);
|
this.number.setTextColor(drawables.getColor(1, 0xff000000));
|
||||||
this.pushLabel.setBackgroundColor(0x99000000);
|
this.pushLabel.setBackgroundColor(drawables.getColor(3, 0x99000000));
|
||||||
} else {
|
} else {
|
||||||
this.name.setTextColor(0xff000000);
|
this.name.setTextColor(drawables.getColor(0, 0xa0000000));
|
||||||
this.number.setTextColor(0xff000000);
|
this.number.setTextColor(drawables.getColor(0, 0xa0000000));
|
||||||
this.pushLabel.setBackgroundColor(0xff64a926);
|
this.pushLabel.setBackgroundColor(drawables.getColor(2, 0xff64a926));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedContacts.containsKey(contactData.id))
|
if (selectedContacts.containsKey(contactData.id))
|
||||||
|
@ -20,6 +20,7 @@ package org.thoughtcrime.securesms;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.MergeCursor;
|
import android.database.MergeCursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -55,11 +56,15 @@ import java.util.HashMap;
|
|||||||
public class SingleContactSelectionListFragment extends SherlockListFragment
|
public class SingleContactSelectionListFragment extends SherlockListFragment
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor>
|
implements LoaderManager.LoaderCallbacks<Cursor>
|
||||||
{
|
{
|
||||||
private final String TAG = SingleContactSelectionListFragment.class.getSimpleName();
|
private final String TAG = SingleContactSelectionListFragment.class.getSimpleName();
|
||||||
|
private final int STYLE_ATTRIBUTES[] = new int[]{R.attr.contact_selection_push_user,
|
||||||
|
R.attr.contact_selection_lay_user,
|
||||||
|
R.attr.contact_selection_push_label,
|
||||||
|
R.attr.contact_selection_lay_label};
|
||||||
|
|
||||||
private final HashMap<Long, ContactData> selectedContacts = new HashMap<Long, ContactData>();
|
private static LayoutInflater li;
|
||||||
private static LayoutInflater li;
|
private OnContactSelectedListener onContactSelectedListener;
|
||||||
private OnContactSelectedListener onContactSelectedListener;
|
private TypedArray drawables;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle icicle) {
|
public void onActivityCreated(Bundle icicle) {
|
||||||
@ -86,7 +91,7 @@ public class SingleContactSelectionListFragment extends SherlockListFragment
|
|||||||
|
|
||||||
private void addMultipleNumberContact(ContactData contactData, TextView textView) {
|
private void addMultipleNumberContact(ContactData contactData, TextView textView) {
|
||||||
String[] options = new String[contactData.numbers.size()];
|
String[] options = new String[contactData.numbers.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (NumberData option : contactData.numbers) {
|
for (NumberData option : contactData.numbers) {
|
||||||
options[i++] = option.type + " " + option.number;
|
options[i++] = option.type + " " + option.number;
|
||||||
@ -108,6 +113,7 @@ public class SingleContactSelectionListFragment extends SherlockListFragment
|
|||||||
|
|
||||||
private void initializeResources() {
|
private void initializeResources() {
|
||||||
this.getListView().setFocusable(true);
|
this.getListView().setFocusable(true);
|
||||||
|
this.drawables = getActivity().obtainStyledAttributes(STYLE_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -181,13 +187,13 @@ public class SingleContactSelectionListFragment extends SherlockListFragment
|
|||||||
this.pushSupport = pushContactData.pushSupport;
|
this.pushSupport = pushContactData.pushSupport;
|
||||||
|
|
||||||
if (!pushSupport) {
|
if (!pushSupport) {
|
||||||
this.name.setTextColor(0xa0000000);
|
this.name.setTextColor(drawables.getColor(1, 0xff000000));
|
||||||
this.number.setTextColor(0xa0000000);
|
this.number.setTextColor(drawables.getColor(1, 0xff000000));
|
||||||
this.pushLabel.setBackgroundColor(0x99000000);
|
this.pushLabel.setBackgroundColor(drawables.getColor(3, 0x99000000));
|
||||||
} else {
|
} else {
|
||||||
this.name.setTextColor(0xff000000);
|
this.name.setTextColor(drawables.getColor(0, 0xa0000000));
|
||||||
this.number.setTextColor(0xff000000);
|
this.number.setTextColor(drawables.getColor(0, 0xa0000000));
|
||||||
this.pushLabel.setBackgroundColor(0xff64a926);
|
this.pushLabel.setBackgroundColor(drawables.getColor(2, 0xff64a926));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.name.setText(contactData.name);
|
this.name.setText(contactData.name);
|
||||||
|
Loading…
Reference in New Issue
Block a user