diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountAdapter.java b/app/src/main/java/com/keylesspalace/tusky/AccountAdapter.java index ab7653a6c..3334b19c4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountAdapter.java @@ -25,15 +25,12 @@ import java.util.List; abstract class AccountAdapter extends RecyclerView.Adapter { List accountList; AccountActionListener accountActionListener; - FooterActionListener footerActionListener; FooterViewHolder.State footerState; - AccountAdapter(AccountActionListener accountActionListener, - FooterActionListener footerActionListener) { + AccountAdapter(AccountActionListener accountActionListener) { super(); accountList = new ArrayList<>(); this.accountActionListener = accountActionListener; - this.footerActionListener = footerActionListener; footerState = FooterViewHolder.State.LOADING; } diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java b/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java index 4afc04c1b..e754abcb5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountFragment.java @@ -37,8 +37,7 @@ import java.util.List; import retrofit2.Call; import retrofit2.Callback; -public class AccountFragment extends Fragment implements AccountActionListener, - FooterActionListener { +public class AccountFragment extends Fragment implements AccountActionListener { private static final String TAG = "Account"; // logging tag public enum Type { @@ -106,7 +105,7 @@ public class AccountFragment extends Fragment implements AccountActionListener, AccountAdapter adapter = (AccountAdapter) view.getAdapter(); Account account = adapter.getItem(adapter.getItemCount() - 2); if (account != null) { - fetchAccounts(account.id); + fetchAccounts(account.id, null); } else { fetchAccounts(); } @@ -114,9 +113,9 @@ public class AccountFragment extends Fragment implements AccountActionListener, }; recyclerView.addOnScrollListener(scrollListener); if (type == Type.BLOCKS) { - adapter = new BlocksAdapter(this, this); + adapter = new BlocksAdapter(this); } else { - adapter = new FollowAdapter(this, this); + adapter = new FollowAdapter(this); } recyclerView.setAdapter(adapter); @@ -151,7 +150,7 @@ public class AccountFragment extends Fragment implements AccountActionListener, super.onDestroyView(); } - private void fetchAccounts(final String fromId) { + private void fetchAccounts(final String fromId, String uptoId) { Callback> cb = new Callback>() { @Override public void onResponse(Call> call, retrofit2.Response> response) { @@ -167,22 +166,22 @@ public class AccountFragment extends Fragment implements AccountActionListener, switch (type) { default: case FOLLOWS: { - api.accountFollowing(accountId, fromId, null, null).enqueue(cb); + api.accountFollowing(accountId, fromId, uptoId, null).enqueue(cb); break; } case FOLLOWERS: { - api.accountFollowers(accountId, fromId, null, null).enqueue(cb); + api.accountFollowers(accountId, fromId, uptoId, null).enqueue(cb); break; } case BLOCKS: { - api.blocks(fromId, null, null).enqueue(cb); + api.blocks(fromId, uptoId, null).enqueue(cb); break; } } } private void fetchAccounts() { - fetchAccounts(null); + fetchAccounts(null, null); } private static boolean findAccount(List accounts, String id) { @@ -229,15 +228,6 @@ public class AccountFragment extends Fragment implements AccountActionListener, } } - public void onLoadMore() { - Account account = adapter.getItem(adapter.getItemCount() - 2); - if (account != null) { - fetchAccounts(account.id); - } else { - fetchAccounts(); - } - } - public void onViewAccount(String id) { Intent intent = new Intent(getContext(), AccountActivity.class); intent.putExtra("id", id); diff --git a/app/src/main/java/com/keylesspalace/tusky/BlocksAdapter.java b/app/src/main/java/com/keylesspalace/tusky/BlocksAdapter.java index 37bfc4034..739cec35c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BlocksAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/BlocksAdapter.java @@ -35,9 +35,8 @@ class BlocksAdapter extends AccountAdapter { private Set unblockedAccountPositions; - BlocksAdapter(AccountActionListener accountActionListener, - FooterActionListener footerActionListener) { - super(accountActionListener, footerActionListener); + BlocksAdapter(AccountActionListener accountActionListener) { + super(accountActionListener); unblockedAccountPositions = new HashSet<>(); } diff --git a/app/src/main/java/com/keylesspalace/tusky/FollowAdapter.java b/app/src/main/java/com/keylesspalace/tusky/FollowAdapter.java index 140e32d02..6512aff24 100644 --- a/app/src/main/java/com/keylesspalace/tusky/FollowAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/FollowAdapter.java @@ -31,9 +31,8 @@ class FollowAdapter extends AccountAdapter { private static final int VIEW_TYPE_ACCOUNT = 0; private static final int VIEW_TYPE_FOOTER = 1; - FollowAdapter(AccountActionListener accountActionListener, - FooterActionListener footerActionListener) { - super(accountActionListener, footerActionListener); + FollowAdapter(AccountActionListener accountActionListener) { + super(accountActionListener); } @Override diff --git a/app/src/main/java/com/keylesspalace/tusky/FooterActionListener.java b/app/src/main/java/com/keylesspalace/tusky/FooterActionListener.java deleted file mode 100644 index da89a4f91..000000000 --- a/app/src/main/java/com/keylesspalace/tusky/FooterActionListener.java +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2017 Andrew Dawson - * - * This file is part of Tusky. - * - * Tusky is free software: you can redistribute it and/or modify it under the terms of the GNU - * General Public License as published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Tusky. If not, see - * . */ - -package com.keylesspalace.tusky; - -public interface FooterActionListener { - void onLoadMore(); -} diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index dca07f907..32b3374f4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -82,7 +82,7 @@ public class LoginActivity extends BaseActivity { private void redirectUserToAuthorizeAndLogin() { /* To authorize this app and log in it's necessary to redirect to the domain given, * activity_login there, and the server will redirect back to the app with its response. */ - String endpoint = getString(R.string.endpoint_authorize); + String endpoint = MastodonAPI.ENDPOINT_AUTHORIZE; String redirectUri = getOauthRedirectUri(); Map parameters = new HashMap<>(); parameters.put("client_id", clientId); diff --git a/app/src/main/java/com/keylesspalace/tusky/MastodonAPI.java b/app/src/main/java/com/keylesspalace/tusky/MastodonAPI.java index 51d8ec052..e881f996e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MastodonAPI.java +++ b/app/src/main/java/com/keylesspalace/tusky/MastodonAPI.java @@ -25,6 +25,8 @@ import retrofit2.http.Path; import retrofit2.http.Query; public interface MastodonAPI { + String ENDPOINT_AUTHORIZE = "/oauth/authorize"; + @GET("api/v1/timelines/home") Call> homeTimeline( @Query("max_id") String maxId, diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java index 5b8ea652e..630b95686 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationsAdapter.java @@ -44,16 +44,13 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe private List notifications; private StatusActionListener statusListener; private FollowListener followListener; - private FooterActionListener footerListener; private FooterViewHolder.State footerState; - NotificationsAdapter(StatusActionListener statusListener, FollowListener followListener, - FooterActionListener footerListener) { + NotificationsAdapter(StatusActionListener statusListener, FollowListener followListener) { super(); notifications = new ArrayList<>(); this.statusListener = statusListener; this.followListener = followListener; - this.footerListener = footerListener; footerState = FooterViewHolder.State.LOADING; } @@ -187,7 +184,6 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe interface FollowListener { void onViewAccount(String id); - void onFollow(String id); } private static class FollowViewHolder extends RecyclerView.ViewHolder { diff --git a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java index 8a410661d..7d3f84ede 100644 --- a/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/NotificationsFragment.java @@ -38,7 +38,7 @@ import retrofit2.Call; import retrofit2.Callback; public class NotificationsFragment extends SFragment implements - SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener, + SwipeRefreshLayout.OnRefreshListener, StatusActionListener, NotificationsAdapter.FollowListener { private static final String TAG = "Notifications"; // logging tag @@ -91,14 +91,14 @@ public class NotificationsFragment extends SFragment implements NotificationsAdapter adapter = (NotificationsAdapter) view.getAdapter(); Notification notification = adapter.getItem(adapter.getItemCount() - 2); if (notification != null) { - sendFetchNotificationsRequest(notification.id); + sendFetchNotificationsRequest(notification.id, null); } else { sendFetchNotificationsRequest(); } } }; recyclerView.addOnScrollListener(scrollListener); - adapter = new NotificationsAdapter(this, this, this); + adapter = new NotificationsAdapter(this, this); recyclerView.setAdapter(adapter); TabLayout layout = (TabLayout) getActivity().findViewById(R.id.tab_layout); @@ -116,8 +116,6 @@ public class NotificationsFragment extends SFragment implements }; layout.addOnTabSelectedListener(onTabSelectedListener); - sendFetchNotificationsRequest(); - return rootView; } @@ -133,10 +131,10 @@ public class NotificationsFragment extends SFragment implements scrollListener.reset(); } - private void sendFetchNotificationsRequest(final String fromId) { + private void sendFetchNotificationsRequest(final String fromId, String uptoId) { MastodonAPI api = ((BaseActivity) getActivity()).mastodonAPI; - api.notifications(fromId, null, null).enqueue(new Callback>() { + api.notifications(fromId, uptoId, null).enqueue(new Callback>() { @Override public void onResponse(Call> call, retrofit2.Response> response) { onFetchNotificationsSuccess(response.body(), fromId); @@ -150,7 +148,7 @@ public class NotificationsFragment extends SFragment implements } private void sendFetchNotificationsRequest() { - sendFetchNotificationsRequest(null); + sendFetchNotificationsRequest(null, null); } private static boolean findNotification(List notifications, String id) { @@ -193,13 +191,9 @@ public class NotificationsFragment extends SFragment implements } public void onRefresh() { - sendFetchNotificationsRequest(); - } - - public void onLoadMore() { - Notification notification = adapter.getItem(adapter.getItemCount() - 2); + Notification notification = adapter.getItem(0); if (notification != null) { - sendFetchNotificationsRequest(notification.id); + sendFetchNotificationsRequest(null, notification.id); } else { sendFetchNotificationsRequest(); } @@ -241,8 +235,4 @@ public class NotificationsFragment extends SFragment implements public void onViewAccount(String id) { super.viewAccount(id); } - - public void onFollow(String id) { - super.follow(id); - } } diff --git a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java index ffc2811ad..17fd82c7e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java @@ -20,7 +20,6 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; public class PreferencesActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener { diff --git a/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java b/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java index 428413cf5..877c8545f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java @@ -32,15 +32,12 @@ class TimelineAdapter extends RecyclerView.Adapter implements AdapterItemRemover private List statuses; private StatusActionListener statusListener; - private FooterActionListener footerListener; private FooterViewHolder.State footerState; - TimelineAdapter(StatusActionListener statusListener, - FooterActionListener footerListener) { + TimelineAdapter(StatusActionListener statusListener) { super(); statuses = new ArrayList<>(); this.statusListener = statusListener; - this.footerListener = footerListener; footerState = FooterViewHolder.State.LOADING; } diff --git a/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java index 9788c1080..b8c0bfbc2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/TimelineFragment.java @@ -18,6 +18,7 @@ package com.keylesspalace.tusky; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.DividerItemDecoration; @@ -35,12 +36,11 @@ import retrofit2.Call; import retrofit2.Callback; public class TimelineFragment extends SFragment implements - SwipeRefreshLayout.OnRefreshListener, StatusActionListener, FooterActionListener { + SwipeRefreshLayout.OnRefreshListener, StatusActionListener { private static final String TAG = "Timeline"; // logging tag - public enum Kind { + enum Kind { HOME, - MENTIONS, PUBLIC, TAG, USER, @@ -106,14 +106,14 @@ public class TimelineFragment extends SFragment implements TimelineAdapter adapter = (TimelineAdapter) view.getAdapter(); Status status = adapter.getItem(adapter.getItemCount() - 2); if (status != null) { - sendFetchTimelineRequest(status.id); + sendFetchTimelineRequest(status.id, null); } else { sendFetchTimelineRequest(); } } }; recyclerView.addOnScrollListener(scrollListener); - adapter = new TimelineAdapter(this, this); + adapter = new TimelineAdapter(this); recyclerView.setAdapter(adapter); if (jumpToTopAllowed()) { @@ -156,7 +156,7 @@ public class TimelineFragment extends SFragment implements scrollListener.reset(); } - private void sendFetchTimelineRequest(final String fromId) { + private void sendFetchTimelineRequest(@Nullable final String fromId, @Nullable String uptoId) { MastodonAPI api = ((BaseActivity) getActivity()).mastodonAPI; Callback> cb = new Callback>() { @@ -174,30 +174,30 @@ public class TimelineFragment extends SFragment implements switch (kind) { default: case HOME: { - api.homeTimeline(fromId, null, null).enqueue(cb); + api.homeTimeline(fromId, uptoId, null).enqueue(cb); break; } case PUBLIC: { - api.publicTimeline(null, fromId, null, null).enqueue(cb); + api.publicTimeline(null, fromId, uptoId, null).enqueue(cb); break; } case TAG: { - api.hashtagTimeline(hashtagOrId, null, fromId, null, null).enqueue(cb); + api.hashtagTimeline(hashtagOrId, null, fromId, uptoId, null).enqueue(cb); break; } case USER: { - api.accountStatuses(hashtagOrId, fromId, null, null).enqueue(cb); + api.accountStatuses(hashtagOrId, fromId, uptoId, null).enqueue(cb); break; } case FAVOURITES: { - api.favourites(fromId, null, null).enqueue(cb); + api.favourites(fromId, uptoId, null).enqueue(cb); break; } } } private void sendFetchTimelineRequest() { - sendFetchTimelineRequest(null); + sendFetchTimelineRequest(null, null); } private static boolean findStatus(List statuses, String id) { @@ -240,13 +240,9 @@ public class TimelineFragment extends SFragment implements } public void onRefresh() { - sendFetchTimelineRequest(); - } - - public void onLoadMore() { - Status status = adapter.getItem(adapter.getItemCount() - 2); + Status status = adapter.getItem(0); if (status != null) { - sendFetchTimelineRequest(status.id); + sendFetchTimelineRequest(null, status.id); } else { sendFetchTimelineRequest(); } diff --git a/app/src/main/res/drawable-hdpi-v11/ic_notify.png b/app/src/main/res/drawable-hdpi-v11/ic_notify.png index 5cb8246bd..610161ea6 100644 Binary files a/app/src/main/res/drawable-hdpi-v11/ic_notify.png and b/app/src/main/res/drawable-hdpi-v11/ic_notify.png differ diff --git a/app/src/main/res/drawable-mdpi-v11/ic_notify.png b/app/src/main/res/drawable-mdpi-v11/ic_notify.png index f578a53f0..b61143b07 100644 Binary files a/app/src/main/res/drawable-mdpi-v11/ic_notify.png and b/app/src/main/res/drawable-mdpi-v11/ic_notify.png differ diff --git a/app/src/main/res/drawable-xhdpi-v11/ic_notify.png b/app/src/main/res/drawable-xhdpi-v11/ic_notify.png index 940498905..37f60b5f1 100644 Binary files a/app/src/main/res/drawable-xhdpi-v11/ic_notify.png and b/app/src/main/res/drawable-xhdpi-v11/ic_notify.png differ diff --git a/app/src/main/res/drawable-xxhdpi-v11/ic_notify.png b/app/src/main/res/drawable-xxhdpi-v11/ic_notify.png index 63ddf6d55..cf90f6887 100644 Binary files a/app/src/main/res/drawable-xxhdpi-v11/ic_notify.png and b/app/src/main/res/drawable-xxhdpi-v11/ic_notify.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 06d8e24fc..94fa83733 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,42 +6,6 @@ oauth2redirect com.keylesspalace.tusky.PREFERENCES - /api/v1/statuses - /api/v1/media - /api/v1/timelines/home - /api/v1/timelines/mentions - /api/v1/timelines/public - /api/v1/timelines/tag/%s - /api/v1/notifications - /api/v1/follows - /api/v1/statuses/%s - /api/v1/accounts/%s - /api/v1/accounts/verify_credentials - /api/v1/accounts/%s/statuses - /api/v1/accounts/%s/following - /api/v1/accounts/%s/followers - /api/v1/accounts/relationships - /api/v1/blocks - /api/v1/favourites - /api/v1/statuses/%s - /api/v1/statuses/%s/reblog - /api/v1/statuses/%s/unreblog - /api/v1/statuses/%s/favourite - /api/v1/statuses/%s/unfavourite - /api/v1/statuses/%s/context - /api/v1/statuses/%s/reblogged_by - /api/v1/statuses/%s/favourited_by - /api/v1/accounts/%s/follow - /api/v1/accounts/%s/unfollow - /api/v1/accounts/%s/block - /api/v1/accounts/%s/unblock - /api/v1/reports - /api/v1/apps - /oauth/authorize - /oauth/token - /api/v1/devices/register - /api/v1/devices/unregister - An unidentified authorization error occurred. Notifications could not be fetched. The status is too long! @@ -157,12 +121,12 @@ Privacy options Welcome back! Share - Share toot URL to... + Share toot URL to… Mute Unmute That user wasn\'t unmuted. That user wasn\'t muted. - Search accounts... + Search accounts… NSFW