Merged tom79/mastodon_etalab/master into original_master

This commit is contained in:
PhotonQyv 2017-10-14 20:04:07 +01:00
commit 7198abb42c
245 changed files with 2192 additions and 1292 deletions

Binary file not shown.

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15
targetSdkVersion 26
versionCode 60
versionName "1.5.0"
versionCode 61
versionName "1.5.1"
}
buildTypes {
release {
@ -41,6 +41,7 @@ dependencies {
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.jsoup:jsoup:1.10.3'
compile 'de.hdodenhof:circleimageview:2.2.0'
safetynetCompile 'com.google.android.gms:play-services-safetynet:11.0.4'
safetynetCompile 'io.github.kobakei:ratethisapp:1.2.0'
}

View File

@ -140,7 +140,7 @@ public class MainActivity extends AppCompatActivity
private String userIdService;
private Intent streamingIntent;
public static String lastHomeId = null, lastNotificationId = null;
boolean notif_follow, notif_add, notif_mention, notif_share;
boolean notif_follow, notif_add, notif_mention, notif_share, show_boosts, show_replies;
public MainActivity() {
}
@ -310,6 +310,70 @@ public class MainActivity extends AppCompatActivity
}
});
tabStrip.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
//Only shown if the tab has focus
if( homeFragment != null && homeFragment.getUserVisibleHint()){
PopupMenu popup = new PopupMenu(MainActivity.this, tabStrip.getChildAt(0));
popup.getMenuInflater()
.inflate(R.menu.option_filter_toots, popup.getMenu());
Menu menu = popup.getMenu();
final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts);
final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies);
show_boosts = sharedpreferences.getBoolean(Helper.SET_SHOW_BOOSTS, true);
show_replies = sharedpreferences.getBoolean(Helper.SET_SHOW_REPLIES, true);
itemShowBoosts.setChecked(show_boosts);
itemShowReplies.setChecked(show_replies);
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
@Override
public void onDismiss(PopupMenu menu) {
if( homeFragment != null)
homeFragment.refreshFilter();
}
});
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
item.setActionView(new View(getApplicationContext()));
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return false;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
return false;
}
});
switch (item.getItemId()) {
case R.id.action_show_boosts:
SharedPreferences.Editor editor = sharedpreferences.edit();
show_boosts = !show_boosts;
editor.putBoolean(Helper.SET_SHOW_BOOSTS, show_boosts);
itemShowBoosts.setChecked(show_boosts);
editor.apply();
break;
case R.id.action_show_replies:
editor = sharedpreferences.edit();
show_replies = !show_replies;
editor.putBoolean(Helper.SET_SHOW_REPLIES, show_replies);
itemShowReplies.setChecked(show_replies);
editor.apply();
break;
}
return false;
}
});
popup.show();
}
return true;
}
});
viewPager = (ViewPager) findViewById(R.id.viewpager);
int countPage = 2;
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true))
@ -538,7 +602,7 @@ public class MainActivity extends AppCompatActivity
.diskCache(new UnlimitedDiskCache(cacheDir))
.build();
imageLoader.init(configImg);
options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(90)).cacheInMemory(false)
options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(20)).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
@ -828,7 +892,8 @@ public class MainActivity extends AppCompatActivity
while (matcher.find()){
int matchStart = matcher.start(1);
int matchEnd = matcher.end();
sharedText = sharedText.substring(matchStart, matchEnd);
if(matchStart < matchEnd && sharedText.length() > matchEnd)
sharedText = sharedText.substring(matchStart, matchEnd);
}
new RetrieveMetaDataAsyncTask(sharedText, MainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Intent intentToot = new Intent(getApplicationContext(), TootActivity.class);
@ -912,9 +977,9 @@ public class MainActivity extends AppCompatActivity
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_globe,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_lock_open,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_lock_closed,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_local_post_office,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_retweet_black,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_fav_black,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_mail_outline,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_retweet,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_favorite_border,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_photo,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_remove_red_eye,R.color.dark_text);
changeDrawableColor(getApplicationContext(), R.drawable.ic_translate,R.color.dark_text);
@ -924,9 +989,9 @@ public class MainActivity extends AppCompatActivity
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_globe,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_lock_open,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_action_lock_closed,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_local_post_office,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_retweet_black,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_fav_black,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_mail_outline,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_retweet,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_favorite_border,R.color.black);
changeDrawableColor(getApplicationContext(), R.drawable.ic_photo,R.color.white);
changeDrawableColor(getApplicationContext(), R.drawable.ic_remove_red_eye,R.color.white);
changeDrawableColor(getApplicationContext(), R.drawable.ic_translate,R.color.white);

