Merged in develop (pull request #14)

This commit is contained in:
tom79 2017-06-11 15:22:35 +00:00
commit bde096b547
26 changed files with 2088 additions and 119 deletions

View File

@ -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 {
@ -26,7 +26,5 @@ dependencies {
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.evernote:android-job:1.1.10'
compile ('com.vdurmont:emoji-java:3.2.0') {
exclude group: 'org.json'
}
}

Binary file not shown.

View File

@ -77,7 +77,6 @@
<activity android:name="fr.gouv.etalab.mastodon.activities.ShowConversationActivity"
android:windowSoftInputMode="stateAlwaysHidden"
android:configChanges="orientation|screenSize"
android:noHistory="true"
android:label="@string/app_name"
/>
<activity android:name="fr.gouv.etalab.mastodon.activities.AboutActivity"

File diff suppressed because it is too large Load Diff

View File

@ -89,7 +89,7 @@ public class HashTagActivity extends AppCompatActivity implements OnRetrieveFeed
nextElementLoader.setVisibility(View.GONE);
statusListAdapter = new StatusListAdapter(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, isOnWifi, behaviorWithAttachments, this.statuses);
lv_status.setAdapter(statusListAdapter);
setTitle(tag);
setTitle(String.format("#%s", tag));
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {

View File

@ -89,7 +89,8 @@ public class MainActivity extends AppCompatActivity
private enum actionSwipe{
RIGHT_TO_LEFT,
LEFT_TO_RIGHT
LEFT_TO_RIGHT,
POP
}
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -120,7 +121,7 @@ public class MainActivity extends AppCompatActivity
final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
drawer.addDrawerListener(toggle);
toggle.syncState();
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
@ -428,16 +429,22 @@ public class MainActivity extends AppCompatActivity
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
}else{
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
else
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
first = false;
}
} else if (id == R.id.nav_local) {
@ -450,10 +457,12 @@ public class MainActivity extends AppCompatActivity
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
} else if (id == R.id.nav_global) {
toot.setVisibility(View.VISIBLE);
statusFragment = new DisplayStatusFragment();
@ -464,9 +473,12 @@ public class MainActivity extends AppCompatActivity
if( currentAction == actionSwipe.RIGHT_TO_LEFT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
else if( currentAction == actionSwipe.LEFT_TO_RIGHT)
fragmentManager.beginTransaction().setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
else
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fadein, R.anim.fadeout)
.replace(R.id.main_app_container, statusFragment, fragmentTag).addToBackStack(fragmentTag).commit();
} else if (id == R.id.nav_settings) {
toot.setVisibility(View.GONE);
TabLayoutSettingsFragment tabLayoutSettingsFragment= new TabLayoutSettingsFragment();
@ -551,11 +563,23 @@ public class MainActivity extends AppCompatActivity
}
}
/**
* Manage touch event
* Allows to swipe from timelines
* @param event MotionEvent
* @return boolean
*/
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
//Default dispatchTouchEvent is returned when not in timeline page
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
//Menu is opened returns default action
if( drawer.isDrawerOpen(GravityCompat.START))
return super.dispatchTouchEvent(event);
//Current screen is not one of the timelines
if( currentScreen >3 || currentScreen < 1)
return super.dispatchTouchEvent(event);
switch(event.getAction()){
case MotionEvent.ACTION_DOWN: {
downX = event.getX();
@ -568,12 +592,12 @@ public class MainActivity extends AppCompatActivity
float deltaX = downX - upX;
float deltaY = downY - upY;
// swipe horizontal
if(Math.abs(deltaX) > MIN_DISTANCE && Math.abs(deltaY) < MIN_DISTANCE){
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if( downX > MIN_DISTANCE & (Math.abs(deltaX) > MIN_DISTANCE && Math.abs(deltaY) < MIN_DISTANCE)){
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
if(deltaX < 0) { switchOnSwipe(actionSwipe.LEFT_TO_RIGHT); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);return true; }
if(deltaX > 0) { switchOnSwipe(actionSwipe.RIGHT_TO_LEFT); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);return true; }
}else{
currentAction = actionSwipe.POP;
}
}
}

