Pinned icons fixes size + API retrieves pinned value
|
@ -17,6 +17,7 @@ package fr.gouv.etalab.mastodon.client;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.loopj.android.http.AsyncHttpResponseHandler;
|
||||
|
@ -1310,6 +1311,7 @@ public class API {
|
|||
status.setReblogs_count(Integer.valueOf(resobj.get("reblogs_count").toString()));
|
||||
status.setReblogged(Boolean.valueOf(resobj.get("reblogged").toString()));
|
||||
status.setFavourited(Boolean.valueOf(resobj.get("favourited").toString()));
|
||||
status.setPinned(Boolean.valueOf(resobj.get("pinned").toString()));
|
||||
try{
|
||||
status.setReblog(parseStatuses(context, resobj.getJSONObject("reblog")));
|
||||
}catch (Exception ignored){}
|
||||
|
|
|
@ -52,7 +52,6 @@ public class Status implements Parcelable {
|
|||
private List<Status> replies;
|
||||
private List<Mention> mentions;
|
||||
private List<Tag> tags;
|
||||
private List<Status> pins;
|
||||
private Application application;
|
||||
private String language;
|
||||
private boolean isTranslated = false;
|
||||
|
@ -83,9 +82,7 @@ public class Status implements Parcelable {
|
|||
isTranslated = in.readByte() != 0;
|
||||
isTranslationShown = in.readByte() != 0;
|
||||
isNew = in.readByte() != 0;
|
||||
|
||||
pinned = false;
|
||||
pins = null;
|
||||
pinned = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public Status(){}
|
||||
|
@ -210,10 +207,6 @@ public class Status implements Parcelable {
|
|||
|
||||
public boolean isPinned() { return pinned; }
|
||||
|
||||
public List<Status> getPins() { return pins; }
|
||||
|
||||
public void setPins(List<Status> pins) { this.pins = pins; }
|
||||
|
||||
public boolean isSensitive() {
|
||||
return sensitive;
|
||||
}
|
||||
|
@ -310,6 +303,7 @@ public class Status implements Parcelable {
|
|||
dest.writeByte((byte) (isTranslated ? 1 : 0));
|
||||
dest.writeByte((byte) (isTranslationShown ? 1 : 0));
|
||||
dest.writeByte((byte) (isNew ? 1 : 0));
|
||||
dest.writeByte((byte) (pinned ? 1 : 0));
|
||||
}
|
||||
|
||||
public boolean isSpoilerShown() {
|
||||
|
|
|
@ -454,7 +454,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
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_fav_black,R.color.dark_text);
|
||||
changeDrawableColor(context, R.drawable.ic_action_pin, R.color.dark_text);
|
||||
changeDrawableColor(context, R.drawable.ic_action_pin_dark, 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_translate,R.color.dark_text);
|
||||
|
@ -467,7 +467,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
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_fav_black,R.color.black);
|
||||
changeDrawableColor(context, R.drawable.ic_action_pin, R.color.black);
|
||||
changeDrawableColor(context, R.drawable.ic_action_pin_dark, R.color.black);
|
||||
changeDrawableColor(context, R.drawable.ic_photo,R.color.white);
|
||||
changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.white);
|
||||
changeDrawableColor(context, R.drawable.ic_translate,R.color.white);
|
||||
|
@ -736,19 +736,13 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
|
||||
// Pinning toots is only available on Mastodon 1._6_.0 instances.
|
||||
if (isOwner && Helper.canPin && (status.getVisibility().equals("public") || status.getVisibility().equals("unlisted"))) {
|
||||
|
||||
final Drawable imgUnPinToot, imgPinToot;
|
||||
imgUnPinToot = ContextCompat.getDrawable(context, R.drawable.ic_action_pin);
|
||||
imgPinToot = ContextCompat.getDrawable(context, R.drawable.ic_action_pin_yellow);
|
||||
|
||||
imgUnPinToot.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
|
||||
imgPinToot.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
|
||||
|
||||
if (status.isPinned())
|
||||
holder.status_pin.setImageDrawable(imgPinToot);
|
||||
Drawable imgPin;
|
||||
if( status.isPinned())
|
||||
imgPin = ContextCompat.getDrawable(context, R.drawable.ic_action_pin_yellow);
|
||||
else
|
||||
holder.status_pin.setImageDrawable(imgUnPinToot);
|
||||
|
||||
imgPin = ContextCompat.getDrawable(context, R.drawable.ic_action_pin_dark);
|
||||
imgPin.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
|
||||
holder.status_pin.setImageDrawable(imgPin);
|
||||
holder.status_pin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -759,10 +753,8 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
pinAction(status);
|
||||
}
|
||||
});
|
||||
|
||||
holder.status_pin.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
else {
|
||||
holder.status_pin.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
After Width: | Height: | Size: 511 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 318 B |
After Width: | Height: | Size: 693 B |
After Width: | Height: | Size: 384 B |
After Width: | Height: | Size: 756 B |
After Width: | Height: | Size: 665 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1007 B |
Before Width: | Height: | Size: 548 B After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 1.1 KiB |
|
@ -384,7 +384,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_action_pin"/>
|
||||
android:src="@drawable/ic_action_pin_dark"/>
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
|