mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-21 13:48:25 +00:00
handlePush and handleMms prototypes
This commit is contained in:
parent
c5d010c86f
commit
bb4a4d33c9
@ -54,7 +54,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
style="@android:style/Widget.ProgressBar.Large" />
|
style="@android:style/Widget.ProgressBar" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/creating_group_text"
|
android:id="@+id/creating_group_text"
|
||||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Looper;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -34,6 +35,7 @@ import org.whispersystems.textsecure.directory.Directory;
|
|||||||
import org.whispersystems.textsecure.directory.NotInDirectoryException;
|
import org.whispersystems.textsecure.directory.NotInDirectoryException;
|
||||||
import org.whispersystems.textsecure.util.InvalidNumberException;
|
import org.whispersystems.textsecure.util.InvalidNumberException;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -58,6 +60,8 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
private PushRecipientsPanel recipientsPanel;
|
private PushRecipientsPanel recipientsPanel;
|
||||||
private ImageView avatar;
|
private ImageView avatar;
|
||||||
|
|
||||||
|
private Bitmap avatarBmp;
|
||||||
|
|
||||||
private Set<Recipient> selectedContacts;
|
private Set<Recipient> selectedContacts;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,7 +84,11 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
dynamicTheme.onResume(this);
|
dynamicTheme.onResume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableWhisperGroupUI() {
|
private boolean whisperGroupUiEnabled() {
|
||||||
|
return groupName.isEnabled() && avatar.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableWhisperGroupUi() {
|
||||||
View pushDisabled = findViewById(R.id.push_disabled);
|
View pushDisabled = findViewById(R.id.push_disabled);
|
||||||
pushDisabled.setVisibility(View.VISIBLE);
|
pushDisabled.setVisibility(View.VISIBLE);
|
||||||
avatar.setEnabled(false);
|
avatar.setEnabled(false);
|
||||||
@ -88,7 +96,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
getSupportActionBar().setTitle(R.string.GroupCreateActivity_actionbar_mms_title);
|
getSupportActionBar().setTitle(R.string.GroupCreateActivity_actionbar_mms_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableWhisperGroupUI() {
|
private void enableWhisperGroupUi() {
|
||||||
findViewById(R.id.push_disabled).setVisibility(View.GONE);
|
findViewById(R.id.push_disabled).setVisibility(View.GONE);
|
||||||
avatar.setEnabled(true);
|
avatar.setEnabled(true);
|
||||||
groupName.setEnabled(true);
|
groupName.setEnabled(true);
|
||||||
@ -114,7 +122,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
|
|
||||||
private void addSelectedContact(Recipient contact) {
|
private void addSelectedContact(Recipient contact) {
|
||||||
selectedContacts.add(contact);
|
selectedContacts.add(contact);
|
||||||
if (!isActiveInDirectory(this, contact)) disableWhisperGroupUI();
|
if (!isActiveInDirectory(this, contact)) disableWhisperGroupUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAllSelectedContacts(Collection<Recipient> contacts) {
|
private void addAllSelectedContacts(Collection<Recipient> contacts) {
|
||||||
@ -131,7 +139,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
if (!isActiveInDirectory(this, recipient))
|
if (!isActiveInDirectory(this, recipient))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
enableWhisperGroupUI();
|
enableWhisperGroupUi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,32 +217,58 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_create_group:
|
case R.id.menu_create_group:
|
||||||
findViewById(R.id.group_details_layout).setVisibility(View.GONE);
|
if (whisperGroupUiEnabled()) {
|
||||||
findViewById(R.id.creating_group_layout).setVisibility(View.VISIBLE);
|
findViewById(R.id.group_details_layout).setVisibility(View.GONE);
|
||||||
((TextView)findViewById(R.id.creating_group_text)).setText("Creating " + groupName.getText().toString() + "...");
|
findViewById(R.id.creating_group_layout).setVisibility(View.VISIBLE);
|
||||||
new AsyncTask<Void,Void,Void>() {
|
findViewById(R.id.menu_create_group).setVisibility(View.GONE);
|
||||||
|
((TextView)findViewById(R.id.creating_group_text)).setText("Creating " + groupName.getText().toString() + "...");
|
||||||
|
new AsyncTask<Void,Void,Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
try {
|
byte[] byteArray = null;
|
||||||
Thread.sleep(5000); // todo network things
|
if (avatarBmp != null) {
|
||||||
} catch (InterruptedException e) {
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
Thread.currentThread().interrupt();
|
avatarBmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
||||||
|
byteArray = stream.toByteArray();
|
||||||
|
}
|
||||||
|
handleCreatePushGroup(groupName.getText().toString(), byteArray, selectedContacts);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
super.onPostExecute(aVoid);
|
super.onPostExecute(aVoid);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(Void... values) {
|
protected void onProgressUpdate(Void... values) {
|
||||||
super.onProgressUpdate(values);
|
super.onProgressUpdate(values);
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
} else {
|
||||||
|
new AsyncTask<Void,Void,Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
handleCreateMmsGroup(selectedContacts);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Void... values) {
|
||||||
|
super.onProgressUpdate(values);
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +313,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
break;
|
break;
|
||||||
case PICK_AVATAR:
|
case PICK_AVATAR:
|
||||||
if(resultCode == RESULT_OK) {
|
if(resultCode == RESULT_OK) {
|
||||||
Bitmap avatarBmp = data.getParcelableExtra("data");
|
avatarBmp = data.getParcelableExtra("data");
|
||||||
avatar.setImageBitmap(avatarBmp);
|
avatar.setImageBitmap(avatarBmp);
|
||||||
//Uri selectedImage = data.getData();
|
//Uri selectedImage = data.getData();
|
||||||
//avatar.setImageURI(selectedImage);
|
//avatar.setImageURI(selectedImage);
|
||||||
@ -295,4 +329,12 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
startActivityForResult(intent, PICK_CONTACT);
|
startActivityForResult(intent, PICK_CONTACT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleCreatePushGroup(String groupName, byte[] avatar, Set<Recipient> members) {
|
||||||
|
//todo
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleCreateMmsGroup(Set<Recipient> members) {
|
||||||
|
//todo
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user