Deprecation fixes

Co-authored-by: Alinson S. Xavier <git@axavier.org>
pull/629/head
TacoTheDank 5 years ago committed by Alinson S. Xavier
parent 3554895a5d
commit d9ff429c28

@ -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

@ -31,9 +31,8 @@ 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.*;
import static androidx.test.InstrumentationRegistry.getTargetContext; import static androidx.test.platform.app.InstrumentationRegistry.*;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.uiautomator.UiDevice.*; import static androidx.test.uiautomator.UiDevice.*;
public class BaseUserInterfaceTest public class BaseUserInterfaceTest
@ -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

@ -19,16 +19,15 @@
package org.isoron.uhabits.acceptance.steps; package org.isoron.uhabits.acceptance.steps;
import android.view.View; import android.view.*;
import androidx.annotation.StringRes; import androidx.annotation.*;
import androidx.recyclerview.widget.*;
import androidx.test.espresso.*; import androidx.test.espresso.*;
import androidx.test.espresso.contrib.*; import androidx.test.espresso.contrib.*;
import androidx.test.uiautomator.*; import androidx.test.uiautomator.*;
import androidx.recyclerview.widget.RecyclerView; import org.hamcrest.*;
import org.hamcrest.Matcher;
import org.isoron.uhabits.*; import org.isoron.uhabits.*;
import org.isoron.uhabits.R; import org.isoron.uhabits.R;
import org.isoron.uhabits.activities.habits.list.*; import org.isoron.uhabits.activities.habits.list.*;
@ -39,8 +38,8 @@ 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.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
public class CommonSteps extends BaseUserInterfaceTest public class CommonSteps extends BaseUserInterfaceTest
{ {
@ -125,7 +124,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,13 @@
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.*;
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 +35,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;

@ -27,8 +27,7 @@ import android.util.*;
import android.view.*; import android.view.*;
import android.widget.*; import android.widget.*;
import androidx.annotation.NonNull; import androidx.annotation.*;
import androidx.annotation.Nullable;
import org.isoron.androidbase.utils.*; import org.isoron.androidbase.utils.*;
import org.isoron.uhabits.*; import org.isoron.uhabits.*;
@ -109,7 +108,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,10 +24,10 @@ 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.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.*;
import static org.isoron.uhabits.core.models.Checkmark.CHECKED_EXPLICITLY; import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.junit.Assert.*;
public class CreateRepetitionCommandTest extends BaseUnitTest public class CreateRepetitionCommandTest extends BaseUnitTest
{ {

@ -24,9 +24,9 @@ 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.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
public class ToggleRepetitionCommandTest extends BaseUnitTest public class ToggleRepetitionCommandTest extends BaseUnitTest
{ {

@ -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,13 +19,11 @@
package org.isoron.uhabits.core.ui.screens.habits.list; package org.isoron.uhabits.core.ui.screens.habits.list;
import junit.framework.Assert;
import org.isoron.uhabits.core.*; import org.isoron.uhabits.core.*;
import org.isoron.uhabits.core.commands.*; import org.isoron.uhabits.core.commands.*;
import org.isoron.uhabits.core.models.*; import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.utils.*; import org.isoron.uhabits.core.utils.*;
import org.junit.Test; import org.junit.*;
import java.util.*; import java.util.*;
@ -100,7 +98,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