Binary file not shown.

View File

@ -234,7 +234,6 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
}
for( int i = 0 ; i < developers.size() ; i++){
if( developers.get(i).getId() != null && developers.get(i).getId().equals(relationship.getId())){
Log.v(Helper.TAG,developers.get(i).getUsername() + " -> " + (relationship.isFollowing() || userId.trim().equals(relationship.getId())));
developers.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
break;
@ -242,7 +241,6 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
}
for( int i = 0 ; i < designers.size() ; i++){
if( designers.get(i).getId() != null && designers.get(i).getId().equals(relationship.getId())){
Log.v(Helper.TAG,designers.get(i).getUsername() + " -> " + (relationship.isFollowing() || userId.trim().equals(relationship.getId())));
designers.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
accountSearchWebAdapterDesigner.notifyDataSetChanged();
break;
@ -250,7 +248,6 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
}
for( int i = 0 ; i < contributors.size() ; i++){
if( contributors.get(i).getId() != null && contributors.get(i).getId().equals(relationship.getId())){
Log.v(Helper.TAG,contributors.get(i).getUsername() + " -> " + (relationship.isFollowing() || userId.trim().equals(relationship.getId())));
contributors.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
accountSearchWebAdapterContributors.notifyDataSetChanged();
break;

View File

@ -14,11 +14,8 @@
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.activities;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@ -29,11 +26,9 @@ import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.RequiresApi;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.FloatingActionButton;
@ -42,14 +37,11 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -63,7 +55,6 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
@ -72,6 +63,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
@ -94,8 +86,6 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
import mastodon.etalab.gouv.fr.mastodon.R;
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
import static fr.gouv.etalab.mastodon.helper.Helper.canPin;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
@ -123,12 +113,12 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
private Relationship relationship;
private boolean showMediaOnly, showPinned;
private ImageView pp_actionBar;
private BroadcastReceiver hide_header;
private boolean isHiddingShowing = false;
private LinearLayout main_header_container;
private LinearLayout small_info;
private ImageView header_edit_profile;
private List<Status> pins;
private String accountUrl;
private int maxScrollSize;
private boolean avatarShown = true;
public enum action{
FOLLOW,
UNFOLLOW,
@ -138,15 +128,16 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
private action doAction;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if( theme == Helper.THEME_LIGHT){
setTheme(R.style.AppTheme);
setTheme(R.style.AppTheme_NoActionBar);
}else {
setTheme(R.style.AppThemeDark);
setTheme(R.style.AppThemeDark_NoActionBar);
}
setContentView(R.layout.activity_show_account);
setTitle("");
@ -155,7 +146,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
Bundle b = getIntent().getExtras();
account_follow = (FloatingActionButton) findViewById(R.id.account_follow);
account_follow_request = (TextView) findViewById(R.id.account_follow_request);
main_header_container = (LinearLayout) findViewById(R.id.main_header_container);
small_info = (LinearLayout) findViewById(R.id.small_info);
header_edit_profile = (ImageView) findViewById(R.id.header_edit_profile);
account_follow.setEnabled(false);
if(b != null){
@ -186,13 +177,10 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
int positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
statusListAdapter = new StatusListAdapter(getApplicationContext(), RetrieveFeedsAsyncTask.Type.USER, accountId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(80)).cacheInMemory(false)
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
tabLayout = (TabLayout) findViewById(R.id.account_tabLayout);
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.toots)));
@ -272,43 +260,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
}
}
});
if( Build.VERSION.SDK_INT < 21) {
//Register LocalBroadcast to receive selected accounts after search
hide_header = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (!isHiddingShowing) {
isHiddingShowing = true;
ImageView account_pp = (ImageView) findViewById(R.id.account_pp);
boolean hide = intent.getBooleanExtra("hide", false);
if (hide) {
main_header_container.setVisibility(View.GONE);
if (pp_actionBar != null)
pp_actionBar.setVisibility(View.VISIBLE);
tabLayout.setVisibility(View.GONE);
} else {
manageButtonVisibility();
tabLayout.setVisibility(View.VISIBLE);
main_header_container.setVisibility(View.VISIBLE);
if (pp_actionBar != null)
pp_actionBar.setVisibility(View.GONE);
}
account_pp.requestLayout();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
isHiddingShowing = false;
}
}, 700);
}
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(hide_header, new IntentFilter(Helper.HEADER_ACCOUNT + String.valueOf(instanceValue)));
}
header_edit_profile.setOnClickListener(new View.OnClickListener() {
@Override
@ -393,7 +344,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
@Override
public void onDestroy(){
super.onDestroy();
LocalBroadcastManager.getInstance(this).unregisterReceiver(hide_header);
}
@Override
@ -407,7 +357,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
}
accountUrl = account.getUrl();
ImageView account_pp = (ImageView) findViewById(R.id.account_pp);
final CircleImageView account_pp = (CircleImageView) findViewById(R.id.account_pp);
TextView account_dn = (TextView) findViewById(R.id.account_dn);
TextView account_un = (TextView) findViewById(R.id.account_un);
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
@ -431,23 +381,21 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
LinearLayout main_header_container = (LinearLayout) findViewById(R.id.main_header_container);
ImageView banner_pp = (ImageView) findViewById(R.id.banner_pp);
Bitmap workingBitmap = Bitmap.createBitmap(loadedImage);
Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap);
Paint p = new Paint(Color.BLACK);
ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);
p.setColorFilter(filter);
canvas.drawBitmap(mutableBitmap, new Matrix(), p);
BitmapDrawable background = new BitmapDrawable(getResources(), mutableBitmap);
main_header_container.setBackground(background);
banner_pp.setImageDrawable(background);
}
@Override
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason) {
LinearLayout main_header_container = (LinearLayout) findViewById(R.id.main_header_container);
main_header_container.setBackgroundResource(R.drawable.side_nav_bar);
}
});
}
@ -462,16 +410,12 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
account_dn.setCompoundDrawables( null, null, null, null);
}
final ActionBar actionBar = getSupportActionBar();
LayoutInflater mInflater = LayoutInflater.from(ShowAccountActivity.this);
if( actionBar != null && account != null){
@SuppressLint("InflateParams") View show_account_actionbar = mInflater.inflate(R.layout.showaccount_actionbar, null);
TextView actionbar_title = (TextView) show_account_actionbar.findViewById(R.id.show_account_title);
if( account != null){
TextView actionbar_title = (TextView) findViewById(R.id.show_account_title);
if( account.getAcct() != null)
actionbar_title.setText(account.getAcct());
actionBar.setCustomView(show_account_actionbar);
actionBar.setDisplayShowCustomEnabled(true);
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
pp_actionBar = (ImageView) findViewById(R.id.pp_actionBar);
String url = account.getAvatar();
if( url.startsWith("/") ){
url = "https://" + Helper.getLiveInstance(getApplicationContext()) + account.getAvatar();
@ -491,27 +435,48 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason){
}});
if( Build.VERSION.SDK_INT >= 21) {
AppBarLayout appBar = (AppBarLayout) findViewById(R.id.appBar);
appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset > 10 ) {
pp_actionBar.setVisibility(View.GONE);
} else {
pp_actionBar.setVisibility(View.VISIBLE);
}
final AppBarLayout appBar = (AppBarLayout) findViewById(R.id.appBar);
maxScrollSize = appBar.getTotalScrollRange();
appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset)-appBar.getTotalScrollRange() == 0) {
if( small_info.getVisibility() == View.GONE)
small_info.setVisibility(View.VISIBLE);
}else {
if( small_info.getVisibility() == View.VISIBLE)
small_info.setVisibility(View.GONE);
}
});
}
if (maxScrollSize == 0)
maxScrollSize = appBarLayout.getTotalScrollRange();
int percentage = (Math.abs(verticalOffset)) * 100 / maxScrollSize;
if (percentage >= 20 && avatarShown) {
avatarShown = false;
account_pp.animate()
.scaleY(0).scaleX(0)
.setDuration(200)
.start();
}
if (percentage <= 20 && !avatarShown) {
avatarShown = true;
account_pp.animate()
.scaleY(1).scaleX(1)
.start();
}
}
});
}else {
if( account != null && account.getAcct() != null)
setTitle(account.getAcct());
}
if( account != null){
account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
account_un.setText(String.format("@%s", account.getUsername()));
account_un.setText(String.format("@%s", account.getAcct()));
SpannableString spannableString = Helper.clickableElementsDescription(ShowAccountActivity.this, account.getNote());
account_note.setText(spannableString, TextView.BufferType.SPANNABLE);
account_note.setMovementMethod(LinkMovementMethod.getInstance());

View File

@ -79,7 +79,6 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
private SwipeRefreshLayout swipeRefreshLayout;
private ListView lv_status;
private boolean isRefreshed;
private TextView title;
private ImageView pp_actionBar;
@Override
@ -101,7 +100,7 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
View view = inflater.inflate(R.layout.conversation_action_bar, null);
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
title.setText(R.string.conversation);
ImageView close_conversation = (ImageView) actionBar.getCustomView().findViewById(R.id.close_conversation);
@ -163,15 +162,9 @@ public class ShowConversationActivity extends AppCompatActivity implements OnRet
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.ONESTATUS, statusId,null, false,false, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if( theme == Helper.THEME_LIGHT) {
swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent,
R.color.colorPrimary,
R.color.colorPrimaryDark);
}else {
swipeRefreshLayout.setColorSchemeResources(R.color.colorAccentD,
R.color.colorPrimaryD,
R.color.colorPrimaryDarkD);
}
swipeRefreshLayout.setColorSchemeResources(R.color.mastodonC4,
R.color.mastodonC2,
R.color.mastodonC3);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {

View File

@ -103,21 +103,27 @@ import java.util.regex.Pattern;
import cz.msebera.android.httpclient.Header;
import fr.gouv.etalab.mastodon.asynctasks.PostStatusAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAccountsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.UploadActionAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.Entities.Mention;
import fr.gouv.etalab.mastodon.client.Entities.Results;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
import fr.gouv.etalab.mastodon.client.Entities.Tag;
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
import fr.gouv.etalab.mastodon.drawers.AccountsSearchAdapter;
import fr.gouv.etalab.mastodon.drawers.DraftsListAdapter;
import fr.gouv.etalab.mastodon.drawers.TagsListAdapter;
import fr.gouv.etalab.mastodon.drawers.TagsSearchAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearcAccountshInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob;
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
@ -133,7 +139,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
* Toot activity class
*/
public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostStatusActionInterface {
public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface {
private String visibility;
@ -422,7 +428,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot_visibility.setImageResource(R.drawable.ic_action_lock_closed);
}else {
if( visibility.equals("direct") ){
toot_visibility.setImageResource(R.drawable.ic_local_post_office);
toot_visibility.setImageResource(R.drawable.ic_mail_outline);
}else{
visibility = "private";
toot_visibility.setImageResource(R.drawable.ic_action_lock_closed);
@ -442,7 +448,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot_visibility.setImageResource(R.drawable.ic_action_lock_closed);
break;
case "direct":
toot_visibility.setImageResource(R.drawable.ic_local_post_office);
toot_visibility.setImageResource(R.drawable.ic_mail_outline);
break;
}
}
@ -539,6 +545,9 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
String pattern = "^(.|\\s)*(@([a-zA-Z0-9_]{2,}))$";
final Pattern sPattern = Pattern.compile(pattern);
String patternTag = "^(.|\\s)*(\\#([\\w-]{2,}))$";
final Pattern tPattern = Pattern.compile(patternTag);
toot_content.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -563,7 +572,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot_space_left.setText(String.valueOf(totalChar));
if( currentCursorPosition- (searchLength-1) < 0 || currentCursorPosition == 0 || currentCursorPosition > s.toString().length())
return;
Matcher m;
Matcher m, mt;
if( s.toString().charAt(0) == '@')
m = sPattern.matcher(s.toString().substring(currentCursorPosition- searchLength, currentCursorPosition));
@ -576,7 +585,22 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
pp_actionBar.setVisibility(View.GONE);
}
new RetrieveSearchAccountsAsyncTask(getApplicationContext(),search,TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else{toot_content.dismissDropDown();}
}else{
if( s.toString().charAt(0) == '#')
mt = tPattern.matcher(s.toString().substring(currentCursorPosition- searchLength, currentCursorPosition));
else
mt = tPattern.matcher(s.toString().substring(currentCursorPosition- (searchLength-1), currentCursorPosition));
if(mt.matches()) {
String search = mt.group(3);
if (pp_progress != null && pp_actionBar != null) {
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
new RetrieveSearchAsyncTask(getApplicationContext(),search,TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else{toot_content.dismissDropDown();}
}
totalChar = toot_cw_content.length() + toot_content.length();
toot_space_left.setText(String.valueOf(totalChar));
}
@ -1039,7 +1063,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot_content.setText(toot_content.getText().toString().replace(attachment.getText_url(), ""));
toot_space_left.setText(String.valueOf(toot_content.length()));
//Moves the cursor
if (selectionBefore >= 0)
if (selectionBefore >= 0 && selectionBefore < toot_content.length())
toot_content.setSelection(selectionBefore);
}
((ViewGroup) namebar.getParent()).removeView(namebar);
@ -1091,7 +1115,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
break;
case 3:
visibility = "direct";
toot_visibility.setImageResource(R.drawable.ic_local_post_office);
toot_visibility.setImageResource(R.drawable.ic_mail_outline);
break;
}
changeColor();
@ -1220,7 +1244,59 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
}
});
}
}
@Override
public void onRetrieveSearch(Results results, Error error) {
if( pp_progress != null && pp_actionBar != null) {
pp_progress.setVisibility(View.GONE);
pp_actionBar.setVisibility(View.VISIBLE);
}
if( results == null){
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true);
if( show_error_messages)
Toast.makeText(getApplicationContext(), R.string.toast_error, Toast.LENGTH_LONG).show();
return;
}
final List<String> tags = results.getHashtags();
if( tags != null && tags.size() > 0){
TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(TootActivity.this, tags);
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter);
final String oldContent = toot_content.getText().toString();
String[] searchA = oldContent.substring(0,currentCursorPosition).split("#");
final String search = searchA[searchA.length-1];
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String tag = tags.get(position);
String deltaSearch = "";
if( currentCursorPosition-searchLength > 0 && currentCursorPosition < oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, currentCursorPosition);
else {
if( currentCursorPosition >= oldContent.length() )
deltaSearch = oldContent.substring(currentCursorPosition-searchLength, oldContent.length());
}
if( !search.equals(""))
deltaSearch = deltaSearch.replace("#"+search,"");
String newContent = oldContent.substring(0,currentCursorPosition-searchLength);
newContent += deltaSearch;
newContent += "#" + tag + " ";
int newPosition = newContent.length();
if( currentCursorPosition < oldContent.length() - 1)
newContent += oldContent.substring(currentCursorPosition, oldContent.length()-1);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.setSelection(newPosition);
TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(TootActivity.this, new ArrayList<String>());
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter);
}
});
}
}
private void restoreToot(long id){
@ -1303,7 +1379,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
break;
case "direct":
visibility = "direct";
toot_visibility.setImageResource(R.drawable.ic_local_post_office);
toot_visibility.setImageResource(R.drawable.ic_mail_outline);
break;
}
changeColor();
@ -1352,7 +1428,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
break;
case "direct":
visibility = "direct";
toot_visibility.setImageResource(R.drawable.ic_local_post_office);
toot_visibility.setImageResource(R.drawable.ic_mail_outline);
break;
}
changeColor();
@ -1431,8 +1507,8 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
changeDrawableColor(TootActivity.this, R.drawable.ic_action_globe, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_open, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_closed, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_local_post_office, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_action_camera, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_mail_outline, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_insert_photo, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_skip_previous, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_skip_next, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_check, R.color.dark_text);
@ -1440,11 +1516,13 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
changeDrawableColor(TootActivity.this, R.drawable.ic_action_globe, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_open, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_closed, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_local_post_office, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_action_camera, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_mail_outline, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_insert_photo, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_skip_previous, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_skip_next, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_check, R.color.white);
}
}
}

