Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump compileSdk, update dependencies, fix #18, #19 and #20 #33

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d4031c6
Bump compileSdk and targetSdk to sdk 33, updated dependencies and mig…
Lej77 Dec 26, 2022
de3acb9
Request permission to send notifications on Android 13 (sdk 33)
Lej77 Dec 26, 2022
c30cacf
Allow more actions when selecting text
Lej77 Dec 26, 2022
2054e3b
Improve tests, ParentPinTest failed because of timeout on newer andro…
Lej77 Dec 26, 2022
41ce154
Fix issue #20 which caused issues when selecting text
Lej77 Dec 26, 2022
517eb9a
Follow system's night mode setting
Lej77 Dec 26, 2022
1c88fd9
Register event listener for "show notification actions" to correctly …
Lej77 Dec 26, 2022
8fca239
Handle overflow when text gets too long, fixes issue #19
Lej77 Dec 26, 2022
ef6b2a1
Create one notification channel for each visibility level and provide…
Lej77 Dec 26, 2022
58c7de1
Don't overlap drop down with the spinner it controls (requires API le…
Lej77 Dec 26, 2022
47c6e3e
Place text inputs vertically and some other small style improvements
Lej77 Dec 26, 2022
03601b6
Close activity when backing out of it
Lej77 Dec 26, 2022
48b77c1
Move package name into gradle file since having it in the manifest is…
Lej77 Dec 27, 2022
dfc6678
Remove label from activity, should fix the name mixup in issue #29
Lej77 Dec 27, 2022
b6b5678
Fix lint warnings
Lej77 Dec 27, 2022
9470fa9
actually restore notifications when app is opened and not just when d…
Lej77 Dec 28, 2022
df46fad
Restore notifications directly after an app update
Lej77 Dec 28, 2022
42c4155
Documentation for OnUpdateReceiver
Lej77 Dec 28, 2022
354b4b3
Don't make sounds when updating an existing notification
Lej77 Dec 28, 2022
3fadbca
Remove old notification channel
Lej77 Dec 29, 2022
1dcaf5f
Don't make sounds when creating notifications
Lej77 Dec 29, 2022
2f620e8
Don't show notification count as application icon badges in Launcher …
Lej77 Dec 29, 2022
b7beec2
simpler return type of helper function
Lej77 Dec 29, 2022
c302570
double check that notification doesn't exist before restoring it
Lej77 Dec 30, 2022
c02ba56
Use a different application id in debug builds
Lej77 Dec 30, 2022
661cc80
Move the namespace property to the right place in the build.gradle file
Lej77 Dec 30, 2022
71dbc6b
Never make sounds when creating notifications
Lej77 Dec 30, 2022
f1a3d19
Revert "Never make sounds when creating notifications"
Lej77 Dec 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 33
buildToolsVersion "30.0.3"
namespace 'de.dotwee.micropinner'

