Skip to content

Commit 8caaf05

Browse files
Remove unnecessary pre-19 code branches.
Now that our minSdk is 19, we can remove a lot of old code paths that only ran pre-19.
1 parent a52c295 commit 8caaf05

Some content is hidden

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

42 files changed

+127
-389
lines changed

src/org/thoughtcrime/securesms/BaseActionBarActivity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
5252
}
5353

5454
private void initializeScreenshotSecurity() {
55-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
56-
TextSecurePreferences.isScreenSecurityEnabled(this))
57-
{
55+
if (TextSecurePreferences.isScreenSecurityEnabled(this)) {
5856
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
5957
} else {
6058
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);

src/org/thoughtcrime/securesms/ContactSelectionListFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
135135
showContactsProgress = view.findViewById(R.id.progress);
136136
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
137137

138-
swipeRefresh.setEnabled(getActivity().getIntent().getBooleanExtra(REFRESHABLE, true) &&
139-
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN);
138+
swipeRefresh.setEnabled(getActivity().getIntent().getBooleanExtra(REFRESHABLE, true));
140139

141140
return view;
142141
}

src/org/thoughtcrime/securesms/ConversationListFragment.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,15 @@
7171
import org.thoughtcrime.securesms.components.reminder.ShareReminder;
7272
import org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder;
7373
import org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder;
74-
import org.thoughtcrime.securesms.components.reminder.UnsupportedAndroidVersionReminder;
7574
import org.thoughtcrime.securesms.database.DatabaseFactory;
7675
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
7776
import org.thoughtcrime.securesms.database.loaders.ConversationListLoader;
7877
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
7978
import org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob;
80-
import org.thoughtcrime.securesms.logging.Log;
8179
import org.thoughtcrime.securesms.mms.GlideApp;
8280
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
8381
import org.thoughtcrime.securesms.notifications.MessageNotifier;
8482
import org.thoughtcrime.securesms.recipients.Recipient;
85-
import org.thoughtcrime.securesms.util.TextSecurePreferences;
8683
import org.thoughtcrime.securesms.util.Util;
8784
import org.thoughtcrime.securesms.util.ViewUtil;
8885
import org.thoughtcrime.securesms.util.task.SnackbarAsyncTask;
@@ -202,8 +199,6 @@ protected Optional<? extends Reminder> doInBackground(Context... params) {
202199
final Context context = params[0];
203200
if (UnauthorizedReminder.isEligible(context)) {
204201
return Optional.of(new UnauthorizedReminder(context));
205-
} else if (UnsupportedAndroidVersionReminder.isEligible()) {
206-
return Optional.of(new UnsupportedAndroidVersionReminder(context));
207202
} else if (ExpiredBuildReminder.isEligible()) {
208203
return Optional.of(new ExpiredBuildReminder(context));
209204
} else if (ServiceOutageReminder.isEligible(context)) {

src/org/thoughtcrime/securesms/PassphrasePromptActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,13 @@ private void resumeScreenLock() {
262262

263263
assert keyguardManager != null;
264264

265-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && !keyguardManager.isKeyguardSecure()) {
265+
if (!keyguardManager.isKeyguardSecure()) {
266266
Log.w(TAG ,"Keyguard not secure...");
267267
handleAuthenticated();
268268
return;
269269
}
270270

271-
if (Build.VERSION.SDK_INT >= 16 && fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
271+
if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
272272
Log.i(TAG, "Listening for fingerprints...");
273273
fingerprintCancellationSignal = new CancellationSignal();
274274
fingerprintManager.authenticate(null, 0, fingerprintCancellationSignal, fingerprintListener, null);
@@ -283,7 +283,7 @@ private void resumeScreenLock() {
283283
}
284284

285285
private void pauseScreenLock() {
286-
if (Build.VERSION.SDK_INT >= 16 && fingerprintCancellationSignal != null) {
286+
if (fingerprintCancellationSignal != null) {
287287
fingerprintCancellationSignal.cancel();
288288
}
289289
}

src/org/thoughtcrime/securesms/VerifyIdentityActivity.java

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -483,30 +483,26 @@ private void setFingerprintViews(Fingerprint fingerprint, boolean animate) {
483483
}
484484

485485
private void setCodeSegment(final TextView codeView, String segment) {
486-
if (Build.VERSION.SDK_INT >= 11) {
487-
ValueAnimator valueAnimator = new ValueAnimator();
488-
valueAnimator.setObjectValues(0, Integer.parseInt(segment));
489-
490-
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
491-
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
492-
@Override
493-
public void onAnimationUpdate(ValueAnimator animation) {
494-
int value = (int) animation.getAnimatedValue();
495-
codeView.setText(String.format("%05d", value));
496-
}
497-
});
486+
ValueAnimator valueAnimator = new ValueAnimator();
487+
valueAnimator.setObjectValues(0, Integer.parseInt(segment));
498488

499-
valueAnimator.setEvaluator(new TypeEvaluator<Integer>() {
500-
public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
501-
return Math.round(startValue + (endValue - startValue) * fraction);
502-
}
503-
});
489+
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
490+
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
491+
@Override
492+
public void onAnimationUpdate(ValueAnimator animation) {
493+
int value = (int) animation.getAnimatedValue();
494+
codeView.setText(String.format("%05d", value));
495+
}
496+
});
504497

505-
valueAnimator.setDuration(1000);
506-
valueAnimator.start();
507-
} else {
508-
codeView.setText(segment);
509-
}
498+
valueAnimator.setEvaluator(new TypeEvaluator<Integer>() {
499+
public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
500+
return Math.round(startValue + (endValue - startValue) * fraction);
501+
}
502+
});
503+
504+
valueAnimator.setDuration(1000);
505+
valueAnimator.start();
510506
}
511507

