From a9b5c269f6f86c487a67533e5399c79d381de5a7 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 9 Jul 2021 11:14:21 +1000 Subject: [PATCH 1/5] Re-organize files & delete unused code --- app/src/main/AndroidManifest.xml | 36 +- .../securesms/ApplicationContext.java | 7 +- .../MessageDetailsRecipientAdapter.java | 2 +- .../PassphraseRequiredActionBarActivity.java | 4 +- .../securesms/ShortcutLauncherActivity.java | 2 +- .../BackupRestoreActivity.kt | 9 +- .../SelectContactsActivity.kt | 6 +- .../SelectContactsAdapter.kt | 3 +- .../SelectContactsLoader.kt | 2 +- .../{loki/views => contacts}/UserView.kt | 2 +- .../conversation/v2/ConversationActivityV2.kt | 5 +- .../MentionCandidateSelectionView.kt | 2 +- .../v2/components}/MentionCandidateView.kt | 2 +- .../v2/components/OpenGroupGuidelinesView.kt | 2 +- .../v2/input_bar/InputBarButton.kt | 5 +- .../v2/menus/ConversationMenuHelper.kt | 6 +- .../CreateClosedGroupActivity.kt | 5 +- .../EditClosedGroupActivity.kt | 3 +- .../EditClosedGroupLoader.kt | 2 +- .../EditClosedGroupMembersAdapter.kt | 4 +- .../JoinPublicChatActivity.kt | 0 .../OpenGroupGuidelinesActivity.kt | 2 +- .../{loki/views => home}/ConversationView.kt | 2 +- .../{loki/activities => home}/HomeActivity.kt | 13 +- .../{loki/activities => home}/HomeAdapter.kt | 3 +- .../{loki/activities => home}/HomeLoader.kt | 2 +- .../NewConversationButtonSetView.kt | 4 +- .../{loki/activities => home}/PathActivity.kt | 6 +- .../{loki/views => home}/PathStatusView.kt | 2 +- .../fragments/ContactSelectionListAdapter.kt | 2 +- .../securesms/loki/views/MessageAudioView.kt | 335 ------------------ .../loki/views/OpenGroupInvitationView.kt | 71 ---- .../securesms/loki/views/WaveformSeekBar.kt | 315 ---------------- .../MultipleRecipientNotificationBuilder.java | 2 +- .../PendingMessageNotificationBuilder.java | 2 +- .../DisplayNameActivity.kt | 2 +- .../views => onboarding}/FakeChatView.kt | 2 +- .../LandingActivity.kt | 4 +- .../LinkDeviceActivity.kt | 3 +- .../PNModeActivity.kt | 7 +- .../RecoveryPhraseRestoreActivity.kt | 2 +- .../RegisterActivity.kt | 2 +- .../activities => onboarding}/SeedActivity.kt | 2 +- .../views => onboarding}/SeedReminderView.kt | 2 +- .../ChatSettingsActivity.kt | 2 +- .../NotificationSettingsActivity.kt | 2 +- .../PrivacySettingsActivity.kt | 2 +- .../QRCodeActivity.kt | 2 +- .../SettingsActivity.kt | 2 +- .../service/GenericForegroundService.java | 2 +- .../securesms/service/KeyCachingService.java | 2 +- .../{loki/views => util}/GlowView.kt | 2 +- .../res/layout-sw400dp/activity_landing.xml | 2 +- .../res/layout-sw400dp/activity_pn_mode.xml | 8 +- .../main/res/layout-sw400dp/activity_seed.xml | 2 +- .../res/layout/activity_edit_closed_group.xml | 2 +- app/src/main/res/layout/activity_home.xml | 8 +- app/src/main/res/layout/activity_landing.xml | 2 +- app/src/main/res/layout/activity_pn_mode.xml | 8 +- app/src/main/res/layout/activity_seed.xml | 2 +- app/src/main/res/layout/activity_settings.xml | 2 +- .../res/layout/view_mention_candidate.xml | 4 +- 62 files changed, 110 insertions(+), 842 deletions(-) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => backup}/BackupRestoreActivity.kt (96%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => contacts}/SelectContactsActivity.kt (93%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => contacts}/SelectContactsAdapter.kt (96%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => contacts}/SelectContactsLoader.kt (92%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => contacts}/UserView.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => conversation/v2/components}/MentionCandidateSelectionView.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => conversation/v2/components}/MentionCandidateView.kt (96%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => groups}/CreateClosedGroupActivity.kt (97%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => groups}/EditClosedGroupActivity.kt (99%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => groups}/EditClosedGroupLoader.kt (94%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => groups}/EditClosedGroupMembersAdapter.kt (95%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => groups}/JoinPublicChatActivity.kt (100%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => groups}/OpenGroupGuidelinesActivity.kt (97%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => home}/ConversationView.kt (99%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => home}/HomeActivity.kt (97%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => home}/HomeAdapter.kt (94%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => home}/HomeLoader.kt (88%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => home}/NewConversationButtonSetView.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => home}/PathActivity.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => home}/PathStatusView.kt (98%) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/views/OpenGroupInvitationView.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => onboarding}/DisplayNameActivity.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => onboarding}/FakeChatView.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => onboarding}/LandingActivity.kt (92%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => onboarding}/LinkDeviceActivity.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => onboarding}/PNModeActivity.kt (97%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => onboarding}/RecoveryPhraseRestoreActivity.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => onboarding}/RegisterActivity.kt (99%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => onboarding}/SeedActivity.kt (98%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => onboarding}/SeedReminderView.kt (97%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => preferences}/ChatSettingsActivity.kt (93%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => preferences}/NotificationSettingsActivity.kt (93%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => preferences}/PrivacySettingsActivity.kt (93%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => preferences}/QRCodeActivity.kt (99%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/activities => preferences}/SettingsActivity.kt (99%) rename app/src/main/java/org/thoughtcrime/securesms/{loki/views => util}/GlowView.kt (99%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 90c34008dc..d734317703 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -93,15 +93,15 @@ android:value="false" /> @@ -111,25 +111,25 @@ android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.Session.DayNight.FlatActionBar" /> + android:targetActivity="org.thoughtcrime.securesms.home.HomeActivity"> @@ -215,14 +215,14 @@ + android:value="org.thoughtcrime.securesms.home.HomeActivity" /> > { diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupActivity.kt similarity index 99% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupActivity.kt index d6508e8975..8c56d9aac2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.groups import android.content.Context import android.content.Intent @@ -33,6 +33,7 @@ import org.session.libsession.utilities.GroupUtil import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.ThemeUtil import org.session.libsignal.utilities.toHexString +import org.thoughtcrime.securesms.contacts.SelectContactsActivity import java.io.IOException class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupLoader.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupLoader.kt similarity index 94% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupLoader.kt rename to app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupLoader.kt index d2bb17a732..5360f4261d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupLoader.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupLoader.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.groups import android.content.Context import org.thoughtcrime.securesms.database.DatabaseFactory diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupMembersAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupMembersAdapter.kt similarity index 95% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupMembersAdapter.kt rename to app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupMembersAdapter.kt index 4a451ba222..b2d0f6255a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupMembersAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/EditClosedGroupMembersAdapter.kt @@ -1,10 +1,10 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.groups import android.content.Context import androidx.recyclerview.widget.RecyclerView import android.view.ViewGroup import org.session.libsession.utilities.Address -import org.thoughtcrime.securesms.loki.views.UserView +import org.thoughtcrime.securesms.contacts.UserView import org.thoughtcrime.securesms.mms.GlideRequests import org.session.libsession.utilities.recipients.Recipient import org.session.libsession.utilities.TextSecurePreferences diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/JoinPublicChatActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/JoinPublicChatActivity.kt similarity index 100% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/JoinPublicChatActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/groups/JoinPublicChatActivity.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/OpenGroupGuidelinesActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupGuidelinesActivity.kt similarity index 97% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/OpenGroupGuidelinesActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupGuidelinesActivity.kt index 9c714b6eff..3b7827679e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/OpenGroupGuidelinesActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/OpenGroupGuidelinesActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.groups import android.os.Bundle import kotlinx.android.synthetic.main.activity_open_group_guidelines.* diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt similarity index 99% rename from app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt rename to app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt index f4341b5ed1..934d40a63b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/ConversationView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationView.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.views +package org.thoughtcrime.securesms.home import android.content.Context import android.content.res.Resources diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt similarity index 97% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index 601820e5a0..643f2b98e4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.home import android.app.AlertDialog import android.content.BroadcastReceiver @@ -11,7 +11,6 @@ import android.text.Spannable import android.text.SpannableString import android.text.style.ForegroundColorSpan import android.util.DisplayMetrics -import android.util.Log import android.view.View import android.widget.RelativeLayout import android.widget.Toast @@ -40,19 +39,19 @@ import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2 import org.thoughtcrime.securesms.crypto.IdentityKeyUtil import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.model.ThreadRecord +import org.thoughtcrime.securesms.groups.CreateClosedGroupActivity +import org.thoughtcrime.securesms.loki.activities.* import org.thoughtcrime.securesms.loki.api.OpenGroupManager import org.thoughtcrime.securesms.loki.dialogs.* import org.thoughtcrime.securesms.loki.protocol.MultiDeviceProtocol import org.thoughtcrime.securesms.loki.utilities.* -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.onboarding.SeedReminderViewDelegate import org.thoughtcrime.securesms.mms.GlideApp import org.thoughtcrime.securesms.mms.GlideRequests -import org.thoughtcrime.securesms.util.DateUtils +import org.thoughtcrime.securesms.onboarding.SeedActivity +import org.thoughtcrime.securesms.preferences.SettingsActivity import java.io.IOException import java.util.* -import java.util.concurrent.TimeUnit class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickListener, SeedReminderViewDelegate, NewConversationButtonSetViewDelegate { private lateinit var glide: GlideRequests diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeAdapter.kt similarity index 94% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeAdapter.kt rename to app/src/main/java/org/thoughtcrime/securesms/home/HomeAdapter.kt index 6005b53b8d..ba718d355f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeAdapter.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.home import android.content.Context import android.database.Cursor @@ -7,7 +7,6 @@ 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.views.ConversationView import org.thoughtcrime.securesms.mms.GlideRequests class HomeAdapter(context: Context, cursor: Cursor) : CursorRecyclerViewAdapter(context, cursor) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeLoader.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeLoader.kt similarity index 88% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeLoader.kt rename to app/src/main/java/org/thoughtcrime/securesms/home/HomeLoader.kt index a48da0c3ca..92e1abacb6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeLoader.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeLoader.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.home import android.content.Context import android.database.Cursor diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/NewConversationButtonSetView.kt b/app/src/main/java/org/thoughtcrime/securesms/home/NewConversationButtonSetView.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/views/NewConversationButtonSetView.kt rename to app/src/main/java/org/thoughtcrime/securesms/home/NewConversationButtonSetView.kt index a418369c90..cb99321eb5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/NewConversationButtonSetView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/NewConversationButtonSetView.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.views +package org.thoughtcrime.securesms.home import android.animation.FloatEvaluator import android.animation.PointFEvaluator @@ -17,6 +17,8 @@ import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import network.loki.messenger.R import org.thoughtcrime.securesms.loki.utilities.* +import org.thoughtcrime.securesms.util.GlowViewUtilities +import org.thoughtcrime.securesms.util.NewConversationButtonImageView class NewConversationButtonSetView : RelativeLayout { private var expandedButton: Button? = null diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PathActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/PathActivity.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/PathActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/home/PathActivity.kt index 2a06562bdf..10ddb11034 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PathActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/PathActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.home import android.content.BroadcastReceiver import android.content.Context @@ -23,8 +23,8 @@ import org.session.libsession.snode.OnionRequestAPI import org.session.libsignal.utilities.Snode import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.loki.utilities.* -import org.thoughtcrime.securesms.loki.views.GlowViewUtilities -import org.thoughtcrime.securesms.loki.views.PathDotView +import org.thoughtcrime.securesms.util.GlowViewUtilities +import org.thoughtcrime.securesms.util.PathDotView class PathActivity : PassphraseRequiredActionBarActivity() { private val broadcastReceivers = mutableListOf() diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/PathStatusView.kt b/app/src/main/java/org/thoughtcrime/securesms/home/PathStatusView.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/views/PathStatusView.kt rename to app/src/main/java/org/thoughtcrime/securesms/home/PathStatusView.kt index 6990849306..5d571f1a9b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/PathStatusView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/PathStatusView.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.views +package org.thoughtcrime.securesms.home import android.content.BroadcastReceiver import android.content.Context diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/fragments/ContactSelectionListAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/fragments/ContactSelectionListAdapter.kt index ba039009bc..043ba1207f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/fragments/ContactSelectionListAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/fragments/ContactSelectionListAdapter.kt @@ -7,7 +7,7 @@ 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.contacts.UserView import org.thoughtcrime.securesms.mms.GlideRequests import org.session.libsession.utilities.recipients.Recipient diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt deleted file mode 100644 index 76f5dee9c4..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt +++ /dev/null @@ -1,335 +0,0 @@ -package org.thoughtcrime.securesms.loki.views - -import android.content.Context -import android.content.res.ColorStateList -import android.graphics.Color -import android.graphics.PorterDuff -import android.graphics.drawable.AnimatedVectorDrawable -import android.util.AttributeSet -import android.view.View -import android.view.View.OnTouchListener -import android.view.ViewGroup -import android.widget.FrameLayout -import android.widget.ImageView -import android.widget.ProgressBar -import android.widget.TextView -import androidx.annotation.ColorInt -import androidx.core.content.ContextCompat -import kotlinx.coroutines.* -import network.loki.messenger.R -import org.greenrobot.eventbus.EventBus -import org.greenrobot.eventbus.Subscribe -import org.greenrobot.eventbus.ThreadMode -import org.session.libsession.messaging.sending_receiving.attachments.AttachmentTransferProgress -import org.thoughtcrime.securesms.ApplicationContext -import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment -import org.thoughtcrime.securesms.audio.AudioSlidePlayer -import org.thoughtcrime.securesms.components.AnimatingToggle -import org.thoughtcrime.securesms.database.DatabaseFactory -import org.thoughtcrime.securesms.events.PartProgressEvent -import org.session.libsignal.utilities.Log -import org.thoughtcrime.securesms.loki.api.PrepareAttachmentAudioExtrasJob -import org.thoughtcrime.securesms.loki.utilities.getColorWithID -import org.thoughtcrime.securesms.mms.AudioSlide -import org.thoughtcrime.securesms.mms.SlideClickListener -import java.io.IOException -import java.util.* -import java.util.concurrent.TimeUnit - -class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener { - - companion object { - private const val TAG = "AudioViewKt" - } - - private val controlToggle: AnimatingToggle - private val container: ViewGroup - private val playButton: ImageView - private val pauseButton: ImageView - private val downloadButton: ImageView - private val downloadProgress: ProgressBar - private val seekBar: WaveformSeekBar - private val totalDuration: TextView - - private var downloadListener: SlideClickListener? = null - private var audioSlidePlayer: AudioSlidePlayer? = null - - /** Background coroutine scope that is available when the view is attached to a window. */ - private var asyncCoroutineScope: CoroutineScope? = null - - private val loadingAnimation: SeekBarLoadingAnimation - - constructor(context: Context): this(context, null) - - constructor(context: Context, attrs: AttributeSet?): this(context, attrs, 0) - - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int): super(context, attrs, defStyleAttr) { - View.inflate(context, R.layout.message_audio_view, this) - container = findViewById(R.id.audio_widget_container) - controlToggle = findViewById(R.id.control_toggle) - playButton = findViewById(R.id.play) - pauseButton = findViewById(R.id.pause) - downloadButton = findViewById(R.id.download) - downloadProgress = findViewById(R.id.download_progress) - seekBar = findViewById(R.id.seek) - totalDuration = findViewById(R.id.total_duration) - - playButton.setOnClickListener { - try { - Log.d(TAG, "playbutton onClick") - if (audioSlidePlayer != null) { - togglePlayToPause() - - // Restart the playback if progress bar is nearly at the end. - val progress = if (seekBar.progress < 0.99f) seekBar.progress.toDouble() else 0.0 - - audioSlidePlayer!!.play(progress) - } - } catch (e: IOException) { - Log.w(TAG, e) - } - } - pauseButton.setOnClickListener { - Log.d(TAG, "pausebutton onClick") - if (audioSlidePlayer != null) { - togglePauseToPlay() - audioSlidePlayer!!.stop() - } - } - seekBar.isEnabled = false - seekBar.progressChangeListener = object : WaveformSeekBar.ProgressChangeListener { - override fun onProgressChanged(waveformSeekBar: WaveformSeekBar, progress: Float, fromUser: Boolean) { - if (fromUser && audioSlidePlayer != null) { - synchronized(audioSlidePlayer!!) { - audioSlidePlayer!!.seekTo(progress.toDouble()) - } - } - } - } - - playButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.play_icon)) - pauseButton.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.pause_icon)) - playButton.background = ContextCompat.getDrawable(context, R.drawable.ic_circle_fill_white_48dp) - pauseButton.background = ContextCompat.getDrawable(context, R.drawable.ic_circle_fill_white_48dp) - - if (attrs != null) { - val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.MessageAudioView, 0, 0) - setTint(typedArray.getColor(R.styleable.MessageAudioView_foregroundTintColor, Color.WHITE), - typedArray.getColor(R.styleable.MessageAudioView_waveformFillColor, Color.WHITE), - typedArray.getColor(R.styleable.MessageAudioView_waveformBackgroundColor, Color.WHITE)) - container.setBackgroundColor(typedArray.getColor(R.styleable.MessageAudioView_widgetBackground, Color.TRANSPARENT)) - typedArray.recycle() - } - - loadingAnimation = SeekBarLoadingAnimation(this, seekBar) - loadingAnimation.start() - } - - override fun onAttachedToWindow() { - super.onAttachedToWindow() - if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this) - - asyncCoroutineScope = CoroutineScope(Job() + Dispatchers.IO) - } - - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - EventBus.getDefault().unregister(this) - - // Cancel all the background operations. - asyncCoroutineScope!!.cancel() - asyncCoroutineScope = null - } - - fun setAudio(audio: AudioSlide, showControls: Boolean) { - when { - showControls && audio.isPendingDownload -> { - controlToggle.displayQuick(downloadButton) - seekBar.isEnabled = false - downloadButton.setOnClickListener { v -> downloadListener?.onClick(v, audio) } - if (downloadProgress.isIndeterminate) { - downloadProgress.isIndeterminate = false - downloadProgress.progress = 0 - } - } - (showControls && audio.transferState == AttachmentTransferProgress.TRANSFER_PROGRESS_STARTED) -> { - controlToggle.displayQuick(downloadProgress) - seekBar.isEnabled = false - downloadProgress.isIndeterminate = true - } - else -> { - controlToggle.displayQuick(playButton) - seekBar.isEnabled = true - if (downloadProgress.isIndeterminate) { - downloadProgress.isIndeterminate = false - downloadProgress.progress = 100 - } - - // Post to make sure it executes only when the view is attached to a window. - post(::updateFromAttachmentAudioExtras) - } - } - audioSlidePlayer = AudioSlidePlayer.createFor(context, audio, this) - } - - fun cleanup() { - if (audioSlidePlayer != null && pauseButton.visibility == View.VISIBLE) { - audioSlidePlayer!!.stop() - } - } - - fun setDownloadClickListener(listener: SlideClickListener?) { - downloadListener = listener - } - - fun setTint(@ColorInt foregroundTint: Int, @ColorInt waveformFill: Int, @ColorInt waveformBackground: Int) { - playButton.backgroundTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.white, context.theme)) - playButton.imageTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme)) - pauseButton.backgroundTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.white, context.theme)) - pauseButton.imageTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme)) - - downloadButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN) - - downloadProgress.backgroundTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.white, context.theme)) - downloadProgress.progressTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme)) - downloadProgress.indeterminateTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme)) - - totalDuration.setTextColor(foregroundTint) - - seekBar.barProgressColor = waveformFill - seekBar.barBackgroundColor = waveformBackground - } - - override fun onPlayerStart(player: AudioSlidePlayer) { - if (pauseButton.visibility != View.VISIBLE) { - togglePlayToPause() - } - } - - override fun onPlayerStop(player: AudioSlidePlayer) { - if (playButton.visibility != View.VISIBLE) { - togglePauseToPlay() - } - } - - override fun onPlayerProgress(player: AudioSlidePlayer, progress: Double, millis: Long) { - seekBar.progress = progress.toFloat() - } - - override fun setFocusable(focusable: Boolean) { - super.setFocusable(focusable) - playButton.isFocusable = focusable - pauseButton.isFocusable = focusable - seekBar.isFocusable = focusable - seekBar.isFocusableInTouchMode = focusable - downloadButton.isFocusable = focusable - } - - override fun setClickable(clickable: Boolean) { - super.setClickable(clickable) - playButton.isClickable = clickable - pauseButton.isClickable = clickable - seekBar.isClickable = clickable - seekBar.setOnTouchListener(if (clickable) null else - OnTouchListener { _, _ -> return@OnTouchListener true }) // Suppress touch events. - downloadButton.isClickable = clickable - } - - override fun setEnabled(enabled: Boolean) { - super.setEnabled(enabled) - playButton.isEnabled = enabled - pauseButton.isEnabled = enabled - downloadButton.isEnabled = enabled - } - - private fun togglePlayToPause() { - controlToggle.displayQuick(pauseButton) - val playToPauseDrawable = ContextCompat.getDrawable(context, R.drawable.play_to_pause_animation) as AnimatedVectorDrawable - pauseButton.setImageDrawable(playToPauseDrawable) - playToPauseDrawable.start() - } - - private fun togglePauseToPlay() { - controlToggle.displayQuick(playButton) - val pauseToPlayDrawable = ContextCompat.getDrawable(context, R.drawable.pause_to_play_animation) as AnimatedVectorDrawable - playButton.setImageDrawable(pauseToPlayDrawable) - pauseToPlayDrawable.start() - } - - private fun obtainDatabaseAttachment(): DatabaseAttachment? { - audioSlidePlayer ?: return null - val attachment = audioSlidePlayer!!.audioSlide.asAttachment() - return if (attachment is DatabaseAttachment) attachment else null - } - - private fun updateFromAttachmentAudioExtras() { - val attachment = obtainDatabaseAttachment() ?: return - - val audioExtras = DatabaseFactory.getAttachmentDatabase(context) - .getAttachmentAudioExtras(attachment.attachmentId) - - // Schedule a job request if no audio extras were generated yet. - if (audioExtras == null) { - ApplicationContext.getInstance(context).jobManager - .add(PrepareAttachmentAudioExtrasJob(attachment.attachmentId)) - return - } - - loadingAnimation.stop() - seekBar.sampleData = audioExtras.visualSamples - - if (audioExtras.durationMs > 0) { - totalDuration.visibility = View.VISIBLE - totalDuration.text = String.format("%02d:%02d", - TimeUnit.MILLISECONDS.toMinutes(audioExtras.durationMs), - TimeUnit.MILLISECONDS.toSeconds(audioExtras.durationMs)) - } - } - - @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) - fun onEvent(event: PartProgressEvent) { - if (audioSlidePlayer != null && event.attachment == audioSlidePlayer!!.audioSlide.asAttachment()) { - val progress = ((event.progress.toFloat() / event.total) * 100f).toInt() - downloadProgress.progress = progress - } - } - - @Subscribe(threadMode = ThreadMode.MAIN) - fun onEvent(event: PrepareAttachmentAudioExtrasJob.AudioExtrasUpdatedEvent) { - if (event.attachmentId == obtainDatabaseAttachment()?.attachmentId) { - updateFromAttachmentAudioExtras() - } - } - - private class SeekBarLoadingAnimation( - private val hostView: View, - private val seekBar: WaveformSeekBar): Runnable { - - private var active = false - - companion object { - private const val UPDATE_PERIOD = 250L // In milliseconds. - private val random = Random() - } - - fun start() { - stop() - active = true - hostView.postDelayed(this, UPDATE_PERIOD) - } - - fun stop() { - active = false - hostView.removeCallbacks(this) - } - - override fun run() { - if (!active) return - - // Generate a random samples with values up to the 50% of the maximum value. - seekBar.sampleData = ByteArray(PrepareAttachmentAudioExtrasJob.VISUAL_RMS_FRAMES) - { (random.nextInt(127) - 64).toByte() } - hostView.postDelayed(this, UPDATE_PERIOD) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/OpenGroupInvitationView.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/OpenGroupInvitationView.kt deleted file mode 100644 index edfc81cf79..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/OpenGroupInvitationView.kt +++ /dev/null @@ -1,71 +0,0 @@ -package org.thoughtcrime.securesms.loki.views - -import android.content.Context -import android.util.AttributeSet -import android.view.View -import android.widget.* -import androidx.appcompat.app.AlertDialog -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import network.loki.messenger.R -import org.session.libsession.utilities.OpenGroupUrlParser -import org.session.libsignal.utilities.Log -import org.thoughtcrime.securesms.loki.api.OpenGroupManager -import org.thoughtcrime.securesms.loki.protocol.MultiDeviceProtocol -import org.thoughtcrime.securesms.loki.utilities.OpenGroupUtilities - -class OpenGroupInvitationView : FrameLayout { - private val joinButton: ImageView - private val openGroupIconContainer: RelativeLayout - private val openGroupIconImageView: ImageView - private val nameTextView: TextView - private val urlTextView: TextView - private var url: String = "" - - constructor(context: Context): this(context, null) - - constructor(context: Context, attrs: AttributeSet?): this(context, attrs, 0) - - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int): super(context, attrs, defStyleAttr) { - View.inflate(context, R.layout.open_group_invitation_view, this) - joinButton = findViewById(R.id.join_open_group_button) - openGroupIconContainer = findViewById(R.id.open_group_icon_image_view_container) - openGroupIconImageView = findViewById(R.id.open_group_icon_image_view) - nameTextView = findViewById(R.id.name_text_view) - urlTextView = findViewById(R.id.url_text_view) - joinButton.setOnClickListener { joinOpenGroup(url) } - } - - fun setOpenGroup(name: String, url: String, isOutgoing: Boolean = false) { - nameTextView.text = name - urlTextView.text = OpenGroupUrlParser.trimQueryParameter(url) - this.url = url - joinButton.visibility = if (isOutgoing) View.GONE else View.VISIBLE - openGroupIconContainer.visibility = if (isOutgoing) View.VISIBLE else View.GONE - } - - private fun joinOpenGroup(url: String) { - val openGroup = OpenGroupUrlParser.parseUrl(url) - val builder = AlertDialog.Builder(context) - builder.setTitle(context.getString(R.string.ConversationActivity_join_open_group, nameTextView.text.toString())) - builder.setCancelable(true) - val message: String = - context.getString(R.string.ConversationActivity_join_open_group_confirmation_message, nameTextView.text.toString()) - builder.setMessage(message) - builder.setPositiveButton(R.string.yes) { dialog, _ -> - GlobalScope.launch(Dispatchers.IO) { - try { - dialog.dismiss() - OpenGroupManager.add(openGroup.server, openGroup.room, openGroup.serverPublicKey, context) - MultiDeviceProtocol.forceSyncConfigurationNowIfNeeded(context) - } catch (e: Exception) { - Log.e("Loki", "Failed to join open group.", e) - Toast.makeText(context, R.string.activity_join_public_chat_error, Toast.LENGTH_SHORT).show() - } - } - } - builder.setNegativeButton(R.string.no, null) - builder.show() - } -} \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt deleted file mode 100644 index df74bd9ca0..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt +++ /dev/null @@ -1,315 +0,0 @@ -package org.thoughtcrime.securesms.loki.views - -import android.animation.ValueAnimator -import android.content.Context -import android.graphics.Canvas -import android.graphics.Color -import android.graphics.Paint -import android.graphics.RectF -import android.util.AttributeSet -import android.util.TypedValue -import android.view.MotionEvent -import android.view.View -import android.view.ViewConfiguration -import android.view.animation.DecelerateInterpolator -import androidx.core.math.MathUtils -import network.loki.messenger.R -import org.session.libsession.utilities.byteToNormalizedFloat -import kotlin.math.abs -import kotlin.math.max -import kotlin.math.min -import kotlin.math.roundToInt - -class WaveformSeekBar : View { - - companion object { - @JvmStatic - fun dp(context: Context, dp: Float): Float { - return TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, - dp, - context.resources.displayMetrics - ) - } - } - - private val sampleDataHolder = SampleDataHolder(::invalidate) - /** An array of signed byte values representing the audio signal. */ - var sampleData: ByteArray? - get() { - return sampleDataHolder.getSamples() - } - set(value) { - sampleDataHolder.setSamples(value) - invalidate() - } - - /** Indicates whether the user is currently interacting with the view and performing a seeking gesture. */ - private var userSeeking = false - private var _progress: Float = 0f - /** In [0..1] range. */ - var progress: Float - set(value) { - // Do not let to modify the progress value from the outside - // when the user is currently interacting with the view. - if (userSeeking) return - - _progress = value - invalidate() - progressChangeListener?.onProgressChanged(this, _progress, false) - } - get() { - return _progress - } - - var barBackgroundColor: Int = Color.LTGRAY - set(value) { - field = value - invalidate() - } - - var barProgressColor: Int = Color.WHITE - set(value) { - field = value - invalidate() - } - - var barGap: Float = dp(context, 2f) - set(value) { - field = value - invalidate() - } - - var barWidth: Float = dp(context, 5f) - set(value) { - field = value - invalidate() - } - - var barMinHeight: Float = barWidth - set(value) { - field = value - invalidate() - } - - var barCornerRadius: Float = dp(context, 2.5f) - set(value) { - field = value - invalidate() - } - - var barGravity: WaveGravity = WaveGravity.CENTER - set(value) { - field = value - invalidate() - } - - var progressChangeListener: ProgressChangeListener? = null - - private val barPaint = Paint(Paint.ANTI_ALIAS_FLAG) - private val barRect = RectF() - - private var canvasWidth = 0 - private var canvasHeight = 0 - - private var touchDownX = 0f - private var touchDownProgress: Float = 0f - private var scaledTouchSlop = ViewConfiguration.get(context).scaledTouchSlop - - constructor(context: Context) : this(context, null) - - constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) - - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) - : super(context, attrs, defStyleAttr) { - - val typedAttrs = context.obtainStyledAttributes(attrs, R.styleable.WaveformSeekBar) - barWidth = typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_width, barWidth) - barGap = typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_gap, barGap) - barCornerRadius = typedAttrs.getDimension( - R.styleable.WaveformSeekBar_bar_corner_radius, - barCornerRadius) - barMinHeight = - typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_min_height, barMinHeight) - barBackgroundColor = typedAttrs.getColor( - R.styleable.WaveformSeekBar_bar_background_color, - barBackgroundColor) - barProgressColor = - typedAttrs.getColor(R.styleable.WaveformSeekBar_bar_progress_color, barProgressColor) - progress = typedAttrs.getFloat(R.styleable.WaveformSeekBar_progress, progress) - barGravity = WaveGravity.fromString( - typedAttrs.getString(R.styleable.WaveformSeekBar_bar_gravity)) - - typedAttrs.recycle() - } - - override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { - super.onSizeChanged(w, h, oldw, oldh) - canvasWidth = w - canvasHeight = h - invalidate() - } - - override fun onDraw(canvas: Canvas) { - super.onDraw(canvas) - - val totalWidth = getAvailableWidth() - val barAmount = (totalWidth / (barWidth + barGap)).toInt() - - var lastBarRight = paddingLeft.toFloat() - - (0 until barAmount).forEach { barIdx -> - // Convert a signed byte to a [0..1] float. - val barValue = byteToNormalizedFloat(sampleDataHolder.computeBarValue(barIdx, barAmount)) - - val barHeight = max(barMinHeight, getAvailableHeight() * barValue) - - val top: Float = when (barGravity) { - WaveGravity.TOP -> paddingTop.toFloat() - WaveGravity.CENTER -> paddingTop + getAvailableHeight() * 0.5f - barHeight * 0.5f - WaveGravity.BOTTOM -> canvasHeight - paddingBottom - barHeight - } - - barRect.set(lastBarRight, top, lastBarRight + barWidth, top + barHeight) - - barPaint.color = if (barRect.right <= totalWidth * progress) - barProgressColor else barBackgroundColor - - canvas.drawRoundRect(barRect, barCornerRadius, barCornerRadius, barPaint) - - lastBarRight = barRect.right + barGap - } - } - - override fun onTouchEvent(event: MotionEvent): Boolean { - if (!isEnabled) return false - - when (event.action) { - MotionEvent.ACTION_DOWN -> { - userSeeking = true - touchDownX = event.x - touchDownProgress = progress - updateProgress(event, false) - } - MotionEvent.ACTION_MOVE -> { - // Prevent any parent scrolling if the user scrolled more - // than scaledTouchSlop on horizontal axis. - if (abs(event.x - touchDownX) > scaledTouchSlop) { - parent.requestDisallowInterceptTouchEvent(true) - } - updateProgress(event, false) - } - MotionEvent.ACTION_UP -> { - userSeeking = false - updateProgress(event, true) - performClick() - } - MotionEvent.ACTION_CANCEL -> { - updateProgress(touchDownProgress, false) - userSeeking = false - } - } - return true - } - - private fun updateProgress(event: MotionEvent, notify: Boolean) { - updateProgress(event.x / getAvailableWidth(), notify) - } - - private fun updateProgress(progress: Float, notify: Boolean) { - _progress = MathUtils.clamp(progress, 0f, 1f) - invalidate() - - if (notify) { - progressChangeListener?.onProgressChanged(this, _progress, true) - } - } - - override fun performClick(): Boolean { - super.performClick() - return true - } - - private fun getAvailableWidth() = canvasWidth - paddingLeft - paddingRight - private fun getAvailableHeight() = canvasHeight - paddingTop - paddingBottom - - private class SampleDataHolder(private val invalidateDelegate: () -> Any) { - - private var sampleDataFrom: ByteArray? = null - private var sampleDataTo: ByteArray? = null - private var progress = 1f // Mix between from and to values. - - private var animation: ValueAnimator? = null - - fun computeBarValue(barIdx: Int, barAmount: Int): Byte { - /** @return The array's value at the interpolated index. */ - fun getSampleValue(sampleData: ByteArray?): Byte { - if (sampleData == null || sampleData.isEmpty()) - return Byte.MIN_VALUE - else { - val sampleIdx = (barIdx * (sampleData.size / barAmount.toFloat())).toInt() - return sampleData[sampleIdx] - } - } - - if (progress == 1f) { - return getSampleValue(sampleDataTo) - } - - val fromValue = getSampleValue(sampleDataFrom) - val toValue = getSampleValue(sampleDataTo) - val rawResultValue = fromValue * (1f - progress) + toValue * progress - return rawResultValue.roundToInt().toByte() - } - - fun setSamples(sampleData: ByteArray?) { - /** @return a mix between [sampleDataFrom] and [sampleDataTo] arrays according to the current [progress] value. */ - fun computeNewDataFromArray(): ByteArray? { - if (sampleDataTo == null) return null - if (sampleDataFrom == null) return sampleDataTo - - val sampleSize = min(sampleDataFrom!!.size, sampleDataTo!!.size) - return ByteArray(sampleSize) { i -> computeBarValue(i, sampleSize) } - } - - sampleDataFrom = computeNewDataFromArray() - sampleDataTo = sampleData - progress = 0f - - animation?.cancel() - animation = ValueAnimator.ofFloat(0f, 1f).apply { - addUpdateListener { animation -> - progress = animation.animatedValue as Float - invalidateDelegate() - } - interpolator = DecelerateInterpolator(3f) - duration = 500 - start() - } - } - - fun getSamples(): ByteArray? { - return sampleDataTo - } - } - - enum class WaveGravity { - TOP, - CENTER, - BOTTOM, - ; - - companion object { - @JvmStatic - fun fromString(gravity: String?): WaveGravity = when (gravity) { - "1" -> TOP - "2" -> CENTER - else -> BOTTOM - } - } - } - - interface ProgressChangeListener { - fun onProgressChanged(waveformSeekBar: WaveformSeekBar, progress: Float, fromUser: Boolean) - } -} \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java index 5165e87ff9..4c4f96b25e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/MultipleRecipientNotificationBuilder.java @@ -16,7 +16,7 @@ import org.session.libsession.utilities.TextSecurePreferences; import org.session.libsession.utilities.Util; import org.session.libsession.utilities.recipients.Recipient; import org.thoughtcrime.securesms.database.DatabaseFactory; -import org.thoughtcrime.securesms.loki.activities.HomeActivity; +import org.thoughtcrime.securesms.home.HomeActivity; import org.thoughtcrime.securesms.loki.database.SessionContactDatabase; import java.util.LinkedList; diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java index efd040a26d..1d19c2c8e3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java @@ -7,7 +7,7 @@ import android.content.Intent; import androidx.core.app.NotificationCompat; import org.session.libsession.utilities.recipients.Recipient; -import org.thoughtcrime.securesms.loki.activities.HomeActivity; +import org.thoughtcrime.securesms.home.HomeActivity; import org.session.libsession.utilities.NotificationPrivacyPreference; import org.session.libsession.utilities.TextSecurePreferences; diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/DisplayNameActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/DisplayNameActivity.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/DisplayNameActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/DisplayNameActivity.kt index 50403dca9c..bf4fb25cc8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/DisplayNameActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/DisplayNameActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.onboarding import android.content.Intent import android.os.Bundle diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/FakeChatView.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/FakeChatView.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/views/FakeChatView.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/FakeChatView.kt index 5f84df4913..835ae4cc70 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/FakeChatView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/FakeChatView.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.views +package org.thoughtcrime.securesms.onboarding import android.animation.FloatEvaluator import android.animation.ValueAnimator diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/LandingActivity.kt similarity index 92% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/LandingActivity.kt index bd7cfc381a..85bb05c464 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/LandingActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.onboarding import android.content.Intent import android.os.Bundle @@ -9,9 +9,7 @@ import org.thoughtcrime.securesms.BaseActionBarActivity import org.thoughtcrime.securesms.crypto.IdentityKeyUtil import org.thoughtcrime.securesms.loki.utilities.push import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo -import org.thoughtcrime.securesms.loki.views.FakeChatView import org.thoughtcrime.securesms.service.KeyCachingService -import org.thoughtcrime.securesms.util.Util class LandingActivity : BaseActionBarActivity() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/LinkDeviceActivity.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/LinkDeviceActivity.kt index f9e1b07b33..c98463f14a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/LinkDeviceActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.onboarding import android.content.Context import android.content.Intent @@ -35,6 +35,7 @@ import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelega import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities import org.thoughtcrime.securesms.loki.utilities.push import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo +import org.thoughtcrime.securesms.onboarding.PNModeActivity class LinkDeviceActivity : BaseActionBarActivity(), ScanQRCodeWrapperFragmentDelegate { private val adapter = LinkDeviceActivityAdapter(this) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/PNModeActivity.kt similarity index 97% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/PNModeActivity.kt index 5ddc8b9682..d83a14819c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/PNModeActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.onboarding import android.animation.ArgbEvaluator import android.animation.ValueAnimator @@ -19,12 +19,13 @@ import network.loki.messenger.R import org.session.libsession.utilities.TextSecurePreferences import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.BaseActionBarActivity +import org.thoughtcrime.securesms.home.HomeActivity import org.thoughtcrime.securesms.loki.utilities.disableClipping import org.thoughtcrime.securesms.loki.utilities.getColorWithID import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo import org.thoughtcrime.securesms.loki.utilities.show -import org.thoughtcrime.securesms.loki.views.GlowViewUtilities -import org.thoughtcrime.securesms.loki.views.PNModeView +import org.thoughtcrime.securesms.util.GlowViewUtilities +import org.thoughtcrime.securesms.util.PNModeView class PNModeActivity : BaseActionBarActivity() { private var selectedOptionView: PNModeView? = null diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/RecoveryPhraseRestoreActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/RecoveryPhraseRestoreActivity.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/RecoveryPhraseRestoreActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/RecoveryPhraseRestoreActivity.kt index f4dc7b323c..649490bfc5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/RecoveryPhraseRestoreActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/RecoveryPhraseRestoreActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.onboarding import android.content.Intent import android.graphics.Typeface diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/RegisterActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/RegisterActivity.kt similarity index 99% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/RegisterActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/RegisterActivity.kt index 27ab501a68..636f0be4c4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/RegisterActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/RegisterActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.onboarding import android.content.ClipData import android.content.ClipboardManager diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SeedActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/SeedActivity.kt similarity index 98% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/SeedActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/SeedActivity.kt index aed826e086..0b281fb6b0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SeedActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/SeedActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.onboarding import android.content.ClipData import android.content.ClipboardManager diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/SeedReminderView.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/SeedReminderView.kt similarity index 97% rename from app/src/main/java/org/thoughtcrime/securesms/loki/views/SeedReminderView.kt rename to app/src/main/java/org/thoughtcrime/securesms/onboarding/SeedReminderView.kt index 591a458227..199ed7a5a1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/SeedReminderView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/SeedReminderView.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.views +package org.thoughtcrime.securesms.onboarding import android.content.Context import android.os.Build diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/ChatSettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/ChatSettingsActivity.kt similarity index 93% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/ChatSettingsActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/preferences/ChatSettingsActivity.kt index 67a2c4f2d5..67faa9da46 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/ChatSettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/ChatSettingsActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.preferences import android.os.Bundle import network.loki.messenger.R diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/NotificationSettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationSettingsActivity.kt similarity index 93% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/NotificationSettingsActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationSettingsActivity.kt index 1468539a72..af039a4fdb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/NotificationSettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationSettingsActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.preferences import android.os.Bundle import network.loki.messenger.R diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PrivacySettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/PrivacySettingsActivity.kt similarity index 93% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/PrivacySettingsActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/preferences/PrivacySettingsActivity.kt index 966dd9b437..bf277dc17f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PrivacySettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/PrivacySettingsActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.preferences import android.os.Bundle import network.loki.messenger.R diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/QRCodeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/QRCodeActivity.kt similarity index 99% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/QRCodeActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/preferences/QRCodeActivity.kt index 2f5638d952..9c48552e55 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/QRCodeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/QRCodeActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.preferences import android.content.Intent import android.graphics.Bitmap diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt similarity index 99% rename from app/src/main/java/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt rename to app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt index c5176d2222..5fbc23848a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.activities +package org.thoughtcrime.securesms.preferences import android.Manifest import android.app.Activity diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java b/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java index 58ed5d7d75..0581883c5e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/GenericForegroundService.java @@ -13,7 +13,7 @@ import androidx.core.app.NotificationCompat; import androidx.core.content.ContextCompat; import org.session.libsignal.utilities.Log; -import org.thoughtcrime.securesms.loki.activities.HomeActivity; +import org.thoughtcrime.securesms.home.HomeActivity; import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.session.libsignal.utilities.guava.Preconditions; diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java index c4507cd766..9e79b93d60 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java @@ -37,7 +37,7 @@ import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.DatabaseUpgradeActivity; import org.thoughtcrime.securesms.DummyActivity; import org.session.libsignal.utilities.Log; -import org.thoughtcrime.securesms.loki.activities.HomeActivity; +import org.thoughtcrime.securesms.home.HomeActivity; import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.session.libsession.utilities.ServiceUtil; import org.session.libsession.utilities.TextSecurePreferences; diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/views/GlowView.kt b/app/src/main/java/org/thoughtcrime/securesms/util/GlowView.kt similarity index 99% rename from app/src/main/java/org/thoughtcrime/securesms/loki/views/GlowView.kt rename to app/src/main/java/org/thoughtcrime/securesms/util/GlowView.kt index c2619a6044..821800a3ef 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/views/GlowView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/GlowView.kt @@ -1,4 +1,4 @@ -package org.thoughtcrime.securesms.loki.views +package org.thoughtcrime.securesms.util import android.animation.ArgbEvaluator import android.animation.ValueAnimator diff --git a/app/src/main/res/layout-sw400dp/activity_landing.xml b/app/src/main/res/layout-sw400dp/activity_landing.xml index dc36e5fa57..d1cbc8f2f3 100644 --- a/app/src/main/res/layout-sw400dp/activity_landing.xml +++ b/app/src/main/res/layout-sw400dp/activity_landing.xml @@ -19,7 +19,7 @@ android:textStyle="bold" android:text="@string/activity_landing_title_2" /> - - - + - - +