View File

@ -58,6 +58,7 @@ public class Status implements Parcelable {
private boolean isTranslationShown = false;
private boolean isNew = false;
private boolean isTakingScreenShot = false;
private boolean isVisible = true;
protected Status(Parcel in) {
id = in.readString();
@ -370,4 +371,12 @@ public class Status implements Parcelable {
public void setTakingScreenShot(boolean takingScreenShot) {
isTakingScreenShot = takingScreenShot;
}
public boolean isVisible() {
return isVisible;
}
public void setVisible(boolean visible) {
isVisible = visible;
}
}

View File

@ -17,6 +17,7 @@ package fr.gouv.etalab.mastodon.drawers;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.content.Context;
@ -75,6 +76,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Notification;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.helper.Helper;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_DARK;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
@ -182,33 +184,33 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_mention));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_mention));
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_mention));
if( theme == Helper.THEME_DARK){
holder.card_status_container.setCardBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1));
}else {
holder.card_status_container.setCardBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1));
}
imgH = null;
imgH = ContextCompat.getDrawable(context, R.drawable.ic_chat_bubble_outline);
break;
case "reblog":
holder.status_action_container.setVisibility(View.GONE);
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_reblog));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_reblog));
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_reblog));
if( theme == Helper.THEME_DARK){
holder.card_status_container.setCardBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_2));
}else {
holder.card_status_container.setCardBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_2));
}
imgH = ContextCompat.getDrawable(context, R.drawable.ic_retweet_notif_header);
imgH = ContextCompat.getDrawable(context, R.drawable.ic_boost_header_notif);
break;
case "favourite":
holder.status_action_container.setVisibility(View.GONE);
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_favourite));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_favourite));
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_favourite));
if( theme == Helper.THEME_DARK){
holder.card_status_container.setCardBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_3));
}else {
@ -221,7 +223,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_follow));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_follow));
typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_follow));
if( theme == Helper.THEME_DARK){
holder.card_status_container.setCardBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_4));
}else {
@ -230,7 +232,8 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
imgH = ContextCompat.getDrawable(context, R.drawable.ic_follow_notif_header);
break;
}
changeDrawableColor(context, R.drawable.ic_retweet_notif_header,R.color.mastodonC4);
changeDrawableColor(context, R.drawable.ic_chat_bubble_outline, R.color.mastodonC4);
changeDrawableColor(context, R.drawable.ic_boost_header_notif,R.color.mastodonC4);
changeDrawableColor(context, R.drawable.ic_fav_notif_header,R.color.mastodonC4);
changeDrawableColor(context, R.drawable.ic_follow_notif_header,R.color.mastodonC4);
holder.notification_type.setText(typeString);
@ -247,7 +250,6 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
holder.notification_status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.notification_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.notification_account_username.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.status_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12*textSizePercent/100);
@ -258,10 +260,9 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
changeDrawableColor(context, R.drawable.ic_action_globe,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_retweet_black,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_retweet,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_fav_black,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_favorite_border,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_delete,R.color.dark_text);
@ -271,10 +272,9 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
changeDrawableColor(context, R.drawable.ic_action_globe,R.color.black);
changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.black);
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.black);
changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.black);
changeDrawableColor(context, R.drawable.ic_retweet_black,R.color.black);
changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.black);
changeDrawableColor(context, R.drawable.ic_retweet,R.color.black);
changeDrawableColor(context, R.drawable.ic_fav_black,R.color.black);
changeDrawableColor(context, R.drawable.ic_favorite_border,R.color.black);
changeDrawableColor(context, R.drawable.ic_photo,R.color.black);
changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.black);
changeDrawableColor(context, R.drawable.ic_delete,R.color.black);
@ -286,17 +286,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
holder.status_document_container.setVisibility(View.GONE);
else
holder.status_document_container.setVisibility(View.VISIBLE);
if( (status.getIn_reply_to_account_id() != null && !status.getIn_reply_to_account_id().equals("null")) || (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null")) ){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply);
img.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
holder.notification_account_username.setCompoundDrawables( img, null, null, null);
}else if( status.isReblogged()){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet);
img.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
holder.notification_account_username.setCompoundDrawables( img, null, null, null);
}else{
holder.notification_account_username.setCompoundDrawables( null, null, null, null);
}
String content = status.getContent();
content = content.replaceAll("</p>","<br/><br/>");
content = content.replaceAll("<p>","");
@ -312,6 +302,9 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
holder.status_reblog_count.setText(String.valueOf(status.getReblogs_count()));
holder.status_date.setText(Helper.dateDiff(context, status.getCreated_at()));
Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/WorkSans-Regular.ttf");
holder.notification_status_content.setTypeface(tf);
//Adds attachment -> disabled, to enable them uncomment the line below
//loadAttachments(status, holder);
holder.notification_status_container.setVisibility(View.VISIBLE);
@ -345,15 +338,27 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
Drawable imgFav, imgReblog;
if( status.isFavourited())
imgFav = ContextCompat.getDrawable(context, R.drawable.ic_fav_yellow);
else
imgFav = ContextCompat.getDrawable(context, R.drawable.ic_fav_black);
if( status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) {
changeDrawableColor(context, R.drawable.ic_favorite,R.color.yellowicon);
imgFav = ContextCompat.getDrawable(context, R.drawable.ic_favorite);
}else {
if( theme == THEME_DARK)
changeDrawableColor(context, R.drawable.ic_favorite_border,R.color.dark_text);
else
changeDrawableColor(context, R.drawable.ic_favorite_border,R.color.black);
imgFav = ContextCompat.getDrawable(context, R.drawable.ic_favorite_border);
}
if( status.isReblogged())
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_retweet_yellow);
else
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_retweet_black);
if( status.isReblogged()|| (status.getReblog() != null && status.getReblog().isReblogged())) {
changeDrawableColor(context, R.drawable.ic_boost,R.color.yellowicon);
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_boost);
}else {
if( theme == THEME_DARK)
changeDrawableColor(context, R.drawable.ic_boost_border,R.color.dark_text);
else
changeDrawableColor(context, R.drawable.ic_boost_border,R.color.black);
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_boost_border);
}
imgFav.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
imgReblog.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
@ -417,7 +422,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
holder.status_privacy.setImageResource(R.drawable.ic_action_lock_closed);
break;
case "direct":
holder.status_privacy.setImageResource(R.drawable.ic_local_post_office);
holder.status_privacy.setImageResource(R.drawable.ic_mail_outline);
break;
}
switch (status.getVisibility()){
@ -447,7 +452,6 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
}else {
holder.notification_status_container.setVisibility(View.GONE);
holder.notification_account_username.setCompoundDrawables( null, null, null, null);
holder.card_status_container.setOnClickListener(null);
}
@ -521,7 +525,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
displayConfirmationNotificationDialog(notification);
}
});
holder.notification_account_username.setText( String.format("@%s",notification.getAccount().getUsername()));
holder.notification_account_username.setVisibility(View.GONE);
final View finalConvertView = convertView;
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);

