Skip to content

Commit 62a9956

Browse files
committed
Merge remote-tracking branch 'upstream/master' into cust_remove_call_confirm
2 parents 404a06f + d24a71b commit 62a9956

63 files changed

Lines changed: 2331 additions & 78 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ protobuf {
5555
}
5656
}
5757

58-
def canonicalVersionCode = 799
59-
def canonicalVersionName = "5.5.0"
58+
def canonicalVersionCode = 800
59+
def canonicalVersionName = "5.5.1"
6060

6161
def postFixSize = 100
6262
def abiPostFix = ['universal' : 0,

app/src/main/java/org/thoughtcrime/securesms/contacts/sync/ContactHolder.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
package org.thoughtcrime.securesms.contacts.sync;
22

3+
import android.net.Uri;
4+
35
import androidx.annotation.NonNull;
6+
import androidx.annotation.Nullable;
47

8+
import org.signal.core.util.logging.Log;
59
import org.thoughtcrime.securesms.database.RecipientDatabase;
610
import org.thoughtcrime.securesms.profiles.ProfileName;
11+
import org.whispersystems.libsignal.util.guava.Optional;
712

813
import java.util.LinkedList;
914
import java.util.List;
1015

1116
final class ContactHolder {
1217

18+
private static final String TAG = Log.tag(ContactHolder.class);
19+
1320
private final String lookupKey;
1421
private final List<PhoneNumberRecord> phoneNumberRecords = new LinkedList<>();
1522

@@ -38,16 +45,18 @@ void commit(@NonNull RecipientDatabase.BulkOperationsHandle handle) {
3845
phoneNumberRecord.getContactPhotoUri(),
3946
phoneNumberRecord.getContactLabel(),
4047
phoneNumberRecord.getPhoneType(),
41-
phoneNumberRecord.getContactUri().toString());
48+
Optional.fromNullable(phoneNumberRecord.getContactUri()).transform(Uri::toString).orNull());
4249
}
4350
}
4451

