From eafa7c7a77e0ebf7815028ed72789f874671b2f7 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Fri, 4 Dec 2020 16:00:52 +1100 Subject: [PATCH] Device link related views removed. General unused code cleanup. --- app/src/main/AndroidManifest.xml | 2 +- .../securesms/DeviceLinkFragment.java | 60 ----- .../securesms/DeviceListFragment.java | 249 ------------------ .../securesms/DeviceListItem.java | 57 ---- .../database/loaders/DeviceListLoader.java | 56 ---- .../SignalCommunicationModule.java | 2 - .../securesms/devicelist/Device.java | 20 -- .../activities/CreateClosedGroupActivity.kt | 6 +- .../activities/EditClosedGroupActivity.kt | 53 ++-- .../loki/activities/LandingActivity.kt | 123 +-------- .../loki/activities/LinkDeviceActivity.kt | 104 -------- .../loki/activities/LinkedDevicesActivity.kt | 178 ------------- .../loki/activities/LinkedDevicesAdapter.kt | 35 --- .../loki/activities/LinkedDevicesLoader.kt | 35 --- ...ty.kt => RecoveryPhraseRestoreActivity.kt} | 6 +- .../loki/activities/SelectContactsActivity.kt | 4 +- .../loki/activities/SettingsActivity.kt | 5 - .../loki/dialogs/EditDeviceNameDialog.kt | 42 --- .../dialogs/LinkDeviceMasterModeDialog.kt | 121 --------- .../loki/dialogs/LinkDeviceSlaveModeDialog.kt | 78 ------ .../securesms/loki/views/DeviceView.kt | 49 ---- ...l => activity_recovery_phrase_restore.xml} | 0 .../layout/activity_create_closed_group.xml | 2 +- .../res/layout/activity_edit_closed_group.xml | 4 +- .../main/res/layout/activity_link_device.xml | 14 - .../res/layout/activity_linked_devices.xml | 37 --- ...l => activity_recovery_phrase_restore.xml} | 0 .../main/res/layout/device_add_fragment.xml | 53 ---- .../main/res/layout/device_link_fragment.xml | 88 ------- .../main/res/layout/device_list_fragment.xml | 49 ---- .../main/res/layout/device_list_item_view.xml | 34 --- .../res/layout/dialog_edit_device_name.xml | 59 ----- .../layout/dialog_link_device_master_mode.xml | 96 ------- .../layout/dialog_link_device_slave_mode.xml | 61 ----- 34 files changed, 53 insertions(+), 1729 deletions(-) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/DeviceLinkFragment.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/DeviceListFragment.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/DeviceListItem.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/devicelist/Device.java delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkedDevicesActivity.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkedDevicesAdapter.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkedDevicesLoader.kt rename app/src/main/java/org/thoughtcrime/securesms/loki/activities/{RestoreActivity.kt => RecoveryPhraseRestoreActivity.kt} (95%) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/dialogs/EditDeviceNameDialog.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceMasterModeDialog.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceSlaveModeDialog.kt delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/loki/views/DeviceView.kt rename app/src/main/res/layout-sw400dp/{activity_restore.xml => activity_recovery_phrase_restore.xml} (100%) delete mode 100644 app/src/main/res/layout/activity_link_device.xml delete mode 100644 app/src/main/res/layout/activity_linked_devices.xml rename app/src/main/res/layout/{activity_restore.xml => activity_recovery_phrase_restore.xml} (100%) delete mode 100644 app/src/main/res/layout/device_add_fragment.xml delete mode 100644 app/src/main/res/layout/device_link_fragment.xml delete mode 100644 app/src/main/res/layout/device_list_fragment.xml delete mode 100644 app/src/main/res/layout/device_list_item_view.xml delete mode 100644 app/src/main/res/layout/dialog_edit_device_name.xml delete mode 100644 app/src/main/res/layout/dialog_link_device_master_mode.xml delete mode 100644 app/src/main/res/layout/dialog_link_device_slave_mode.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 72d3509fa7..ab08ce3459 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -101,7 +101,7 @@ android:screenOrientation="portrait" android:theme="@style/Theme.Session.DayNight.FlatActionBar"/> diff --git a/app/src/main/java/org/thoughtcrime/securesms/DeviceLinkFragment.java b/app/src/main/java/org/thoughtcrime/securesms/DeviceLinkFragment.java deleted file mode 100644 index 4c7e3eb4fc..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/DeviceLinkFragment.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.thoughtcrime.securesms; - -import android.content.res.Configuration; -import android.net.Uri; -import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; - -import network.loki.messenger.R; - -public class DeviceLinkFragment extends Fragment implements View.OnClickListener { - - private LinearLayout container; - private LinkClickedListener linkClickedListener; - private Uri uri; - - @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { - this.container = (LinearLayout) inflater.inflate(R.layout.device_link_fragment, container, false); - this.container.findViewById(R.id.link_device).setOnClickListener(this); - - if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - container.setOrientation(LinearLayout.HORIZONTAL); - } else { - container.setOrientation(LinearLayout.VERTICAL); - } - - return this.container; - } - - @Override - public void onConfigurationChanged(Configuration newConfiguration) { - super.onConfigurationChanged(newConfiguration); - if (newConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE) { - container.setOrientation(LinearLayout.HORIZONTAL); - } else { - container.setOrientation(LinearLayout.VERTICAL); - } - } - - public void setLinkClickedListener(Uri uri, LinkClickedListener linkClickedListener) { - this.uri = uri; - this.linkClickedListener = linkClickedListener; - } - - @Override - public void onClick(View v) { - if (linkClickedListener != null) { - linkClickedListener.onLink(uri); - } - } - - public interface LinkClickedListener { - void onLink(Uri uri); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/DeviceListFragment.java b/app/src/main/java/org/thoughtcrime/securesms/DeviceListFragment.java deleted file mode 100644 index a4b75e4f2f..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/DeviceListFragment.java +++ /dev/null @@ -1,249 +0,0 @@ -package org.thoughtcrime.securesms; - -import android.app.Activity; -import android.content.Context; -import android.content.DialogInterface; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.ListView; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; -import androidx.fragment.app.ListFragment; -import androidx.loader.app.LoaderManager; -import androidx.loader.content.Loader; - -import com.melnykov.fab.FloatingActionButton; - -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.dialogs.DeviceEditingOptionsBottomSheet; -import org.thoughtcrime.securesms.util.TextSecurePreferences; -import org.thoughtcrime.securesms.util.ViewUtil; -import org.session.libsignal.libsignal.util.guava.Function; - -import java.util.List; -import java.util.Locale; - -import kotlin.Pair; -import kotlin.Unit; -import network.loki.messenger.R; - -import static org.thoughtcrime.securesms.loki.utilities.GeneralUtilitiesKt.toPx; - -public class DeviceListFragment extends ListFragment - implements LoaderManager.LoaderCallbacks>, - ListView.OnItemClickListener, InjectableType, Button.OnClickListener -{ - - private static final String TAG = DeviceListFragment.class.getSimpleName(); - - private Locale locale; - private View empty; - private View progressContainer; - private FloatingActionButton addDeviceButton; - private Button.OnClickListener addDeviceButtonListener; - private Function handleDisconnectDevice; - private Function, Void> handleDeviceNameChange; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.locale = (Locale) getArguments().getSerializable(PassphraseRequiredActionBarActivity.LOCALE_EXTRA); - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - ApplicationContext.getInstance(activity).injectDependencies(this); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { - View view = inflater.inflate(R.layout.device_list_fragment, container, false); - - this.empty = view.findViewById(R.id.emptyStateTextView); - this.progressContainer = view.findViewById(R.id.activityIndicator); - this.addDeviceButton = ViewUtil.findById(view, R.id.addDeviceButton); - this.addDeviceButton.setOnClickListener(this); - updateAddDeviceButtonVisibility(); - - return view; - } - - @Override - public void onActivityCreated(Bundle bundle) { - super.onActivityCreated(bundle); - getLoaderManager().initLoader(0, null, this); - getListView().setOnItemClickListener(this); - } - - public void setAddDeviceButtonListener(Button.OnClickListener listener) { - this.addDeviceButtonListener = listener; - } - - public void setHandleDisconnectDevice(Function handler) { - this.handleDisconnectDevice = handler; - } - - public void setHandleDeviceNameChange(Function, Void> handler) { - this.handleDeviceNameChange = handler; - } - - @Override - public @NonNull Loader> onCreateLoader(int id, Bundle args) { - empty.setVisibility(View.GONE); - progressContainer.setVisibility(View.VISIBLE); - - return new DeviceListLoader(getActivity()); - } - - @Override - public void onLoadFinished(@NonNull Loader> loader, List data) { - progressContainer.setVisibility(View.GONE); - - if (data == null) { - handleLoaderFailed(); - return; - } - - setListAdapter(new DeviceListAdapter(getActivity(), R.layout.device_list_item_view, data, locale)); - - if (data.isEmpty()) { - empty.setVisibility(View.VISIBLE); - TextSecurePreferences.setMultiDevice(getActivity(), false); - } else { - empty.setVisibility(View.GONE); - } - } - - @Override - public void onLoaderReset(@NonNull Loader> loader) { - setListAdapter(null); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - final boolean hasDeviceName = ((DeviceListItem)view).hasDeviceName(); // Tells us whether the name is set to shortId or the device name - final String deviceName = ((DeviceListItem)view).getDeviceName(); - final String deviceId = ((DeviceListItem)view).getDeviceId(); - - DeviceEditingOptionsBottomSheet bottomSheet = new DeviceEditingOptionsBottomSheet(); - bottomSheet.setOnEditTapped(() -> { - bottomSheet.dismiss(); - EditText deviceNameEditText = new EditText(getContext()); - LinearLayout deviceNameEditTextContainer = new LinearLayout(getContext()); - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); - layoutParams.setMarginStart(toPx(18, getResources())); - layoutParams.setMarginEnd(toPx(18, getResources())); - deviceNameEditText.setLayoutParams(layoutParams); - deviceNameEditTextContainer.addView(deviceNameEditText); - deviceNameEditText.setText(hasDeviceName ? deviceName : ""); - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setTitle(R.string.DeviceListActivity_edit_device_name); - builder.setView(deviceNameEditTextContainer); - builder.setNegativeButton(android.R.string.cancel, null); - builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - if (handleDeviceNameChange != null) { handleDeviceNameChange.apply(new Pair<>(deviceId, deviceNameEditText.getText().toString().trim())); } - } - }); - builder.show(); - return Unit.INSTANCE; - }); - bottomSheet.setOnUnlinkTapped(() -> { - bottomSheet.dismiss(); - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setTitle(getActivity().getString(R.string.DeviceListActivity_unlink_s, deviceName)); - builder.setMessage(R.string.DeviceListActivity_by_unlinking_this_device_it_will_no_longer_be_able_to_send_or_receive); - builder.setNegativeButton(android.R.string.cancel, null); - builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - if (handleDisconnectDevice != null) { handleDisconnectDevice.apply(deviceId); } - } - }); - builder.show(); - return Unit.INSTANCE; - }); - bottomSheet.show(getFragmentManager(), bottomSheet.getTag()); - } - - public void refresh() { - updateAddDeviceButtonVisibility(); - getLoaderManager().restartLoader(0, null, DeviceListFragment.this); - } - - private void updateAddDeviceButtonVisibility() { - if (addDeviceButton != null) { - String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(getContext()); - boolean isDeviceLinkingEnabled = DatabaseFactory.getLokiAPIDatabase(getContext()).getDeviceLinks(userHexEncodedPublicKey).isEmpty(); - addDeviceButton.setVisibility(isDeviceLinkingEnabled ? View.VISIBLE : View.INVISIBLE); - } - } - - private void handleLoaderFailed() { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setMessage(R.string.DeviceListActivity_network_connection_failed); - builder.setPositiveButton(R.string.DeviceListActivity_try_again, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - getLoaderManager().restartLoader(0, null, DeviceListFragment.this); - } - }); - - builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - DeviceListFragment.this.getActivity().onBackPressed(); - } - }); - builder.setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - DeviceListFragment.this.getActivity().onBackPressed(); - } - }); - - builder.show(); - } - - @Override - public void onClick(View v) { - if (addDeviceButtonListener != null) addDeviceButtonListener.onClick(v); - } - - private static class DeviceListAdapter extends ArrayAdapter { - - private final int resource; - private final Locale locale; - - public DeviceListAdapter(Context context, int resource, List objects, Locale locale) { - super(context, resource, objects); - this.resource = resource; - this.locale = locale; - } - - @Override - public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent) { - if (convertView == null) { - convertView = ((Activity)getContext()).getLayoutInflater().inflate(resource, parent, false); - } - - ((DeviceListItem)convertView).set(getItem(position), locale); - - return convertView; - } - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/DeviceListItem.java b/app/src/main/java/org/thoughtcrime/securesms/DeviceListItem.java deleted file mode 100644 index bfc96b4d7a..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/DeviceListItem.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.thoughtcrime.securesms; - -import android.content.Context; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.widget.LinearLayout; -import android.widget.TextView; - -import org.thoughtcrime.securesms.devicelist.Device; -import org.thoughtcrime.securesms.util.DateUtils; - -import java.util.Locale; - -import network.loki.messenger.R; - -public class DeviceListItem extends LinearLayout { - - private String deviceId; - private TextView name; - private TextView shortId; - - public DeviceListItem(Context context) { - super(context); - } - - public DeviceListItem(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public void onFinishInflate() { - super.onFinishInflate(); - this.name = (TextView) findViewById(R.id.name); - this.shortId = (TextView) findViewById(R.id.shortId); - } - - public void set(Device deviceInfo, Locale locale) { - this.deviceId = deviceInfo.getId(); - boolean hasName = !TextUtils.isEmpty(deviceInfo.getName()); - this.name.setText(hasName ? deviceInfo.getName() : deviceInfo.getShortId()); - this.shortId.setText(deviceInfo.getShortId()); - this.shortId.setVisibility(hasName ? VISIBLE : GONE); - } - - public String getDeviceId() { - return deviceId; - } - - public String getDeviceName() { - return name.getText().toString(); - } - - public boolean hasDeviceName() { - return shortId.getVisibility() == VISIBLE; - } - -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java b/app/src/main/java/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java deleted file mode 100644 index b74254fc49..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.thoughtcrime.securesms.database.loaders; - -import android.content.Context; - -import androidx.annotation.NonNull; - -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.util.AsyncLoader; -import org.thoughtcrime.securesms.util.TextSecurePreferences; -import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Set; - -public class DeviceListLoader extends AsyncLoader> { - - private static final String TAG = DeviceListLoader.class.getSimpleName(); - - public DeviceListLoader(Context context) { - super(context); - } - - @Override - public List loadInBackground() { - try { - String userPublicKey = TextSecurePreferences.getLocalNumber(getContext()); - Set slaveDevicePublicKeys = MultiDeviceProtocol.shared.getSlaveDevices(userPublicKey); - List devices = Stream.of(slaveDevicePublicKeys).map(this::mapToDevice).toList(); - Collections.sort(devices, new DeviceComparator()); - return devices; - } catch (Exception e) { - Log.w(TAG, e); - return null; - } - } - - private Device mapToDevice(@NonNull String hexEncodedPublicKey) { - String shortId = ""; - String name = DatabaseFactory.getLokiUserDatabase(getContext()).getDisplayName(hexEncodedPublicKey); - return new Device(hexEncodedPublicKey, shortId, name); - } - - private static class DeviceComparator implements Comparator { - - @Override - public int compare(Device lhs, Device rhs) { - return lhs.getName().compareTo(rhs.getName()); - } - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java index d8d4070662..9cd8a048b3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java +++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java @@ -12,7 +12,6 @@ import org.session.libsignal.service.api.util.UptimeSleepTimer; import org.session.libsignal.service.api.websocket.ConnectivityListener; import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.CreateProfileActivity; -import org.thoughtcrime.securesms.DeviceListFragment; import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob; @@ -79,7 +78,6 @@ import network.loki.messenger.BuildConfig; MultiDeviceGroupUpdateJob.class, MultiDeviceReadUpdateJob.class, MultiDeviceBlockedUpdateJob.class, - DeviceListFragment.class, RefreshAttributesJob.class, RequestGroupInfoJob.class, PushGroupUpdateJob.class, diff --git a/app/src/main/java/org/thoughtcrime/securesms/devicelist/Device.java b/app/src/main/java/org/thoughtcrime/securesms/devicelist/Device.java deleted file mode 100644 index e6f4f13967..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/devicelist/Device.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.thoughtcrime.securesms.devicelist; - -public class Device { - - private final String id; - private final String shortId; - private final String name; - - public Device(String id, String shortId, String name) { - this.id = id; - this.shortId = shortId; - this.name = name; - } - - public String getId() { - return id; - } - public String getShortId() { return shortId; } - public String getName() { return name; } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt index e5282902bc..60599de1e2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt @@ -13,7 +13,6 @@ import android.view.MenuItem import android.view.View import android.widget.Toast import kotlinx.android.synthetic.main.activity_create_closed_group.* -import kotlinx.android.synthetic.main.activity_linked_devices.recyclerView import network.loki.messenger.R import nl.komponents.kovenant.ui.successUi import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity @@ -31,6 +30,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences import org.session.libsignal.libsignal.util.guava.Optional import java.lang.ref.WeakReference +//TODO Refactor to avoid using kotlinx.android.synthetic class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), LoaderManager.LoaderCallbacks> { private var isLoading = false set(newValue) { field = newValue; invalidateOptionsMenu() } @@ -121,9 +121,9 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), LoaderM } val userPublicKey = TextSecurePreferences.getLocalNumber(this) isLoading = true - loader.fadeIn() + loaderContainer.fadeIn() ClosedGroupsProtocol.createClosedGroup(this, name.toString(), selectedMembers + setOf( userPublicKey )).successUi { groupID -> - loader.fadeOut() + loaderContainer.fadeOut() isLoading = false val threadID = DatabaseFactory.getThreadDatabase(this).getOrCreateThreadIdFor(Recipient.from(this, Address.fromSerialized(groupID), false)) if (!isFinishing) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt index c83892f862..27c4974546 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt @@ -3,25 +3,20 @@ package org.thoughtcrime.securesms.loki.activities import android.content.Context import android.content.Intent import android.os.Bundle -import androidx.loader.app.LoaderManager -import androidx.loader.content.Loader -import androidx.recyclerview.widget.LinearLayoutManager import android.view.Menu import android.view.MenuItem import android.view.View import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager -import android.widget.Toast -import androidx.appcompat.content.res.AppCompatResources -import kotlinx.android.synthetic.main.activity_create_closed_group.* -import kotlinx.android.synthetic.main.activity_create_closed_group.emptyStateContainer -import kotlinx.android.synthetic.main.activity_create_closed_group.mainContentContainer -import kotlinx.android.synthetic.main.activity_edit_closed_group.* -import kotlinx.android.synthetic.main.activity_edit_closed_group.loader -import kotlinx.android.synthetic.main.activity_linked_devices.recyclerView +import android.widget.* +import androidx.loader.app.LoaderManager +import androidx.loader.content.Loader +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import network.loki.messenger.R import nl.komponents.kovenant.ui.failUi import nl.komponents.kovenant.ui.successUi +import org.session.libsignal.service.loki.utilities.toHexString import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.database.Address import org.thoughtcrime.securesms.database.DatabaseFactory @@ -32,10 +27,8 @@ import org.thoughtcrime.securesms.loki.utilities.fadeIn import org.thoughtcrime.securesms.loki.utilities.fadeOut import org.thoughtcrime.securesms.mms.GlideApp import org.thoughtcrime.securesms.recipients.Recipient -import org.thoughtcrime.securesms.util.GroupUtil import org.thoughtcrime.securesms.util.TextSecurePreferences import org.thoughtcrime.securesms.util.ThemeUtil -import org.session.libsignal.service.loki.utilities.toHexString import java.io.IOException class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { @@ -60,6 +53,14 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { EditClosedGroupMembersAdapter(this, GlideApp.with(this), this::onMemberClick) } + private lateinit var mainContentContainer: LinearLayout + private lateinit var cntGroupNameEdit: LinearLayout + private lateinit var cntGroupNameDisplay: LinearLayout + private lateinit var edtGroupName: EditText + private lateinit var emptyStateContainer: LinearLayout + private lateinit var lblGroupNameDisplay: TextView + private lateinit var loaderContainer: View + companion object { @JvmStatic val groupIDKey = "groupIDKey" private val loaderID = 0 @@ -79,15 +80,27 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { originalName = DatabaseFactory.getGroupDatabase(this).getGroup(groupID).get().title name = originalName - addMembersClosedGroupButton.setOnClickListener { onAddMembersClick() } + mainContentContainer = findViewById(R.id.mainContentContainer) + cntGroupNameEdit = findViewById(R.id.cntGroupNameEdit) + cntGroupNameDisplay = findViewById(R.id.cntGroupNameDisplay) + edtGroupName = findViewById(R.id.edtGroupName) + emptyStateContainer = findViewById(R.id.emptyStateContainer) + lblGroupNameDisplay = findViewById(R.id.lblGroupNameDisplay) + loaderContainer = findViewById(R.id.loaderContainer) - recyclerView.adapter = memberListAdapter - recyclerView.layoutManager = LinearLayoutManager(this) + findViewById(R.id.addMembersClosedGroupButton).setOnClickListener { + onAddMembersClick() + } + + findViewById(R.id.rvUserList).apply { + adapter = memberListAdapter + layoutManager = LinearLayoutManager(this@EditClosedGroupActivity) + } lblGroupNameDisplay.text = originalName cntGroupNameDisplay.setOnClickListener { isEditingName = true } - btnCancelGroupNameEdit.setOnClickListener { isEditingName = false } - btnSaveGroupNameEdit.setOnClickListener { saveName() } + findViewById