defaultConfig {
applicationId "de.dotwee.micropinner"
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion 33
versionCode 29
versionName "v2.2.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

buildTypes {

debug {
minifyEnabled false
applicationIdSuffix '.debug'
}

release {
Expand All @@ -34,20 +36,20 @@ android {
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'androidx.appcompat:appcompat:1.5.1'

androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1') {
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.0') {
// Necessary if your app targets Marshmallow (since Espresso
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}

androidTestImplementation('com.android.support.test.espresso:espresso-intents:3.0.1') {
androidTestImplementation('androidx.test.espresso:espresso-intents:3.5.0') {
// Necessary to avoid version conflicts
exclude group: 'com.android.support', module: 'support-annotations'
}

androidTestImplementation('com.android.support.test:runner:1.0.1') {
androidTestImplementation('androidx.test.ext:junit:1.1.4') {
// Necessary if your app targets Marshmallow (since the test runner
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
18 changes: 14 additions & 4 deletions app/src/androidTest/java/de/dotwee/micropinner/tools/Matches.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package de.dotwee.micropinner.tools;

import android.graphics.drawable.ColorDrawable;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.test.espresso.intent.Checks;
import android.support.test.espresso.matcher.BoundedMatcher;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.test.espresso.Root;
import androidx.test.espresso.intent.Checks;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;

Expand All @@ -16,6 +17,15 @@
*/
public final class Matches {

@NonNull
public static Matcher<Root> isToast() {
return new ToastMatcher();
}
@NonNull
public static Matcher<Root> isToast(int maxRetries) {
return new ToastMatcher(maxRetries);
}

/**
* This matcher checks if a TextView displays its text in
* a specific color.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Rule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.dotwee.micropinner.tools;

import android.support.test.rule.ActivityTestRule;
import androidx.test.rule.ActivityTestRule;

import de.dotwee.micropinner.view.MainDialog;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package de.dotwee.micropinner.tools;

import android.os.IBinder;
import androidx.test.espresso.Root;
import android.view.WindowManager.LayoutParams;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

/**
* This class allows to match Toast messages in tests with Espresso.
*
* Idea taken from: <a href="https://stackoverflow.com/questions/28390574/checking-toast-message-in-android-espresso">Checking toast message in android espresso - Stack Overflow</a>
*
* Usage in test class:
*
* <pre>
* {@code
* import somepkg.ToastMatcher.Companion.onToast;
*
* // To assert a toast does *not* pop up:
* onView(withText("text")).inRoot(new ToastMatcher()).check(doesNotExist());
* onView(withText(textId)).inRoot(new ToastMatcher()).check(doesNotExist());
*
* // To assert a toast does pop up:
* onView(withText("text")).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
* onView(withText(textId)).inRoot(new ToastMatcher()).check(matches(isDisplayed()));
* }
*/
public class ToastMatcher extends TypeSafeMatcher<Root> {

/** Default for maximum number of retries to wait for the toast to pop up */
private static final int DEFAULT_MAX_FAILURES = 5;

/** Restrict number of false results from matchesSafely to avoid endless loop */
private int failures = 0;
private final int maxFailures;

public ToastMatcher() {
this(DEFAULT_MAX_FAILURES);
}
public ToastMatcher(int maxFailures) {
this.maxFailures = maxFailures;
}

@Override
public void describeTo(Description description) {
description.appendText("is toast");
}

@Override
public boolean matchesSafely(Root root) {
int type = root.getWindowLayoutParams().get().type;
if (type == LayoutParams.TYPE_TOAST || type == LayoutParams.TYPE_APPLICATION_OVERLAY) {
IBinder windowToken = root.getDecorView().getWindowToken();
IBinder appToken = root.getDecorView().getApplicationWindowToken();
if (windowToken == appToken) {
// windowToken == appToken means this window isn't contained by any other windows.
// if it was a window for an activity, it would have TYPE_BASE_APPLICATION.
return true;
}
}
// Method is called again if false is returned which is useful because a toast may take some time to pop up. But for
// obvious reasons an infinite wait isn't of help. So false is only returned as often as maxFailures specifies.
return (++failures >= maxFailures);
}

}
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package de.dotwee.micropinner.view;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import de.dotwee.micropinner.R;
import de.dotwee.micropinner.database.PinDatabase;
import de.dotwee.micropinner.tools.Matches;
import de.dotwee.micropinner.tools.PreferencesHandler;

import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.RootMatchers.withDecorView;
import static android.support.test.espresso.matcher.ViewMatchers.isChecked;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.isFocusable;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withSpinnerText;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isChecked;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isFocusable;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withSpinnerText;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static de.dotwee.micropinner.tools.TestTools.getPreferencesHandler;
import static de.dotwee.micropinner.tools.TestTools.recreateActivity;
import static org.hamcrest.Matchers.allOf;
Expand Down Expand Up @@ -108,9 +109,12 @@ public void testEmptyTitleToast() throws Exception {
// click pin button
onView(withText(R.string.dialog_action_pin)).perform(click());

// can't see toast if another toast is already present
onView(withText(R.string.message_visibility_unsupported)).inRoot(Matches.isToast())
.check(doesNotExist());

// verify toast existence
onView(withText(R.string.message_empty_title)).inRoot(
withDecorView(not(activityTestRule.getActivity().getWindow().getDecorView())))
onView(withText(R.string.message_empty_title)).inRoot(Matches.isToast())
.check(matches(isDisplayed()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.support.test.espresso.intent.Intents;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.espresso.intent.Intents;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -18,12 +19,12 @@
import de.dotwee.micropinner.R;
import de.dotwee.micropinner.tools.NotificationTools;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isChecked;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withSpinnerText;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isChecked;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withSpinnerText;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

/**
* Created by Lukas Wolfsteiner on 06.11.2015.
Expand All @@ -38,19 +39,11 @@ public class MainDialogParentPinTest {
* activity to be launched before each test
*/
@Rule
public ActivityTestRule<MainDialog> activityTestRule =
new ActivityTestRule<>(MainDialog.class);

@Before
public void setUp() {

final Intent testIntent =
new Intent(activityTestRule.getActivity(), MainDialog.class).putExtra(
NotificationTools.EXTRA_INTENT, Constants.testPin);

Intents.init();
activityTestRule.launchActivity(testIntent);
}
public ActivityScenarioRule<MainDialog> activityTestRule =
new ActivityScenarioRule<>(
new Intent(ApplicationProvider.getApplicationContext(), MainDialog.class)
.putExtra(NotificationTools.EXTRA_INTENT, Constants.testPin)
);

/**
* @throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import android.content.res.Configuration;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatDelegate;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.test.filters.SdkSuppress;
import androidx.test.rule.ActivityTestRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatDelegate;

import org.junit.Before;
import org.junit.Rule;
Expand All @@ -18,10 +19,10 @@
import de.dotwee.micropinner.R;
import de.dotwee.micropinner.tools.Matches;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static de.dotwee.micropinner.tools.TestTools.recreateActivity;

/**
Expand All @@ -40,6 +41,7 @@ public class MainDialogThemeTest {
new ActivityTestRule<>(MainDialog.class);

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR1)
@ColorInt
private static int getAccentColor(@NonNull ActivityTestRule<MainDialog> activityTestRule, boolean light) {
Configuration configuration = new Configuration();
Expand All @@ -49,6 +51,7 @@ private static int getAccentColor(@NonNull ActivityTestRule<MainDialog> activity
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR1)
@ColorInt
private static int getBackgroundColor(@NonNull ActivityTestRule<MainDialog> activityTestRule, boolean light) {
Configuration configuration = new Configuration();
Expand All @@ -73,6 +76,7 @@ public void setUp() {
* This method verifies the light theme's accent.
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Test
public void testThemeLightAccent() throws Exception {
changeUiMode(activityTestRule, AppCompatDelegate.MODE_NIGHT_NO);
Expand All @@ -90,6 +94,7 @@ public void testThemeLightAccent() throws Exception {
* This method verifies the light theme's background.
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Test
public void testThemeLightBackground() throws Exception {
changeUiMode(activityTestRule, AppCompatDelegate.MODE_NIGHT_NO);
Expand All @@ -101,6 +106,7 @@ public void testThemeLightBackground() throws Exception {
* This method verifies the light theme's accent.
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Test
public void testThemeDarkAccent() throws Exception {
changeUiMode(activityTestRule, AppCompatDelegate.MODE_NIGHT_YES);
Expand All @@ -120,6 +126,7 @@ public void testThemeDarkAccent() throws Exception {
* This method verifies the dark theme's background.
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Test
public void testThemeDarkBackground() throws Exception {
changeUiMode(activityTestRule, AppCompatDelegate.MODE_NIGHT_YES);
Expand Down
Loading