Merge branch 'bug_fix' into develop

This commit is contained in:
stom79 2017-12-13 15:35:48 +01:00
commit 37e83f8c64
8 changed files with 207 additions and 25 deletions

View File

@ -9,6 +9,7 @@ android {
targetSdkVersion 27
versionCode 88
versionName "1.6.7-beta-1"
vectorDrawables.useSupportLibrary = true
}
flavorDimensions "default"
buildTypes {

View File

@ -35,6 +35,7 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppThemeDark">
<service
android:name=".services.StreamingService"
android:exported="false"/>
@ -75,7 +76,7 @@
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:launchMode="singleTop"
android:windowSoftInputMode = "adjustResize"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/AppThemeDark_NoActionBar">
@ -117,17 +118,14 @@
<activity android:name=".activities.WebviewConnectActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
/>
<activity android:name=".activities.WebviewActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
/>
<activity android:name=".activities.MediaActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:noHistory="true"
/>
<activity android:name=".activities.RemoteFollowActivity"

View File

@ -1057,6 +1057,7 @@ public abstract class BaseMainActivity extends BaseActivity
b.putString("sharedContent", sharedText);
intentToot.putExtras(b);
startActivity(intentToot);
finish();
}
} else if (type.startsWith("image/")) {
@ -1072,6 +1073,7 @@ public abstract class BaseMainActivity extends BaseActivity
b.putInt("uriNumberMast", 1);
intentToot.putExtras(b);
startActivity(intentToot);
finish();
}
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null ) {
@ -1086,6 +1088,7 @@ public abstract class BaseMainActivity extends BaseActivity
b.putInt("uriNumberMast", imageList.size());
intentToot.putExtras(b);
startActivity(intentToot);
finish();
}
}
}

View File

@ -68,6 +68,7 @@ import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.Entities.Mention;
import fr.gouv.etalab.mastodon.helper.CrossActions;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
import fr.gouv.etalab.mastodon.interfaces.OnPostNotificationsActionInterface;
@ -209,6 +210,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_reply.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_reply.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.notification_status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.notification_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
@ -251,7 +253,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
if( !status.isEmojiFound())
status.makeEmojis(context, NotificationsListAdapter.this);
holder.notification_status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
holder.notification_status_content.setMovementMethod(null);
holder.notification_status_content.setMovementMethod(LinkMovementMethod.getInstance());
@ -261,6 +263,10 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
Helper.absoluteDateTimeReveal(context, holder.status_date, status.getCreated_at());
holder.status_mention_spoiler.setText(Helper.makeMentionsClick(context,status.getMentions()), TextView.BufferType.SPANNABLE);
holder.status_mention_spoiler.setMovementMethod(null);
holder.status_mention_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
//Adds attachment -> disabled, to enable them uncomment the line below
//loadAttachments(status, holder);
holder.notification_status_container.setVisibility(View.VISIBLE);
@ -289,6 +295,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.notification_status_content.setVisibility(View.VISIBLE);
holder.status_show_more.setVisibility(View.GONE);
holder.status_action_container.setVisibility(View.INVISIBLE);
holder.status_spoiler_button.setVisibility(View.GONE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
}else {
holder.status_action_container.setVisibility(View.VISIBLE);
@ -316,6 +324,42 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_repeat);
}
if( status.getReblog() == null) {
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
holder.notification_status_container.setVisibility(View.GONE);
holder.status_spoiler_container.setVisibility(View.VISIBLE);
holder.status_spoiler_button.setVisibility(View.VISIBLE);
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
holder.status_spoiler.setVisibility(View.VISIBLE);
} else {
holder.status_spoiler_button.setVisibility(View.GONE);
holder.notification_status_container.setVisibility(View.VISIBLE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0)
holder.status_spoiler_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_container.setVisibility(View.GONE);
}
}else {
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
holder.notification_status_container.setVisibility(View.GONE);
holder.status_spoiler_container.setVisibility(View.VISIBLE);
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
holder.status_spoiler_button.setVisibility(View.VISIBLE);
holder.status_spoiler.setVisibility(View.VISIBLE);
} else {
holder.status_spoiler_button.setVisibility(View.GONE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.notification_status_container.setVisibility(View.VISIBLE);
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0)
holder.status_spoiler_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_container.setVisibility(View.GONE);
}
}
assert imgFav != null;
imgFav.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
assert imgReblog != null;
@ -378,6 +422,17 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
}
}
}
//Spoiler opens
holder.status_spoiler_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
status.setSpoilerShown(true);
notificationsListAdapter.notifyDataSetChanged();
}
});
switch (status.getVisibility()){
case "public":
holder.status_privacy.setImageResource(R.drawable.ic_public);
@ -423,6 +478,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
}
holder.status_favorite_count.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -915,6 +972,9 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
FrameLayout card_status_container;
TextView notification_status_content;
TextView notification_type;
LinearLayout status_spoiler_container;
TextView status_spoiler;
Button status_spoiler_button;
TextView notification_account_username;
ImageView notification_account_profile;
ImageView notification_delete;
@ -940,6 +1000,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
LinearLayout notification_status_container;
RelativeLayout main_container_trans;
ImageView status_privacy;
LinearLayout status_spoiler_mention_container;
TextView status_mention_spoiler;
public View getView(){
return itemView;
@ -975,6 +1037,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
status_prev4_container = itemView.findViewById(R.id.status_prev4_container);
status_action_container = itemView.findViewById(R.id.status_action_container);
status_more = itemView.findViewById(R.id.status_more);
status_spoiler_container = itemView.findViewById(R.id.status_spoiler_container);
status_spoiler = itemView.findViewById(R.id.status_spoiler);
status_spoiler_button = itemView.findViewById(R.id.status_spoiler_button);
status_spoiler_mention_container = itemView.findViewById(R.id.status_spoiler_mention_container);
status_mention_spoiler = itemView.findViewById(R.id.status_mention_spoiler);
}
}