View File

@ -38,14 +38,14 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.emojione.Emojione;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.vdurmont.emoji.EmojiParser;
import java.util.ArrayList;
import java.util.List;
@ -283,7 +283,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
if( account != null){
setTitle(account.getAcct());
account_dn.setText(EmojiParser.parseToUnicode(account.getDisplay_name()));
account_dn.setText(Emojione.shortnameToUnicode(account.getDisplay_name(), true));
account_un.setText(String.format("@%s", account.getUsername()));
if( account.getAcct() != null && account.getAcct().equals(account.getUsername()))
account_ac.setVisibility(View.GONE);

View File

@ -1,9 +1,20 @@
package fr.gouv.etalab.mastodon.client;
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
*
* This program 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.
*
* Mastodon Etalab 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 Thomas Schneider; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import java.util.List;
import fr.gouv.etalab.mastodon.client.Entities.*;
import fr.gouv.etalab.mastodon.client.Entities.Error;

View File

@ -1,42 +0,0 @@
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
*
* This program 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.
*
* Mastodon Etalab 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 Thomas Schneider; if not,
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.client;
/**
* Created by Thomas on 23/04/2017.
*/
public class Error {
private int code;
private String message;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@ -1,11 +1,27 @@
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
*
* This program 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.
*
* Mastodon Etalab 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 Thomas Schneider; if not,
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.client;
/**
/*
* Created by Thomas on 20/05/2017.
* Custom MySSLSocketFactory
*/
import android.annotation.SuppressLint;
import java.io.IOException;
import java.net.Socket;
import java.security.KeyManagementException;
@ -42,9 +58,11 @@ public class MastalabSSLSocketFactory extends com.loopj.android.http.MySSLSocket
public MastalabSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(truststore);
X509TrustManager tm = new X509TrustManager() {
@SuppressLint("TrustAllX509TrustManager")
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@SuppressLint("TrustAllX509TrustManager")
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}

View File

@ -1,5 +1,19 @@
package fr.gouv.etalab.mastodon.client;
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
*
* This program 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.
*
* Mastodon Etalab 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 Thomas Schneider; if not,
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
import android.content.Context;
import com.nostra13.universalimageloader.core.assist.ContentLengthInputStream;
@ -60,9 +74,11 @@ public class PatchBaseImageDownloader extends BaseImageDownloader {
MySSLSocketFactory() throws Exception {
super();
TrustManager tm = new X509TrustManager() {
@SuppressLint("TrustAllX509TrustManager")
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@SuppressLint("TrustAllX509TrustManager")
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}

View File

@ -34,10 +34,10 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.emojione.Emojione;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.vdurmont.emoji.EmojiParser;
import java.util.ArrayList;
import java.util.List;
@ -152,7 +152,7 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
holder.account_ds.setVisibility(View.VISIBLE);
}
});
holder.account_dn.setText(EmojiParser.parseToUnicode(account.getDisplay_name()));
holder.account_dn.setText(Emojione.shortnameToUnicode(account.getDisplay_name(), true));
holder.account_un.setText(String.format("@%s",account.getUsername()));
holder.account_ac.setText(account.getAcct());
if( account.getDisplay_name().equals(account.getAcct()))
@ -162,6 +162,7 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
holder.account_ds.setText(Html.fromHtml(account.getNote(), Html.FROM_HTML_MODE_COMPACT));
else
//noinspection deprecation
holder.account_ds.setText(Html.fromHtml(account.getNote()));
holder.account_ds.setAutoLinkMask(Linkify.WEB_URLS);
holder.account_sc.setText(String.valueOf(account.getStatuses_count()));

View File

@ -26,10 +26,10 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.emojione.Emojione;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.vdurmont.emoji.EmojiParser;
import java.util.List;
import fr.gouv.etalab.mastodon.client.Entities.Account;
@ -91,8 +91,7 @@ public class AccountsSearchAdapter extends BaseAdapter {
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.account_dn.setText(EmojiParser.parseToUnicode(account.getDisplay_name()));
holder.account_dn.setText(Emojione.shortnameToUnicode(account.getDisplay_name(), true));
holder.account_un.setText(String.format("@%s",account.getUsername()));
//Profile picture
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);

View File

@ -14,13 +14,9 @@ package fr.gouv.etalab.mastodon.drawers;
* You should have received a copy of the GNU General Public License along with Thomas Schneider; if not,
* see <http://www.gnu.org/licenses>. */
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
@ -29,29 +25,22 @@ import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.VideoView;
import com.emojione.Emojione;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import com.vdurmont.emoji.EmojiParser;
import java.util.List;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
import fr.gouv.etalab.mastodon.activities.TootActivity;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import mastodon.etalab.gouv.fr.mastodon.R;
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.helper.Helper;
@ -162,6 +151,7 @@ public class NotificationsListAdapter extends BaseAdapter {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
holder.notification_status_content.setText(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_COMPACT));
else
//noinspection deprecation
holder.notification_status_content.setText(Html.fromHtml(status.getContent()));
holder.notification_status_content.setAutoLinkMask(Linkify.WEB_URLS);
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
@ -220,8 +210,7 @@ public class NotificationsListAdapter extends BaseAdapter {
}
});
holder.notification_account_displayname.setText(EmojiParser.parseToUnicode(notification.getAccount().getDisplay_name()));
holder.notification_account_displayname.setText(Emojione.shortnameToUnicode(notification.getAccount().getDisplay_name(), true));
holder.notification_account_username.setText( String.format("@%s",notification.getAccount().getUsername()));
//Profile picture
imageLoader.displayImage(notification.getAccount().getAvatar(), holder.notification_account_profile, options);

