From d33345dd5cdac7820bb5d737e523fa9e1e9a542d Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Tue, 8 May 2018 19:15:10 +0200 Subject: [PATCH] 1.8 fixes (#637) * fix lint warnings * upgrade dependencies * auto cancel notifications * improve dependency injection * fix tests * remove old comment from BaseActivity * fix missing injectors --- app/build.gradle | 2 +- .../keylesspalace/tusky/AccountActivity.java | 9 --------- .../com/keylesspalace/tusky/BaseActivity.java | 13 ++++--------- .../keylesspalace/tusky/BottomSheetActivity.kt | 6 ++++-- .../keylesspalace/tusky/FavouritesActivity.java | 10 ---------- .../com/keylesspalace/tusky/MainActivity.java | 17 ----------------- .../tusky/ModalTimelineActivity.kt | 7 ------- .../tusky/NotificationPullJobCreator.java | 2 +- .../com/keylesspalace/tusky/SearchActivity.java | 11 +---------- .../keylesspalace/tusky/ViewTagActivity.java | 10 ---------- .../keylesspalace/tusky/ViewThreadActivity.java | 10 ---------- .../tusky/adapter/StatusBaseViewHolder.java | 1 - .../tusky/adapter/ThreadAdapter.java | 1 + .../keylesspalace/tusky/di/ActivitiesModule.kt | 12 ++++++++++++ .../keylesspalace/tusky/di/ServicesModule.kt | 2 +- .../com/keylesspalace/tusky/entity/Instance.kt | 1 - .../com/keylesspalace/tusky/entity/Profile.kt | 11 ----------- .../tusky/fragment/NotificationsFragment.java | 2 +- .../tusky/fragment/ViewThreadFragment.java | 10 ++-------- .../tusky/network/ProgressRequestBody.java | 2 +- .../tusky/util/ClickableSpanNoUnderline.kt | 2 +- .../tusky/util/NotificationHelper.java | 2 +- .../keylesspalace/tusky/util/StringUtils.java | 17 ----------------- .../tusky/BottomSheetActivityTest.kt | 7 ++----- build.gradle | 2 +- 25 files changed, 34 insertions(+), 135 deletions(-) delete mode 100644 app/src/main/java/com/keylesspalace/tusky/entity/Profile.kt diff --git a/app/build.gradle b/app/build.gradle index f728c46d..e23be76e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -44,7 +44,7 @@ android { } ext.supportLibraryVersion = '27.1.1' -ext.daggerVersion = '2.15' +ext.daggerVersion = '2.16' dependencies { implementation('com.mikepenz:materialdrawer:6.0.7@aar') { diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index ff648cc4..1000031d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -47,12 +47,10 @@ import android.widget.ImageView; import android.widget.TextView; import com.keylesspalace.tusky.db.AccountEntity; -import com.keylesspalace.tusky.db.AccountManager; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.entity.Relationship; import com.keylesspalace.tusky.interfaces.ActionButtonActivity; import com.keylesspalace.tusky.interfaces.LinkListener; -import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.pager.AccountPagerAdapter; import com.keylesspalace.tusky.receiver.TimelineReceiver; import com.keylesspalace.tusky.util.Assert; @@ -85,8 +83,6 @@ public final class AccountActivity extends BottomSheetActivity implements Action REQUESTED, } - @Inject - public MastodonApi mastodonApi; @Inject public DispatchingAndroidInjector dispatchingAndroidInjector; @@ -712,9 +708,4 @@ public final class AccountActivity extends BottomSheetActivity implements Action return dispatchingAndroidInjector; } - @NonNull - @Override - public MastodonApi getMastodonApi() { - return mastodonApi; - } } diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index 67a4960c..2e180509 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -32,6 +32,7 @@ import com.evernote.android.job.JobManager; import com.evernote.android.job.JobRequest; import com.keylesspalace.tusky.db.AccountEntity; import com.keylesspalace.tusky.db.AccountManager; +import com.keylesspalace.tusky.di.Injectable; import com.keylesspalace.tusky.util.ThemeUtils; import java.util.ArrayList; @@ -41,7 +42,7 @@ import javax.inject.Inject; import retrofit2.Call; -public abstract class BaseActivity extends AppCompatActivity { +public abstract class BaseActivity extends AppCompatActivity implements Injectable { protected List callList; @@ -111,20 +112,14 @@ public abstract class BaseActivity extends AppCompatActivity { return getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE); } - protected boolean redirectIfNotLoggedIn() { - // This is very ugly but we cannot inject into parent class and injecting into every - // subclass seems inconvenient as well. - AccountEntity account = ((TuskyApplication) getApplicationContext()) - .getServiceLocator().get(AccountManager.class) - .getActiveAccount(); + protected void redirectIfNotLoggedIn() { + AccountEntity account = accountManager.getActiveAccount(); if (account == null) { Intent intent = new Intent(this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); - return true; } - return false; } @Override diff --git a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt index 6fa36e74..b464b9c7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/BottomSheetActivity.kt @@ -30,6 +30,7 @@ import retrofit2.Callback import retrofit2.Response import java.net.URI import java.net.URISyntaxException +import javax.inject.Inject /** this is the base class for all activities that open links * links are checked against the api if they are mastodon links so they can be openend in Tusky @@ -41,7 +42,8 @@ abstract class BottomSheetActivity : BaseActivity() { lateinit var bottomSheet: BottomSheetBehavior var searchUrl: String? = null - abstract fun getMastodonApi(): MastodonApi + @Inject + lateinit var mastodonApi: MastodonApi override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) @@ -67,7 +69,7 @@ abstract class BottomSheetActivity : BaseActivity() { return } - val call = getMastodonApi().search(url, true) + val call = mastodonApi.search(url, true) call.enqueue(object : Callback { override fun onResponse(call: Call, response: Response) { if (getCancelSearchRequested(url)) { diff --git a/app/src/main/java/com/keylesspalace/tusky/FavouritesActivity.java b/app/src/main/java/com/keylesspalace/tusky/FavouritesActivity.java index 0d885839..add0a660 100644 --- a/app/src/main/java/com/keylesspalace/tusky/FavouritesActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/FavouritesActivity.java @@ -24,9 +24,6 @@ import android.support.v7.widget.Toolbar; import android.view.MenuItem; import com.keylesspalace.tusky.fragment.TimelineFragment; -import com.keylesspalace.tusky.network.MastodonApi; - -import org.jetbrains.annotations.NotNull; import javax.inject.Inject; @@ -36,8 +33,6 @@ import dagger.android.support.HasSupportFragmentInjector; public class FavouritesActivity extends BottomSheetActivity implements HasSupportFragmentInjector { - @Inject - public MastodonApi mastodonApi; @Inject public DispatchingAndroidInjector dispatchingAndroidInjector; @@ -77,9 +72,4 @@ public class FavouritesActivity extends BottomSheetActivity implements HasSuppor return dispatchingAndroidInjector; } - @NotNull - @Override - public MastodonApi getMastodonApi() { - return mastodonApi; - } } diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 0674457a..815fd537 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -37,10 +37,8 @@ import android.widget.ImageButton; import android.widget.ImageView; import com.keylesspalace.tusky.db.AccountEntity; -import com.keylesspalace.tusky.db.AccountManager; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.interfaces.ActionButtonActivity; -import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.pager.TimelinePagerAdapter; import com.keylesspalace.tusky.util.NotificationHelper; import com.keylesspalace.tusky.util.ThemeUtils; @@ -60,8 +58,6 @@ import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader; import com.mikepenz.materialdrawer.util.DrawerImageLoader; import com.squareup.picasso.Picasso; -import org.jetbrains.annotations.NotNull; - import java.util.ArrayList; import java.util.List; @@ -90,8 +86,6 @@ public class MainActivity extends BottomSheetActivity implements ActionButtonAct private static final long DRAWER_ITEM_SAVED_TOOT = 9; private static final long DRAWER_ITEM_LISTS = 10; - @Inject - public MastodonApi mastodonApi; @Inject public DispatchingAndroidInjector fragmentInjector; @@ -268,12 +262,6 @@ public class MainActivity extends BottomSheetActivity implements ActionButtonAct return super.onKeyDown(keyCode, event); } - // Fix for GitHub issues #190, #259 (MainActivity won't restart on screen rotation.) - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - } - private void tintTab(TabLayout.Tab tab, boolean tinted) { int color = (tinted) ? R.attr.tab_icon_selected_tint : R.attr.toolbar_icon_tint; ThemeUtils.setDrawableTint(this, tab.getIcon(), color); @@ -553,9 +541,4 @@ public class MainActivity extends BottomSheetActivity implements ActionButtonAct return fragmentInjector; } - @NotNull - @Override - public MastodonApi getMastodonApi() { - return mastodonApi; - } } \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/ModalTimelineActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ModalTimelineActivity.kt index 13caf1ce..5f5a122a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ModalTimelineActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ModalTimelineActivity.kt @@ -10,7 +10,6 @@ import android.view.MenuItem import android.widget.FrameLayout import com.keylesspalace.tusky.fragment.TimelineFragment import com.keylesspalace.tusky.interfaces.ActionButtonActivity -import com.keylesspalace.tusky.network.MastodonApi import dagger.android.AndroidInjector import dagger.android.DispatchingAndroidInjector import dagger.android.support.HasSupportFragmentInjector @@ -18,8 +17,6 @@ import javax.inject.Inject class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportFragmentInjector { - @Inject - lateinit var api: MastodonApi @Inject lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector @@ -79,8 +76,4 @@ class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSu return dispatchingAndroidInjector } - override fun getMastodonApi(): MastodonApi { - return api - } - } diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationPullJobCreator.java b/app/src/main/java/com/keylesspalace/tusky/NotificationPullJobCreator.java index df616c92..77ea5274 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationPullJobCreator.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationPullJobCreator.java @@ -131,7 +131,7 @@ public final class NotificationPullJobCreator implements JobCreator { } private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) { - return lastShownNotificationId.compareTo(newId) == -1; + return lastShownNotificationId.compareTo(newId) < 0; } } } diff --git a/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java b/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java index 4c1566a7..0281347b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/SearchActivity.java @@ -30,9 +30,6 @@ import android.view.Menu; import android.view.MenuItem; import com.keylesspalace.tusky.fragment.SearchFragment; -import com.keylesspalace.tusky.network.MastodonApi; - -import org.jetbrains.annotations.NotNull; import javax.inject.Inject; @@ -42,8 +39,7 @@ import dagger.android.support.HasSupportFragmentInjector; public class SearchActivity extends BottomSheetActivity implements SearchView.OnQueryTextListener, HasSupportFragmentInjector { - @Inject - public MastodonApi mastodonApi; + @Inject public DispatchingAndroidInjector fragmentInjector; @@ -144,9 +140,4 @@ public class SearchActivity extends BottomSheetActivity implements SearchView.On return fragmentInjector; } - @NotNull - @Override - public MastodonApi getMastodonApi() { - return mastodonApi; - } } diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java index f3c9b754..f5144dc5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewTagActivity.java @@ -24,9 +24,6 @@ import android.support.v7.widget.Toolbar; import android.view.MenuItem; import com.keylesspalace.tusky.fragment.TimelineFragment; -import com.keylesspalace.tusky.network.MastodonApi; - -import org.jetbrains.annotations.NotNull; import javax.inject.Inject; @@ -36,8 +33,6 @@ import dagger.android.support.HasSupportFragmentInjector; public class ViewTagActivity extends BottomSheetActivity implements HasSupportFragmentInjector { - @Inject - public MastodonApi mastodonApi; @Inject public DispatchingAndroidInjector dispatchingAndroidInjector; @@ -80,9 +75,4 @@ public class ViewTagActivity extends BottomSheetActivity implements HasSupportFr return dispatchingAndroidInjector; } - @NotNull - @Override - public MastodonApi getMastodonApi() { - return mastodonApi; - } } diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java index ad62f4f5..07087259 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewThreadActivity.java @@ -25,11 +25,8 @@ import android.view.Menu; import android.view.MenuItem; import com.keylesspalace.tusky.fragment.ViewThreadFragment; -import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.util.LinkHelper; -import org.jetbrains.annotations.NotNull; - import javax.inject.Inject; import dagger.android.AndroidInjector; @@ -44,8 +41,6 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor private int revealButtonState = REVEAL_BUTTON_HIDDEN; - @Inject - public MastodonApi mastodonApi; @Inject public DispatchingAndroidInjector dispatchingAndroidInjector; @@ -119,9 +114,4 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor return dispatchingAndroidInjector; } - @NotNull - @Override - public MastodonApi getMastodonApi() { - return mastodonApi; - } } diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java index 062781f6..c22aadd9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -11,7 +11,6 @@ import android.text.Spanned; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; -import android.widget.CompoundButton; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/ThreadAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/ThreadAdapter.java index abb51aca..b5b1cb34 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/ThreadAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/ThreadAdapter.java @@ -45,6 +45,7 @@ public class ThreadAdapter extends RecyclerView.Adapter { detailedStatusPosition = RecyclerView.NO_POSITION; } + @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { switch (viewType) { diff --git a/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt index dde3df4f..67b9c1e8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt @@ -74,4 +74,16 @@ abstract class ActivitiesModule { @ContributesAndroidInjector abstract fun contributesReportActivity(): ReportActivity + @ContributesAndroidInjector + abstract fun contributesSavedTootActivity(): SavedTootActivity + + @ContributesAndroidInjector + abstract fun contributesSPreferencesActivity(): PreferencesActivity + + @ContributesAndroidInjector + abstract fun contributesViewMediaActivity(): ViewMediaActivity + + @ContributesAndroidInjector + abstract fun contributesViewVideoActivity(): ViewVideoActivity + } \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt index f024df6b..9015b5f2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt @@ -22,5 +22,5 @@ import dagger.android.ContributesAndroidInjector @Module abstract class ServicesModule { @ContributesAndroidInjector - abstract fun contributeMyService(): SendTootService + abstract fun contributesSendTootService(): SendTootService } \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt index ee440247..959af1fa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Instance.kt @@ -16,7 +16,6 @@ package com.keylesspalace.tusky.entity import com.google.gson.annotations.SerializedName -import java.util.* data class Instance ( val uri: String, diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Profile.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Profile.kt deleted file mode 100644 index ba69a533..00000000 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Profile.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.keylesspalace.tusky.entity - -import com.google.gson.annotations.SerializedName - -data class Profile( - @SerializedName("display_name") val displayName: String?, - val note: String?, - val avatar: String?, - val header: String? = null -) - diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index bd5a1fd1..4d4c52ca 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -623,7 +623,7 @@ public class NotificationsFragment extends SFragment implements private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) { - return lastShownNotificationId.compareTo(newId) == -1; + return lastShownNotificationId.compareTo(newId) < 0; } private void update(@Nullable List newNotifications, @Nullable String fromId, diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java index 05e1cdd7..75a573f9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java @@ -29,6 +29,7 @@ import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -100,7 +101,6 @@ public final class ViewThreadFragment extends SFragment implements return timelineCases; } - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -532,11 +532,6 @@ public final class ViewThreadFragment extends SFragment implements } } - public void clear() { - statuses.clear(); - adapter.clear(); - } - private void updateRevealIcon() { ViewThreadActivity activity = ((ViewThreadActivity) getActivity()); if (activity == null) return; @@ -544,8 +539,7 @@ public final class ViewThreadFragment extends SFragment implements boolean hasAnyWarnings = false; // Statuses are updated from the main thread so nothing should change while iterating for (int i = 0; i < statuses.size(); i++) { - if (statuses.get(i).getSpoilerText() != null - && !statuses.get(i).getSpoilerText().isEmpty()) { + if (!TextUtils.isEmpty(statuses.get(i).getSpoilerText())) { hasAnyWarnings = true; break; } diff --git a/app/src/main/java/com/keylesspalace/tusky/network/ProgressRequestBody.java b/app/src/main/java/com/keylesspalace/tusky/network/ProgressRequestBody.java index 8e010526..2851d47e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/network/ProgressRequestBody.java +++ b/app/src/main/java/com/keylesspalace/tusky/network/ProgressRequestBody.java @@ -49,7 +49,7 @@ public final class ProgressRequestBody extends RequestBody { } @Override - public long contentLength() throws IOException { + public long contentLength() { return content.length; } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ClickableSpanNoUnderline.kt b/app/src/main/java/com/keylesspalace/tusky/util/ClickableSpanNoUnderline.kt index bd4bceb3..dfe6ce78 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ClickableSpanNoUnderline.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/ClickableSpanNoUnderline.kt @@ -6,6 +6,6 @@ import android.text.style.ClickableSpan abstract class ClickableSpanNoUnderline : ClickableSpan() { override fun updateDrawState(ds: TextPaint?) { super.updateDrawState(ds) - ds?.isUnderlineText = false; + ds?.isUnderlineText = false } } \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java b/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java index bdbf1a71..43623e6b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/NotificationHelper.java @@ -264,6 +264,7 @@ public class NotificationHelper { .setDeleteIntent(deletePendingIntent) .setColor(ContextCompat.getColor(context, (R.color.primary))) .setGroup(account.getAccountId()) + .setAutoCancel(true) .setDefaults(0); // So it doesn't ring twice, notify only in Target callback setupPreferences(account, builder); @@ -521,7 +522,6 @@ public class NotificationHelper { return null; } - @Nullable private static String bodyForType(Notification notification) { switch (notification.getType()) { case FOLLOW: diff --git a/app/src/main/java/com/keylesspalace/tusky/util/StringUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/StringUtils.java index 1d909751..6c395794 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/StringUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/StringUtils.java @@ -1,17 +1,9 @@ package com.keylesspalace.tusky.util; -import android.util.Patterns; - -import java.util.ArrayList; -import java.util.List; import java.util.Random; -import java.util.regex.Matcher; public class StringUtils { - public final static String carriageReturn = System.getProperty("line.separator"); - final static String QUOTE = "\""; - public static String randomAlphanumericString(int count) { char[] chars = new char[count]; Random random = new Random(); @@ -22,13 +14,4 @@ public class StringUtils { return new String(chars); } - static List extractUrl(String text) { - List links = new ArrayList<>(); - Matcher m = Patterns.WEB_URL.matcher(text); - while (m.find()) { - String url = m.group(); - links.add(url); - } - return links; - } } diff --git a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt index ca693097..0ffda354 100644 --- a/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt +++ b/app/src/test/java/com/keylesspalace/tusky/BottomSheetActivityTest.kt @@ -282,22 +282,19 @@ class BottomSheetActivityTest { override fun request(): Request { throw NotImplementedError() } } - class FakeBottomSheetActivity(val api: MastodonApi) : BottomSheetActivity() { + class FakeBottomSheetActivity(api: MastodonApi) : BottomSheetActivity() { var status: Status? = null var accountId: String? = null var link: String? = null init { + mastodonApi = api @Suppress("UNCHECKED_CAST") bottomSheet = Mockito.mock(BottomSheetBehavior::class.java) as BottomSheetBehavior callList = arrayListOf() } - override fun getMastodonApi(): MastodonApi { - return api - } - override fun openLink(url: String) { this.link = url } diff --git a/build.gradle b/build.gradle index a559d86e..5f0ec69d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.40' + ext.kotlin_version = '1.2.41' repositories { jcenter() google()