Skip to content

Commit

Permalink
Add polish to groups v2 creation flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal authored and greyson-signal committed May 29, 2020
1 parent 8947b82 commit 558a8e4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
Expand Up @@ -23,6 +23,7 @@
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -314,7 +315,11 @@ public void onLoadFinished(@NonNull Loader<Cursor> loader, @Nullable Cursor data
}

if (headerAdapter != null) {
headerAdapter.show();
if (TextUtils.isEmpty(cursorFilter)) {
headerAdapter.show();
} else {
headerAdapter.hide();
}
}

emptyText.setText(R.string.contact_selection_group_activity__no_contacts);
Expand Down
Expand Up @@ -1451,7 +1451,7 @@ public void updateSystemContactColors(@NonNull ColorUpdater updater) {
args = new String[] { "0", String.valueOf(RegisteredState.REGISTERED.getId()), "1" };
} else {
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;
Expand Down
Expand Up @@ -140,7 +140,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

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"));
members.setRecipientLongClickListener(this::handleRecipientLongClick);
members.setRecipientClickListener(this::handleRecipientClick);
Expand All @@ -162,11 +162,19 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
.into(avatar);
}
});

name.requestFocus();
}

@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
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 DecryptableStreamUriLoader.DecryptableUri decryptableUri = new DecryptableStreamUriLoader.DecryptableUri(result.getUri());

Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
Expand Down Expand Up @@ -72,10 +73,14 @@ public final class AddGroupDetailsViewModel extends ViewModel {
return isMms;
}

void setAvatar(@NonNull byte[] avatar) {
void setAvatar(@Nullable byte[] avatar) {
this.avatar.setValue(avatar);
}

boolean hasAvatar() {
return avatar.getValue() != null;
}

void setName(@NonNull String name) {
this.name.setValue(name);
}
Expand Down

0 comments on commit 558a8e4

Please sign in to comment.