View File

@ -31,10 +31,10 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.emojione.Emojione;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.vdurmont.emoji.EmojiParser;
import java.util.ArrayList;
import java.util.List;
@ -168,7 +168,7 @@ public class SearchListAdapter extends BaseAdapter {
final String content, displayName, username, ppurl;
if( status.getReblog() != null){
content = status.getReblog().getContent();
displayName = EmojiParser.parseToUnicode(status.getReblog().getAccount().getDisplay_name());
displayName = Emojione.shortnameToUnicode(status.getReblog().getAccount().getDisplay_name(), true);
username = status.getReblog().getAccount().getUsername();
holder.status_reblog_user.setText(displayName + " " +String.format("@%s",username));
ppurl = status.getReblog().getAccount().getAvatar();
@ -178,7 +178,7 @@ public class SearchListAdapter extends BaseAdapter {
}else {
ppurl = status.getAccount().getAvatar();
content = status.getContent();
displayName = EmojiParser.parseToUnicode(status.getAccount().getDisplay_name());
displayName = Emojione.shortnameToUnicode(status.getAccount().getDisplay_name(), true);
username = status.getAccount().getUsername();
holder.status_reblog_user.setVisibility(View.GONE);
holder.status_account_displayname.setText(displayName);

View File

@ -34,7 +34,6 @@ import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.text.util.Linkify;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -50,12 +49,12 @@ import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import com.emojione.Emojione;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import com.vdurmont.emoji.EmojiParser;
import java.util.ArrayList;
import java.util.List;
@ -233,7 +232,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
}else {
ppurl = status.getAccount().getAvatar();
content = status.getContent();
displayName = EmojiParser.parseToUnicode(status.getAccount().getDisplay_name());
displayName = Emojione.shortnameToUnicode(status.getAccount().getDisplay_name(), true);
username = status.getAccount().getUsername();
holder.status_reblog_user.setVisibility(View.GONE);
holder.status_account_displayname.setText(displayName);

View File

@ -23,7 +23,6 @@ import android.widget.BaseAdapter;;
import android.widget.TextView;
import java.util.List;
import fr.gouv.etalab.mastodon.client.Entities.Tag;
import mastodon.etalab.gouv.fr.mastodon.R;
@ -35,12 +34,10 @@ public class TagsListAdapter extends BaseAdapter {
private List<String> tags;
private LayoutInflater layoutInflater;
private Context context;
public TagsListAdapter(Context context, List<String> tags){
this.tags = tags;
layoutInflater = LayoutInflater.from(context);
this.context = context;
}
@Override

View File

@ -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<Void, Void, Void> 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<Account> 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);

View File

@ -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<Account> 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

View File

@ -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<Notification> 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);

View File

@ -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<Status> 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);

View File

@ -35,6 +35,7 @@ import android.net.NetworkInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.design.widget.NavigationView;
import android.support.v4.app.NotificationCompat;
@ -64,6 +65,7 @@ import java.util.Locale;
import java.util.TimeZone;
import fr.gouv.etalab.mastodon.activities.LoginActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
@ -578,7 +580,17 @@ public class Helper {
arrow.setImageResource(R.drawable.ic_arrow_drop_down);
navigationView.getMenu().clear();
navigationView.inflateMenu(R.menu.activity_main_drawer);
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new AccountDAO(activity, db).getAccountByID(userId);
if( account != null) {
if (account.isLocked()) {
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
} else {
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
}
}
}
menuAccountsOpened = !menuAccountsOpened;
@ -626,7 +638,7 @@ public class Helper {
* @param imageLoader ImageLoader - instance of ImageLoader
* @param options DisplayImageOptions - current configuration of ImageLoader
*/
public static void updateHeaderAccountInfo(Activity activity, Account account, View headerLayout, ImageLoader imageLoader, DisplayImageOptions options){
public static void updateHeaderAccountInfo(final Activity activity, final Account account, View headerLayout, ImageLoader imageLoader, DisplayImageOptions options){
ImageView profilePicture = (ImageView) headerLayout.findViewById(R.id.profilePicture);
TextView username = (TextView) headerLayout.findViewById(R.id.username);
TextView displayedName = (TextView) headerLayout.findViewById(R.id.displayedName);
@ -647,5 +659,18 @@ public class Helper {
displayedName.setText(account.getDisplay_name());
imageLoader.displayImage(account.getAvatar(), profilePicture, options);
}
profilePicture.setOnClickListener(null);
profilePicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (account != null) {
Intent intent = new Intent(activity, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", account.getId());
intent.putExtras(b);
activity.startActivity(intent);
}
}
});
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="1000"
/>
</set>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="1000"
/>
</set>

View File

@ -51,6 +51,32 @@
android:layout_height="wrap_content" />
</LinearLayout>
<!-- data -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/fab_margin"
android:layout_marginTop="10dp"
android:orientation="vertical"
tools:ignore="UselessParent">
<!-- DATA PRIVACY TITLE -->
<TextView
android:text="@string/privacy_data_title"
android:background="@drawable/shape_border_bottom_settings"
android:paddingBottom="10dp"
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- DATA PRIVACY CONTENT -->
<TextView
android:text="@string/privacy_data"
android:autoLink="web"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- App authorizations -->
<LinearLayout
android:layout_width="match_parent"

View File

@ -256,6 +256,14 @@
<!-- PRIVACY -->
<string name="privacy_data_title">Données enregistrées</string>
<string name="privacy_data">
Seules les informations de base des comptes connectés sont enregistrées sur l\'appareil.
Ces données sont strictement confidentielles et ne sont utilisables que par l\'application. La suppression de l\'application entraîne immédiatement la suppression de ces données.\n
&#9888; Les identifiants et les mots de passe ne sont jamais enregistrés, ils ne sont utilisés que lors de l\'authentification sécurisée (SSL) vers l\'instance.
</string>
<string name="privacy_authorizations_title">Autorisations de l\'application</string>
<string name="privacy_authorizations">
- <b>ACCESS_NETWORK_STATE</b> : Utilisée pour savoir si l\'appareil est connecté au WIFI.\n
@ -279,7 +287,6 @@
L\'utilisation de bibliothèques est réduite au strict minimum :\n
- <b>Android Asynchronous Http Client</b> : Pour la gestion des requêtes\n
- <b>Universal Image Loader</b> : Pour la gestion des médias\n
- <b>Android-Job</b> : Pour la gestion des services\n
- <b>Emoji-java</b> : Pour l\'affichage des emoji
- <b>Android-Job</b> : Pour la gestion des services
</string>
</resources>