45-
private @NonNull ProfileName getProfileName(@NonNull String displayName) {
46-
if (structuredNameRecord.hasGivenName()) {
52+
private @NonNull ProfileName getProfileName(@Nullable String displayName) {
53+
if (structuredNameRecord != null && structuredNameRecord.hasGivenName()) {
4754
return structuredNameRecord.asProfileName();
48-
} else {
55+
} else if (displayName != null) {
4956
return ProfileName.asGiven(displayName);
57+
} else {
58+
Log.w(TAG, "Failed to find a suitable display name!");
59+
return ProfileName.EMPTY;
5060
}
5161
}
52-
5362
}

app/src/main/java/org/thoughtcrime/securesms/contacts/sync/DirectoryHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private static void updateContactsDatabase(@NonNull Context context,
334334
Log.w(TAG, "Ignoring unexpected mime type: " + mimeType);
335335
}
336336

337-
while (getLookupKey(cursor).equals(lookupKey) && isPhoneMimeType(getMimeType(cursor))) {
337+
while (!cursor.isAfterLast() && getLookupKey(cursor).equals(lookupKey) && isPhoneMimeType(getMimeType(cursor))) {
338338
String number = CursorUtil.requireString(cursor, ContactsContract.CommonDataKinds.Phone.NUMBER);
339339

340340
if (isValidContactNumber(number)) {
@@ -359,7 +359,7 @@ private static void updateContactsDatabase(@NonNull Context context,
359359
cursor.moveToNext();
360360
}
361361

362-
if (getLookupKey(cursor).equals(lookupKey)) {
362+
if (!cursor.isAfterLast() && getLookupKey(cursor).equals(lookupKey)) {
363363
if (isStructuredNameMimeType(getMimeType(cursor))) {
364364
StructuredNameRecord.Builder builder = new StructuredNameRecord.Builder();
365365

app/src/main/java/org/thoughtcrime/securesms/help/HelpFragment.java

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
import android.view.LayoutInflater;
77
import android.view.View;
88
import android.view.ViewGroup;
9+
import android.widget.AdapterView;
10+
import android.widget.ArrayAdapter;
911
import android.widget.CheckBox;
1012
import android.widget.EditText;
13+
import android.widget.Spinner;
1114
import android.widget.Toast;
1215

1316
import androidx.annotation.IdRes;
@@ -32,14 +35,16 @@
3235

3336
public class HelpFragment extends LoggingFragment {
3437

35-
private EditText problem;
36-
private CheckBox includeDebugLogs;
37-
private View debugLogInfo;
38-
private View faq;
39-
private CircularProgressButton next;
40-
private View toaster;
41-
private List<EmojiImageView> emoji;
42-
private HelpViewModel helpViewModel;
38+
private EditText problem;
39+
private CheckBox includeDebugLogs;
40+
private View debugLogInfo;
41+
private View faq;
42+
private CircularProgressButton next;
43+
private View toaster;
44+
private List<EmojiImageView> emoji;
45+
private HelpViewModel helpViewModel;
46+
private Spinner categorySpinner;
47+
private ArrayAdapter<CharSequence> categoryAdapter;
4348

4449
@Override
4550
public @Nullable View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -57,7 +62,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
5762
@Override
5863
public void onResume() {
5964
super.onResume();
60-
((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.preferences__help);
65+
((ApplicationPreferencesActivity) requireActivity()).requireSupportActionBar().setTitle(R.string.preferences__help);
6166

6267
cancelSpinning(next);
6368
problem.setEnabled(true);
@@ -74,13 +79,19 @@ private void initializeViews(@NonNull View view) {
7479
faq = view.findViewById(R.id.help_fragment_faq);
7580
next = view.findViewById(R.id.help_fragment_next);
7681
toaster = view.findViewById(R.id.help_fragment_next_toaster);
82+
categorySpinner = view.findViewById(R.id.help_fragment_category);
7783
emoji = new ArrayList<>(Feeling.values().length);
7884

7985
for (Feeling feeling : Feeling.values()) {
8086
EmojiImageView emojiView = view.findViewById(feeling.getViewId());
8187
emojiView.setImageEmoji(feeling.getEmojiCode());
8288
emoji.add(view.findViewById(feeling.getViewId()));
8389
}
90+
91+
categoryAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.HelpFragment__categories, android.R.layout.simple_spinner_item);
92+
categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
93+
94+
categorySpinner.setAdapter(categoryAdapter);
8495
}
8596

8697
private void initializeListeners() {
@@ -90,6 +101,16 @@ private void initializeListeners() {
90101
debugLogInfo.setOnClickListener(v -> launchDebugLogInfo());
91102
next.setOnClickListener(v -> submitForm());
92103
toaster.setOnClickListener(v -> Toast.makeText(requireContext(), R.string.HelpFragment__please_be_as_descriptive_as_possible, Toast.LENGTH_LONG).show());
104+
categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
105+
@Override
106+
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
107+
helpViewModel.onCategorySelected(position);
108+
}
109+
110+
@Override
111+
public void onNothingSelected(AdapterView<?> parent) {
112+
}
113+
});
93114
}
94115

95116
private void initializeObservers() {
@@ -144,6 +165,7 @@ private void submitFormWithDebugLog(@Nullable String debugLog) {
144165
.map(view -> Feeling.getByViewId(view.getId()))
145166
.findFirst().orElse(null);
146167

168+
147169
CommunicationActions.openEmail(requireContext(),
148170
SupportEmailUtil.getSupportEmailAddress(requireContext()),
149171
getEmailSubject(),
@@ -171,8 +193,11 @@ private String getEmailBody(@Nullable String debugLog, @Nullable Feeling feeling
171193
suffix.append(getString(feeling.getStringId()));
172194
}
173195

196+
String category = categoryAdapter.getItem(helpViewModel.getCategoryIndex()).toString();
197+
174198
return SupportEmailUtil.generateSupportEmailBody(requireContext(),
175199
R.string.HelpFragment__signal_android_support_request,
200+
" - " + category,
176201
problem.getText().toString() + "\n\n",
177202
suffix.toString());
178203
}

app/src/main/java/org/thoughtcrime/securesms/help/HelpViewModel.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class HelpViewModel extends ViewModel {
2121
private MutableLiveData<Boolean> problemMeetsLengthRequirements = new MutableLiveData<>();
2222
private MutableLiveData<Boolean> hasLines = new MutableLiveData<>(false);
2323
private LiveData<Boolean> isFormValid = Transformations.map(new LiveDataPair<>(problemMeetsLengthRequirements, hasLines), this::transformValidationData);
24+
private int categoryIndex = 0;
2425

2526
private final SubmitDebugLogRepository submitDebugLogRepository;
2627

@@ -43,6 +44,14 @@ void onProblemChanged(@NonNull String problem) {
4344
problemMeetsLengthRequirements.setValue(problem.length() >= MINIMUM_PROBLEM_CHARS);
4445
}
4546

47+
void onCategorySelected(int index) {
48+
this.categoryIndex = index;
49+
}
50+
51+
int getCategoryIndex() {
52+
return this.categoryIndex;
53+
}
54+
4655
LiveData<SubmitResult> onSubmitClicked(boolean includeDebugLogs) {
4756
MutableLiveData<SubmitResult> resultLiveData = new MutableLiveData<>();
4857

app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public static long getServerErrorMaxBackoff() {
322322

323323
/** Whether or not to allow automatic retries from OkHttp */
324324
public static boolean okHttpAutomaticRetry() {
325-
return getBoolean(OKHTTP_AUTOMATIC_RETRY, false);
325+
return getBoolean(OKHTTP_AUTOMATIC_RETRY, true);
326326
}
327327

328328
/** The minimum memory class required for rendering animated stickers in the keyboard and such */

app/src/main/java/org/thoughtcrime/securesms/util/SupportEmailUtil.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,35 @@ private SupportEmailUtil() { }
2727
* Generates a support email body with system info near the top.
2828
*/
2929
public static @NonNull String generateSupportEmailBody(@NonNull Context context,
30-
@StringRes int subject,
30+
@StringRes int filter,
3131
@Nullable String prefix,
3232
@Nullable String suffix)
3333
{
34-
prefix = Util.firstNonNull(prefix, "");
35-
suffix = Util.firstNonNull(suffix, "");
36-
return String.format("%s\n%s\n%s", prefix, buildSystemInfo(context, subject), suffix);
34+
return generateSupportEmailBody(context, filter, null, prefix, suffix);
3735
}
3836

39-
private static @NonNull String buildSystemInfo(@NonNull Context context, @StringRes int subject) {
37+
/**
38+
* Generates a support email body with system info near the top.
39+
*/
40+
public static @NonNull String generateSupportEmailBody(@NonNull Context context,
41+
@StringRes int filter,
42+
@Nullable String filterSuffix,
43+
@Nullable String prefix,
44+
@Nullable String suffix)
45+
{
46+
filterSuffix = Util.emptyIfNull(filterSuffix);
47+
prefix = Util.emptyIfNull(prefix);
48+
suffix = Util.emptyIfNull(suffix);
49+
50+
return String.format("%s\n%s\n%s", prefix, buildSystemInfo(context, filter, filterSuffix), suffix);
51+
}
52+
53+
private static @NonNull String buildSystemInfo(@NonNull Context context, @StringRes int filter, @NonNull String filterSuffix) {
4054
Resources englishResources = ResourceUtil.getEnglishResources(context);
4155

4256
return "--- " + context.getString(R.string.HelpFragment__support_info) + " ---" +
4357
"\n" +
44-
context.getString(R.string.SupportEmailUtil_filter) + " " + englishResources.getString(subject) +
58+
context.getString(R.string.SupportEmailUtil_filter) + " " + englishResources.getString(filter) + filterSuffix +
4559
"\n" +
4660
context.getString(R.string.SupportEmailUtil_device_info) + " " + getDeviceInfo() +
4761
"\n" +

app/src/main/res/layout/help_fragment.xml

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,48 +54,43 @@
5454
app:layout_constraintStart_toStartOf="parent"
5555
app:layout_constraintTop_toBottomOf="@id/help_fragment_contact" />
5656

57-
<CheckBox
58-
android:id="@+id/help_fragment_debug"
59-
android:layout_width="wrap_content"
60-
android:layout_height="0dp"
57+
<TextView
58+
android:id="@+id/help_fragment_category_title"
59+
android:layout_width="match_parent"
60+
android:layout_height="wrap_content"
6161
android:layout_marginStart="16dp"
62-
android:checked="true"
63-
android:text="@string/HelpFragment__include_debug_log"
62+
android:layout_marginTop="16dp"
63+
android:layout_marginEnd="16dp"
64+
android:text="@string/HelpFragment__tell_us_why_youre_reaching_out"
65+
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
6466
android:textColor="@color/signal_text_secondary"
65-
android:textSize="14sp"
66-
app:layout_constraintBottom_toBottomOf="@id/help_fragment_debug_info"
67+
app:layout_constraintEnd_toEndOf="parent"
6768
app:layout_constraintStart_toStartOf="parent"
68-
app:layout_constraintTop_toTopOf="@id/help_fragment_debug_info" />
69+
app:layout_constraintTop_toBottomOf="@id/help_fragment_problem" />
6970

70-
<Button
71-
android:id="@+id/help_fragment_debug_info"
72-
style="@style/Button.Borderless"
71+
<Spinner
72+
android:id="@+id/help_fragment_category"
7373
android:layout_width="wrap_content"
7474
android:layout_height="wrap_content"
75-
android:layout_marginStart="2dp"
76-
android:background="@android:color/transparent"
77-
android:text="@string/HelpFragment__whats_this"
78-
android:textAllCaps="false"
79-
android:textAppearance="@style/Signal.Text.Body"
80-
android:textSize="14sp"
81-
app:layout_constraintEnd_toEndOf="parent"
82-
app:layout_constraintHorizontal_bias="0"
83-
app:layout_constraintStart_toEndOf="@id/help_fragment_debug"
84-
app:layout_constraintTop_toBottomOf="@id/help_fragment_problem" />
75+
android:layout_marginTop="8dp"
76+
android:layout_marginStart="16dp"
77+
android:layout_marginEnd="16dp"
78+
app:layout_constraintTop_toBottomOf="@id/help_fragment_category_title"
79+
app:layout_constraintStart_toStartOf="parent"/>
8580

8681
<TextView
8782
android:id="@+id/help_fragment_feelings"
8883
android:layout_width="match_parent"
8984
android:layout_height="wrap_content"
9085
android:layout_marginStart="16dp"
91-
android:layout_marginTop="8dp"
86+
android:layout_marginTop="16dp"
9287
android:layout_marginEnd="16dp"
9388
android:text="@string/HelpFragment__how_do_you_feel"
9489
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
9590
android:textColor="@color/signal_text_secondary"
9691
app:layout_constraintEnd_toEndOf="parent"
9792
app:layout_constraintStart_toStartOf="parent"
98-
app:layout_constraintTop_toBottomOf="@id/help_fragment_debug_info" />
93+
app:layout_constraintTop_toBottomOf="@id/help_fragment_category" />
9994

10095
<org.thoughtcrime.securesms.components.emoji.EmojiImageView
10196
android:id="@+id/help_fragment_emoji_5"
@@ -170,6 +165,37 @@
170165
app:layout_constraintStart_toEndOf="@id/help_fragment_emoji_2"
171166
app:layout_constraintTop_toTopOf="@id/help_fragment_emoji_2" />
172167

168+
<CheckBox
169+
android:id="@+id/help_fragment_debug"
170+
android:layout_width="wrap_content"
171+
android:layout_height="0dp"
172+
android:layout_marginStart="16dp"
173+
android:checked="true"
174+
android:text="@string/HelpFragment__include_debug_log"
175+
android:textColor="@color/signal_text_secondary"
176+
android:textSize="14sp"
177+
app:layout_constraintBottom_toBottomOf="@id/help_fragment_debug_info"
178+
app:layout_constraintStart_toStartOf="parent"
179+
app:layout_constraintTop_toTopOf="@id/help_fragment_debug_info" />
180+
181+
<Button
182+
android:id="@+id/help_fragment_debug_info"
183+
style="@style/Button.Borderless"
184+
android:layout_width="wrap_content"
185+
android:layout_height="wrap_content"
186+
android:layout_marginStart="2dp"
187+
android:layout_marginTop="16dp"
188+
android:background="@android:color/transparent"
189+
android:text="@string/HelpFragment__whats_this"
190+
android:textAllCaps="false"
191+
android:textAppearance="@style/Signal.Text.Body"
192+
android:textSize="14sp"
193+
app:layout_constraintEnd_toEndOf="parent"
194+
app:layout_constraintHorizontal_bias="0"
195+
app:layout_constraintStart_toEndOf="@id/help_fragment_debug"
196+
app:layout_constraintTop_toBottomOf="@id/help_fragment_emoji_1" />
197+
198+
173199
</androidx.constraintlayout.widget.ConstraintLayout>
174200

175201
</ScrollView>

app/src/main/res/values-ar/strings.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,27 @@
26332633
<string name="prompt_passphrase_activity__signal_is_locked">Signal مُقفَل</string>
26342634
<string name="prompt_passphrase_activity__tap_to_unlock">أنقُر لفك القُفل</string>
26352635
<string name="Recipient_unknown">مجهول</string>
2636+
<!--TransferOrRestoreFragment-->
2637+
<!--NewDeviceTransferInstructionsFragment-->
2638+
<string name="NewDeviceTransferInstructions__continue">الاِستِمرار</string>
2639+
<!--NewDeviceTransferSetupFragment-->
2640+
<!--OldDeviceTransferSetupFragment-->
2641+
<!--DeviceTransferSetupFragment-->
2642+
<string name="DeviceTransferSetup__retry">إعادة المُحاولة</string>
2643+
<string name="DeviceTransferSetup__continue">الاِستِمرار</string>
2644+
<string name="DeviceTransferSetup__wifi">الـWi-Fi</string>
2645+
<string name="DeviceTransferSetup__try_again">حاول مجدداً</string>
2646+
<!--NewDeviceTransferFragment-->
2647+
<!--DeviceTransferFragment-->
2648+
<string name="DeviceTransfer__cancel">إلغاء</string>
2649+
<string name="DeviceTransfer__try_again">حاول مجدداً</string>
2650+
<!--OldDeviceTransferInstructionsFragment-->
2651+
<string name="OldDeviceTransferInstructions__transfer_account">نقل الحساب</string>
2652+
<string name="OldDeviceTransferInstructions__continue">الاِستِمرار</string>
2653+
<!--OldDeviceTransferComplete-->
2654+
<string name="OldDeviceTransferComplete__close">إغلاق</string>
2655+
<!--NewDeviceTransferComplete-->
2656+
<!--DeviceToDeviceTransferService-->
26362657
<!--RecipientBottomSheet-->
26372658
<string name="RecipientBottomSheet_block">حظر</string>
26382659
<string name="RecipientBottomSheet_unblock">رفع الحظر</string>

0 commit comments

Comments
 (0)