Skip to content

Commit

Permalink
Merge pull request #238 from jlewis13/recipient_sync
Browse files Browse the repository at this point in the history
Contacts sync and recipient cache updates
  • Loading branch information
jlewis13 authored Dec 18, 2017
2 parents e66df26 + 50fb786 commit d4b4774
Show file tree
Hide file tree
Showing 44 changed files with 835 additions and 512 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ android {
applicationId 'io.forsta.relay'
minSdkVersion 14
targetSdkVersion 22
versionName "0.1.78"
versionCode 178
versionName "0.1.80"
versionCode 180
multiDexEnabled true
buildConfigField "long", "BUILD_TIMESTAMP", getLastCommitTimestamp() + "L"
resValue "string", "forsta_authorities", applicationId + '.provider.ccsm'
Expand Down
Binary file added res/drawable-mdpi/ic_forsta_pin_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 2 additions & 10 deletions res/layout/activity_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
android:layout_height="wrap_content" android:orientation="horizontal"
android:visibility="gone">
<Button
android:id="@+id/socket_tester"
android:layout_width="wrap_content"
Expand All @@ -32,15 +33,6 @@
android:visibility="visible"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/search_directory"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

<TextView
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion res/layout/activity_thread_preference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<TextView android:id="@+id/forsta_thread_recipients" android:layout_width="match_parent" android:layout_height="wrap_content"></TextView>
<LinearLayout
android:id="@+id/forsta_thread_debug_details"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:visibility="gone">
<TextView style="@style/TextAppearance.AppCompat.Subhead"
Expand Down
8 changes: 8 additions & 0 deletions res/layout/alert_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@
android:layout_gravity="center_vertical"
android:contentDescription="@string/conversation_item_sent__pending_approval_description" />

<ImageView
android:id="@+id/pinned_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="?pinned_icon"
android:visibility="gone"
android:layout_gravity="center_vertical"/>

</merge>
28 changes: 20 additions & 8 deletions res/layout/contact_selection_list_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView android:id="@+id/contact_selection_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/contact_selection_activity__no_results"
android:padding="10dp"
android:textSize="16dp"
android:textAlignment="center"
android:visibility="gone"></TextView>
<LinearLayout
android:id="@+id/contact_selection_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/contact_selection_activity__no_results"
android:textSize="16dp"
android:textAlignment="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/contact_selection_activity__no_results_search"
android:textAlignment="center"/>
</LinearLayout>

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
Expand Down
6 changes: 2 additions & 4 deletions res/layout/conversation_list_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
android:layout_gravity="center_horizontal"/>
</LinearLayout>


<FrameLayout
android:id="@+id/forsta_conversation_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" android:layout_above="@id/layout_container"/>


android:orientation="vertical"
android:layout_above="@id/layout_container"/>

</RelativeLayout>
<LinearLayout
Expand Down
3 changes: 0 additions & 3 deletions res/menu/text_secure_normal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<item android:title="Refresh Directory"
android:id="@+id/menu_directory"/>

<item
android:id="@+id/menu_archive"
android:title="Archived Conversations" />
Expand Down
1 change: 1 addition & 0 deletions res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

<attr name="dialog_info_icon" format="reference" />
<attr name="dialog_alert_icon" format="reference" />
<attr name="pinned_icon" format="reference" />

<attr name="conversation_icon_attach_audio" format="reference"/>
<attr name="conversation_icon_attach_video" format="reference" />
Expand Down
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@
<string name="contact_selection_activity__enter_custom_expression">Enter a tag or tag expression</string>
<string name="contact_selection_activity__title">Create Conversation</string>
<string name="contact_selection_activity__no_results">No results.</string>
<string name="contact_selection_activity__no_results_search">To find a specific user, enter a fully qualified identifier (john.doe:forsta), valid phone number or email address.</string>

<!-- contact_selection_group_activity -->
<string name="contact_selection_group_activity__no_contacts">No contacts.</string>
Expand Down Expand Up @@ -834,8 +835,10 @@

<string name="thread_preferences__title">Conversation Title</string>
<string name="thread_preferences__recipients">Recipients</string>
<string name="thread_preferences_pin_conversation">Pinned</string>
<string name="thread_preferences__mute_conversation">Mute conversation</string>
<string name="thread_preferences__disable_notifications_for_this_conversation">Disable notifications for this conversation</string>
<string name="thread_preferences__pin_for_this_conversation">Pin this conversation</string>
<string name="thread_preferences__notification_sound">Notification sound</string>
<string name="thread_preferences__vibrate">Vibrate</string>
<string name="thread_preferences__block">Block</string>
Expand Down
2 changes: 2 additions & 0 deletions res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

<item name="dialog_info_icon">@drawable/ic_info_outline_light</item>
<item name="dialog_alert_icon">@drawable/ic_warning_light</item>
<item name="pinned_icon">@drawable/ic_forsta_pin_dark</item>

<item name="device_link_item_card_background">@color/device_link_item_background_light</item>

Expand Down Expand Up @@ -241,6 +242,7 @@

<item name="dialog_info_icon">@drawable/ic_info_outline_dark</item>
<item name="dialog_alert_icon">@drawable/ic_warning_dark</item>
<item name="pinned_icon">@drawable/ic_forsta_pin_light</item>

<item name="device_link_item_card_background">@color/device_link_item_background_dark</item>

Expand Down
6 changes: 0 additions & 6 deletions res/xml/preferences_advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="advanced_preferences_screen">

<io.forsta.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_forsta_otr"
android:title="@string/preferences__forsta_off_the_record"
android:summary="@string/preferences__forsta_off_the_record_summary"/>

<io.forsta.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_enter_sends"
Expand Down
32 changes: 16 additions & 16 deletions res/xml/preferences_chats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@
android:entryValues="@array/pref_media_download_entries" />
</PreferenceCategory>

<!--<PreferenceCategory android:key="message_trimming" android:title="@string/preferences_chats__message_trimming">-->
<!--<io.forsta.securesms.components.SwitchPreferenceCompat-->
<!--android:defaultValue="true"-->
<!--android:key="pref_trim_threads"-->
<!--android:summary="@string/preferences__automatically_delete_older_messages_once_a_conversation_exceeds_a_specified_length"-->
<!--android:title="@string/preferences__delete_old_messages" android:enabled="false"/>-->
<PreferenceCategory android:key="message_trimming" android:title="@string/preferences_chats__message_trimming">
<io.forsta.securesms.components.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_trim_threads"
android:summary="@string/preferences__automatically_delete_older_messages_once_a_conversation_exceeds_a_specified_length"
android:title="@string/preferences__delete_old_messages"/>

<!--<EditTextPreference android:defaultValue="5000"-->
<!--android:key="pref_trim_length"-->
<!--android:title="@string/preferences__conversation_length_limit"-->
<!--android:inputType="number"-->
<!--android:dependency="pref_trim_threads" />-->
<EditTextPreference android:defaultValue="5000"
android:key="pref_trim_length"
android:title="@string/preferences__conversation_length_limit"
android:inputType="number"
android:dependency="pref_trim_threads" />

<!--<Preference android:key="pref_trim_now"-->
<!--android:title="@string/preferences__trim_all_conversations_now"-->
<!--android:summary="@string/preferences__scan_through_all_conversations_and_enforce_conversation_length_limits"-->
<!--android:dependency="pref_trim_threads" />-->
<!--</PreferenceCategory>-->
<Preference android:key="pref_trim_now"
android:title="@string/preferences__trim_all_conversations_now"
android:summary="@string/preferences__scan_through_all_conversations_and_enforce_conversation_length_limits"
android:dependency="pref_trim_threads" />
</PreferenceCategory>
</PreferenceScreen>
7 changes: 7 additions & 0 deletions res/xml/thread_preferences.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<io.forsta.securesms.components.SwitchPreferenceCompat
android:key="pref_key_thread_pinned"
android:title="@string/thread_preferences_pin_conversation"
android:summary="@string/thread_preferences__pin_for_this_conversation"
android:defaultValue="false"
android:disableDependentsState="true"
android:persistent="false" />
<io.forsta.securesms.components.SwitchPreferenceCompat
android:key="pref_key_thread_mute"
android:title="@string/thread_preferences__mute_conversation"
Expand Down
35 changes: 4 additions & 31 deletions src/io/forsta/ccsm/DashboardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import io.forsta.ccsm.api.model.ForstaJWT;
import io.forsta.ccsm.api.model.ForstaMessage;
import io.forsta.ccsm.database.model.ForstaGroup;
import io.forsta.ccsm.database.model.ForstaTag;
import io.forsta.ccsm.database.model.ForstaUser;
import io.forsta.ccsm.database.ContactDb;
import io.forsta.ccsm.database.DbFactory;
Expand Down Expand Up @@ -257,33 +257,6 @@ public void onClick(View v) {
ForstaPreferences.setCCSMDebug(DashboardActivity.this, mToggleSyncMessages.isChecked());
}
});
EditText search = (EditText) findViewById(R.id.search_directory);
search.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (charSequence.length() > 2) {
new AsyncTask<String, Void, Void>() {
@Override
protected Void doInBackground(String[] objects) {
JSONObject response = CcsmApi.searchUserDirectory(DashboardActivity.this, objects[0]);
List<ForstaUser> users = CcsmApi.parseUsers(DashboardActivity.this, response);
Log.w(TAG, "Getting response");
return null;
}
}.execute(charSequence.toString());
}
}

@Override
public void afterTextChanged(Editable editable) {

}
});
printLoginInformation();
}

Expand Down Expand Up @@ -718,10 +691,10 @@ protected JSONObject doInBackground(Void... voids) {

@Override
protected void onPostExecute(JSONObject jsonObject) {
List<ForstaGroup> groups = CcsmApi.parseTagGroups(jsonObject);
List<ForstaTag> groups = CcsmApi.parseTagGroups(jsonObject);

StringBuilder sb = new StringBuilder();
for (ForstaGroup group : groups) {
for (ForstaTag group : groups) {
String groupId = group.id;
sb.append(groupId).append("\n");
String encoded = GroupUtil.getEncodedId(groupId.getBytes());
Expand Down Expand Up @@ -769,7 +742,7 @@ private class GetDirectory extends AsyncTask<Void, Void, JSONObject> {

@Override
protected JSONObject doInBackground(Void... voids) {
return CcsmApi.getUserDirectory(DashboardActivity.this, null);
return CcsmApi.getUserDirectory(DashboardActivity.this, new ArrayList<String>());
}

@Override
Expand Down
Loading

0 comments on commit d4b4774

Please sign in to comment.