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
This commit is contained in:
parent
26fb180d1a
commit
27b4cf8739
|
@ -44,7 +44,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.supportLibraryVersion = '27.1.1'
|
ext.supportLibraryVersion = '27.1.1'
|
||||||
ext.daggerVersion = '2.15'
|
ext.daggerVersion = '2.16'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation('com.mikepenz:materialdrawer:6.0.7@aar') {
|
implementation('com.mikepenz:materialdrawer:6.0.7@aar') {
|
||||||
|
|
|
@ -47,12 +47,10 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.db.AccountEntity;
|
import com.keylesspalace.tusky.db.AccountEntity;
|
||||||
import com.keylesspalace.tusky.db.AccountManager;
|
|
||||||
import com.keylesspalace.tusky.entity.Account;
|
import com.keylesspalace.tusky.entity.Account;
|
||||||
import com.keylesspalace.tusky.entity.Relationship;
|
import com.keylesspalace.tusky.entity.Relationship;
|
||||||
import com.keylesspalace.tusky.interfaces.ActionButtonActivity;
|
import com.keylesspalace.tusky.interfaces.ActionButtonActivity;
|
||||||
import com.keylesspalace.tusky.interfaces.LinkListener;
|
import com.keylesspalace.tusky.interfaces.LinkListener;
|
||||||
import com.keylesspalace.tusky.network.MastodonApi;
|
|
||||||
import com.keylesspalace.tusky.pager.AccountPagerAdapter;
|
import com.keylesspalace.tusky.pager.AccountPagerAdapter;
|
||||||
import com.keylesspalace.tusky.receiver.TimelineReceiver;
|
import com.keylesspalace.tusky.receiver.TimelineReceiver;
|
||||||
import com.keylesspalace.tusky.util.Assert;
|
import com.keylesspalace.tusky.util.Assert;
|
||||||
|
@ -85,8 +83,6 @@ public final class AccountActivity extends BottomSheetActivity implements Action
|
||||||
REQUESTED,
|
REQUESTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
|
||||||
public MastodonApi mastodonApi;
|
|
||||||
@Inject
|
@Inject
|
||||||
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
||||||
|
|
||||||
|
@ -712,9 +708,4 @@ public final class AccountActivity extends BottomSheetActivity implements Action
|
||||||
return dispatchingAndroidInjector;
|
return dispatchingAndroidInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public MastodonApi getMastodonApi() {
|
|
||||||
return mastodonApi;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.evernote.android.job.JobManager;
|
||||||
import com.evernote.android.job.JobRequest;
|
import com.evernote.android.job.JobRequest;
|
||||||
import com.keylesspalace.tusky.db.AccountEntity;
|
import com.keylesspalace.tusky.db.AccountEntity;
|
||||||
import com.keylesspalace.tusky.db.AccountManager;
|
import com.keylesspalace.tusky.db.AccountManager;
|
||||||
|
import com.keylesspalace.tusky.di.Injectable;
|
||||||
import com.keylesspalace.tusky.util.ThemeUtils;
|
import com.keylesspalace.tusky.util.ThemeUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -41,7 +42,7 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity {
|
public abstract class BaseActivity extends AppCompatActivity implements Injectable {
|
||||||
|
|
||||||
protected List<Call> callList;
|
protected List<Call> callList;
|
||||||
|
|
||||||
|
@ -111,20 +112,14 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||||
return getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
return getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean redirectIfNotLoggedIn() {
|
protected void redirectIfNotLoggedIn() {
|
||||||
// This is very ugly but we cannot inject into parent class and injecting into every
|
AccountEntity account = accountManager.getActiveAccount();
|
||||||
// subclass seems inconvenient as well.
|
|
||||||
AccountEntity account = ((TuskyApplication) getApplicationContext())
|
|
||||||
.getServiceLocator().get(AccountManager.class)
|
|
||||||
.getActiveAccount();
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
Intent intent = new Intent(this, LoginActivity.class);
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,6 +30,7 @@ import retrofit2.Callback
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.net.URISyntaxException
|
import java.net.URISyntaxException
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
/** this is the base class for all activities that open links
|
/** 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
|
* 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<LinearLayout>
|
lateinit var bottomSheet: BottomSheetBehavior<LinearLayout>
|
||||||
var searchUrl: String? = null
|
var searchUrl: String? = null
|
||||||
|
|
||||||
abstract fun getMastodonApi(): MastodonApi
|
@Inject
|
||||||
|
lateinit var mastodonApi: MastodonApi
|
||||||
|
|
||||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||||
super.onPostCreate(savedInstanceState)
|
super.onPostCreate(savedInstanceState)
|
||||||
|
@ -67,7 +69,7 @@ abstract class BottomSheetActivity : BaseActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val call = getMastodonApi().search(url, true)
|
val call = mastodonApi.search(url, true)
|
||||||
call.enqueue(object : Callback<SearchResults> {
|
call.enqueue(object : Callback<SearchResults> {
|
||||||
override fun onResponse(call: Call<SearchResults>, response: Response<SearchResults>) {
|
override fun onResponse(call: Call<SearchResults>, response: Response<SearchResults>) {
|
||||||
if (getCancelSearchRequested(url)) {
|
if (getCancelSearchRequested(url)) {
|
||||||
|
|
|
@ -24,9 +24,6 @@ import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.fragment.TimelineFragment;
|
import com.keylesspalace.tusky.fragment.TimelineFragment;
|
||||||
import com.keylesspalace.tusky.network.MastodonApi;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -36,8 +33,6 @@ import dagger.android.support.HasSupportFragmentInjector;
|
||||||
|
|
||||||
public class FavouritesActivity extends BottomSheetActivity implements HasSupportFragmentInjector {
|
public class FavouritesActivity extends BottomSheetActivity implements HasSupportFragmentInjector {
|
||||||
|
|
||||||
@Inject
|
|
||||||
public MastodonApi mastodonApi;
|
|
||||||
@Inject
|
@Inject
|
||||||
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
||||||
|
|
||||||
|
@ -77,9 +72,4 @@ public class FavouritesActivity extends BottomSheetActivity implements HasSuppor
|
||||||
return dispatchingAndroidInjector;
|
return dispatchingAndroidInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public MastodonApi getMastodonApi() {
|
|
||||||
return mastodonApi;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,8 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.db.AccountEntity;
|
import com.keylesspalace.tusky.db.AccountEntity;
|
||||||
import com.keylesspalace.tusky.db.AccountManager;
|
|
||||||
import com.keylesspalace.tusky.entity.Account;
|
import com.keylesspalace.tusky.entity.Account;
|
||||||
import com.keylesspalace.tusky.interfaces.ActionButtonActivity;
|
import com.keylesspalace.tusky.interfaces.ActionButtonActivity;
|
||||||
import com.keylesspalace.tusky.network.MastodonApi;
|
|
||||||
import com.keylesspalace.tusky.pager.TimelinePagerAdapter;
|
import com.keylesspalace.tusky.pager.TimelinePagerAdapter;
|
||||||
import com.keylesspalace.tusky.util.NotificationHelper;
|
import com.keylesspalace.tusky.util.NotificationHelper;
|
||||||
import com.keylesspalace.tusky.util.ThemeUtils;
|
import com.keylesspalace.tusky.util.ThemeUtils;
|
||||||
|
@ -60,8 +58,6 @@ import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
|
||||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
|
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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_SAVED_TOOT = 9;
|
||||||
private static final long DRAWER_ITEM_LISTS = 10;
|
private static final long DRAWER_ITEM_LISTS = 10;
|
||||||
|
|
||||||
@Inject
|
|
||||||
public MastodonApi mastodonApi;
|
|
||||||
@Inject
|
@Inject
|
||||||
public DispatchingAndroidInjector<Fragment> fragmentInjector;
|
public DispatchingAndroidInjector<Fragment> fragmentInjector;
|
||||||
|
|
||||||
|
@ -268,12 +262,6 @@ public class MainActivity extends BottomSheetActivity implements ActionButtonAct
|
||||||
return super.onKeyDown(keyCode, event);
|
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) {
|
private void tintTab(TabLayout.Tab tab, boolean tinted) {
|
||||||
int color = (tinted) ? R.attr.tab_icon_selected_tint : R.attr.toolbar_icon_tint;
|
int color = (tinted) ? R.attr.tab_icon_selected_tint : R.attr.toolbar_icon_tint;
|
||||||
ThemeUtils.setDrawableTint(this, tab.getIcon(), color);
|
ThemeUtils.setDrawableTint(this, tab.getIcon(), color);
|
||||||
|
@ -553,9 +541,4 @@ public class MainActivity extends BottomSheetActivity implements ActionButtonAct
|
||||||
return fragmentInjector;
|
return fragmentInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public MastodonApi getMastodonApi() {
|
|
||||||
return mastodonApi;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -10,7 +10,6 @@ import android.view.MenuItem
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import com.keylesspalace.tusky.fragment.TimelineFragment
|
import com.keylesspalace.tusky.fragment.TimelineFragment
|
||||||
import com.keylesspalace.tusky.interfaces.ActionButtonActivity
|
import com.keylesspalace.tusky.interfaces.ActionButtonActivity
|
||||||
import com.keylesspalace.tusky.network.MastodonApi
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.DispatchingAndroidInjector
|
import dagger.android.DispatchingAndroidInjector
|
||||||
import dagger.android.support.HasSupportFragmentInjector
|
import dagger.android.support.HasSupportFragmentInjector
|
||||||
|
@ -18,8 +17,6 @@ import javax.inject.Inject
|
||||||
|
|
||||||
class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportFragmentInjector {
|
class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportFragmentInjector {
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var api: MastodonApi
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
|
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
|
||||||
|
|
||||||
|
@ -79,8 +76,4 @@ class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSu
|
||||||
return dispatchingAndroidInjector
|
return dispatchingAndroidInjector
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMastodonApi(): MastodonApi {
|
|
||||||
return api
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ public final class NotificationPullJobCreator implements JobCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) {
|
private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) {
|
||||||
return lastShownNotificationId.compareTo(newId) == -1;
|
return lastShownNotificationId.compareTo(newId) < 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,6 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.fragment.SearchFragment;
|
import com.keylesspalace.tusky.fragment.SearchFragment;
|
||||||
import com.keylesspalace.tusky.network.MastodonApi;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -42,8 +39,7 @@ import dagger.android.support.HasSupportFragmentInjector;
|
||||||
|
|
||||||
public class SearchActivity extends BottomSheetActivity implements SearchView.OnQueryTextListener,
|
public class SearchActivity extends BottomSheetActivity implements SearchView.OnQueryTextListener,
|
||||||
HasSupportFragmentInjector {
|
HasSupportFragmentInjector {
|
||||||
@Inject
|
|
||||||
public MastodonApi mastodonApi;
|
|
||||||
@Inject
|
@Inject
|
||||||
public DispatchingAndroidInjector<Fragment> fragmentInjector;
|
public DispatchingAndroidInjector<Fragment> fragmentInjector;
|
||||||
|
|
||||||
|
@ -144,9 +140,4 @@ public class SearchActivity extends BottomSheetActivity implements SearchView.On
|
||||||
return fragmentInjector;
|
return fragmentInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public MastodonApi getMastodonApi() {
|
|
||||||
return mastodonApi;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,6 @@ import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.fragment.TimelineFragment;
|
import com.keylesspalace.tusky.fragment.TimelineFragment;
|
||||||
import com.keylesspalace.tusky.network.MastodonApi;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -36,8 +33,6 @@ import dagger.android.support.HasSupportFragmentInjector;
|
||||||
|
|
||||||
public class ViewTagActivity extends BottomSheetActivity implements HasSupportFragmentInjector {
|
public class ViewTagActivity extends BottomSheetActivity implements HasSupportFragmentInjector {
|
||||||
|
|
||||||
@Inject
|
|
||||||
public MastodonApi mastodonApi;
|
|
||||||
@Inject
|
@Inject
|
||||||
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
||||||
|
|
||||||
|
@ -80,9 +75,4 @@ public class ViewTagActivity extends BottomSheetActivity implements HasSupportFr
|
||||||
return dispatchingAndroidInjector;
|
return dispatchingAndroidInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public MastodonApi getMastodonApi() {
|
|
||||||
return mastodonApi;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,8 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.fragment.ViewThreadFragment;
|
import com.keylesspalace.tusky.fragment.ViewThreadFragment;
|
||||||
import com.keylesspalace.tusky.network.MastodonApi;
|
|
||||||
import com.keylesspalace.tusky.util.LinkHelper;
|
import com.keylesspalace.tusky.util.LinkHelper;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.AndroidInjector;
|
import dagger.android.AndroidInjector;
|
||||||
|
@ -44,8 +41,6 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor
|
||||||
|
|
||||||
private int revealButtonState = REVEAL_BUTTON_HIDDEN;
|
private int revealButtonState = REVEAL_BUTTON_HIDDEN;
|
||||||
|
|
||||||
@Inject
|
|
||||||
public MastodonApi mastodonApi;
|
|
||||||
@Inject
|
@Inject
|
||||||
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
public DispatchingAndroidInjector<Fragment> dispatchingAndroidInjector;
|
||||||
|
|
||||||
|
@ -119,9 +114,4 @@ public class ViewThreadActivity extends BottomSheetActivity implements HasSuppor
|
||||||
return dispatchingAndroidInjector;
|
return dispatchingAndroidInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public MastodonApi getMastodonApi() {
|
|
||||||
return mastodonApi;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class ThreadAdapter extends RecyclerView.Adapter {
|
||||||
detailedStatusPosition = RecyclerView.NO_POSITION;
|
detailedStatusPosition = RecyclerView.NO_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
|
|
|
@ -74,4 +74,16 @@ abstract class ActivitiesModule {
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract fun contributesReportActivity(): ReportActivity
|
abstract fun contributesReportActivity(): ReportActivity
|
||||||
|
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesSavedTootActivity(): SavedTootActivity
|
||||||
|
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesSPreferencesActivity(): PreferencesActivity
|
||||||
|
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesViewMediaActivity(): ViewMediaActivity
|
||||||
|
|
||||||
|
@ContributesAndroidInjector
|
||||||
|
abstract fun contributesViewVideoActivity(): ViewVideoActivity
|
||||||
|
|
||||||
}
|
}
|
|
@ -22,5 +22,5 @@ import dagger.android.ContributesAndroidInjector
|
||||||
@Module
|
@Module
|
||||||
abstract class ServicesModule {
|
abstract class ServicesModule {
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract fun contributeMyService(): SendTootService
|
abstract fun contributesSendTootService(): SendTootService
|
||||||
}
|
}
|
|
@ -16,7 +16,6 @@
|
||||||
package com.keylesspalace.tusky.entity
|
package com.keylesspalace.tusky.entity
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
data class Instance (
|
data class Instance (
|
||||||
val uri: String,
|
val uri: String,
|
||||||
|
|
|
@ -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
|
|
||||||
)
|
|
||||||
|
|
|
@ -623,7 +623,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
|
|
||||||
private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) {
|
private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) {
|
||||||
|
|
||||||
return lastShownNotificationId.compareTo(newId) == -1;
|
return lastShownNotificationId.compareTo(newId) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(@Nullable List<Notification> newNotifications, @Nullable String fromId,
|
private void update(@Nullable List<Notification> newNotifications, @Nullable String fromId,
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.DividerItemDecoration;
|
import android.support.v7.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -100,7 +101,6 @@ public final class ViewThreadFragment extends SFragment implements
|
||||||
return timelineCases;
|
return timelineCases;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -532,11 +532,6 @@ public final class ViewThreadFragment extends SFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
statuses.clear();
|
|
||||||
adapter.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateRevealIcon() {
|
private void updateRevealIcon() {
|
||||||
ViewThreadActivity activity = ((ViewThreadActivity) getActivity());
|
ViewThreadActivity activity = ((ViewThreadActivity) getActivity());
|
||||||
if (activity == null) return;
|
if (activity == null) return;
|
||||||
|
@ -544,8 +539,7 @@ public final class ViewThreadFragment extends SFragment implements
|
||||||
boolean hasAnyWarnings = false;
|
boolean hasAnyWarnings = false;
|
||||||
// Statuses are updated from the main thread so nothing should change while iterating
|
// Statuses are updated from the main thread so nothing should change while iterating
|
||||||
for (int i = 0; i < statuses.size(); i++) {
|
for (int i = 0; i < statuses.size(); i++) {
|
||||||
if (statuses.get(i).getSpoilerText() != null
|
if (!TextUtils.isEmpty(statuses.get(i).getSpoilerText())) {
|
||||||
&& !statuses.get(i).getSpoilerText().isEmpty()) {
|
|
||||||
hasAnyWarnings = true;
|
hasAnyWarnings = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class ProgressRequestBody extends RequestBody {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long contentLength() throws IOException {
|
public long contentLength() {
|
||||||
return content.length;
|
return content.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,6 @@ import android.text.style.ClickableSpan
|
||||||
abstract class ClickableSpanNoUnderline : ClickableSpan() {
|
abstract class ClickableSpanNoUnderline : ClickableSpan() {
|
||||||
override fun updateDrawState(ds: TextPaint?) {
|
override fun updateDrawState(ds: TextPaint?) {
|
||||||
super.updateDrawState(ds)
|
super.updateDrawState(ds)
|
||||||
ds?.isUnderlineText = false;
|
ds?.isUnderlineText = false
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -264,6 +264,7 @@ public class NotificationHelper {
|
||||||
.setDeleteIntent(deletePendingIntent)
|
.setDeleteIntent(deletePendingIntent)
|
||||||
.setColor(ContextCompat.getColor(context, (R.color.primary)))
|
.setColor(ContextCompat.getColor(context, (R.color.primary)))
|
||||||
.setGroup(account.getAccountId())
|
.setGroup(account.getAccountId())
|
||||||
|
.setAutoCancel(true)
|
||||||
.setDefaults(0); // So it doesn't ring twice, notify only in Target callback
|
.setDefaults(0); // So it doesn't ring twice, notify only in Target callback
|
||||||
|
|
||||||
setupPreferences(account, builder);
|
setupPreferences(account, builder);
|
||||||
|
@ -521,7 +522,6 @@ public class NotificationHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static String bodyForType(Notification notification) {
|
private static String bodyForType(Notification notification) {
|
||||||
switch (notification.getType()) {
|
switch (notification.getType()) {
|
||||||
case FOLLOW:
|
case FOLLOW:
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
package com.keylesspalace.tusky.util;
|
package com.keylesspalace.tusky.util;
|
||||||
|
|
||||||
import android.util.Patterns;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
|
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
|
|
||||||
public final static String carriageReturn = System.getProperty("line.separator");
|
|
||||||
final static String QUOTE = "\"";
|
|
||||||
|
|
||||||
public static String randomAlphanumericString(int count) {
|
public static String randomAlphanumericString(int count) {
|
||||||
char[] chars = new char[count];
|
char[] chars = new char[count];
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
@ -22,13 +14,4 @@ public class StringUtils {
|
||||||
return new String(chars);
|
return new String(chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<String> extractUrl(String text) {
|
|
||||||
List<String> links = new ArrayList<>();
|
|
||||||
Matcher m = Patterns.WEB_URL.matcher(text);
|
|
||||||
while (m.find()) {
|
|
||||||
String url = m.group();
|
|
||||||
links.add(url);
|
|
||||||
}
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,22 +282,19 @@ class BottomSheetActivityTest {
|
||||||
override fun request(): Request { throw NotImplementedError() }
|
override fun request(): Request { throw NotImplementedError() }
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeBottomSheetActivity(val api: MastodonApi) : BottomSheetActivity() {
|
class FakeBottomSheetActivity(api: MastodonApi) : BottomSheetActivity() {
|
||||||
|
|
||||||
var status: Status? = null
|
var status: Status? = null
|
||||||
var accountId: String? = null
|
var accountId: String? = null
|
||||||
var link: String? = null
|
var link: String? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
mastodonApi = api
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
bottomSheet = Mockito.mock(BottomSheetBehavior::class.java) as BottomSheetBehavior<LinearLayout>
|
bottomSheet = Mockito.mock(BottomSheetBehavior::class.java) as BottomSheetBehavior<LinearLayout>
|
||||||
callList = arrayListOf()
|
callList = arrayListOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMastodonApi(): MastodonApi {
|
|
||||||
return api
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun openLink(url: String) {
|
override fun openLink(url: String) {
|
||||||
this.link = url
|
this.link = url
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.40'
|
ext.kotlin_version = '1.2.41'
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
google()
|
google()
|
||||||
|
|
Loading…
Reference in New Issue