Fix a bunch of deprecations

pull/604/head
TacoTheDank 5 years ago
parent f50ff35cb1
commit 37f55d0a95

@ -95,7 +95,7 @@ open class AndroidBugReporter @Inject constructor(@AppContext private val contex
appendln("App Version Name: ${BuildConfig.VERSION_NAME}") appendln("App Version Name: ${BuildConfig.VERSION_NAME}")
appendln("App Version Code: ${BuildConfig.VERSION_CODE}") appendln("App Version Code: ${BuildConfig.VERSION_CODE}")
appendln("OS Version: ${System.getProperty("os.version")} (${Build.VERSION.INCREMENTAL})") appendln("OS Version: ${System.getProperty("os.version")} (${Build.VERSION.INCREMENTAL})")
appendln("OS API Level: ${Build.VERSION.SDK}") appendln("OS API Level: ${Build.VERSION.SDK_INT}")
appendln("Device: ${Build.DEVICE}") appendln("Device: ${Build.DEVICE}")
appendln("Model (Product): ${Build.MODEL} (${Build.PRODUCT})") appendln("Model (Product): ${Build.MODEL} (${Build.PRODUCT})")
appendln("Manufacturer: ${Build.MANUFACTURER}") appendln("Manufacturer: ${Build.MANUFACTURER}")

@ -18,12 +18,9 @@
*/ */
package org.isoron.androidbase package org.isoron.androidbase
import java.lang.annotation.Documented
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import javax.inject.Qualifier import javax.inject.Qualifier
@Qualifier @Qualifier
@Documented @MustBeDocumented
@Retention(RetentionPolicy.RUNTIME) @Retention(AnnotationRetention.RUNTIME)
annotation class AppContext annotation class AppContext

@ -18,6 +18,7 @@ package com.android.colorpicker;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
@ -47,9 +48,9 @@ public class ColorStateDrawable extends LayerDrawable {
} }
if (pressedOrFocused) { if (pressedOrFocused) {
super.setColorFilter(getPressedColor(mColor), PorterDuff.Mode.SRC_ATOP); super.setColorFilter(new PorterDuffColorFilter(getPressedColor(mColor), PorterDuff.Mode.SRC_ATOP));
} else { } else {
super.setColorFilter(mColor, PorterDuff.Mode.SRC_ATOP); super.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
} }
return super.onStateChange(states); return super.onStateChange(states);

@ -27,6 +27,8 @@ import android.view.View.*;
import android.view.animation.*; import android.view.animation.*;
import android.widget.*; import android.widget.*;
import androidx.fragment.app.DialogFragment;
import com.android.*; import com.android.*;
import com.android.datetimepicker.*; import com.android.datetimepicker.*;
import com.android.datetimepicker.date.MonthAdapter.*; import com.android.datetimepicker.date.MonthAdapter.*;

