Messaging: Fix a few android related things
* NotificationBuilder.addPerson(String) -> .addPerson(Person) * Wearableextenter.addPage deprecated without replacement * Html.fromHtml(String) -> .fromHtml(String, int) * Handlers need Loopers * Resource-IDs are not final by default (if-else instead of switch-case) * call super.onFinishInflate() in override of onFinishInflate() * Configuration.locale -> configuration.getLocales().get(0) * SimpleDateFormat needs localization as well * AudioAttributes instead of setAudioStreamType() * isDataEnabled() is a public method, no need for reflection anymore Change-Id: Icd830768b86edca3e0b44f1edc6c57facc9f731a
This commit is contained in:
@@ -27,7 +27,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap.Config;
|
import android.graphics.Bitmap.Config;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -45,6 +44,7 @@ import androidx.collection.SimpleArrayMap;
|
|||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationCompat.WearableExtender;
|
import androidx.core.app.NotificationCompat.WearableExtender;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
import androidx.core.app.Person;
|
||||||
import androidx.core.app.RemoteInput;
|
import androidx.core.app.RemoteInput;
|
||||||
|
|
||||||
import com.android.messaging.Factory;
|
import com.android.messaging.Factory;
|
||||||
@@ -649,7 +649,8 @@ public class BugleNotifications {
|
|||||||
if (notificationState.mParticipantContactUris != null &&
|
if (notificationState.mParticipantContactUris != null &&
|
||||||
notificationState.mParticipantContactUris.size() > 0) {
|
notificationState.mParticipantContactUris.size() > 0) {
|
||||||
for (final Uri contactUri : notificationState.mParticipantContactUris) {
|
for (final Uri contactUri : notificationState.mParticipantContactUris) {
|
||||||
notificationState.mNotificationBuilder.addPerson(contactUri.toString());
|
Person p = new Person.Builder().setUri(contactUri.toString()).build();
|
||||||
|
notificationState.mNotificationBuilder.addPerson(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,16 +728,6 @@ public class BugleNotifications {
|
|||||||
final WearableExtender wearableExtender = new WearableExtender();
|
final WearableExtender wearableExtender = new WearableExtender();
|
||||||
setWearableGroupOptions(notifBuilder, notificationState);
|
setWearableGroupOptions(notifBuilder, notificationState);
|
||||||
|
|
||||||
if (avatarHiResBitmap != null) {
|
|
||||||
wearableExtender.setBackground(avatarHiResBitmap);
|
|
||||||
} else if (avatarBitmap != null) {
|
|
||||||
// Nothing to do here; we already set avatarBitmap as the notification icon
|
|
||||||
} else {
|
|
||||||
final Bitmap defaultBackground = BitmapFactory.decodeResource(
|
|
||||||
context.getResources(), R.drawable.bg_sms);
|
|
||||||
wearableExtender.setBackground(defaultBackground);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notificationState instanceof MultiMessageNotificationState) {
|
if (notificationState instanceof MultiMessageNotificationState) {
|
||||||
if (attachmentBitmap != null) {
|
if (attachmentBitmap != null) {
|
||||||
// When we've got a picture attachment, we do some switcheroo trickery. When
|
// When we've got a picture attachment, we do some switcheroo trickery. When
|
||||||
@@ -754,29 +745,8 @@ public class BugleNotifications {
|
|||||||
.bigPicture(attachmentBitmap)
|
.bigPicture(attachmentBitmap)
|
||||||
.bigLargeIcon(avatarBitmap);
|
.bigLargeIcon(avatarBitmap);
|
||||||
notificationState.mNotificationBuilder.setLargeIcon(smallBitmap);
|
notificationState.mNotificationBuilder.setLargeIcon(smallBitmap);
|
||||||
|
|
||||||
// Add a wearable page with no visible card so you can more easily see the photo.
|
|
||||||
String conversationId = notificationState.mConversationIds.first();
|
|
||||||
String id = NotificationsUtil.DEFAULT_CHANNEL_ID;
|
|
||||||
if (NotificationsUtil.getNotificationChannel(context, conversationId) != null) {
|
|
||||||
id = conversationId;
|
|
||||||
}
|
|
||||||
final NotificationCompat.Builder photoPageNotifBuilder =
|
|
||||||
new NotificationCompat.Builder(Factory.get().getApplicationContext(),
|
|
||||||
NotificationsUtil.DEFAULT_CHANNEL_ID);
|
|
||||||
final WearableExtender photoPageWearableExtender = new WearableExtender();
|
|
||||||
photoPageWearableExtender.setHintShowBackgroundOnly(true);
|
|
||||||
if (attachmentBitmap != null) {
|
|
||||||
final Bitmap wearBitmap = ImageUtils.scaleCenterCrop(attachmentBitmap,
|
|
||||||
sWearableImageWidth, sWearableImageHeight);
|
|
||||||
photoPageWearableExtender.setBackground(wearBitmap);
|
|
||||||
}
|
|
||||||
photoPageNotifBuilder.extend(photoPageWearableExtender);
|
|
||||||
wearableExtender.addPage(photoPageNotifBuilder.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maybeAddWearableConversationLog(wearableExtender,
|
|
||||||
(MultiMessageNotificationState) notificationState);
|
|
||||||
addDownloadMmsAction(notifBuilder, wearableExtender, notificationState);
|
addDownloadMmsAction(notifBuilder, wearableExtender, notificationState);
|
||||||
addWearableVoiceReplyAction(notifBuilder, wearableExtender, notificationState);
|
addWearableVoiceReplyAction(notifBuilder, wearableExtender, notificationState);
|
||||||
}
|
}
|
||||||
@@ -804,22 +774,6 @@ public class BugleNotifications {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void maybeAddWearableConversationLog(
|
|
||||||
final WearableExtender wearableExtender,
|
|
||||||
final MultiMessageNotificationState notificationState) {
|
|
||||||
if (!isWearCompanionAppInstalled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final String convId = notificationState.mConversationIds.first();
|
|
||||||
ConversationLineInfo convInfo = notificationState.mConvList.mConvInfos.get(0);
|
|
||||||
final Notification page = MessageNotificationState.buildConversationPageForWearable(
|
|
||||||
convId,
|
|
||||||
convInfo.mParticipantCount);
|
|
||||||
if (page != null) {
|
|
||||||
wearableExtender.addPage(page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addWearableVoiceReplyAction(final NotificationCompat.Builder notifBuilder,
|
private static void addWearableVoiceReplyAction(final NotificationCompat.Builder notifBuilder,
|
||||||
final WearableExtender wearableExtender, final NotificationState notificationState) {
|
final WearableExtender wearableExtender, final NotificationState notificationState) {
|
||||||
if (!(notificationState instanceof MultiMessageNotificationState)) {
|
if (!(notificationState instanceof MultiMessageNotificationState)) {
|
||||||
|
|||||||
@@ -1084,7 +1084,7 @@ public abstract class MessageNotificationState extends NotificationState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static CharSequence convertHtmlAndStripUrls(final String s) {
|
private static CharSequence convertHtmlAndStripUrls(final String s) {
|
||||||
final Spanned text = Html.fromHtml(s);
|
final Spanned text = Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY);
|
||||||
if (text instanceof Spannable) {
|
if (text instanceof Spannable) {
|
||||||
stripUrls((Spannable) text);
|
stripUrls((Spannable) text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class BlockedParticipantListItemView extends LinearLayout {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
mNameTextView = (TextView) findViewById(R.id.name);
|
mNameTextView = (TextView) findViewById(R.id.name);
|
||||||
mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
|
mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
|
||||||
setOnClickListener(v -> mData.unblock(getContext()));
|
setOnClickListener(v -> mData.unblock(getContext()));
|
||||||
|
|||||||
@@ -39,15 +39,11 @@ public class BlockedParticipantsActivity extends BugleActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == android.R.id.home) {// Treat the home press as back press so that when we go back to
|
||||||
case android.R.id.home:
|
// ConversationActivity, it doesn't lose its original intent (conversation id etc.)
|
||||||
// Treat the home press as back press so that when we go back to
|
onBackPressed();
|
||||||
// ConversationActivity, it doesn't lose its original intent (conversation id etc.)
|
return true;
|
||||||
onBackPressed();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,12 +203,11 @@ public class BugleActionBarActivity extends AppCompatActivity implements ImeUtil
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (menuItem.getItemId()) {
|
if (menuItem.getItemId() == android.R.id.home) {
|
||||||
case android.R.id.home:
|
if (mActionMode != null) {
|
||||||
if (mActionMode != null) {
|
dismissActionMode();
|
||||||
dismissActionMode();
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(menuItem);
|
return super.onOptionsItemSelected(menuItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.content.DialogInterface.OnClickListener;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.Telephony.Sms;
|
import android.provider.Telephony.Sms;
|
||||||
@@ -66,7 +67,7 @@ public class ClassZeroActivity extends Activity {
|
|||||||
|
|
||||||
private ArrayList<ContentValues> mMessageQueue = null;
|
private ArrayList<ContentValues> mMessageQueue = null;
|
||||||
|
|
||||||
private final Handler mHandler = new Handler() {
|
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(final Message msg) {
|
public void handleMessage(final Message msg) {
|
||||||
// Do not handle an invalid message.
|
// Do not handle an invalid message.
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class PersonItemView extends LinearLayout implements PersonItemDataListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
mNameTextView = (TextView) findViewById(R.id.name);
|
mNameTextView = (TextView) findViewById(R.id.name);
|
||||||
mDetailsTextView = (TextView) findViewById(R.id.details);
|
mDetailsTextView = (TextView) findViewById(R.id.details);
|
||||||
mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
|
mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
|
||||||
|
|||||||
@@ -56,15 +56,12 @@ public class VCardDetailActivity extends BugleActionBarActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
case android.R.id.home:
|
// Treat the home press as back press so that when we go back to
|
||||||
// Treat the home press as back press so that when we go back to
|
// ConversationActivity, it doesn't lose its original intent (conversation id etc.)
|
||||||
// ConversationActivity, it doesn't lose its original intent (conversation id etc.)
|
onBackPressed();
|
||||||
onBackPressed();
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,41 +125,38 @@ public class VCardDetailFragment extends Fragment implements PersonItemDataListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == R.id.action_add_contact) {
|
||||||
case R.id.action_add_contact:
|
mBinding.ensureBound();
|
||||||
mBinding.ensureBound();
|
final Uri vCardUri = mBinding.getData().getVCardUri();
|
||||||
final Uri vCardUri = mBinding.getData().getVCardUri();
|
|
||||||
|
|
||||||
// We have to do things in the background in case we need to copy the vcard data.
|
// We have to do things in the background in case we need to copy the vcard data.
|
||||||
new SafeAsyncTask<Void, Void, Uri>() {
|
new SafeAsyncTask<Void, Void, Uri>() {
|
||||||
@Override
|
@Override
|
||||||
protected Uri doInBackgroundTimed(final Void... params) {
|
protected Uri doInBackgroundTimed(final Void... params) {
|
||||||
// We can't delete the persisted vCard file because we don't know when to
|
// We can't delete the persisted vCard file because we don't know when to
|
||||||
// delete it, since the app that uses it (contacts, dialer) may start or
|
// delete it, since the app that uses it (contacts, dialer) may start or
|
||||||
// shut down at any point. Therefore, we rely on the system to clean up
|
// shut down at any point. Therefore, we rely on the system to clean up
|
||||||
// the cache directory for us.
|
// the cache directory for us.
|
||||||
return mScratchSpaceUri != null ? mScratchSpaceUri :
|
return mScratchSpaceUri != null ? mScratchSpaceUri :
|
||||||
UriUtil.persistContentToScratchSpace(vCardUri);
|
UriUtil.persistContentToScratchSpace(vCardUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(final Uri result) {
|
protected void onPostExecute(final Uri result) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
mScratchSpaceUri = result;
|
mScratchSpaceUri = result;
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
MediaScratchFileProvider.addUriToDisplayNameEntry(
|
MediaScratchFileProvider.addUriToDisplayNameEntry(
|
||||||
result, mBinding.getData().getDisplayName());
|
result, mBinding.getData().getDisplayName());
|
||||||
UIIntents.get().launchSaveVCardToContactsActivity(getActivity(),
|
UIIntents.get().launchSaveVCardToContactsActivity(getActivity(),
|
||||||
result);
|
result);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.executeOnThreadPool();
|
}
|
||||||
return true;
|
}.executeOnThreadPool();
|
||||||
|
return true;
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVCardUri(final Uri vCardUri) {
|
public void setVCardUri(final Uri vCardUri) {
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case android.R.id.home:
|
if (itemId == android.R.id.home) {
|
||||||
NavUtils.navigateUpFromSameTask(this);
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_license:
|
} else if (itemId == R.id.action_license) {
|
||||||
final Intent intent = new Intent(this, LicenseActivity.class);
|
final Intent intent = new Intent(this, LicenseActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ public class PerSubscriptionSettingsActivity extends BugleActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
case android.R.id.home:
|
|
||||||
NavUtils.navigateUpFromSameTask(this);
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ public class SettingsActivity extends BugleActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
case android.R.id.home:
|
|
||||||
NavUtils.navigateUpFromSameTask(this);
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,14 +87,11 @@ public class AttachmentChooserFragment extends Fragment implements DraftMessageD
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == R.id.action_confirm_selection) {
|
||||||
case R.id.action_confirm_selection:
|
confirmSelection();
|
||||||
confirmSelection();
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
* Copyright (C) 2024 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -64,6 +65,7 @@ public class ContactListItemView extends LinearLayout implements OnClickListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate () {
|
protected void onFinishInflate () {
|
||||||
|
super.onFinishInflate();
|
||||||
mContactNameTextView = (TextView) findViewById(R.id.contact_name);
|
mContactNameTextView = (TextView) findViewById(R.id.contact_name);
|
||||||
mContactDetailsTextView = (TextView) findViewById(R.id.contact_details);
|
mContactDetailsTextView = (TextView) findViewById(R.id.contact_details);
|
||||||
mContactDetailTypeTextView = (TextView) findViewById(R.id.contact_detail_type);
|
mContactDetailTypeTextView = (TextView) findViewById(R.id.contact_detail_type);
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
|
|||||||
mCustomHeaderViewPager.setViewHolders(viewHolders);
|
mCustomHeaderViewPager.setViewHolders(viewHolders);
|
||||||
mCustomHeaderViewPager.setViewPagerTabHeight(CustomHeaderViewPager.DEFAULT_TAB_STRIP_SIZE);
|
mCustomHeaderViewPager.setViewPagerTabHeight(CustomHeaderViewPager.DEFAULT_TAB_STRIP_SIZE);
|
||||||
mCustomHeaderViewPager.setBackgroundColor(getResources()
|
mCustomHeaderViewPager.setBackgroundColor(getResources()
|
||||||
.getColor(R.color.contact_picker_background, getContext().getTheme()));
|
.getColor(R.color.contact_picker_background, requireActivity().getTheme()));
|
||||||
|
|
||||||
// The view pager defaults to the frequent contacts page.
|
// The view pager defaults to the frequent contacts page.
|
||||||
mCustomHeaderViewPager.setCurrentItem(0);
|
mCustomHeaderViewPager.setCurrentItem(0);
|
||||||
@@ -220,32 +220,29 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(final MenuItem menuItem) {
|
public boolean onMenuItemClick(final MenuItem menuItem) {
|
||||||
switch (menuItem.getItemId()) {
|
int itemId = menuItem.getItemId();
|
||||||
case R.id.action_ime_dialpad_toggle:
|
if (itemId == R.id.action_ime_dialpad_toggle) {
|
||||||
final int baseInputType = InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
final int baseInputType = InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
||||||
if ((mRecipientTextView.getInputType() & InputType.TYPE_CLASS_PHONE) !=
|
if ((mRecipientTextView.getInputType() & InputType.TYPE_CLASS_PHONE) !=
|
||||||
InputType.TYPE_CLASS_PHONE) {
|
InputType.TYPE_CLASS_PHONE) {
|
||||||
mRecipientTextView.setInputType(baseInputType | InputType.TYPE_CLASS_PHONE);
|
mRecipientTextView.setInputType(baseInputType | InputType.TYPE_CLASS_PHONE);
|
||||||
menuItem.setIcon(R.drawable.ic_ime_light);
|
menuItem.setIcon(R.drawable.ic_ime_light);
|
||||||
} else {
|
} else {
|
||||||
mRecipientTextView.setInputType(baseInputType | InputType.TYPE_CLASS_TEXT);
|
mRecipientTextView.setInputType(baseInputType | InputType.TYPE_CLASS_TEXT);
|
||||||
menuItem.setIcon(R.drawable.ic_numeric_dialpad);
|
menuItem.setIcon(R.drawable.ic_numeric_dialpad);
|
||||||
}
|
}
|
||||||
ImeUtil.get().showImeKeyboard(getActivity(), mRecipientTextView);
|
ImeUtil.get().showImeKeyboard(requireActivity(), mRecipientTextView);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (itemId == R.id.action_add_more_participants) {
|
||||||
case R.id.action_add_more_participants:
|
mHost.onInitiateAddMoreParticipants();
|
||||||
mHost.onInitiateAddMoreParticipants();
|
return true;
|
||||||
return true;
|
} else if (itemId == R.id.action_confirm_participants) {
|
||||||
|
maybeGetOrCreateConversation();
|
||||||
case R.id.action_confirm_participants:
|
return true;
|
||||||
maybeGetOrCreateConversation();
|
} else if (itemId == R.id.action_delete_text) {
|
||||||
return true;
|
Assert.equals(MODE_PICK_INITIAL_CONTACT, mContactPickingMode);
|
||||||
|
mRecipientTextView.setText("");
|
||||||
case R.id.action_delete_text:
|
return true;
|
||||||
Assert.equals(MODE_PICK_INITIAL_CONTACT, mContactPickingMode);
|
|
||||||
mRecipientTextView.setText("");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
|
||||||
import com.android.messaging.Factory;
|
import com.android.messaging.Factory;
|
||||||
import com.android.messaging.R;
|
import com.android.messaging.R;
|
||||||
import com.android.messaging.datamodel.binding.Binding;
|
import com.android.messaging.datamodel.binding.Binding;
|
||||||
@@ -190,6 +191,7 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
mComposeEditText = (PlainTextEditText) findViewById(
|
mComposeEditText = (PlainTextEditText) findViewById(
|
||||||
R.id.compose_message_text);
|
R.id.compose_message_text);
|
||||||
mComposeEditText.setOnEditorActionListener(this);
|
mComposeEditText.setOnEditorActionListener(this);
|
||||||
@@ -730,7 +732,7 @@ public class ComposeMessageView extends LinearLayout
|
|||||||
} else {
|
} else {
|
||||||
mComposeEditText.setHint(Html.fromHtml(getResources().getString(
|
mComposeEditText.setHint(Html.fromHtml(getResources().getString(
|
||||||
R.string.compose_message_view_hint_text_multi_sim,
|
R.string.compose_message_view_hint_text_multi_sim,
|
||||||
subscriptionListEntry.displayName)));
|
subscriptionListEntry.displayName), Html.FROM_HTML_MODE_LEGACY));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int type = -1;
|
int type = -1;
|
||||||
|
|||||||
@@ -306,67 +306,67 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
|||||||
public boolean onActionItemClicked(final ActionMode actionMode, final MenuItem menuItem) {
|
public boolean onActionItemClicked(final ActionMode actionMode, final MenuItem menuItem) {
|
||||||
final ConversationMessageData data = mSelectedMessage.getData();
|
final ConversationMessageData data = mSelectedMessage.getData();
|
||||||
final String messageId = data.getMessageId();
|
final String messageId = data.getMessageId();
|
||||||
switch (menuItem.getItemId()) {
|
int itemId = menuItem.getItemId();
|
||||||
case R.id.save_attachment:
|
if (itemId == R.id.save_attachment) {
|
||||||
if (OsUtil.hasStoragePermission()) {
|
if (OsUtil.hasStoragePermission()) {
|
||||||
final SaveAttachmentTask saveAttachmentTask = new SaveAttachmentTask(
|
final SaveAttachmentTask saveAttachmentTask = new SaveAttachmentTask(
|
||||||
getActivity());
|
getActivity());
|
||||||
for (final MessagePartData part : data.getAttachments()) {
|
for (final MessagePartData part : data.getAttachments()) {
|
||||||
saveAttachmentTask.addAttachmentToSave(part.getContentUri(),
|
saveAttachmentTask.addAttachmentToSave(part.getContentUri(),
|
||||||
part.getContentType());
|
part.getContentType());
|
||||||
}
|
|
||||||
if (saveAttachmentTask.getAttachmentCount() > 0) {
|
|
||||||
saveAttachmentTask.executeOnThreadPool();
|
|
||||||
mHost.dismissActionMode();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
getActivity().requestPermissions(
|
|
||||||
new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
|
|
||||||
}
|
}
|
||||||
return true;
|
if (saveAttachmentTask.getAttachmentCount() > 0) {
|
||||||
case R.id.action_delete_message:
|
saveAttachmentTask.executeOnThreadPool();
|
||||||
if (mSelectedMessage != null) {
|
|
||||||
deleteMessage(messageId);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.action_download:
|
|
||||||
if (mSelectedMessage != null) {
|
|
||||||
retryDownload(messageId);
|
|
||||||
mHost.dismissActionMode();
|
mHost.dismissActionMode();
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
case R.id.action_send:
|
getActivity().requestPermissions(
|
||||||
if (mSelectedMessage != null) {
|
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||||
retrySend(messageId);
|
}
|
||||||
mHost.dismissActionMode();
|
return true;
|
||||||
}
|
} else if (itemId == R.id.action_delete_message) {
|
||||||
return true;
|
if (mSelectedMessage != null) {
|
||||||
case R.id.copy_text:
|
deleteMessage(messageId);
|
||||||
Assert.isTrue(data.hasText());
|
}
|
||||||
final ClipboardManager clipboard = (ClipboardManager) getActivity()
|
return true;
|
||||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
} else if (itemId == R.id.action_download) {
|
||||||
clipboard.setPrimaryClip(
|
if (mSelectedMessage != null) {
|
||||||
ClipData.newPlainText(null /* label */, data.getText()));
|
retryDownload(messageId);
|
||||||
mHost.dismissActionMode();
|
mHost.dismissActionMode();
|
||||||
return true;
|
}
|
||||||
case R.id.details_menu:
|
return true;
|
||||||
MessageDetailsDialog.show(
|
} else if (itemId == R.id.action_send) {
|
||||||
getActivity(), data, mBinding.getData().getParticipants(),
|
if (mSelectedMessage != null) {
|
||||||
mBinding.getData().getSelfParticipantById(data.getSelfParticipantId()));
|
retrySend(messageId);
|
||||||
mHost.dismissActionMode();
|
mHost.dismissActionMode();
|
||||||
return true;
|
}
|
||||||
case R.id.share_message_menu:
|
return true;
|
||||||
shareMessage(data);
|
} else if (itemId == R.id.copy_text) {
|
||||||
mHost.dismissActionMode();
|
Assert.isTrue(data.hasText());
|
||||||
return true;
|
final ClipboardManager clipboard = (ClipboardManager) getActivity()
|
||||||
case R.id.forward_message_menu:
|
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
// TODO: Currently we are forwarding one part at a time, instead of
|
clipboard.setPrimaryClip(
|
||||||
// the entire message. Change this to forwarding the entire message when we
|
ClipData.newPlainText(null /* label */, data.getText()));
|
||||||
// use message-based cursor in conversation.
|
mHost.dismissActionMode();
|
||||||
final MessageData message = mBinding.getData().createForwardedMessage(data);
|
return true;
|
||||||
UIIntents.get().launchForwardMessageActivity(getActivity(), message);
|
} else if (itemId == R.id.details_menu) {
|
||||||
mHost.dismissActionMode();
|
MessageDetailsDialog.show(
|
||||||
return true;
|
getActivity(), data, mBinding.getData().getParticipants(),
|
||||||
|
mBinding.getData().getSelfParticipantById(data.getSelfParticipantId()));
|
||||||
|
mHost.dismissActionMode();
|
||||||
|
return true;
|
||||||
|
} else if (itemId == R.id.share_message_menu) {
|
||||||
|
shareMessage(data);
|
||||||
|
mHost.dismissActionMode();
|
||||||
|
return true;
|
||||||
|
} else if (itemId == R.id.forward_message_menu) {
|
||||||
|
// TODO: Currently we are forwarding one part at a time, instead of
|
||||||
|
// the entire message. Change this to forwarding the entire message when we
|
||||||
|
// use message-based cursor in conversation.
|
||||||
|
final MessageData message = mBinding.getData().createForwardedMessage(data);
|
||||||
|
UIIntents.get().launchForwardMessageActivity(getActivity(), message);
|
||||||
|
mHost.dismissActionMode();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -774,72 +774,66 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case R.id.action_people_and_options:
|
if (itemId == R.id.action_people_and_options) {
|
||||||
Assert.isTrue(mBinding.getData().getParticipantsLoaded());
|
Assert.isTrue(mBinding.getData().getParticipantsLoaded());
|
||||||
UIIntents.get().launchPeopleAndOptionsActivity(getActivity(), mConversationId);
|
UIIntents.get().launchPeopleAndOptionsActivity(getActivity(), mConversationId);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (itemId == R.id.action_call) {
|
||||||
case R.id.action_call:
|
final String phoneNumber = mBinding.getData().getParticipantPhoneNumber();
|
||||||
final String phoneNumber = mBinding.getData().getParticipantPhoneNumber();
|
Assert.notNull(phoneNumber);
|
||||||
Assert.notNull(phoneNumber);
|
// Can't make a call to emergency numbers using ACTION_CALL.
|
||||||
// Can't make a call to emergency numbers using ACTION_CALL.
|
if (PhoneNumberUtils.isEmergencyNumber(phoneNumber)) {
|
||||||
if (PhoneNumberUtils.isEmergencyNumber(phoneNumber)) {
|
UiUtils.showToast(R.string.disallow_emergency_call);
|
||||||
UiUtils.showToast(R.string.disallow_emergency_call);
|
} else {
|
||||||
|
final View targetView = getActivity().findViewById(R.id.action_call);
|
||||||
|
Point centerPoint;
|
||||||
|
if (targetView != null) {
|
||||||
|
final int[] screenLocation = new int[2];
|
||||||
|
targetView.getLocationOnScreen(screenLocation);
|
||||||
|
final int centerX = screenLocation[0] + targetView.getWidth() / 2;
|
||||||
|
final int centerY = screenLocation[1] + targetView.getHeight() / 2;
|
||||||
|
centerPoint = new Point(centerX, centerY);
|
||||||
} else {
|
} else {
|
||||||
final View targetView = getActivity().findViewById(R.id.action_call);
|
// In the overflow menu, just use the center of the screen.
|
||||||
Point centerPoint;
|
final Display display =
|
||||||
if (targetView != null) {
|
getActivity().getWindowManager().getDefaultDisplay();
|
||||||
final int[] screenLocation = new int[2];
|
centerPoint = new Point(display.getWidth() / 2, display.getHeight() / 2);
|
||||||
targetView.getLocationOnScreen(screenLocation);
|
|
||||||
final int centerX = screenLocation[0] + targetView.getWidth() / 2;
|
|
||||||
final int centerY = screenLocation[1] + targetView.getHeight() / 2;
|
|
||||||
centerPoint = new Point(centerX, centerY);
|
|
||||||
} else {
|
|
||||||
// In the overflow menu, just use the center of the screen.
|
|
||||||
final Display display =
|
|
||||||
getActivity().getWindowManager().getDefaultDisplay();
|
|
||||||
centerPoint = new Point(display.getWidth() / 2, display.getHeight() / 2);
|
|
||||||
}
|
|
||||||
UIIntents.get()
|
|
||||||
.launchPhoneCallActivity(getActivity(), phoneNumber, centerPoint);
|
|
||||||
}
|
}
|
||||||
return true;
|
UIIntents.get()
|
||||||
|
.launchPhoneCallActivity(getActivity(), phoneNumber, centerPoint);
|
||||||
case R.id.action_archive:
|
}
|
||||||
mBinding.getData().archiveConversation(mBinding);
|
return true;
|
||||||
closeConversation(mConversationId);
|
} else if (itemId == R.id.action_archive) {
|
||||||
return true;
|
mBinding.getData().archiveConversation(mBinding);
|
||||||
|
closeConversation(mConversationId);
|
||||||
case R.id.action_unarchive:
|
return true;
|
||||||
mBinding.getData().unarchiveConversation(mBinding);
|
} else if (itemId == R.id.action_unarchive) {
|
||||||
return true;
|
mBinding.getData().unarchiveConversation(mBinding);
|
||||||
|
return true;
|
||||||
case R.id.action_settings:
|
} else if (itemId == R.id.action_settings) {
|
||||||
return true;
|
return true;
|
||||||
|
} else if (itemId == R.id.action_add_contact) {
|
||||||
case R.id.action_add_contact:
|
final ParticipantData participant = mBinding.getData().getOtherParticipant();
|
||||||
final ParticipantData participant = mBinding.getData().getOtherParticipant();
|
Assert.notNull(participant);
|
||||||
Assert.notNull(participant);
|
final String destination = participant.getNormalizedDestination();
|
||||||
final String destination = participant.getNormalizedDestination();
|
final Uri avatarUri = AvatarUriUtil.createAvatarUri(participant);
|
||||||
final Uri avatarUri = AvatarUriUtil.createAvatarUri(participant);
|
(new AddContactsConfirmationDialog(getActivity(), avatarUri, destination)).show();
|
||||||
(new AddContactsConfirmationDialog(getActivity(), avatarUri, destination)).show();
|
return true;
|
||||||
return true;
|
} else if (itemId == R.id.action_delete) {
|
||||||
|
if (isReadyForDeleteAction()) {
|
||||||
case R.id.action_delete:
|
new AlertDialog.Builder(getActivity())
|
||||||
if (isReadyForDeleteAction()) {
|
.setTitle(getResources().getQuantityString(
|
||||||
new AlertDialog.Builder(getActivity())
|
R.plurals.delete_conversations_confirmation_dialog_title, 1))
|
||||||
.setTitle(getResources().getQuantityString(
|
.setPositiveButton(R.string.delete_conversation_confirmation_button,
|
||||||
R.plurals.delete_conversations_confirmation_dialog_title, 1))
|
(dialog, button) -> deleteConversation())
|
||||||
.setPositiveButton(R.string.delete_conversation_confirmation_button,
|
.setNegativeButton(R.string.delete_conversation_decline_button, null)
|
||||||
(dialog, button) -> deleteConversation())
|
.show();
|
||||||
.setNegativeButton(R.string.delete_conversation_decline_button, null)
|
} else {
|
||||||
.show();
|
warnOfMissingActionConditions(false /*sending*/,
|
||||||
} else {
|
null /*commandToRunAfterActionConditionResolved*/);
|
||||||
warnOfMissingActionConditions(false /*sending*/,
|
}
|
||||||
null /*commandToRunAfterActionConditionResolved*/);
|
return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon);
|
mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon);
|
||||||
mContactIconView.setOnLongClickListener(view -> {
|
mContactIconView.setOnLongClickListener(view -> {
|
||||||
ConversationMessageView.this.performLongClick();
|
ConversationMessageView.this.performLongClick();
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class SimSelectorItemView extends LinearLayout {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
mNameTextView = (TextView) findViewById(R.id.name);
|
mNameTextView = (TextView) findViewById(R.id.name);
|
||||||
mDetailsTextView = (TextView) findViewById(R.id.details);
|
mDetailsTextView = (TextView) findViewById(R.id.details);
|
||||||
mSimIconView = (SimIconView) findViewById(R.id.sim_icon);
|
mSimIconView = (SimIconView) findViewById(R.id.sim_icon);
|
||||||
|
|||||||
@@ -64,13 +64,11 @@ public class ArchivedConversationListActivity extends AbstractConversationListAc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||||
switch(menuItem.getItemId()) {
|
if (menuItem.getItemId() == android.R.id.home) {
|
||||||
case android.R.id.home:
|
onActionBarHome();
|
||||||
onActionBarHome();
|
return true;
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(menuItem);
|
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(menuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -85,19 +85,19 @@ public class ConversationListActivity extends AbstractConversationListActivity i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem menuItem) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem menuItem) {
|
||||||
switch(menuItem.getItemId()) {
|
int itemId = menuItem.getItemId();
|
||||||
case R.id.action_start_new_conversation:
|
if (itemId == R.id.action_start_new_conversation) {
|
||||||
onActionBarStartNewConversation();
|
onActionBarStartNewConversation();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_settings:
|
} else if (itemId == R.id.action_settings) {
|
||||||
onActionBarSettings();
|
onActionBarSettings();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_show_archived:
|
} else if (itemId == R.id.action_show_archived) {
|
||||||
onActionBarArchived();
|
onActionBarArchived();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_show_blocked_contacts:
|
} else if (itemId == R.id.action_show_blocked_contacts) {
|
||||||
onActionBarBlockedParticipants();
|
onActionBarBlockedParticipants();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(menuItem);
|
return super.onOptionsItemSelected(menuItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
mSwipeableContainer = (ViewGroup) findViewById(R.id.swipeableContainer);
|
mSwipeableContainer = (ViewGroup) findViewById(R.id.swipeableContainer);
|
||||||
mCrossSwipeBackground = (ViewGroup) findViewById(R.id.crossSwipeBackground);
|
mCrossSwipeBackground = (ViewGroup) findViewById(R.id.crossSwipeBackground);
|
||||||
mSwipeableContent = (ViewGroup) findViewById(R.id.swipeableContent);
|
mSwipeableContent = (ViewGroup) findViewById(R.id.swipeableContent);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
* Copyright (C) 2024 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -95,30 +96,29 @@ public class MultiSelectActionModeCallback implements Callback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
|
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
|
||||||
switch(menuItem.getItemId()) {
|
int itemId = menuItem.getItemId();
|
||||||
case R.id.action_delete:
|
if (itemId == R.id.action_delete) {
|
||||||
mListener.onActionBarDelete(mSelectedConversations.values());
|
mListener.onActionBarDelete(mSelectedConversations.values());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_archive:
|
} else if (itemId == R.id.action_archive) {
|
||||||
mListener.onActionBarArchive(mSelectedConversations.values(), true);
|
mListener.onActionBarArchive(mSelectedConversations.values(), true);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_unarchive:
|
} else if (itemId == R.id.action_unarchive) {
|
||||||
mListener.onActionBarArchive(mSelectedConversations.values(), false);
|
mListener.onActionBarArchive(mSelectedConversations.values(), false);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_add_contact:
|
} else if (itemId == R.id.action_add_contact) {
|
||||||
Assert.isTrue(mSelectedConversations.size() == 1);
|
Assert.isTrue(mSelectedConversations.size() == 1);
|
||||||
mListener.onActionBarAddContact(mSelectedConversations.valueAt(0));
|
mListener.onActionBarAddContact(mSelectedConversations.valueAt(0));
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_block:
|
} else if (itemId == R.id.action_block) {
|
||||||
Assert.isTrue(mSelectedConversations.size() == 1);
|
Assert.isTrue(mSelectedConversations.size() == 1);
|
||||||
mListener.onActionBarBlock(mSelectedConversations.valueAt(0));
|
mListener.onActionBarBlock(mSelectedConversations.valueAt(0));
|
||||||
return true;
|
return true;
|
||||||
case android.R.id.home:
|
} else if (itemId == android.R.id.home) {
|
||||||
mListener.onActionBarHome();
|
mListener.onActionBarHome();
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -55,15 +55,12 @@ public class PeopleAndOptionsActivity extends BugleActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
case android.R.id.home:
|
// Treat the home press as back press so that when we go back to
|
||||||
// Treat the home press as back press so that when we go back to
|
// ConversationActivity, it doesn't lose its original intent (conversation id etc.)
|
||||||
// ConversationActivity, it doesn't lose its original intent (conversation id etc.)
|
onBackPressed();
|
||||||
onBackPressed();
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,45 +123,41 @@ public class PeopleAndOptionsFragment extends Fragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOptionsItemViewClicked(final PeopleOptionsItemData item) {
|
public void onOptionsItemViewClicked(final PeopleOptionsItemData item) {
|
||||||
switch (item.getItemId()) {
|
if (item.getItemId() == PeopleOptionsItemData.SETTING_NOTIFICATION) {
|
||||||
case PeopleOptionsItemData.SETTING_NOTIFICATION:
|
ArrayList<String> participantsNames = new ArrayList<>();
|
||||||
ArrayList<String> participantsNames = new ArrayList<>();
|
for (ParticipantData participant : mOtherParticipants) {
|
||||||
for (ParticipantData participant : mOtherParticipants) {
|
participantsNames.add(participant.getDisplayName(true));
|
||||||
participantsNames.add(participant.getDisplayName(true));
|
}
|
||||||
}
|
NotificationsUtil.createNotificationChannelGroup(getActivity(),
|
||||||
NotificationsUtil.createNotificationChannelGroup(getActivity(),
|
NotificationsUtil.CONVERSATION_GROUP_NAME,
|
||||||
NotificationsUtil.CONVERSATION_GROUP_NAME,
|
R.string.notification_channel_messages_title);
|
||||||
R.string.notification_channel_messages_title);
|
NotificationsUtil.createNotificationChannel(getActivity(),
|
||||||
NotificationsUtil.createNotificationChannel(getActivity(),
|
mBinding.getData().getConversationId(),
|
||||||
mBinding.getData().getConversationId(),
|
String.join(", ", participantsNames),
|
||||||
String.join(", ", participantsNames),
|
NotificationManager.IMPORTANCE_DEFAULT,
|
||||||
NotificationManager.IMPORTANCE_DEFAULT,
|
NotificationsUtil.CONVERSATION_GROUP_NAME);
|
||||||
NotificationsUtil.CONVERSATION_GROUP_NAME);
|
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||||
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName());
|
||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName());
|
startActivity(intent);
|
||||||
startActivity(intent);
|
} else if (item.getItemId() == PeopleOptionsItemData.SETTING_BLOCKED) {
|
||||||
break;
|
if (item.getOtherParticipant().isBlocked()) {
|
||||||
|
mBinding.getData().setDestinationBlocked(mBinding, false);
|
||||||
case PeopleOptionsItemData.SETTING_BLOCKED:
|
return;
|
||||||
if (item.getOtherParticipant().isBlocked()) {
|
}
|
||||||
mBinding.getData().setDestinationBlocked(mBinding, false);
|
final Resources res = getResources();
|
||||||
break;
|
final Activity activity = getActivity();
|
||||||
}
|
new AlertDialog.Builder(activity)
|
||||||
final Resources res = getResources();
|
.setTitle(res.getString(R.string.block_confirmation_title,
|
||||||
final Activity activity = getActivity();
|
item.getOtherParticipant().getDisplayDestination()))
|
||||||
new AlertDialog.Builder(activity)
|
.setMessage(res.getString(R.string.block_confirmation_message))
|
||||||
.setTitle(res.getString(R.string.block_confirmation_title,
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
item.getOtherParticipant().getDisplayDestination()))
|
.setPositiveButton(android.R.string.ok, (arg0, arg1) -> {
|
||||||
.setMessage(res.getString(R.string.block_confirmation_message))
|
mBinding.getData().setDestinationBlocked(mBinding, true);
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
activity.setResult(ConversationActivity.FINISH_RESULT_CODE);
|
||||||
.setPositiveButton(android.R.string.ok, (arg0, arg1) -> {
|
activity.finish();
|
||||||
mBinding.getData().setDestinationBlocked(mBinding, true);
|
})
|
||||||
activity.setResult(ConversationActivity.FINISH_RESULT_CODE);
|
.create()
|
||||||
activity.finish();
|
.show();
|
||||||
})
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class PeopleOptionsItemView extends LinearLayout {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate () {
|
protected void onFinishInflate () {
|
||||||
|
super.onFinishInflate();
|
||||||
mTitle = (TextView) findViewById(R.id.title);
|
mTitle = (TextView) findViewById(R.id.title);
|
||||||
setOnClickListener(v -> mHostInterface.onOptionsItemViewClicked(mData));
|
setOnClickListener(v -> mHostInterface.onOptionsItemViewClicked(mData));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,16 +122,15 @@ public class AudioRecordView extends FrameLayout implements
|
|||||||
mSoundLevels.setLevelSource(mMediaRecorder.getLevelSource());
|
mSoundLevels.setLevelSource(mMediaRecorder.getLevelSource());
|
||||||
mRecordButton.setOnTouchListener((v, event) -> {
|
mRecordButton.setOnTouchListener((v, event) -> {
|
||||||
final int action = event.getActionMasked();
|
final int action = event.getActionMasked();
|
||||||
switch (action) {
|
if (action == MotionEvent.ACTION_DOWN) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
onRecordButtonTouchDown();
|
||||||
onRecordButtonTouchDown();
|
|
||||||
|
|
||||||
// Don't let the record button handle the down event to let it fall through
|
// Don't let the record button handle the down event to let it fall through
|
||||||
// so that we can handle it for the entire panel in onTouchEvent(). This is
|
// so that we can handle it for the entire panel in onTouchEvent(). This is
|
||||||
// done so that: 1) the user taps on the record button to start recording
|
// done so that: 1) the user taps on the record button to start recording
|
||||||
// 2) the entire panel owns the touch event so we'd keep recording even
|
// 2) the entire panel owns the touch event so we'd keep recording even
|
||||||
// if the user moves outside the button region.
|
// if the user moves outside the button region.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.graphics.Point;
|
|||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
@@ -115,7 +116,7 @@ public class PieRenderer extends OverlayRenderer
|
|||||||
private LinearAnimation mFadeIn;
|
private LinearAnimation mFadeIn;
|
||||||
private volatile boolean mFocusCancelled;
|
private volatile boolean mFocusCancelled;
|
||||||
|
|
||||||
private final Handler mHandler = new Handler() {
|
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch(msg.what) {
|
switch(msg.what) {
|
||||||
case MSG_OPEN:
|
case MSG_OPEN:
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ public class Dates {
|
|||||||
flags = FORCE_12_HOUR;
|
flags = FORCE_12_HOUR;
|
||||||
}
|
}
|
||||||
return getOlderThanAYearTimestamp(time,
|
return getOlderThanAYearTimestamp(time,
|
||||||
context.getResources().getConfiguration().locale, false /*abbreviated*/,
|
context.getResources().getConfiguration().getLocales().get(0),
|
||||||
flags);
|
false /*abbreviated*/, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CharSequence getTimeString(final long time, final boolean abbreviated,
|
private static CharSequence getTimeString(final long time, final boolean abbreviated,
|
||||||
@@ -124,7 +124,8 @@ public class Dates {
|
|||||||
flags = FORCE_12_HOUR;
|
flags = FORCE_12_HOUR;
|
||||||
}
|
}
|
||||||
return getTimestamp(time, System.currentTimeMillis(), abbreviated,
|
return getTimestamp(time, System.currentTimeMillis(), abbreviated,
|
||||||
context.getResources().getConfiguration().locale, flags, minPeriodToday);
|
context.getResources().getConfiguration().getLocales().get(0), flags,
|
||||||
|
minPeriodToday);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
* Copyright (C) 2024 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +22,6 @@ import android.content.Context;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.android.messaging.Factory;
|
import com.android.messaging.Factory;
|
||||||
import com.android.messaging.R;
|
import com.android.messaging.R;
|
||||||
@@ -39,7 +39,8 @@ public class FileUtil {
|
|||||||
private static synchronized File getNewFile(File directory, String extension,
|
private static synchronized File getNewFile(File directory, String extension,
|
||||||
String fileNameFormat) throws IOException {
|
String fileNameFormat) throws IOException {
|
||||||
final Date date = new Date(System.currentTimeMillis());
|
final Date date = new Date(System.currentTimeMillis());
|
||||||
final SimpleDateFormat dateFormat = new SimpleDateFormat(fileNameFormat);
|
final SimpleDateFormat dateFormat = new SimpleDateFormat(fileNameFormat,
|
||||||
|
Locale.getDefault(Locale.Category.FORMAT));
|
||||||
final String numberedFileNameFormat = dateFormat.format(date) + "_%02d" + "." + extension;
|
final String numberedFileNameFormat = dateFormat.format(date) + "_%02d" + "." + extension;
|
||||||
for (int i = 1; i <= 99; i++) { // Only save 99 of the same file name.
|
for (int i = 1; i <= 99; i++) { // Only save 99 of the same file name.
|
||||||
final String newName = String.format(Locale.US, numberedFileNameFormat, i);
|
final String newName = String.format(Locale.US, numberedFileNameFormat, i);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.messaging.util;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
import android.media.AudioAttributes;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
|
|
||||||
@@ -37,7 +38,9 @@ public class MediaUtilImpl extends MediaUtil {
|
|||||||
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
try {
|
try {
|
||||||
final MediaPlayer mediaPlayer = new MediaPlayer();
|
final MediaPlayer mediaPlayer = new MediaPlayer();
|
||||||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
|
AudioAttributes.Builder attributes = new AudioAttributes.Builder();
|
||||||
|
attributes.setLegacyStreamType(AudioManager.STREAM_NOTIFICATION);
|
||||||
|
mediaPlayer.setAudioAttributes(attributes.build());
|
||||||
final AssetFileDescriptor afd = context.getResources().openRawResourceFd(resId);
|
final AssetFileDescriptor afd = context.getResources().openRawResourceFd(resId);
|
||||||
mediaPlayer.setDataSource(
|
mediaPlayer.setDataSource(
|
||||||
afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
|
afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package com.android.messaging.util;
|
package com.android.messaging.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioAttributes;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.media.MediaPlayer.OnCompletionListener;
|
import android.media.MediaPlayer.OnCompletionListener;
|
||||||
@@ -92,7 +93,9 @@ public class NotificationPlayer implements OnCompletionListener {
|
|||||||
.getSystemService(Context.AUDIO_SERVICE);
|
.getSystemService(Context.AUDIO_SERVICE);
|
||||||
try {
|
try {
|
||||||
final MediaPlayer player = new MediaPlayer();
|
final MediaPlayer player = new MediaPlayer();
|
||||||
player.setAudioStreamType(mCmd.stream);
|
AudioAttributes.Builder attributes = new AudioAttributes.Builder();
|
||||||
|
attributes.setLegacyStreamType(mCmd.stream);
|
||||||
|
player.setAudioAttributes(attributes.build());
|
||||||
player.setDataSource(Factory.get().getApplicationContext(), mCmd.uri);
|
player.setDataSource(Factory.get().getApplicationContext(), mCmd.uri);
|
||||||
player.setLooping(mCmd.looping);
|
player.setLooping(mCmd.looping);
|
||||||
player.setVolume(mCmd.volume, mCmd.volume);
|
player.setVolume(mCmd.volume, mCmd.volume);
|
||||||
|
|||||||
@@ -40,13 +40,11 @@ import com.android.messaging.Factory;
|
|||||||
import com.android.messaging.R;
|
import com.android.messaging.R;
|
||||||
import com.android.messaging.datamodel.data.ParticipantData;
|
import com.android.messaging.datamodel.data.ParticipantData;
|
||||||
import com.android.messaging.sms.MmsSmsUtils;
|
import com.android.messaging.sms.MmsSmsUtils;
|
||||||
|
|
||||||
import com.google.i18n.phonenumbers.NumberParseException;
|
import com.google.i18n.phonenumbers.NumberParseException;
|
||||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||||
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
|
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
|
||||||
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
|
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -297,19 +295,7 @@ public class PhoneUtils {
|
|||||||
* @return true if mobile data is enabled, false otherwise
|
* @return true if mobile data is enabled, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isMobileDataEnabled() {
|
public boolean isMobileDataEnabled() {
|
||||||
boolean mobileDataEnabled = false;
|
return mTelephonyManager.createForSubscriptionId(mSubId).isDataEnabled();
|
||||||
try {
|
|
||||||
final Class cmClass = mTelephonyManager.getClass();
|
|
||||||
final Method method = cmClass.getDeclaredMethod("getDataEnabled", Integer.TYPE);
|
|
||||||
method.setAccessible(true); // Make the method callable
|
|
||||||
// get the setting for "mobile data"
|
|
||||||
mobileDataEnabled = (Boolean) method.invoke(
|
|
||||||
mTelephonyManager, Integer.valueOf(mSubId));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
LogUtil.e(TAG, "PhoneUtil.isMobileDataEnabled: system api not found", e);
|
|
||||||
}
|
|
||||||
return mobileDataEnabled;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user