mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd0cbcee6a | |||
| ca14e0dcc6 | |||
| 04ad02f56d | |||
| e578853a62 | |||
| fc25f2ed9e |
@@ -23,9 +23,7 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Activity container for selecting a list of contacts.
|
||||
@@ -36,9 +34,6 @@ import java.util.Set;
|
||||
public class ContactMultiSelectionActivity extends ContactSelectionActivity {
|
||||
|
||||
public static final String CONTACTS_EXTRA = "contacts_extra";
|
||||
public static final String REMOVED_CONTACTS_EXTRA = "removed_contacts_extra";
|
||||
|
||||
private ArrayList<Integer> preselectedContacts;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle, boolean ready) {
|
||||
@@ -49,9 +44,6 @@ public class ContactMultiSelectionActivity extends ContactSelectionActivity {
|
||||
// it's a bit confusing having one "X" button on the left and one on the right -
|
||||
// and the "clear search" button is not that important.
|
||||
getToolbar().setUseClearButton(false);
|
||||
|
||||
// Store preselected contacts to track which ones were removed
|
||||
preselectedContacts = getIntent().getIntegerArrayListExtra(ContactSelectionListFragment.PRESELECTED_CONTACTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,19 +72,6 @@ public class ContactMultiSelectionActivity extends ContactSelectionActivity {
|
||||
Intent resultIntent = getIntent();
|
||||
List<Integer> selectedContacts = contactsFragment.getSelectedContacts();
|
||||
resultIntent.putIntegerArrayListExtra(CONTACTS_EXTRA, new ArrayList<>(selectedContacts));
|
||||
|
||||
// Calculate which contacts were removed (preselected but not in final selection)
|
||||
if (preselectedContacts != null) {
|
||||
Set<Integer> selectedSet = new HashSet<>(selectedContacts);
|
||||
ArrayList<Integer> removedContacts = new ArrayList<>();
|
||||
for (Integer preselectedId : preselectedContacts) {
|
||||
if (!selectedSet.contains(preselectedId)) {
|
||||
removedContacts.add(preselectedId);
|
||||
}
|
||||
}
|
||||
resultIntent.putIntegerArrayListExtra(REMOVED_CONTACTS_EXTRA, removedContacts);
|
||||
}
|
||||
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,8 +569,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
} else if (itemId == R.id.menu_show_map) {
|
||||
WebxdcActivity.openMaps(this, chatId);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_start_call) {
|
||||
CallUtil.startCall(this, chatId);
|
||||
} else if (itemId == R.id.menu_audio_call) {
|
||||
CallUtil.startCall(this, chatId, true);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_video_call) {
|
||||
CallUtil.startCall(this, chatId, false);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_all_media) {
|
||||
handleAllMedia();
|
||||
|
||||
@@ -310,24 +310,13 @@ public class ProfileFragment extends Fragment
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode==REQUEST_CODE_PICK_CONTACT && resultCode==Activity.RESULT_OK && data!=null) {
|
||||
List<Integer> selected = data.getIntegerArrayListExtra(ContactMultiSelectionActivity.CONTACTS_EXTRA);
|
||||
List<Integer> removed = data.getIntegerArrayListExtra(ContactMultiSelectionActivity.REMOVED_CONTACTS_EXTRA);
|
||||
if(selected == null) return;
|
||||
Util.runOnAnyBackgroundThread(() -> {
|
||||
// Add new members
|
||||
for (Integer contactId : selected) {
|
||||
if (contactId != null) {
|
||||
if (contactId!=null) {
|
||||
dcContext.addContactToChat(chatId, contactId);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove members that were explicitly unchecked
|
||||
if (removed != null) {
|
||||
for (Integer contactId : removed) {
|
||||
if (contactId != null) {
|
||||
dcContext.removeContactFromChat(chatId, contactId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,23 +19,40 @@ public class CallUtil {
|
||||
private static final String TAG = CallUtil.class.getSimpleName();
|
||||
|
||||
public static void startCall(Activity activity, int chatId) {
|
||||
startCall(activity, chatId, false);
|
||||
}
|
||||
|
||||
public static void startCall(Activity activity, int chatId, boolean audioOnly) {
|
||||
String[] permissions = audioOnly
|
||||
? new String[] { Manifest.permission.RECORD_AUDIO }
|
||||
: new String[] { Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
|
||||
|
||||
String permissionExplanation = audioOnly
|
||||
? activity.getString(R.string.perm_explain_access_to_mic_for_calls_denied)
|
||||
: activity.getString(R.string.perm_explain_access_to_camera_and_mic_denied);
|
||||
|
||||
Permissions.with(activity)
|
||||
.request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)
|
||||
.request(permissions)
|
||||
.ifNecessary()
|
||||
.withPermanentDenialDialog(activity.getString(R.string.perm_explain_access_to_camera_denied))
|
||||
.withPermanentDenialDialog(permissionExplanation)
|
||||
.onAllGranted(() -> {
|
||||
int accId = DcHelper.getContext(activity).getAccountId();
|
||||
startCall(activity, accId, chatId);
|
||||
startCall(activity, accId, chatId, audioOnly);
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
public static void startCall(Context context, int accId, int chatId) {
|
||||
startCall(context, accId, chatId, false);
|
||||
}
|
||||
|
||||
public static void startCall(Context context, int accId, int chatId, boolean audioOnly) {
|
||||
Intent intent = new Intent(context, CallActivity.class);
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.putExtra(CallActivity.EXTRA_ACCOUNT_ID, accId);
|
||||
intent.putExtra(CallActivity.EXTRA_CHAT_ID, chatId);
|
||||
intent.putExtra(CallActivity.EXTRA_HASH, "#startCall");
|
||||
String hash = audioOnly ? "?disableVideoCompletely#startCall" : "#startCall";
|
||||
intent.putExtra(CallActivity.EXTRA_HASH, hash);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,14 @@
|
||||
<item android:id="@+id/menu_start_call"
|
||||
android:title="@string/start_call"
|
||||
android:icon="@drawable/ic_videocam_white_24dp"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="always">
|
||||
<menu>
|
||||
<item android:id="@+id/menu_audio_call"
|
||||
android:title="@string/start_audio_call" />
|
||||
<item android:id="@+id/menu_video_call"
|
||||
android:title="@string/start_video_call" />
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item android:id="@+id/menu_all_media"
|
||||
android:title="@string/apps_and_media"
|
||||
|
||||
@@ -380,6 +380,8 @@
|
||||
|
||||
<!-- the action "to call someone", used as a tooltip for the "phone" icon. not: "the call" -->
|
||||
<string name="start_call">Call</string>
|
||||
<string name="start_audio_call">Audio Call</string>
|
||||
<string name="start_video_call">Video Call</string>
|
||||
<!-- the action "to answer" or to "accept" or to "pick up" a call. not: "the answer" -->
|
||||
<string name="answer_call">Answer</string>
|
||||
<!-- the action "to decline" a call, not: "the decline" -->
|
||||
@@ -1037,6 +1039,8 @@
|
||||
<string name="perm_explain_access_to_camera_denied">To take photos or capture videos, go to the app settings, select \"Permissions\", and enable \"Camera\".</string>
|
||||
<!-- give the user an idea where to find the "Microphone" option. the hint is only shown if access was initially denied by the user. pick up wordings really used on the systems, but do not be overly precise: things shift around often and there are too many system we support to track every detail and click path -->
|
||||
<string name="perm_explain_access_to_mic_denied">To send audio messages, go to system or app settings, select "Permissions" or "Privacy & Security", and enable \"Microphone\".</string>
|
||||
<string name="perm_explain_access_to_camera_and_mic_denied">To make video calls, go to the app settings, select \"Permissions\", and enable \"Camera\" and \"Microphone\".</string>
|
||||
<string name="perm_explain_access_to_mic_for_calls_denied">To make audio calls, go to system or app settings, select "Permissions" or "Privacy & Security", and enable \"Microphone\".</string>
|
||||
<string name="perm_explain_access_to_storage_denied">To receive or send files, go to the app settings, select \"Permissions\", and enable \"Storage\".</string>
|
||||
<string name="perm_explain_access_to_location_denied">To attach a location, go to the app settings, select \"Permissions\", and enable \"Location\".</string>
|
||||
<string name="perm_explain_access_to_notifications_denied">To receive notifications, go to \"System Settings / Apps / Delta Chat\" and enable \"Notifications\".</string>
|
||||
|
||||
Reference in New Issue
Block a user