512508
private String[] getSegments(Fingerprint fingerprint, int segmentCount) {

src/org/thoughtcrime/securesms/WebRtcCallActivity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
121121
}
122122

123123
private void initializeScreenshotSecurity() {
124-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
125-
TextSecurePreferences.isScreenSecurityEnabled(this))
126-
{
124+
if (TextSecurePreferences.isScreenSecurityEnabled(this)) {
127125
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
128126
} else {
129127
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);

src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ public AttachmentTypeSelector(@NonNull Context context, @NonNull LoaderManager l
8787
this.closeButton.setOnClickListener(new CloseClickListener());
8888
this.recentRail.setListener(new RecentPhotoSelectedListener());
8989

90-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
91-
ViewUtil.findById(layout, R.id.location_linear_layout).setVisibility(View.INVISIBLE);
92-
}
93-
9490
setContentView(layout);
9591
setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
9692
setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);

src/org/thoughtcrime/securesms/components/AudioView.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ public void setTint(int foregroundTint, int backgroundTint) {
218218

219219
this.timestamp.setTextColor(foregroundTint);
220220
this.seekBar.getProgressDrawable().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
221-
222-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
223-
this.seekBar.getThumb().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
224-
}
221+
this.seekBar.getThumb().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
225222
}
226223

227224
private double getProgress() {

src/org/thoughtcrime/securesms/components/ConversationItemThumbnail.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,9 @@ private void init(@Nullable AttributeSet attrs) {
7373
@SuppressWarnings("SuspiciousNameCombination")
7474
@Override
7575
protected void dispatchDraw(Canvas canvas) {
76-
if (cornerMask.isLegacy()) {
77-
cornerMask.mask(canvas);
78-
}
79-
8076
super.dispatchDraw(canvas);
8177

82-
if (!cornerMask.isLegacy()) {
83-
cornerMask.mask(canvas);
84-
}
78+
cornerMask.mask(canvas);
8579

8680
if (album.getVisibility() != VISIBLE) {
8781
outliner.draw(canvas);

src/org/thoughtcrime/securesms/components/CornerMask.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ public class CornerMask {
2020
private final RectF bounds = new RectF();
2121

2222
public CornerMask(@NonNull View view) {
23-
if (isLegacy()) {
24-
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
25-
} else {
26-
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
27-
}
23+
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
2824

2925
clearPaint.setColor(Color.BLACK);
3026
clearPaint.setStyle(Paint.Style.FILL);
@@ -42,21 +38,12 @@ public void mask(Canvas canvas) {
4238
corners.addRoundRect(bounds, radii, Path.Direction.CW);
4339

4440
// Note: There's a bug in the P beta where most PorterDuff modes aren't working. But CLEAR does.
45-
// So we find and inverse path and use Mode.CLEAR for versions that support Path.op().
41+
// So we find and inverse path and use Mode.CLEAR.
4642
// See issue https://issuetracker.google.com/issues/111394085.
47-
if (!isLegacy()) {
48-
outline.reset();
49-
outline.addRect(bounds, Path.Direction.CW);
50-
outline.op(corners, Path.Op.DIFFERENCE);
51-
canvas.drawPath(outline, clearPaint);
52-
} else {
53-
corners.addRoundRect(bounds, radii, Path.Direction.CW);
54-
canvas.clipPath(corners);
55-
}
56-
}
57-
58-
public boolean isLegacy() {
59-
return Build.VERSION.SDK_INT < 19;
43+
outline.reset();
44+
outline.addRect(bounds, Path.Direction.CW);
45+
outline.op(corners, Path.Op.DIFFERENCE);
46+
canvas.drawPath(outline, clearPaint);
6047
}
6148

6249
public void setRadius(int radius) {

0 commit comments

Comments
 (0)