View File

@ -84,6 +84,7 @@ import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.Entities.Mention;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
import fr.gouv.etalab.mastodon.helper.CrossActions;
@ -229,6 +230,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
ProgressBar loader_replies;
Button fetch_more;
ImageView new_element;
LinearLayout status_spoiler_mention_container;
TextView status_mention_spoiler;
public View getView(){
return itemView;
@ -277,6 +280,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
status_replies_profile_pictures = itemView.findViewById(R.id.status_replies_profile_pictures);
new_element = itemView.findViewById(R.id.new_element);
status_action_container = itemView.findViewById(R.id.status_action_container);
status_spoiler_mention_container = itemView.findViewById(R.id.status_spoiler_mention_container);
status_mention_spoiler = itemView.findViewById(R.id.status_mention_spoiler);
}
}
@ -586,6 +591,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
});
holder.status_mention_spoiler.setText(Helper.makeMentionsClick(context,status.getMentions()), TextView.BufferType.SPANNABLE);
holder.status_mention_spoiler.setMovementMethod(null);
holder.status_mention_spoiler.setMovementMethod(LinkMovementMethod.getInstance());
if( status.getReblog() == null)
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
else
@ -616,6 +625,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_content.setVisibility(View.VISIBLE);
holder.status_content_translated_container.setVisibility(View.GONE);
holder.status_spoiler_button.setVisibility(View.GONE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_content_container.setVisibility(View.VISIBLE);
holder.status_translate.setVisibility(View.GONE);
holder.status_show_more.setVisibility(View.GONE);
@ -631,29 +641,36 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
holder.status_content_container.setVisibility(View.GONE);
holder.status_spoiler_container.setVisibility(View.VISIBLE);
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
holder.status_spoiler_button.setVisibility(View.VISIBLE);
holder.status_spoiler.setVisibility(View.VISIBLE);
} else {
holder.status_spoiler_button.setVisibility(View.GONE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.status_content_container.setVisibility(View.VISIBLE);
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0)
holder.status_spoiler_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_container.setVisibility(View.GONE);
}
}else {
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
holder.status_content_container.setVisibility(View.GONE);
holder.status_spoiler_container.setVisibility(View.VISIBLE);
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
holder.status_spoiler_button.setVisibility(View.VISIBLE);
holder.status_spoiler.setVisibility(View.VISIBLE);
} else {
holder.status_spoiler_button.setVisibility(View.GONE);
holder.status_content_container.setVisibility(View.VISIBLE);
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0)
if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0) {
holder.status_spoiler_container.setVisibility(View.VISIBLE);
else
holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
}else {
holder.status_spoiler_container.setVisibility(View.GONE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
}
}
}
@ -929,7 +946,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
@Override
public void onClick(View v) {
status.setSpoilerShown(true);
holder.status_spoiler_button.setVisibility(View.GONE);
statusListAdapter.notifyDataSetChanged();
}
});

View File

