mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:33:39 +00:00
Refactor
This commit is contained in:
parent
410bb9df43
commit
ed2ab2d78a
@ -96,62 +96,62 @@
|
||||
|
||||
<!-- Session -->
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.LandingActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.LandingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.RegisterActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.RegisterActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.RestoreActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.RestoreActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.LinkDeviceActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.LinkDeviceActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.DisplayNameActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.DisplayNameActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.PNModeActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.PNModeActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.HomeActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/Session.DarkTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.SettingsActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.SettingsActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Session.DarkTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.QRCodeActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.QRCodeActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.CreatePrivateChatActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.CreatePrivateChatActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.CreateClosedGroupActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.CreateClosedGroupActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.JoinPublicChatActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.JoinPublicChatActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.SeedActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.SeedActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.PrivacySettingsActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.PrivacySettingsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.NotificationSettingsActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.NotificationSettingsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.ChatSettingsActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.ChatSettingsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.activities.LinkedDevicesActivity"
|
||||
android:name="org.thoughtcrime.securesms.loki.activities.LinkedDevicesActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<!-- Session -->
|
||||
<activity
|
||||
@ -166,7 +166,7 @@
|
||||
<activity
|
||||
android:name="org.thoughtcrime.securesms.InviteActivity"
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||
android:parentActivityName="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity"
|
||||
android:parentActivityName="org.thoughtcrime.securesms.loki.activities.HomeActivity"
|
||||
android:theme="@style/TextSecure.HighlightTheme"
|
||||
android:windowSoftInputMode="stateHidden">
|
||||
<meta-data
|
||||
@ -225,7 +225,7 @@
|
||||
<activity-alias
|
||||
android:name=".RoutingActivity"
|
||||
android:exported="true"
|
||||
android:targetActivity="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity">
|
||||
android:targetActivity="org.thoughtcrime.securesms.loki.activities.HomeActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@ -264,7 +264,7 @@
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||
android:label="@string/AndroidManifest_archived_conversations"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity">
|
||||
android:parentActivityName="org.thoughtcrime.securesms.loki.activities.HomeActivity">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="PsiClass:HomeActivity" />
|
||||
@ -275,7 +275,7 @@
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Session.DarkTheme.NoActionBar"
|
||||
android:parentActivityName="org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity"
|
||||
android:parentActivityName="org.thoughtcrime.securesms.loki.activities.HomeActivity"
|
||||
android:windowSoftInputMode="stateUnchanged">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
@ -673,12 +673,12 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- Session -->
|
||||
<receiver android:name="org.thoughtcrime.securesms.loki.redesign.messaging.BackgroundPollWorker">
|
||||
<receiver android:name="org.thoughtcrime.securesms.loki.api.BackgroundPollWorker">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name="org.thoughtcrime.securesms.loki.redesign.messaging.BackgroundOpenGroupPollWorker">
|
||||
<receiver android:name="org.thoughtcrime.securesms.loki.api.BackgroundOpenGroupPollWorker">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
|
@ -21,7 +21,7 @@
|
||||
android:textColor="@color/text"
|
||||
android:text="Your Session begins here..." />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.FakeChatView
|
||||
<org.thoughtcrime.securesms.loki.views.FakeChatView
|
||||
android:id="@+id/fakeChatView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/fake_chat_view_height"
|
||||
|
@ -7,7 +7,7 @@
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.SeedReminderView
|
||||
<org.thoughtcrime.securesms.loki.views.SeedReminderView
|
||||
android:id="@+id/seedReminderView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
@ -30,7 +30,7 @@
|
||||
android:textAlignment="center"
|
||||
android:text="Users can share their Session ID by going into their account settings and tapping "Share Session ID", or by sharing their QR code." />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.LabeledSeparatorView
|
||||
<org.thoughtcrime.securesms.loki.views.LabeledSeparatorView
|
||||
android:id="@+id/separatorView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
|
@ -21,7 +21,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/profileButton"
|
||||
android:layout_width="@dimen/small_profile_picture_size"
|
||||
android:layout_height="@dimen/small_profile_picture_size"
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.SeedReminderView
|
||||
<org.thoughtcrime.securesms.loki.views.SeedReminderView
|
||||
android:id="@+id/seedReminderView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
@ -66,7 +66,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/home_activity_gradient" />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.NewConversationButtonSetView
|
||||
<org.thoughtcrime.securesms.loki.views.NewConversationButtonSetView
|
||||
android:id="@+id/newConversationButtonSet"
|
||||
android:layout_width="252dp"
|
||||
android:layout_height="212dp"
|
||||
|
@ -21,7 +21,7 @@
|
||||
android:textColor="@color/text"
|
||||
android:text="Your Session begins here..." />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.FakeChatView
|
||||
<org.thoughtcrime.securesms.loki.views.FakeChatView
|
||||
android:id="@+id/fakeChatView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/fake_chat_view_height"
|
||||
|
@ -7,7 +7,7 @@
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.SeedReminderView
|
||||
<org.thoughtcrime.securesms.loki.views.SeedReminderView
|
||||
android:id="@+id/seedReminderView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
@ -70,7 +70,7 @@
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/large_profile_picture_size"
|
||||
android:layout_height="@dimen/large_profile_picture_size"
|
||||
@ -107,7 +107,7 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.LabeledSeparatorView
|
||||
<org.thoughtcrime.securesms.loki.views.LabeledSeparatorView
|
||||
android:id="@+id/separatorView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
|
@ -19,6 +19,6 @@
|
||||
<fragment android:id="@+id/contact_selection_list_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment" />
|
||||
android:name="org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment" />
|
||||
|
||||
</LinearLayout>
|
@ -104,7 +104,7 @@
|
||||
android:indeterminate="false"
|
||||
android:progress="0" />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.SessionRestoreBannerView
|
||||
<org.thoughtcrime.securesms.loki.views.SessionRestoreBannerView
|
||||
android:id="@+id/sessionRestoreBannerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
@ -28,7 +28,7 @@
|
||||
android:layout_height="42dp"
|
||||
android:layout_alignParentStart="true">
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_width="@dimen/small_profile_picture_size"
|
||||
@ -208,7 +208,7 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.FriendRequestView
|
||||
<org.thoughtcrime.securesms.loki.views.FriendRequestView
|
||||
android:id="@+id/friend_request_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -161,7 +161,7 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.FriendRequestView
|
||||
<org.thoughtcrime.securesms.loki.views.FriendRequestView
|
||||
android:id="@+id/friend_request_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -30,7 +30,7 @@
|
||||
android:textAlignment="center"
|
||||
android:text="Users can share their Session ID by going into their account settings and tapping "Share Session ID", or by sharing their QR code." />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.LabeledSeparatorView
|
||||
<org.thoughtcrime.securesms.loki.views.LabeledSeparatorView
|
||||
android:id="@+id/separatorView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
|
@ -94,7 +94,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment"
|
||||
android:name="org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment"
|
||||
tools:layout="@layout/contact_selection_list_fragment"/>
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
|
@ -49,7 +49,7 @@
|
||||
android:layout_below="@id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:name="org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment" />
|
||||
android:name="org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.SearchToolbar
|
||||
android:id="@+id/search_toolbar"
|
||||
|
@ -13,7 +13,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/accent" />
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/medium_profile_picture_size"
|
||||
android:layout_height="@dimen/medium_profile_picture_size"
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.MentionCandidateView
|
||||
<org.thoughtcrime.securesms.loki.views.MentionCandidateView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
@ -13,7 +13,7 @@
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="32dp">
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/very_small_profile_picture_size"
|
||||
android:layout_height="@dimen/very_small_profile_picture_size"
|
||||
@ -39,4 +39,4 @@
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end" />
|
||||
|
||||
</org.thoughtcrime.securesms.loki.redesign.views.MentionCandidateView>
|
||||
</org.thoughtcrime.securesms.loki.views.MentionCandidateView>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.MentionCandidateSelectionView
|
||||
<org.thoughtcrime.securesms.loki.views.MentionCandidateSelectionView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/userSelectionView"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -14,7 +14,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:padding="@dimen/medium_spacing">
|
||||
|
||||
<org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView
|
||||
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/medium_profile_picture_size"
|
||||
android:layout_height="@dimen/medium_profile_picture_size" />
|
||||
|
@ -65,13 +65,13 @@ import org.thoughtcrime.securesms.logging.UncaughtExceptionLogger;
|
||||
import org.thoughtcrime.securesms.loki.LokiPublicChatManager;
|
||||
import org.thoughtcrime.securesms.loki.LokiPushNotificationManager;
|
||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.BackgroundOpenGroupPollWorker;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.BackgroundPollWorker;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.shelved.LokiRSSFeedPoller;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.Broadcaster;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.api.BackgroundOpenGroupPollWorker;
|
||||
import org.thoughtcrime.securesms.loki.api.BackgroundPollWorker;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.loki.shelved.LokiRSSFeedPoller;
|
||||
import org.thoughtcrime.securesms.loki.utilities.Broadcaster;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
@ -633,7 +633,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
}
|
||||
if (publicChatAPI != null) {
|
||||
byte[] profileKey = ProfileKeyUtil.getProfileKey(this);
|
||||
String url = TextSecurePreferences.getProfileAvatarUrl(this);
|
||||
String url = TextSecurePreferences.getProfilePictureURL(this);
|
||||
String ourMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(this);
|
||||
if (ourMasterDevice != null) {
|
||||
Recipient masterDevice = Recipient.from(this, Address.fromSerialized(ourMasterDevice), false).resolve();
|
||||
@ -651,10 +651,10 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
}
|
||||
|
||||
public void checkNeedsDatabaseReset() {
|
||||
if (TextSecurePreferences.resetDatabase(this)) {
|
||||
boolean wasUnlinked = TextSecurePreferences.databaseResetFromUnpair(this);
|
||||
if (TextSecurePreferences.getNeedsDatabaseReset(this)) {
|
||||
boolean wasUnlinked = TextSecurePreferences.setNeedsDatabaseResetFromUnlink(this);
|
||||
TextSecurePreferences.clearAll(this);
|
||||
TextSecurePreferences.setDatabaseResetFromUnpair(this, wasUnlinked); // Loki - Re-set the preference so we can use it in the starting screen to determine whether device was unlinked or not
|
||||
TextSecurePreferences.setNeedDatabaseResetFromUnlink(this, wasUnlinked); // Loki - Re-set the preference so we can use it in the starting screen to determine whether device was unlinked or not
|
||||
MasterSecretUtil.clear(this);
|
||||
if (this.deleteDatabase("signal.db")) {
|
||||
Log.d("Loki", "Deleted database");
|
||||
@ -663,7 +663,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
TextSecurePreferences.setResetDatabase(this, true);
|
||||
TextSecurePreferences.setNeedsDatabaseReset(this, true);
|
||||
new Handler().postDelayed(this::restartApplication, 200);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.preferences.CorrectedPreferenceFragment;
|
||||
|
@ -20,8 +20,8 @@ import android.os.Bundle;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
|
||||
import org.thoughtcrime.securesms.components.ContactFilterToolbar;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
|
@ -50,7 +50,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.lock.RegistrationLockDialog;
|
||||
import org.thoughtcrime.securesms.loki.RecipientAvatarModifiedEvent;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.JoinPublicChatActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.JoinPublicChatActivity;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
|
@ -74,7 +74,7 @@ import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||
import org.thoughtcrime.securesms.database.loaders.ConversationListLoader;
|
||||
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
||||
import org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.CreatePrivateChatActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.CreatePrivateChatActivity;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
|
@ -37,8 +37,8 @@ import org.thoughtcrime.securesms.components.FromTextView;
|
||||
import org.thoughtcrime.securesms.components.ThumbnailView;
|
||||
import org.thoughtcrime.securesms.components.TypingIndicatorView;
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIUtilities;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.loki.api.MentionManagerUtilities;
|
||||
import org.thoughtcrime.securesms.loki.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
||||
@ -272,7 +272,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
}
|
||||
|
||||
private @NonNull CharSequence getTrimmedSnippet(@NonNull CharSequence snippet) {
|
||||
LokiAPIUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(threadId, getContext()); // TODO: Terrible place to do this, but okay for now
|
||||
MentionManagerUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(threadId, getContext()); // TODO: Terrible place to do this, but okay for now
|
||||
snippet = MentionUtilities.highlightMentions(snippet, threadId, getContext());
|
||||
return snippet.length() <= MAX_SNIPPET_LENGTH ? snippet : snippet.subSequence(0, MAX_SNIPPET_LENGTH);
|
||||
}
|
||||
|
@ -415,9 +415,9 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
Log.d("Loki", "Profile photo uploaded, the url is " + result.getUrl());
|
||||
TextSecurePreferences.setProfileAvatarUrl(context, result.getUrl());
|
||||
TextSecurePreferences.setProfilePictureURL(context, result.getUrl());
|
||||
} else {
|
||||
TextSecurePreferences.setProfileAvatarUrl(context, null);
|
||||
TextSecurePreferences.setProfilePictureURL(context, null);
|
||||
}
|
||||
|
||||
AvatarHelper.setAvatar(context, Address.fromSerialized(TextSecurePreferences.getLocalNumber(context)), avatarBytes);
|
||||
|
@ -18,7 +18,7 @@ import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.thoughtcrime.securesms.database.SmsMigrator.ProgressDescription;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.service.ApplicationMigrationService;
|
||||
import org.thoughtcrime.securesms.service.ApplicationMigrationService.ImportState;
|
||||
|
||||
|
@ -25,8 +25,8 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.loaders.DeviceListLoader;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.devicelist.Device;
|
||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.DeviceEditingOptionsBottomSheet;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities;
|
||||
import org.thoughtcrime.securesms.loki.dialogs.DeviceEditingOptionsBottomSheet;
|
||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.whispersystems.libsignal.util.guava.Function;
|
||||
|
@ -19,7 +19,7 @@ import com.nineoldandroids.animation.ArgbEvaluator;
|
||||
|
||||
import org.thoughtcrime.securesms.IntroPagerAdapter.IntroPage;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
@ -56,8 +56,8 @@ import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager.GroupActionResult;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
|
@ -28,8 +28,8 @@ import org.thoughtcrime.securesms.components.ContactFilterToolbar;
|
||||
import org.thoughtcrime.securesms.components.ContactFilterToolbar.OnFilterChangedListener;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
|
@ -13,9 +13,9 @@ import android.support.v4.app.Fragment;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.LandingActivity;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.SeedActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.LandingActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.SeedActivity;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
@ -19,7 +19,7 @@ package org.thoughtcrime.securesms;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -40,8 +40,8 @@ import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.contactselection.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.loki.fragments.ContactSelectionListLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.mediasend.Media;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
|
@ -11,7 +11,7 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||
|
||||
|
@ -31,7 +31,7 @@ import org.thoughtcrime.securesms.conversation.ConversationStickerSuggestionAdap
|
||||
import org.thoughtcrime.securesms.database.model.StickerRecord;
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.loki.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.mms.QuoteModel;
|
||||
|
@ -159,12 +159,12 @@ import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiThreadDatabaseDelegate;
|
||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIUtilities;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.MentionCandidateSelectionView;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.SessionRestoreBannerView;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.api.MentionManagerUtilities;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.loki.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.loki.views.MentionCandidateSelectionView;
|
||||
import org.thoughtcrime.securesms.loki.views.SessionRestoreBannerView;
|
||||
import org.thoughtcrime.securesms.mediasend.Media;
|
||||
import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
|
||||
import org.thoughtcrime.securesms.mms.AttachmentManager;
|
||||
@ -468,7 +468,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
|
||||
LokiAPIUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(threadId, this);
|
||||
MentionManagerUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(threadId, this);
|
||||
|
||||
LokiPublicChat publicChat = DatabaseFactory.getLokiThreadDatabase(this).getPublicChat(threadId);
|
||||
if (publicChat != null) {
|
||||
@ -747,7 +747,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
MenuInflater inflater = this.getMenuInflater();
|
||||
menu.clear();
|
||||
|
||||
boolean isOpenGroupOrRSSFeed = recipient.getAddress().isPublicChat() || recipient.getAddress().isRSSFeed();
|
||||
boolean isOpenGroupOrRSSFeed = recipient.getAddress().isOpenGroup() || recipient.getAddress().isRSSFeed();
|
||||
|
||||
if (isSecureText && !isOpenGroupOrRSSFeed) {
|
||||
if (recipient.getExpireMessages() > 0) {
|
||||
@ -2073,7 +2073,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void setGroupShareProfileReminder(@NonNull Recipient recipient) {
|
||||
if (recipient.isPushGroupRecipient() && !recipient.isProfileSharing() && !recipient.getAddress().isPublicChat() && !recipient.getAddress().isRSSFeed()) {
|
||||
if (recipient.isPushGroupRecipient() && !recipient.isProfileSharing() && !recipient.getAddress().isOpenGroup() && !recipient.getAddress().isRSSFeed()) {
|
||||
groupShareProfileView.get().setRecipient(recipient);
|
||||
groupShareProfileView.get().setVisibility(View.GONE); // Loki - Always hide for now
|
||||
} else if (groupShareProfileView.resolved()) {
|
||||
|
@ -40,7 +40,7 @@ import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.loki.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
@ -79,7 +79,7 @@ import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.loki.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.longmessage.LongMessageActivity;
|
||||
import org.thoughtcrime.securesms.mediasend.Media;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
|
@ -87,10 +87,10 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestView;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.ProfilePictureView;
|
||||
import org.thoughtcrime.securesms.loki.utilities.MentionUtilities;
|
||||
import org.thoughtcrime.securesms.loki.views.FriendRequestView;
|
||||
import org.thoughtcrime.securesms.loki.views.FriendRequestViewDelegate;
|
||||
import org.thoughtcrime.securesms.loki.views.ProfilePictureView;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.mms.ImageSlide;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
|
@ -105,11 +105,11 @@ public class Address implements Parcelable, Comparable<Address> {
|
||||
|
||||
public boolean isGroup() { return GroupUtil.isEncodedGroup(address); }
|
||||
|
||||
public boolean isSignalGroup() { return GroupUtil.isSignalGroup(address); }
|
||||
public boolean isClosedGroup() { return GroupUtil.isClosedGroup(address); }
|
||||
|
||||
public boolean isPublicChat() { return GroupUtil.isPublicChat(address); }
|
||||
public boolean isOpenGroup() { return GroupUtil.isOpenGroup(address); }
|
||||
|
||||
public boolean isRSSFeed() { return GroupUtil.isRssFeed(address); }
|
||||
public boolean isRSSFeed() { return GroupUtil.isRSSFeed(address); }
|
||||
|
||||
public boolean isMmsGroup() { return GroupUtil.isMmsGroup(address); }
|
||||
|
||||
@ -127,7 +127,7 @@ public class Address implements Parcelable, Comparable<Address> {
|
||||
}
|
||||
|
||||
public @NonNull String toPhoneString() {
|
||||
if (!isPhone() && !isPublicChat()) {
|
||||
if (!isPhone() && !isOpenGroup()) {
|
||||
if (isEmail()) throw new AssertionError("Not e164, is email");
|
||||
if (isGroup()) throw new AssertionError("Not e164, is group");
|
||||
throw new AssertionError("Not e164, unknown");
|
||||
|
@ -32,10 +32,10 @@ import org.thoughtcrime.securesms.database.helpers.ClassicOpenHelper;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherMigrationHelper;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||
import org.thoughtcrime.securesms.loki.*;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyRecordDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiPreKeyRecordDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class DatabaseFactory {
|
||||
|
@ -489,11 +489,11 @@ public class GroupDatabase extends Database {
|
||||
return mms;
|
||||
}
|
||||
|
||||
public boolean isPublicChat() { return Address.fromSerialized(id).isPublicChat(); }
|
||||
public boolean isPublicChat() { return Address.fromSerialized(id).isOpenGroup(); }
|
||||
|
||||
public boolean isRSSFeed() { return Address.fromSerialized(id).isRSSFeed(); }
|
||||
|
||||
public boolean isSignalGroup() { return Address.fromSerialized(id).isSignalGroup(); }
|
||||
public boolean isSignalGroup() { return Address.fromSerialized(id).isClosedGroup(); }
|
||||
|
||||
public String getUrl() { return url; }
|
||||
|
||||
|
@ -37,10 +37,10 @@ import org.thoughtcrime.securesms.jobs.RefreshPreKeysJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyRecordDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiPreKeyRecordDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiUserDatabase;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
|
@ -8,7 +8,7 @@ import com.annimon.stream.Stream;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.devicelist.Device;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities;
|
||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities;
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.LokiDeviceLinkUtilities;
|
||||
|
@ -73,11 +73,11 @@ import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiSessionResetImplementation;
|
||||
import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
|
||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIUtilities;
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.Broadcaster;
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.OpenGroupUtilities;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.api.MentionManagerUtilities;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.loki.utilities.Broadcaster;
|
||||
import org.thoughtcrime.securesms.loki.utilities.OpenGroupUtilities;
|
||||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
||||
@ -137,7 +137,6 @@ import org.whispersystems.signalservice.api.messages.multidevice.StickerPackOper
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage;
|
||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
||||
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI;
|
||||
import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChat;
|
||||
import org.whispersystems.signalservice.loki.crypto.LokiServiceCipher;
|
||||
@ -343,7 +342,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
// Make sure we got the request from our master device
|
||||
String ourMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||
if (ourMasterDevice != null && ourMasterDevice.equals(content.getSender())) {
|
||||
TextSecurePreferences.setDatabaseResetFromUnpair(context, true);
|
||||
TextSecurePreferences.setNeedDatabaseResetFromUnlink(context, true);
|
||||
MultiDeviceUtilities.checkIsRevokedSlaveDevice(context);
|
||||
}
|
||||
} else {
|
||||
@ -1147,7 +1146,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
if (insertResult.isPresent()) {
|
||||
InsertResult result = insertResult.get();
|
||||
// Loki - Cache the user hex encoded public key (for mentions)
|
||||
LokiAPIUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(result.getThreadId(), context);
|
||||
MentionManagerUtilities.INSTANCE.populateUserHexEncodedPublicKeyCacheIfNeeded(result.getThreadId(), context);
|
||||
MentionsManager.INSTANCE.cache(textMessage.getSender().serialize(), result.getThreadId());
|
||||
|
||||
// Loki - Store message server ID
|
||||
@ -1896,7 +1895,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
boolean isGroupActive = groupId.isPresent() && groupDatabase.isActive(groupId.get());
|
||||
boolean isLeaveMessage = message.getGroupInfo().isPresent() && message.getGroupInfo().get().getType() == SignalServiceGroup.Type.QUIT;
|
||||
|
||||
boolean isClosedGroup = conversation.getAddress().isSignalGroup();
|
||||
boolean isClosedGroup = conversation.getAddress().isClosedGroup();
|
||||
boolean isGroupMember = true;
|
||||
|
||||
// Only allow messages from group members
|
||||
|
@ -169,7 +169,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
// Only send messages to the contacts we have sessions with
|
||||
List<Address> validTargets = Stream.of(target).filter(member -> {
|
||||
if (member.isPublicChat()) { return true; }
|
||||
if (member.isOpenGroup()) { return true; }
|
||||
|
||||
// Our device is always valid
|
||||
if (member.serialize().equalsIgnoreCase(localNumber)) { return true; }
|
||||
@ -287,11 +287,11 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
.toList();
|
||||
|
||||
SignalServiceGroup.GroupType groupType = SignalServiceGroup.GroupType.SIGNAL;
|
||||
if (groupAddress.isPublicChat()) {
|
||||
if (groupAddress.isOpenGroup()) {
|
||||
groupType = SignalServiceGroup.GroupType.PUBLIC_CHAT;
|
||||
}
|
||||
|
||||
if (message.isGroup() && groupAddress.isSignalGroup()) {
|
||||
if (message.isGroup() && groupAddress.isClosedGroup()) {
|
||||
// Loki - Only send GroupUpdate or GroupQuit to signal groups
|
||||
OutgoingGroupMediaMessage groupMessage = (OutgoingGroupMediaMessage) message;
|
||||
GroupContext groupContext = groupMessage.getGroupContext();
|
||||
@ -327,10 +327,10 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
private @NonNull List<Address> getGroupMessageRecipients(String groupId, long messageId) {
|
||||
if (GroupUtil.isRssFeed(groupId)) { return new ArrayList<>(); }
|
||||
if (GroupUtil.isRSSFeed(groupId)) { return new ArrayList<>(); }
|
||||
|
||||
// Loki - All public chat group messages should be directed to their respective servers
|
||||
if (GroupUtil.isPublicChat(groupId)) {
|
||||
if (GroupUtil.isOpenGroup(groupId)) {
|
||||
ArrayList<Address> result = new ArrayList<>();
|
||||
long threadID = GroupManager.getThreadIdFromGroupId(groupId, context);
|
||||
LokiPublicChat publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID);
|
||||
|
@ -6,10 +6,10 @@ import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.Database
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.getInt
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.getString
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.insertOrUpdate
|
||||
import org.thoughtcrime.securesms.loki.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.utilities.getInt
|
||||
import org.thoughtcrime.securesms.loki.utilities.getString
|
||||
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
||||
import org.whispersystems.signalservice.loki.database.LokiMessageDatabaseProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiMessageFriendRequestStatus
|
||||
|
||||
|
@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.database.DatabaseContentProviders
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.groups.GroupManager
|
||||
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPublicChatPoller
|
||||
import org.thoughtcrime.securesms.loki.api.LokiPublicChatPoller
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChat
|
||||
|
@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.Database
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.*
|
||||
import org.thoughtcrime.securesms.loki.utilities.*
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.libsignal.loki.LokiSessionResetStatus
|
||||
|
@ -58,7 +58,7 @@ class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters)
|
||||
}
|
||||
|
||||
if (openGroups.size > 0) {
|
||||
messageSender.sendMessage(0, SignalServiceSyncMessage.forOpenGroups(openGroups),
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forOpenGroups(openGroups),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context))
|
||||
} else {
|
||||
Log.d("Loki", "No open groups to sync.")
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import network.loki.messenger.R
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
@ -1,10 +1,10 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.ViewGroup
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.UserView
|
||||
import org.thoughtcrime.securesms.loki.views.UserView
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.ContactUtilities
|
||||
import org.thoughtcrime.securesms.loki.utilities.ContactUtilities
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader
|
||||
|
||||
class CreateClosedGroupLoader(context: Context) : AsyncLoader<List<String>>(context) {
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
@ -19,8 +19,8 @@ import org.thoughtcrime.securesms.conversation.ConversationActivity
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
@ -10,8 +10,8 @@ import android.widget.Toast
|
||||
import kotlinx.android.synthetic.main.activity_display_name.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.api.crypto.ProfileCipher
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
@ -32,12 +32,12 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||
import org.thoughtcrime.securesms.loki.getColorWithID
|
||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.PNModeBottomSheet
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.show
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.ConversationView
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.NewConversationButtonSetViewDelegate
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.SeedReminderViewDelegate
|
||||
import org.thoughtcrime.securesms.loki.dialogs.PNModeBottomSheet
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.show
|
||||
import org.thoughtcrime.securesms.loki.views.ConversationView
|
||||
import org.thoughtcrime.securesms.loki.views.NewConversationButtonSetViewDelegate
|
||||
import org.thoughtcrime.securesms.loki.views.SeedReminderViewDelegate
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier
|
||||
@ -269,7 +269,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
||||
val dialog = AlertDialog.Builder(activity)
|
||||
dialog.setMessage(dialogMessage)
|
||||
dialog.setPositiveButton(R.string.yes) { _, _ ->
|
||||
val isClosedGroup = recipient.address.isSignalGroup
|
||||
val isClosedGroup = recipient.address.isClosedGroup
|
||||
// Send a leave group message if this is an active closed group
|
||||
if (isClosedGroup && DatabaseFactory.getGroupDatabase(activity).isActive(recipient.address.toGroupString())) {
|
||||
if (!GroupUtil.leaveGroup(activity, recipient)) {
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
@ -7,7 +7,7 @@ import android.view.ViewGroup
|
||||
import org.thoughtcrime.securesms.database.CursorRecyclerViewAdapter
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.ConversationView
|
||||
import org.thoughtcrime.securesms.loki.views.ConversationView
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
|
||||
class HomeAdapter(context: Context, cursor: Cursor) : CursorRecyclerViewAdapter<HomeAdapter.ViewHolder>(context, cursor) {
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
@ -18,9 +18,9 @@ import nl.komponents.kovenant.ui.failUi
|
||||
import nl.komponents.kovenant.ui.successUi
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.OpenGroupUtilities
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.thoughtcrime.securesms.loki.utilities.OpenGroupUtilities
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
|
||||
class JoinPublicChatActivity : PassphraseRequiredActionBarActivity(), ScanQRCodeWrapperFragmentDelegate {
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.AsyncTask
|
||||
@ -13,12 +13,12 @@ import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase
|
||||
import org.thoughtcrime.securesms.logging.Log
|
||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.LinkDeviceSlaveModeDialog
|
||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.LinkDeviceSlaveModeDialogDelegate
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.show
|
||||
import org.thoughtcrime.securesms.loki.dialogs.LinkDeviceSlaveModeDialog
|
||||
import org.thoughtcrime.securesms.loki.dialogs.LinkDeviceSlaveModeDialogDelegate
|
||||
import org.thoughtcrime.securesms.loki.sendDeviceLinkMessage
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.utilities.show
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.Hex
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
@ -40,7 +40,7 @@ class LandingActivity : BaseActionBarActivity(), LinkDeviceSlaveModeDialogDelega
|
||||
registerButton.setOnClickListener { register() }
|
||||
restoreButton.setOnClickListener { restore() }
|
||||
linkButton.setOnClickListener { linkDevice() }
|
||||
if (TextSecurePreferences.databaseResetFromUnpair(this)) {
|
||||
if (TextSecurePreferences.setNeedsDatabaseResetFromUnlink(this)) {
|
||||
Toast.makeText(this, "Your device was unlinked successfully", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
@ -13,8 +13,8 @@ import kotlinx.android.synthetic.main.activity_link_device.*
|
||||
import kotlinx.android.synthetic.main.fragment_enter_session_id.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation
|
||||
|
||||
class LinkDeviceActivity : BaseActionBarActivity(), ScanQRCodeWrapperFragmentDelegate {
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
@ -19,7 +19,7 @@ import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.devicelist.Device
|
||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.*
|
||||
import org.thoughtcrime.securesms.loki.dialogs.*
|
||||
import org.thoughtcrime.securesms.loki.signAndSendDeviceLinkMessage
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
@ -1,10 +1,10 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.ViewGroup
|
||||
import org.thoughtcrime.securesms.devicelist.Device
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.DeviceView
|
||||
import org.thoughtcrime.securesms.loki.views.DeviceView
|
||||
|
||||
class LinkedDevicesAdapter(private val context: Context) : RecyclerView.Adapter<LinkedDevicesAdapter.ViewHolder>() {
|
||||
var devices = listOf<Device>()
|
@ -1,9 +1,9 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.devicelist.Device
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities
|
||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.LokiDeviceLinkUtilities
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import network.loki.messenger.R
|
@ -1,24 +1,20 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.TransitionDrawable
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Toast
|
||||
import kotlinx.android.synthetic.main.activity_display_name.registerButton
|
||||
import kotlinx.android.synthetic.main.activity_home.*
|
||||
import kotlinx.android.synthetic.main.activity_pn_mode.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.show
|
||||
import org.thoughtcrime.securesms.util.GroupUtil
|
||||
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.utilities.show
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
|
||||
class PNModeActivity : BaseActionBarActivity() {
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import network.loki.messenger.R
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Intent
|
||||
@ -20,9 +20,9 @@ import org.thoughtcrime.securesms.conversation.ConversationActivity
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.QRCodeUtilities
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragment
|
||||
import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelegate
|
||||
import org.thoughtcrime.securesms.loki.utilities.QRCodeUtilities
|
||||
import org.thoughtcrime.securesms.loki.toPx
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.FileProviderUtil
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
@ -22,8 +22,8 @@ import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.Hex
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Typeface
|
||||
@ -18,8 +18,8 @@ import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.Hex
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||
package org.thoughtcrime.securesms.loki.activities
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
@ -29,9 +29,9 @@ import org.thoughtcrime.securesms.avatar.AvatarSelection
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.ClearAllDataDialog
|
||||
import org.thoughtcrime.securesms.loki.redesign.dialogs.SeedDialog
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.dialogs.ClearAllDataDialog
|
||||
import org.thoughtcrime.securesms.loki.dialogs.SeedDialog
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.toPx
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
@ -169,7 +169,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
val (_, url) = storageAPI.uploadProfilePicture(storageAPI.server, profileKey, stream) {
|
||||
TextSecurePreferences.setLastProfilePictureUpload(this@SettingsActivity, Date().time)
|
||||
}
|
||||
TextSecurePreferences.setProfileAvatarUrl(this, url)
|
||||
TextSecurePreferences.setProfilePictureURL(this, url)
|
||||
deferred.resolve(Unit)
|
||||
}
|
||||
promises.add(deferred.promise)
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.api
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.api
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
@ -1,10 +1,9 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.api
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.functional.bind
|
||||
import nl.komponents.kovenant.then
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.api
|
||||
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
@ -6,10 +6,10 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager
|
||||
|
||||
object LokiAPIUtilities {
|
||||
object MentionManagerUtilities {
|
||||
|
||||
fun populateUserHexEncodedPublicKeyCacheIfNeeded(threadID: Long, context: Context) {
|
||||
if (MentionsManager.userHexEncodedPublicKeyCache[threadID] != null) { return }
|
||||
if (MentionsManager.shared.userHexEncodedPublicKeyCache[threadID] != null) { return }
|
||||
val result = mutableSetOf<String>()
|
||||
val messageDatabase = DatabaseFactory.getMmsSmsDatabase(context)
|
||||
val reader = messageDatabase.readerFor(messageDatabase.getConversation(threadID))
|
||||
@ -24,6 +24,6 @@ object LokiAPIUtilities {
|
||||
}
|
||||
reader.close()
|
||||
result.add(TextSecurePreferences.getLocalNumber(context))
|
||||
MentionsManager.userHexEncodedPublicKeyCache[threadID] = result
|
||||
MentionsManager.shared.userHexEncodedPublicKeyCache[threadID] = result
|
||||
}
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.database
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.Database
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.*
|
||||
import org.thoughtcrime.securesms.loki.utilities.*
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol
|
||||
import org.whispersystems.signalservice.loki.api.LokiAPITarget
|
||||
import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink
|
||||
|
||||
// TODO: Clean this up a bit
|
||||
|
||||
class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiAPIDatabaseProtocol {
|
||||
|
||||
private val userPublicKey get() = TextSecurePreferences.getLocalNumber(context)
|
||||
@ -71,9 +69,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
val components = targetAsString.split("-")
|
||||
val address = components[0]
|
||||
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
||||
val idKey = components.getOrNull(2) ?: return@mapNotNull null
|
||||
val encryptionKey = components.getOrNull(3)?: return@mapNotNull null
|
||||
LokiAPITarget(address, port, LokiAPITarget.KeySet(idKey, encryptionKey))
|
||||
val ed25519Key = components.getOrNull(2) ?: return@mapNotNull null
|
||||
val x25519Key = components.getOrNull(3)?: return@mapNotNull null
|
||||
LokiAPITarget(address, port, LokiAPITarget.KeySet(ed25519Key, x25519Key))
|
||||
}
|
||||
}?.toSet()
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.database
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
@ -9,10 +9,10 @@ import org.thoughtcrime.securesms.database.Database
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.logging.Log
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.getBase64EncodedData
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.getInt
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.insertOrUpdate
|
||||
import org.thoughtcrime.securesms.loki.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.utilities.getBase64EncodedData
|
||||
import org.thoughtcrime.securesms.loki.utilities.getInt
|
||||
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.libsignal.IdentityKey
|
@ -1,13 +1,13 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.database
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil
|
||||
import org.thoughtcrime.securesms.database.Database
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.getInt
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.insertOrUpdate
|
||||
import org.thoughtcrime.securesms.loki.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.utilities.getInt
|
||||
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
||||
import org.whispersystems.libsignal.state.PreKeyRecord
|
||||
import org.whispersystems.signalservice.loki.database.LokiPreKeyRecordDatabaseProtocol
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.messaging
|
||||
package org.thoughtcrime.securesms.loki.database
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
@ -7,8 +7,8 @@ import android.util.Log
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.Database
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.insertOrUpdate
|
||||
import org.thoughtcrime.securesms.loki.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.loki.database.LokiUserDatabaseProtocol
|
||||
@ -71,7 +71,7 @@ class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database
|
||||
|
||||
override fun getProfilePictureURL(hexEncodedPublicKey: String): String? {
|
||||
return if (hexEncodedPublicKey == TextSecurePreferences.getLocalNumber(context)) {
|
||||
TextSecurePreferences.getProfileAvatarUrl(context)
|
||||
TextSecurePreferences.getProfilePictureURL(context)
|
||||
} else {
|
||||
Recipient.from(context, Address.fromSerialized(hexEncodedPublicKey), false).resolve().profileAvatar
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.graphics.Color
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.BottomSheetDialogFragment
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.graphics.Color
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.graphics.Color
|
||||
@ -12,15 +12,15 @@ import android.widget.LinearLayout
|
||||
import kotlinx.android.synthetic.main.dialog_link_device_master_mode.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.QRCodeUtilities
|
||||
import org.thoughtcrime.securesms.loki.toPx
|
||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
||||
import org.thoughtcrime.securesms.loki.utilities.QRCodeUtilities
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLinkingSession
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLinkingSessionListener
|
||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
||||
|
||||
class LinkDeviceMasterModeDialog : DialogFragment(), DeviceLinkingSessionListener {
|
||||
private val languageFileDirectory by lazy { MnemonicUtilities.getLanguageFileDirectory(context!!) }
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.graphics.Color
|
||||
@ -12,7 +12,7 @@ import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import kotlinx.android.synthetic.main.dialog_link_device_slave_mode.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities
|
||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.BottomSheetDialogFragment
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.DialogInterface
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.dialogs
|
||||
package org.thoughtcrime.securesms.loki.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.ClipData
|
@ -0,0 +1,85 @@
|
||||
package org.thoughtcrime.securesms.loki.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import kotlinx.android.synthetic.main.contact_selection_list_divider.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.loki.views.UserView
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
class ContactSelectionListAdapter(private val context: Context, private val multiSelect: Boolean) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
lateinit var glide: GlideRequests
|
||||
val selectedContacts = mutableSetOf<Recipient>()
|
||||
var items = listOf<ContactSelectionListItem>()
|
||||
set(value) { field = value; notifyDataSetChanged() }
|
||||
var contactClickListener: ContactClickListener? = null
|
||||
|
||||
private object ViewType {
|
||||
const val Contact = 0
|
||||
const val Divider = 1
|
||||
}
|
||||
|
||||
class UserViewHolder(val view: UserView) : RecyclerView.ViewHolder(view)
|
||||
class DividerViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return items.size
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when (items[position]) {
|
||||
is ContactSelectionListItem.Header -> ViewType.Divider
|
||||
else -> ViewType.Contact
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return if (viewType == ViewType.Contact) {
|
||||
UserViewHolder(UserView(context))
|
||||
} else {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.contact_selection_list_divider, parent, false)
|
||||
DividerViewHolder(view)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
if (viewHolder is UserViewHolder) {
|
||||
item as ContactSelectionListItem.Contact
|
||||
viewHolder.view.setOnClickListener { contactClickListener?.onContactClick(item.recipient) }
|
||||
val isSelected = selectedContacts.contains(item.recipient)
|
||||
viewHolder.view.bind(item.recipient, isSelected, glide)
|
||||
viewHolder.view.setCheckBoxVisible(multiSelect)
|
||||
} else if (viewHolder is DividerViewHolder) {
|
||||
item as ContactSelectionListItem.Header
|
||||
viewHolder.view.label.text = item.name
|
||||
}
|
||||
}
|
||||
|
||||
fun onContactClick(recipient: Recipient) {
|
||||
if (selectedContacts.contains(recipient)) {
|
||||
selectedContacts.remove(recipient)
|
||||
contactClickListener?.onContactDeselected(recipient)
|
||||
} else if (multiSelect || selectedContacts.isEmpty()) {
|
||||
selectedContacts.add(recipient)
|
||||
contactClickListener?.onContactSelected(recipient)
|
||||
}
|
||||
val index = items.indexOfFirst {
|
||||
when (it) {
|
||||
is ContactSelectionListItem.Header -> false
|
||||
is ContactSelectionListItem.Contact -> it.recipient == recipient
|
||||
}
|
||||
}
|
||||
notifyItemChanged(index)
|
||||
}
|
||||
}
|
||||
|
||||
interface ContactClickListener {
|
||||
fun onContactClick(contact: Recipient)
|
||||
fun onContactSelected(contact: Recipient)
|
||||
fun onContactDeselected(contact: Recipient)
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package org.thoughtcrime.securesms.loki.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.LoaderManager
|
||||
import android.support.v4.content.Loader
|
||||
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import kotlinx.android.synthetic.main.contact_selection_list_fragment.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.contacts.ContactsCursorLoader
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
class ContactSelectionListFragment : Fragment(), LoaderManager.LoaderCallbacks<List<ContactSelectionListItem>>, ContactClickListener {
|
||||
private var cursorFilter: String? = null
|
||||
var onContactSelectedListener: OnContactSelectedListener? = null
|
||||
|
||||
val selectedContacts: List<String>
|
||||
get() = listAdapter.selectedContacts.map { it.address.serialize() }
|
||||
|
||||
private val multiSelect: Boolean by lazy {
|
||||
activity!!.intent.getBooleanExtra(MULTI_SELECT, false)
|
||||
}
|
||||
|
||||
private val listAdapter by lazy {
|
||||
val result = ContactSelectionListAdapter(activity!!, multiSelect)
|
||||
result.glide = GlideApp.with(this)
|
||||
result.contactClickListener = this
|
||||
result
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField val DISPLAY_MODE = "display_mode"
|
||||
@JvmField val MULTI_SELECT = "multi_select"
|
||||
@JvmField val REFRESHABLE = "refreshable"
|
||||
}
|
||||
|
||||
interface OnContactSelectedListener {
|
||||
fun onContactSelected(number: String?)
|
||||
fun onContactDeselected(number: String?)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
recyclerView.layoutManager = LinearLayoutManager(activity)
|
||||
recyclerView.adapter = listAdapter
|
||||
swipeRefreshLayout.isEnabled = activity!!.intent.getBooleanExtra(REFRESHABLE, true)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
LoaderManager.getInstance(this).initLoader(0, null, this)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.contact_selection_list_fragment, container, false)
|
||||
}
|
||||
|
||||
fun setQueryFilter(filter: String?) {
|
||||
cursorFilter = filter
|
||||
LoaderManager.getInstance(this).restartLoader(0, null, this)
|
||||
}
|
||||
|
||||
fun resetQueryFilter() {
|
||||
setQueryFilter(null)
|
||||
swipeRefreshLayout.isRefreshing = false
|
||||
}
|
||||
|
||||
fun setRefreshing(refreshing: Boolean) {
|
||||
swipeRefreshLayout.isRefreshing = refreshing
|
||||
}
|
||||
|
||||
fun setOnRefreshListener(onRefreshListener: OnRefreshListener?) {
|
||||
swipeRefreshLayout.setOnRefreshListener(onRefreshListener)
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ContactSelectionListItem>> {
|
||||
return ContactSelectionListLoader(activity!!,
|
||||
activity!!.intent.getIntExtra(DISPLAY_MODE, ContactsCursorLoader.DisplayMode.FLAG_ALL),
|
||||
cursorFilter)
|
||||
}
|
||||
|
||||
override fun onLoadFinished(loader: Loader<List<ContactSelectionListItem>>, items: List<ContactSelectionListItem>) {
|
||||
update(items)
|
||||
}
|
||||
|
||||
override fun onLoaderReset(loader: Loader<List<ContactSelectionListItem>>) {
|
||||
update(listOf())
|
||||
}
|
||||
|
||||
private fun update(items: List<ContactSelectionListItem>) {
|
||||
listAdapter.items = items
|
||||
mainContentContainer.visibility = if (items.isEmpty()) View.GONE else View.VISIBLE
|
||||
emptyStateContainer.visibility = if (items.isEmpty()) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun onContactClick(contact: Recipient) {
|
||||
listAdapter.onContactClick(contact)
|
||||
}
|
||||
|
||||
override fun onContactSelected(contact: Recipient) {
|
||||
onContactSelectedListener?.onContactSelected(contact.address.serialize())
|
||||
}
|
||||
|
||||
override fun onContactDeselected(contact: Recipient) {
|
||||
onContactSelectedListener?.onContactDeselected(contact.address.serialize())
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package org.thoughtcrime.securesms.loki.fragments
|
||||
|
||||
import android.content.Context
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.loki.utilities.Contact
|
||||
import org.thoughtcrime.securesms.loki.utilities.ContactUtilities
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader
|
||||
|
||||
sealed class ContactSelectionListItem {
|
||||
class Header(val name: String) : ContactSelectionListItem()
|
||||
class Contact(val recipient: Recipient) : ContactSelectionListItem()
|
||||
}
|
||||
|
||||
class ContactSelectionListLoader(context: Context, val mode: Int, val filter: String?) : AsyncLoader<List<ContactSelectionListItem>>(context) {
|
||||
|
||||
object DisplayMode {
|
||||
const val FLAG_FRIENDS = 1
|
||||
const val FLAG_CLOSED_GROUPS = 1 shl 1
|
||||
const val FLAG_OPEN_GROUPS = 1 shl 2
|
||||
const val FLAG_ALL = FLAG_FRIENDS or FLAG_CLOSED_GROUPS or FLAG_OPEN_GROUPS
|
||||
}
|
||||
|
||||
private fun isFlagSet(flag: Int): Boolean {
|
||||
return mode and flag > 0
|
||||
}
|
||||
|
||||
override fun loadInBackground(): List<ContactSelectionListItem> {
|
||||
val contacts = ContactUtilities.getAllContacts(context).filter {
|
||||
if (filter.isNullOrEmpty()) return@filter true
|
||||
it.recipient.toShortString().contains(filter.trim(), true) || it.recipient.address.serialize().contains(filter.trim(), true)
|
||||
}.sortedBy {
|
||||
it.recipient.toShortString()
|
||||
}
|
||||
val list = mutableListOf<ContactSelectionListItem>()
|
||||
if (isFlagSet(DisplayMode.FLAG_CLOSED_GROUPS)) {
|
||||
list.addAll(getClosedGroups(contacts))
|
||||
}
|
||||
if (isFlagSet(DisplayMode.FLAG_OPEN_GROUPS)) {
|
||||
list.addAll(getOpenGroups(contacts))
|
||||
}
|
||||
if (isFlagSet(DisplayMode.FLAG_FRIENDS)) {
|
||||
list.addAll(getFriends(contacts))
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
private fun getFriends(contacts: List<Contact>): List<ContactSelectionListItem> {
|
||||
return getItems(contacts, context.getString(R.string.fragment_contact_selection_contacts_title)) {
|
||||
!it.recipient.isGroupRecipient && it.isFriend && !it.isOurDevice && !it.isSlave
|
||||
}
|
||||
}
|
||||
|
||||
private fun getClosedGroups(contacts: List<Contact>): List<ContactSelectionListItem> {
|
||||
return getItems(contacts, context.getString(R.string.fragment_contact_selection_closed_groups_title)) {
|
||||
it.recipient.address.isClosedGroup
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOpenGroups(contacts: List<Contact>): List<ContactSelectionListItem> {
|
||||
return getItems(contacts, context.getString(R.string.fragment_contact_selection_open_groups_title)) {
|
||||
it.recipient.address.isOpenGroup
|
||||
}
|
||||
}
|
||||
|
||||
private fun getItems(contacts: List<Contact>, title: String, contactFilter: (Contact) -> Boolean): List<ContactSelectionListItem> {
|
||||
val items = contacts.filter(contactFilter).map {
|
||||
ContactSelectionListItem.Contact(it.recipient)
|
||||
}
|
||||
if (items.isEmpty()) return listOf()
|
||||
val header = ContactSelectionListItem.Header(title)
|
||||
return listOf(header) + items
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.fragments
|
||||
package org.thoughtcrime.securesms.loki.fragments
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.fragments
|
||||
package org.thoughtcrime.securesms.loki.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.fragments
|
||||
package org.thoughtcrime.securesms.loki.fragments
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
@ -0,0 +1,28 @@
|
||||
package org.thoughtcrime.securesms.loki.protocol
|
||||
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.util.GroupUtil
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
|
||||
object ClosedGroupsProtocol {
|
||||
|
||||
fun leaveGroup(context: Context, recipient: Recipient): Boolean {
|
||||
if (!recipient.address.isClosedGroup) { return true }
|
||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient)
|
||||
val message = GroupUtil.createGroupLeaveMessage(context, recipient)
|
||||
if (threadID < 0 || !message.isPresent) { return false }
|
||||
MessageSender.send(context, message.get(), threadID, false, null)
|
||||
// Remove the *master* device from the group
|
||||
val masterHexPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||
val userPublicKey = masterHexPublicKey ?: TextSecurePreferences.getLocalNumber(context)
|
||||
val groupDatabase = DatabaseFactory.getGroupDatabase(context)
|
||||
val groupID = recipient.address.toGroupString()
|
||||
groupDatabase.setActive(groupID, false)
|
||||
groupDatabase.remove(groupID, Address.fromSerialized(userPublicKey))
|
||||
return true
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.fragments.contactselection
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import kotlinx.android.synthetic.main.contact_selection_list_divider.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.loki.redesign.views.UserView
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
class ContactSelectionListAdapter(private val context: Context, private val multiSelect: Boolean) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
lateinit var glide: GlideRequests
|
||||
val selectedContacts = mutableSetOf<Recipient>()
|
||||
var items = listOf<ContactSelectionListItem>()
|
||||
set(value) { field = value; notifyDataSetChanged() }
|
||||
var contactClickListener: ContactClickListener? = null
|
||||
|
||||
private object ViewType {
|
||||
const val Contact = 0
|
||||
const val Divider = 1
|
||||
}
|
||||
|
||||
class UserViewHolder(val view: UserView) : RecyclerView.ViewHolder(view)
|
||||
class DividerViewHolder(val view: View) : RecyclerView.ViewHolder(view)
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return items.size
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when (items[position]) {
|
||||
is ContactSelectionListItem.Header -> ViewType.Divider
|
||||
else -> ViewType.Contact
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return if (viewType == ViewType.Contact) {
|
||||
UserViewHolder(UserView(context))
|
||||
} else {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.contact_selection_list_divider, parent, false)
|
||||
DividerViewHolder(view)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
if (viewHolder is UserViewHolder) {
|
||||
item as ContactSelectionListItem.Contact
|
||||
viewHolder.view.setOnClickListener { contactClickListener?.onContactClick(item.recipient) }
|
||||
val isSelected = selectedContacts.contains(item.recipient)
|
||||
viewHolder.view.bind(item.recipient, isSelected, glide)
|
||||
viewHolder.view.setCheckBoxVisible(multiSelect)
|
||||
} else if (viewHolder is DividerViewHolder) {
|
||||
item as ContactSelectionListItem.Header
|
||||
viewHolder.view.label.text = item.name
|
||||
}
|
||||
}
|
||||
|
||||
fun onContactClick(recipient: Recipient) {
|
||||
if (selectedContacts.contains(recipient)) {
|
||||
selectedContacts.remove(recipient)
|
||||
contactClickListener?.onContactDeselected(recipient)
|
||||
} else if (multiSelect || selectedContacts.isEmpty()) {
|
||||
selectedContacts.add(recipient)
|
||||
contactClickListener?.onContactSelected(recipient)
|
||||
}
|
||||
val index = items.indexOfFirst {
|
||||
when (it) {
|
||||
is ContactSelectionListItem.Header -> false
|
||||
is ContactSelectionListItem.Contact -> it.recipient == recipient
|
||||
}
|
||||
}
|
||||
notifyItemChanged(index)
|
||||
}
|
||||
}
|
||||
|
||||
interface ContactClickListener {
|
||||
fun onContactClick(contact: Recipient)
|
||||
fun onContactSelected(contact: Recipient)
|
||||
fun onContactDeselected(contact: Recipient)
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.fragments.contactselection
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.LoaderManager
|
||||
import android.support.v4.content.Loader
|
||||
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import kotlinx.android.synthetic.main.contact_selection_list_fragment.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.contacts.ContactsCursorLoader
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
class ContactSelectionListFragment : Fragment(), LoaderManager.LoaderCallbacks<List<ContactSelectionListItem>>, ContactClickListener {
|
||||
private var cursorFilter: String? = null
|
||||
var onContactSelectedListener: OnContactSelectedListener? = null
|
||||
|
||||
val selectedContacts: List<String>
|
||||
get() = listAdapter.selectedContacts.map { it.address.serialize() }
|
||||
|
||||
private val multiSelect: Boolean by lazy {
|
||||
activity!!.intent.getBooleanExtra(MULTI_SELECT, false)
|
||||
}
|
||||
|
||||
private val listAdapter by lazy {
|
||||
val result = ContactSelectionListAdapter(activity!!, multiSelect)
|
||||
result.glide = GlideApp.with(this)
|
||||
result.contactClickListener = this
|
||||
result
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField val DISPLAY_MODE = "display_mode"
|
||||
@JvmField val MULTI_SELECT = "multi_select"
|
||||
@JvmField val REFRESHABLE = "refreshable"
|
||||
}
|
||||
|
||||
interface OnContactSelectedListener {
|
||||
fun onContactSelected(number: String?)
|
||||
fun onContactDeselected(number: String?)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
recyclerView.layoutManager = LinearLayoutManager(activity)
|
||||
recyclerView.adapter = listAdapter
|
||||
swipeRefreshLayout.isEnabled = activity!!.intent.getBooleanExtra(REFRESHABLE, true)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
LoaderManager.getInstance(this).initLoader(0, null, this)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.contact_selection_list_fragment, container, false)
|
||||
}
|
||||
|
||||
fun setQueryFilter(filter: String?) {
|
||||
cursorFilter = filter
|
||||
LoaderManager.getInstance(this).restartLoader(0, null, this)
|
||||
}
|
||||
|
||||
fun resetQueryFilter() {
|
||||
setQueryFilter(null)
|
||||
swipeRefreshLayout.isRefreshing = false
|
||||
}
|
||||
|
||||
fun setRefreshing(refreshing: Boolean) {
|
||||
swipeRefreshLayout.isRefreshing = refreshing
|
||||
}
|
||||
|
||||
fun setOnRefreshListener(onRefreshListener: OnRefreshListener?) {
|
||||
swipeRefreshLayout.setOnRefreshListener(onRefreshListener)
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ContactSelectionListItem>> {
|
||||
return ContactSelectionListLoader(activity!!,
|
||||
activity!!.intent.getIntExtra(DISPLAY_MODE, ContactsCursorLoader.DisplayMode.FLAG_ALL),
|
||||
cursorFilter)
|
||||
}
|
||||
|
||||
override fun onLoadFinished(loader: Loader<List<ContactSelectionListItem>>, items: List<ContactSelectionListItem>) {
|
||||
update(items)
|
||||
}
|
||||
|
||||
override fun onLoaderReset(loader: Loader<List<ContactSelectionListItem>>) {
|
||||
update(listOf())
|
||||
}
|
||||
|
||||
private fun update(items: List<ContactSelectionListItem>) {
|
||||
listAdapter.items = items
|
||||
mainContentContainer.visibility = if (items.isEmpty()) View.GONE else View.VISIBLE
|
||||
emptyStateContainer.visibility = if (items.isEmpty()) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun onContactClick(contact: Recipient) {
|
||||
listAdapter.onContactClick(contact)
|
||||
}
|
||||
|
||||
override fun onContactSelected(contact: Recipient) {
|
||||
onContactSelectedListener?.onContactSelected(contact.address.serialize())
|
||||
}
|
||||
|
||||
override fun onContactDeselected(contact: Recipient) {
|
||||
onContactSelectedListener?.onContactDeselected(contact.address.serialize())
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package org.thoughtcrime.securesms.loki.redesign.fragments.contactselection
|
||||
|
||||
import android.content.Context
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.Contact
|
||||
import org.thoughtcrime.securesms.loki.redesign.utilities.ContactUtilities
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader
|
||||
|
||||
sealed class ContactSelectionListItem {
|
||||
class Header(val name: String) : ContactSelectionListItem()
|
||||
class Contact(val recipient: Recipient) : ContactSelectionListItem()
|
||||
}
|
||||
|
||||
class ContactSelectionListLoader(context: Context, val mode: Int, val filter: String?) : AsyncLoader<List<ContactSelectionListItem>>(context) {
|
||||
|
||||
object DisplayMode {
|
||||
const val FLAG_FRIENDS = 1
|
||||
const val FLAG_CLOSED_GROUPS = 1 shl 1
|
||||
const val FLAG_OPEN_GROUPS = 1 shl 2
|
||||
const val FLAG_ALL = FLAG_FRIENDS or FLAG_CLOSED_GROUPS or FLAG_OPEN_GROUPS
|
||||
}
|
||||
|
||||
private fun isFlagSet(flag: Int): Boolean {
|
||||
return mode and flag > 0
|
||||
}
|
||||
|
||||
override fun loadInBackground(): List<ContactSelectionListItem> {
|
||||
val contacts = ContactUtilities.getAllContacts(context).filter {
|
||||
if (filter.isNullOrEmpty()) return@filter true
|
||||
|
||||
it.recipient.toShortString().contains(filter.trim(), true) || it.recipient.address.serialize().contains(filter.trim(), true)
|
||||
}.sortedBy {
|
||||
it.recipient.toShortString()
|
||||
}
|
||||
|
||||
val list = mutableListOf<ContactSelectionListItem>()
|
||||
|
||||
if (isFlagSet(DisplayMode.FLAG_CLOSED_GROUPS)) {
|
||||
list.addAll(getClosedGroups(contacts))
|
||||
}
|
||||
|
||||
if (isFlagSet(DisplayMode.FLAG_OPEN_GROUPS)) {
|
||||
list.addAll(getOpenGroups(contacts))
|
||||
}
|
||||
|
||||
if (isFlagSet(DisplayMode.FLAG_FRIENDS)) {
|
||||
list.addAll(getFriends(contacts))
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
private fun getFriends(contacts: List<Contact>): List<ContactSelectionListItem> {
|
||||
return getItems(contacts, context.getString(R.string.fragment_contact_selection_contacts_title)) {
|
||||
!it.recipient.isGroupRecipient && it.isFriend && !it.isOurDevice && !it.isSlave
|
||||
}
|
||||
}
|
||||
|
||||
private fun getClosedGroups(contacts: List<Contact>): List<ContactSelectionListItem> {
|
||||
return getItems(contacts, context.getString(R.string.fragment_contact_selection_closed_groups_title)) {
|
||||
it.recipient.address.isSignalGroup
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOpenGroups(contacts: List<Contact>): List<ContactSelectionListItem> {
|
||||
return getItems(contacts, context.getString(R.string.fragment_contact_selection_open_groups_title)) {
|
||||
it.recipient.address.isPublicChat
|
||||
}
|
||||
}
|
||||
|
||||
private fun getItems(contacts: List<Contact>, title: String, contactFilter: (Contact) -> Boolean): List<ContactSelectionListItem> {
|
||||
val items = contacts.filter(contactFilter).map {
|
||||
ContactSelectionListItem.Contact(it.recipient)
|
||||
}
|
||||
|
||||
if (items.isEmpty()) return listOf()
|
||||
|
||||
val header = ContactSelectionListItem.Header(title)
|
||||
|
||||
return listOf(header) + items
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user