Add polish to groups v2 creation flow.

This commit is contained in:
Alex Hart 2020-05-26 16:25:03 -03:00 committed by Greyson Parrelli
parent 8947b82034
commit 558a8e4a14
4 changed files with 22 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -314,7 +315,11 @@ public final class ContactSelectionListFragment extends Fragment
} }
if (headerAdapter != null) { if (headerAdapter != null) {
headerAdapter.show(); if (TextUtils.isEmpty(cursorFilter)) {
headerAdapter.show();
} else {
headerAdapter.hide();
}
} }
emptyText.setText(R.string.contact_selection_group_activity__no_contacts); emptyText.setText(R.string.contact_selection_group_activity__no_contacts);

View File

@ -1451,7 +1451,7 @@ public class RecipientDatabase extends Database {
args = new String[] { "0", String.valueOf(RegisteredState.REGISTERED.getId()), "1" }; args = new String[] { "0", String.valueOf(RegisteredState.REGISTERED.getId()), "1" };
} else { } else {
selection += " AND " + ID + " != ?"; selection += " AND " + ID + " != ?";
args = new String[] { "0", String.valueOf(RegisteredState.REGISTERED.getId()), Recipient.self().getId().serialize() }; args = new String[] { "0", String.valueOf(RegisteredState.REGISTERED.getId()), "1", Recipient.self().getId().serialize() };
} }
String orderBy = SORT_NAME + ", " + SYSTEM_DISPLAY_NAME + ", " + SEARCH_PROFILE_NAME + ", " + USERNAME + ", " + PHONE; String orderBy = SORT_NAME + ", " + SYSTEM_DISPLAY_NAME + ", " + SEARCH_PROFILE_NAME + ", " + USERNAME + ", " + PHONE;

View File

@ -140,7 +140,7 @@ public class AddGroupDetailsFragment extends Fragment {
initializeViewModel(); initializeViewModel();
avatar.setOnClickListener(v -> AvatarSelectionBottomSheetDialogFragment.create(false, true, REQUEST_CODE_AVATAR, true) avatar.setOnClickListener(v -> AvatarSelectionBottomSheetDialogFragment.create(viewModel.hasAvatar(), true, REQUEST_CODE_AVATAR, true)
.show(getChildFragmentManager(), "BOTTOM")); .show(getChildFragmentManager(), "BOTTOM"));
members.setRecipientLongClickListener(this::handleRecipientLongClick); members.setRecipientLongClickListener(this::handleRecipientLongClick);
members.setRecipientClickListener(this::handleRecipientClick); members.setRecipientClickListener(this::handleRecipientClick);
@ -162,11 +162,19 @@ public class AddGroupDetailsFragment extends Fragment {
.into(avatar); .into(avatar);
} }
}); });
name.requestFocus();
} }
@Override @Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == REQUEST_CODE_AVATAR && resultCode == Activity.RESULT_OK && data != null) { if (requestCode == REQUEST_CODE_AVATAR && resultCode == Activity.RESULT_OK && data != null) {
if (data.getBooleanExtra("delete", false)) {
viewModel.setAvatar(null);
return;
}
final Media result = data.getParcelableExtra(AvatarSelectionActivity.EXTRA_MEDIA); final Media result = data.getParcelableExtra(AvatarSelectionActivity.EXTRA_MEDIA);
final DecryptableStreamUriLoader.DecryptableUri decryptableUri = new DecryptableStreamUriLoader.DecryptableUri(result.getUri()); final DecryptableStreamUriLoader.DecryptableUri decryptableUri = new DecryptableStreamUriLoader.DecryptableUri(result.getUri());

View File

@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.groups.ui.creategroup.details;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations; import androidx.lifecycle.Transformations;
@ -72,10 +73,14 @@ public final class AddGroupDetailsViewModel extends ViewModel {
return isMms; return isMms;
} }
void setAvatar(@NonNull byte[] avatar) { void setAvatar(@Nullable byte[] avatar) {
this.avatar.setValue(avatar); this.avatar.setValue(avatar);
} }
boolean hasAvatar() {
return avatar.getValue() != null;
}
void setName(@NonNull String name) { void setName(@NonNull String name) {
this.name.setValue(name); this.name.setValue(name);
} }