@ -455,8 +455,8 @@ public abstract class DayPickerView extends ListView implements OnScrollListener
@Override @Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info);
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
} }
/** /**

@ -522,7 +522,7 @@ public abstract class MonthView extends View {
* has focus * has focus
*/ */
public CalendarDay getAccessibilityFocus() { public CalendarDay getAccessibilityFocus() {
final int day = mTouchHelper.getFocusedVirtualView(); final int day = mTouchHelper.getAccessibilityFocusedVirtualViewId();
if (day >= 0) { if (day >= 0) {
return new CalendarDay(mYear, mMonth, day); return new CalendarDay(mYear, mMonth, day);
} }
@ -572,7 +572,7 @@ public abstract class MonthView extends View {
} }
public void clearFocusedVirtualView() { public void clearFocusedVirtualView() {
final int focusedVirtualView = getFocusedVirtualView(); final int focusedVirtualView = getAccessibilityFocusedVirtualViewId();
if (focusedVirtualView != ExploreByTouchHelper.INVALID_ID) { if (focusedVirtualView != ExploreByTouchHelper.INVALID_ID) {
getAccessibilityNodeProvider(MonthView.this).performAction( getAccessibilityNodeProvider(MonthView.this).performAction(
focusedVirtualView, focusedVirtualView,

@ -741,8 +741,8 @@ public class RadialPickerLayout extends FrameLayout implements OnTouchListener {
@Override @Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info); super.onInitializeAccessibilityNodeInfo(info);
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
} }
/** /**

@ -31,8 +31,7 @@ import org.isoron.uhabits.core.ui.screens.habits.list.*;
import org.isoron.uhabits.core.utils.*; import org.isoron.uhabits.core.utils.*;
import org.junit.*; import org.junit.*;
import static androidx.test.InstrumentationRegistry.getContext; import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.uiautomator.UiDevice.*; import static androidx.test.uiautomator.UiDevice.*;
@ -59,18 +58,18 @@ public class BaseUserInterfaceTest
intent.setComponent(new ComponentName(PKG, cls.getCanonicalName())); intent.setComponent(new ComponentName(PKG, cls.getCanonicalName()));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent); getApplicationContext().startActivity(intent);
} }
@Before @Before
public void setUp() throws Exception public void setUp() throws Exception
{ {
device = getInstance(getInstrumentation()); device = getInstance(getInstrumentation());
TestButler.setup(getTargetContext()); TestButler.setup(getApplicationContext());
TestButler.verifyAnimationsDisabled(getTargetContext()); TestButler.verifyAnimationsDisabled(getApplicationContext());
HabitsApplication app = HabitsApplication app =
(HabitsApplication) getTargetContext().getApplicationContext(); (HabitsApplication) getApplicationContext().getApplicationContext();
component = app.getComponent(); component = app.getComponent();
habitList = component.getHabitList(); habitList = component.getHabitList();
prefs = component.getPreferences(); prefs = component.getPreferences();
@ -83,7 +82,7 @@ public class BaseUserInterfaceTest
public void tearDown() throws Exception public void tearDown() throws Exception
{ {
for (int i = 0; i < 10; i++) device.pressBack(); for (int i = 0; i < 10; i++) device.pressBack();
TestButler.teardown(getTargetContext()); TestButler.teardown(getApplicationContext());
} }
private void resetState() throws Exception private void resetState() throws Exception

@ -39,7 +39,7 @@ import static androidx.test.espresso.action.ViewActions.*;
import static androidx.test.espresso.assertion.PositionAssertions.*; import static androidx.test.espresso.assertion.PositionAssertions.*;
import static androidx.test.espresso.assertion.ViewAssertions.*; import static androidx.test.espresso.assertion.ViewAssertions.*;
import static androidx.test.espresso.matcher.ViewMatchers.*; import static androidx.test.espresso.matcher.ViewMatchers.*;
import static junit.framework.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
public class CommonSteps extends BaseUserInterfaceTest public class CommonSteps extends BaseUserInterfaceTest
@ -125,7 +125,7 @@ public class CommonSteps extends BaseUserInterfaceTest
verifyDisplaysText(text[0]); verifyDisplaysText(text[0]);
for(int i = 1; i < text.length; i++) { for(int i = 1; i < text.length; i++) {
verifyDisplaysText(text[i]); verifyDisplaysText(text[i]);
onView(withText(text[i])).check(isBelow(withText(text[i-1]))); onView(withText(text[i])).check(isCompletelyBelow(withText(text[i-1])));
} }
} }

@ -22,7 +22,7 @@ package org.isoron.uhabits.acceptance.steps;
import androidx.test.uiautomator.*; import androidx.test.uiautomator.*;
import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION.SDK_INT;
import static junit.framework.Assert.*; import static org.junit.Assert.*;
import static org.isoron.uhabits.BaseUserInterfaceTest.*; import static org.isoron.uhabits.BaseUserInterfaceTest.*;
public class WidgetSteps { public class WidgetSteps {

@ -20,14 +20,12 @@
package org.isoron.uhabits.activities.common.views; package org.isoron.uhabits.activities.common.views;
import android.os.*; import android.os.*;
import androidx.core.os.*;
import androidx.customview.view.AbsSavedState; import androidx.customview.view.AbsSavedState;
public class BundleSavedState extends AbsSavedState public class BundleSavedState extends AbsSavedState
{ {
public static final Parcelable.Creator<BundleSavedState> CREATOR = public static final Parcelable.Creator<BundleSavedState> CREATOR =
ParcelableCompat.newCreator( new ClassLoaderCreator<BundleSavedState>()
new ParcelableCompatCreatorCallbacks<BundleSavedState>()
{ {
@Override @Override
public BundleSavedState createFromParcel(Parcel source, public BundleSavedState createFromParcel(Parcel source,
@ -36,12 +34,18 @@ public class BundleSavedState extends AbsSavedState
return new BundleSavedState(source, loader); return new BundleSavedState(source, loader);
} }
@Override
public BundleSavedState createFromParcel(Parcel source)
{
return null;
}
@Override @Override
public BundleSavedState[] newArray(int size) public BundleSavedState[] newArray(int size)
{ {
return new BundleSavedState[size]; return new BundleSavedState[size];
} }
}); };
public final Bundle bundle; public final Bundle bundle;

@ -109,7 +109,7 @@ public abstract class HabitWidgetView extends FrameLayout
backgroundPaint.setAlpha(backgroundAlpha); backgroundPaint.setAlpha(backgroundAlpha);
frame = (ViewGroup) findViewById(R.id.frame); frame = (ViewGroup) findViewById(R.id.frame);
if (frame != null) frame.setBackgroundDrawable(background); if (frame != null) frame.setBackground(background);
} }
private void init() private void init()

@ -25,8 +25,8 @@ import org.junit.*;
import java.util.*; import java.util.*;
import static junit.framework.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
public class ArchiveHabitsCommandTest extends BaseUnitTest public class ArchiveHabitsCommandTest extends BaseUnitTest

@ -23,7 +23,7 @@ import org.isoron.uhabits.core.*;
import org.isoron.uhabits.core.models.*; import org.isoron.uhabits.core.models.*;
import org.junit.*; import org.junit.*;
import static junit.framework.Assert.*; import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.MatcherAssert.*;

@ -24,7 +24,7 @@ import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.utils.*; import org.isoron.uhabits.core.utils.*;
import org.junit.*; import org.junit.*;
import static junit.framework.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.isoron.uhabits.core.models.Checkmark.CHECKED_EXPLICITLY; import static org.isoron.uhabits.core.models.Checkmark.CHECKED_EXPLICITLY;

@ -24,7 +24,7 @@ import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.utils.*; import org.isoron.uhabits.core.utils.*;
import org.junit.*; import org.junit.*;
import static junit.framework.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;

@ -25,7 +25,7 @@ import org.junit.*;
import java.util.*; import java.util.*;
import static junit.framework.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;

@ -22,8 +22,8 @@ package org.isoron.uhabits.core.models;
import org.isoron.uhabits.core.*; import org.isoron.uhabits.core.*;
import org.junit.*; import org.junit.*;
import static junit.framework.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.*; import static org.hamcrest.core.IsEqual.*;
public class WeekdayListTest extends BaseUnitTest public class WeekdayListTest extends BaseUnitTest

@ -19,7 +19,7 @@
package org.isoron.uhabits.core.ui.screens.habits.list; package org.isoron.uhabits.core.ui.screens.habits.list;
import junit.framework.Assert; import org.junit.Assert;
import org.isoron.uhabits.core.*; import org.isoron.uhabits.core.*;
import org.isoron.uhabits.core.commands.*; import org.isoron.uhabits.core.commands.*;
@ -100,7 +100,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
assertThat(cache.getHabitCount(), equalTo(10)); assertThat(cache.getHabitCount(), equalTo(10));
Habit h = habitList.getByPosition(3); Habit h = habitList.getByPosition(3);
junit.framework.Assert.assertNotNull(h.getId()); Assert.assertNotNull(h.getId());
double score = h.getScores().getTodayValue(); double score = h.getScores().getTodayValue();
assertThat(cache.getHabitByPosition(3), equalTo(h)); assertThat(cache.getHabitByPosition(3), equalTo(h));

Loading…
Cancel
Save