View File

@ -122,13 +122,13 @@ public class ScheduledTootsListAdapter extends BaseAdapter {
changeDrawableColor(context, R.drawable.ic_action_globe,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.dark_text);
}else {
changeDrawableColor(context, R.drawable.ic_cancel,R.color.black);
changeDrawableColor(context, R.drawable.ic_action_globe,R.color.black);
changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.black);
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.black);
changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.black);
changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.black);
}
final Status status = storedStatus.getStatus();
@ -144,7 +144,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter {
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_action_lock_closed);
break;
case "direct":
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_local_post_office);
holder.scheduled_toot_privacy.setImageResource(R.drawable.ic_mail_outline);
break;
}
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();

View File

@ -157,7 +157,7 @@ public class SearchListAdapter extends BaseAdapter {
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
holder.status_account_displayname.setCompoundDrawables( img, null, null, null);
}else if( status.getReblog() != null){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet_header);
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
holder.status_account_displayname.setCompoundDrawables( img, null, null, null);
}else{
@ -236,6 +236,7 @@ public class SearchListAdapter extends BaseAdapter {
holder.account_fgc = (TextView) v.findViewById(R.id.account_fgc);
holder.account_frc = (TextView) v.findViewById(R.id.account_frc);
holder.account_search_title = (TextView) v.findViewById(R.id.account_search_title);
holder.main_container = (LinearLayout) v.findViewById(R.id.main_container);
v.setTag(holder);
} else {
holder = (ViewHolderAccounts) v.getTag();
@ -260,7 +261,7 @@ public class SearchListAdapter extends BaseAdapter {
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
holder.account_pp.setOnClickListener(new View.OnClickListener() {
holder.main_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
@ -335,6 +336,7 @@ public class SearchListAdapter extends BaseAdapter {
TextView account_fgc;
TextView account_frc;
TextView account_search_title;
LinearLayout main_container;
}
private class ViewHolderTag {

View File

@ -0,0 +1,133 @@
package fr.gouv.etalab.mastodon.drawers;
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastalab
*
* 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.
*
* Mastalab 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 Mastalab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import mastodon.etalab.gouv.fr.mastodon.R;
/**
* Created by Thomas on 09/10/2017.
* Adapter for tags when searching
*/
public class TagsSearchAdapter extends ArrayAdapter<String> implements Filterable {
private List<String> tags, tempTags, suggestions ;
private LayoutInflater layoutInflater;
public TagsSearchAdapter(Context context, List<String> tags){
super(context, android.R.layout.simple_list_item_1, tags);
this.tags = tags;
this.tempTags = new ArrayList<>(tags);
this.suggestions = new ArrayList<>(tags);
layoutInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return tags.size();
}
@Override
public String getItem(int position) {
return tags.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final String tag = tags.get(position);
final ViewHolder holder;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.drawer_tag_search, parent, false);
holder = new ViewHolder();
holder.tag_name = (TextView) convertView.findViewById(R.id.tag_name);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tag_name.setText(String.format("#%s", tag));
return convertView;
}
@Override
public Filter getFilter() {
return searchFilter;
}
private Filter searchFilter = new Filter() {
@Override
public CharSequence convertResultToString(Object resultValue) {
String tag = (String) resultValue;
return "#" + tag;
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
if (constraint != null) {
suggestions.clear();
for (String tag : tempTags) {
suggestions.add(tag);
}
FilterResults filterResults = new FilterResults();
filterResults.values = suggestions;
filterResults.count = suggestions.size();
return filterResults;
} else {
return new FilterResults();
}
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
ArrayList<String> c = (ArrayList<String>) results.values;
if (results.count > 0) {
clear();
for (String cust : c) {
add(cust);
notifyDataSetChanged();
}
} else{
clear();
notifyDataSetChanged();
}
}
};
private class ViewHolder {
TextView tag_name;
}
}

View File

@ -370,6 +370,17 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
}
}
/**
* Refresh status in list
*/
public void refreshFilter(){
int index = lv_status.getFirstVisiblePosition() + 1;
View v = lv_status.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();
statusListAdapter.notifyDataSetChanged();
lv_status.setSelectionFromTop(index, top);
}
@Override
public void onResume(){
super.onResume();

View File

@ -373,7 +373,7 @@ public class SettingsFragment extends Fragment {
set_toot_visibility.setImageResource(R.drawable.ic_action_lock_closed);
break;
case "direct":
set_toot_visibility.setImageResource(R.drawable.ic_local_post_office);
set_toot_visibility.setImageResource(R.drawable.ic_mail_outline);
break;
}
changeColor();
@ -415,7 +415,7 @@ public class SettingsFragment extends Fragment {
break;
case 3:
visibility = "direct";
set_toot_visibility.setImageResource(R.drawable.ic_local_post_office);
set_toot_visibility.setImageResource(R.drawable.ic_mail_outline);
break;
}
if( account != null) {
@ -482,12 +482,12 @@ public class SettingsFragment extends Fragment {
changeDrawableColor(context, R.drawable.ic_action_globe,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.dark_text);
}else {
changeDrawableColor(context, R.drawable.ic_action_globe,R.color.white);
changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.white);
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.white);
changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.white);
changeDrawableColor(context, R.drawable.ic_mail_outline,R.color.white);
}
}

View File

@ -209,6 +209,9 @@ public class Helper {
public static final String SET_PREVIEW_REPLIES_PP = "set_preview_replies_pp";
public static final String SET_TRANSLATOR = "set_translator";
public static final String SET_LED_COLOUR = "set_led_colour";
public static final String SET_SHOW_BOOSTS = "set_show_boost";
public static final String SET_SHOW_REPLIES = "set_show_replies";
public static final int ATTACHMENT_ALWAYS = 1;
public static final int ATTACHMENT_WIFI = 2;
@ -825,7 +828,6 @@ public class Helper {
if( currentSubmenu == null)
continue;
final MenuItem item = currentSubmenu.add("@" + account.getAcct());
//final MenuItem item = mainMenu.addSubMenu("@" + account.getAcct()).add("@" + account.getAcct());
ImageLoader imageLoader;
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
@ -989,7 +991,7 @@ public class Helper {
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
Resources res = activity.getResources();
BitmapDrawable icon = new BitmapDrawable(res, getRoundedCornerBitmap(loadedImage, 150));
BitmapDrawable icon = new BitmapDrawable(res, getRoundedCornerBitmap(loadedImage, 20));
imageView.setImageDrawable(icon);
}
@Override
@ -1021,7 +1023,7 @@ public class Helper {
activity.startActivity(myIntent);
activity.finish(); //User is logged out to get a new token
}else {
username.setText(String.format("@%s",account.getUsername()));
username.setText(String.format("@%s",account.getUsername() + "@" + account.getInstance()));
displayedName.setText(account.getDisplay_name());
String url = account.getAvatar();
if( url.startsWith("/") ){

View File

@ -1,9 +0,0 @@
package fr.gouv.etalab.mastodon.helper;
/**
* Created by Thomas on 02/09/2017.
*/
public class ManageHeader {
}

View File

@ -141,7 +141,7 @@ public class HomeTimelineSyncJob extends Job implements OnRetrieveHomeTimelineSe
for(Status status: statuses){
//The notification associated to max_id is discarded as it is supposed to have already been sent
//Also, if the toot comes from the owner, we will avoid to warn him/her...
if( (status.getId().equals(max_id)) || (acct != null && status.getAccount().getAcct().trim().equals(acct.trim()) ))
if( max_id != null && (status.getId().equals(max_id)) || (acct != null && status.getAccount().getAcct().trim().equals(acct.trim()) ))
continue;
String notificationUrl = status.getAccount().getAvatar();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 926 B

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 829 B

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 829 B

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 353 B

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 695 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 B

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 181 B

Some files were not shown because too many files have changed in this diff Show More