diff --git a/app/build.gradle b/app/build.gradle index 5618316c5..2d60f0a1d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "fr.gouv.etalab.mastodon" minSdkVersion 15 targetSdkVersion 25 - versionCode 16 - versionName "1.1.9" + versionCode 17 + versionName "1.2.0" } buildTypes { release { diff --git a/app/mastodon-etalab-v1.2.0.apk b/app/mastodon-etalab-v1.2.0.apk new file mode 100644 index 000000000..901e9b4af Binary files /dev/null and b/app/mastodon-etalab-v1.2.0.apk differ diff --git a/app/src/main/java/com/emojione/Emojione.java b/app/src/main/java/com/emojione/Emojione.java index 7955ae8f8..4ea879322 100644 --- a/app/src/main/java/com/emojione/Emojione.java +++ b/app/src/main/java/com/emojione/Emojione.java @@ -18,8 +18,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -//See: https://github.com/Vavassor/Tusky/blob/master/app/src/main/java/com/emojione/Emojione.java -// +//From: https://github.com/Vavassor/Tusky/blob/master/app/src/main/java/com/emojione/Emojione.java +//And also from: https://github.com/emojione/emojione/blob/master/lib/android/com/emojione/Emojione.java + package com.emojione; import android.os.Build; @@ -30,7 +31,7 @@ import java.util.regex.Pattern; public abstract class Emojione { - private static final HashMap _shortNameToUnicode = new HashMap(); + private static final HashMap _shortNameToUnicode = new HashMap<>(); private static final Pattern SHORTNAME_PATTERN = Pattern.compile(":([-+\\w]+):"); /** @@ -49,7 +50,7 @@ public abstract class Emojione if (supported) { input = input.replace(":" + matcher.group(1) + ":", unicode); - } else if (!supported && removeIfUnsupported) { + } else if (removeIfUnsupported) { input = input.replace(":" + matcher.group(1) + ":", ""); } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java index f5a941485..ce2c68c3e 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java @@ -22,23 +22,18 @@ import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.widget.SwipeRefreshLayout; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.ListView; import android.widget.RelativeLayout; -import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.List; - -import fr.gouv.etalab.mastodon.client.API; import fr.gouv.etalab.mastodon.client.APIResponse; import fr.gouv.etalab.mastodon.client.Entities.Account; -import fr.gouv.etalab.mastodon.client.Entities.Error; import fr.gouv.etalab.mastodon.helper.Helper; import mastodon.etalab.gouv.fr.mastodon.R; import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask; @@ -52,8 +47,6 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface; */ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccountsInterface { - - private TextView noAction; private boolean flag_loading; private Context context; private AsyncTask asyncTask; @@ -66,8 +59,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou private SwipeRefreshLayout swipeRefreshLayout; private int accountPerPage; private String targetedId; - private boolean hideHeader = false; - private boolean comesFromSearch = false; + private boolean swiped; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -75,6 +67,8 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou View rootView = inflater.inflate(R.layout.fragment_accounts, container, false); context = getContext(); + boolean comesFromSearch = false; + boolean hideHeader = false; Bundle bundle = this.getArguments(); accounts = new ArrayList<>(); if (bundle != null) { @@ -93,7 +87,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou max_id = null; firstLoad = true; flag_loading = true; - + swiped = false; swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); @@ -109,8 +103,6 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou lv_accounts.setAdapter(accountsListAdapter); if( !comesFromSearch) { - - //Hide account header when scrolling for ShowAccountActivity if (hideHeader) { lv_accounts.setOnScrollListener(new AbsListView.OnScrollListener() { @@ -187,6 +179,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou accounts = new ArrayList<>(); firstLoad = true; flag_loading = true; + swiped = true; if (type != RetrieveAccountsAsyncTask.Type.FOLLOWERS && type != RetrieveAccountsAsyncTask.Type.FOLLOWING) asyncTask = new RetrieveAccountsAsyncTask(context, type, max_id, DisplayAccountsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); else @@ -248,7 +241,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou return; } List accounts = apiResponse.getAccounts(); - if( firstLoad && (accounts == null || accounts.size() == 0)) + if( !swiped && firstLoad && (accounts == null || accounts.size() == 0)) textviewNoAction.setVisibility(View.VISIBLE); else textviewNoAction.setVisibility(View.GONE); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java index c2fb41dd5..875965e0c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java @@ -57,6 +57,7 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr private SwipeRefreshLayout swipeRefreshLayout; private int accountPerPage; private TextView no_action_text; + private boolean swiped; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -69,7 +70,7 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr max_id = null; firstLoad = true; flag_loading = true; - + swiped = false; swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); @@ -111,6 +112,7 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr accounts = new ArrayList<>(); firstLoad = true; flag_loading = true; + swiped = true; asyncTask = new RetrieveFollowRequestSentAsyncTask(context, max_id, DisplayFollowRequestSentFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); @@ -159,7 +161,7 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr return; } List accounts = apiResponse.getAccounts(); - if( firstLoad && (accounts == null || accounts.size() == 0)) { + if( !swiped && firstLoad && (accounts == null || accounts.size() == 0)) { no_action_text.setText(context.getString(R.string.no_follow_request)); textviewNoAction.setVisibility(View.VISIBLE); }else diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java index 31dd1ca9f..ec0308fdb 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java @@ -61,6 +61,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve private boolean firstLoad; private SwipeRefreshLayout swipeRefreshLayout; private int notificationPerPage; + private boolean swiped; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -71,6 +72,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve firstLoad = true; flag_loading = true; notifications = new ArrayList<>(); + swiped = false; swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); @@ -110,6 +112,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve notifications = new ArrayList<>(); firstLoad = true; flag_loading = true; + swiped = true; asyncTask = new RetrieveNotificationsAsyncTask(context, null, null, max_id, null, null, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); @@ -159,7 +162,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve return; } List notifications = apiResponse.getNotifications(); - if( firstLoad && (notifications == null || notifications.size() == 0)) + if( !swiped && firstLoad && (notifications == null || notifications.size() == 0)) textviewNoAction.setVisibility(View.VISIBLE); else textviewNoAction.setVisibility(View.GONE); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java index 3a6b868cf..e3528a663 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java @@ -63,9 +63,8 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn private SwipeRefreshLayout swipeRefreshLayout; private String targetedId; private String tag; - private boolean hideHeader = false; private int tootsPerPage; - private boolean comesFromSearch = false; + private boolean swiped; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -74,6 +73,8 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn statuses = new ArrayList<>(); context = getContext(); Bundle bundle = this.getArguments(); + boolean comesFromSearch = false; + boolean hideHeader = false; if (bundle != null) { type = (RetrieveFeedsAsyncTask.Type) bundle.get("type"); targetedId = bundle.getString("targetedId", null); @@ -91,6 +92,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn max_id = null; flag_loading = true; firstLoad = true; + swiped = false; boolean isOnWifi = Helper.isOnWIFI(context); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer); @@ -110,7 +112,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn if( !comesFromSearch){ //Hide account header when scrolling for ShowAccountActivity - if( hideHeader ) { + if(hideHeader) { lv_status.setOnScrollListener(new AbsListView.OnScrollListener() { int lastFirstVisibleItem = 0; @@ -188,6 +190,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn statuses = new ArrayList<>(); firstLoad = true; flag_loading = true; + swiped = true; if( type == RetrieveFeedsAsyncTask.Type.USER) asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); else if( type == RetrieveFeedsAsyncTask.Type.TAG) @@ -257,7 +260,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn return; } List statuses = apiResponse.getStatuses(); - if( firstLoad && (statuses == null || statuses.size() == 0)) + if( !swiped && firstLoad && (statuses == null || statuses.size() == 0)) textviewNoAction.setVisibility(View.VISIBLE); else textviewNoAction.setVisibility(View.GONE);