@ -112,6 +112,7 @@ import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
@ -133,6 +134,7 @@ import fr.gouv.etalab.mastodon.activities.WebviewActivity;
import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.Entities.Account;
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.sqlite.AccountDAO;
@ -1083,6 +1085,43 @@ public class Helper {
}
public static SpannableString makeMentionsClick(final Context context, List<Mention> mentions){
String cw_mention = "";
for(Mention mention:mentions){
cw_mention = String.format("@%s %s",mention.getAcct(),cw_mention);
}
SpannableString spannableString = new SpannableString(cw_mention);
for (final Mention mention : mentions) {
String targetedAccount = "@" + mention.getUsername();
if (spannableString.toString().contains(targetedAccount)) {
//Accounts can be mentioned several times so we have to loop
for(int startPosition = -1 ; (startPosition = spannableString.toString().indexOf(targetedAccount, startPosition + 1)) != -1 ; startPosition++){
int endPosition = startPosition + targetedAccount.length();
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(View textView) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", mention.getId());
intent.putExtras(b);
context.startActivity(intent);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
}
},
startPosition, endPosition,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
}
}
return spannableString;
}
/**
* Update the header with the new selected account
* @param activity Activity

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with Mastalab; if not,
see <http://www.gnu.org/licenses>.
-->
<FrameLayout
<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/tools"
@ -50,7 +50,7 @@
android:gravity="center_horizontal"
android:id="@+id/notification_delete"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_delete"
app:srcCompat="@drawable/ic_delete"
android:layout_width="25dp"
android:layout_height="25dp"
tools:ignore="ContentDescription" />
@ -84,6 +84,39 @@
android:layout_gravity="end"
android:gravity="end"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/status_spoiler_container"
android:layout_width="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:layout_height="wrap_content">
<TextView
android:id="@+id/status_spoiler"
android:layout_marginTop="10dp"
android:autoLink="web"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/status_spoiler_button"
android:textAllCaps="false"
android:drawableLeft="@drawable/ic_remove_red_eye"
android:drawableStart="@drawable/ic_remove_red_eye"
android:gravity="center"
android:drawablePadding="5dp"
android:paddingLeft="10dp"
android:paddingStart="10dp"
android:paddingRight="10dp"
android:paddingEnd="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:maxLines="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:text="@string/load_attachment_spoiler" />
</LinearLayout>
<LinearLayout
android:id="@+id/notification_status_container"
android:layout_width="match_parent"
@ -118,7 +151,7 @@
android:visibility="gone"
android:layout_centerInParent="true"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
</RelativeLayout>
@ -146,7 +179,7 @@
android:id="@+id/status_prev2_play"
android:layout_centerInParent="true"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
</RelativeLayout>
@ -173,7 +206,7 @@
android:id="@+id/status_prev3_play"
android:layout_centerInParent="true"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:visibility="gone"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
@ -196,7 +229,7 @@
android:layout_centerInParent="true"
android:visibility="gone"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
</RelativeLayout>
@ -222,6 +255,19 @@
android:layout_height="wrap_content"
android:text="@string/load_attachment" />
</LinearLayout>
<LinearLayout
android:id="@+id/status_spoiler_mention_container"
android:layout_width="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:layout_height="wrap_content">
<TextView
android:id="@+id/status_mention_spoiler"
android:layout_marginTop="10dp"
android:autoLink="web"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
@ -241,7 +287,7 @@
android:layout_gravity="center_vertical"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_reply"
app:srcCompat="@drawable/ic_reply"
tools:ignore="ContentDescription" />
<TextView
android:layout_marginLeft="20dp"
@ -262,7 +308,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
@ -285,7 +330,7 @@
android:id="@+id/status_more"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/ic_more_horiz"
app:srcCompat="@drawable/ic_more_horiz"
tools:ignore="ContentDescription" />
</LinearLayout>
</LinearLayout>

View File

@ -77,7 +77,7 @@
android:layout_marginTop="5dp"
android:id="@+id/new_element"
android:visibility="gone"
android:src="@drawable/ic_fiber_new"
app:srcCompat="@drawable/ic_fiber_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ContentDescription" />
@ -217,7 +217,7 @@
android:visibility="gone"
android:layout_centerInParent="true"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
</RelativeLayout>
@ -245,7 +245,7 @@
android:id="@+id/status_prev2_play"
android:layout_centerInParent="true"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
</RelativeLayout>
@ -272,7 +272,7 @@
android:id="@+id/status_prev3_play"
android:layout_centerInParent="true"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:visibility="gone"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
@ -295,7 +295,7 @@
android:layout_centerInParent="true"
android:visibility="gone"
android:layout_width="20dp"
android:src="@drawable/ic_play_arrow"
app:srcCompat="@drawable/ic_play_arrow"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
</RelativeLayout>
@ -323,8 +323,21 @@
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:text="@string/load_attachment" />
</LinearLayout>
<LinearLayout
android:id="@+id/status_spoiler_mention_container"
android:layout_width="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:layout_height="wrap_content">
<TextView
android:id="@+id/status_mention_spoiler"
android:layout_marginTop="10dp"
android:autoLink="web"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/status_action_container"
@ -387,7 +400,7 @@
android:layout_gravity="center_vertical"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_pin_drop"/>
app:srcCompat="@drawable/ic_pin_drop"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
@ -410,7 +423,7 @@
android:id="@+id/status_more"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/ic_more_horiz"
app:srcCompat="@drawable/ic_more_horiz"
tools:ignore="ContentDescription" />
</LinearLayout>
</LinearLayout>