MastoArt Timeline
This commit is contained in:
parent
1280bec827
commit
01a8fff703
|
@ -205,7 +205,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
private String instance_id;
|
||||
private int style;
|
||||
private Activity activity;
|
||||
|
||||
private HashMap<String, Integer> tabPosition = new HashMap<>();
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -313,7 +313,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
|
||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
ImageView iconArt = tabPublic.getCustomView().findViewById(R.id.tab_icon);
|
||||
ImageView iconArt = tabArt.getCustomView().findViewById(R.id.tab_icon);
|
||||
iconArt.setImageResource(R.drawable.ic_color_lens);
|
||||
|
||||
if( theme == THEME_LIGHT){
|
||||
|
@ -689,20 +689,32 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
|
||||
startSreaming();
|
||||
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
||||
tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
||||
|
||||
|
||||
tabLayout.addTab(tabHome);
|
||||
tabLayout.addTab(tabNotif);
|
||||
if( display_direct)
|
||||
tabPosition.put("home",0);
|
||||
tabPosition.put("notifications",1);
|
||||
int i = 2;
|
||||
if( display_direct) {
|
||||
tabLayout.addTab(tabDirect);
|
||||
if( display_local)
|
||||
tabPosition.put("direct",i);
|
||||
i++;
|
||||
}
|
||||
if( display_local) {
|
||||
tabLayout.addTab(tabLocal);
|
||||
if( display_global)
|
||||
tabPosition.put("local",i);
|
||||
i++;
|
||||
}
|
||||
if( display_global) {
|
||||
tabLayout.addTab(tabPublic);
|
||||
if( display_art)
|
||||
tabPosition.put("global",i);
|
||||
i++;
|
||||
}
|
||||
if( display_art) {
|
||||
tabLayout.addTab(tabArt);
|
||||
tabPosition.put("art",i);
|
||||
}
|
||||
|
||||
//Display filter for notification when long pressing the tab
|
||||
final LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
|
||||
|
@ -830,7 +842,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true))
|
||||
countPage++;
|
||||
|
||||
viewPager.setOffscreenPageLimit(countPage<=4?countPage:4);
|
||||
viewPager.setOffscreenPageLimit(countPage);
|
||||
main_app_container = findViewById(R.id.main_app_container);
|
||||
adapter = new PagerAdapter
|
||||
(getSupportFragmentManager(), tabLayout.getTabCount());
|
||||
|
@ -852,10 +864,16 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
viewPager.setVisibility(View.VISIBLE);
|
||||
delete_instance.setVisibility(View.GONE);
|
||||
Helper.switchLayout(BaseMainActivity.this);
|
||||
if( tab.getPosition() != 1 )
|
||||
toot.show();
|
||||
else
|
||||
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))) {
|
||||
toot.hide();
|
||||
federatedTimelines.hide();
|
||||
}else {
|
||||
toot.show();
|
||||
if( !displayFollowInstance)
|
||||
federatedTimelines.hide();
|
||||
else
|
||||
federatedTimelines.show();
|
||||
}
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
if( tab.getCustomView() != null) {
|
||||
|
@ -891,10 +909,16 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
}
|
||||
if( tab.getPosition() != 1 )
|
||||
toot.show();
|
||||
else
|
||||
if( tab.getPosition() == 1 || (tabPosition.containsKey("art") && tab.getPosition() == tabPosition.get("art"))) {
|
||||
toot.hide();
|
||||
federatedTimelines.hide();
|
||||
}else {
|
||||
toot.show();
|
||||
if( !displayFollowInstance)
|
||||
federatedTimelines.hide();
|
||||
else
|
||||
federatedTimelines.show();
|
||||
}
|
||||
|
||||
if( viewPager.getAdapter() != null) {
|
||||
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tab.getPosition());
|
||||
|
@ -925,25 +949,38 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
updateTimeLine(RetrieveFeedsAsyncTask.Type.LOCAL, 0);
|
||||
else if (display_global)
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC, 0);
|
||||
else if(display_art)
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.ART, 0);
|
||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
displayStatusFragment.scrollToTop();
|
||||
break;
|
||||
case 3:
|
||||
if (display_local && display_direct){
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.LOCAL, 0);
|
||||
}else if (display_global && !display_direct){
|
||||
}else if (display_global && !display_direct && display_local){
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC, 0);
|
||||
} else if (display_global ) {
|
||||
} else if (display_global && !display_local && display_direct) {
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC, 0);
|
||||
}else if (display_art ) {
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.ART, 0);
|
||||
}
|
||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
displayStatusFragment.scrollToTop();
|
||||
break;
|
||||
case 4:
|
||||
if( countPage == 5) {
|
||||
if( display_global && display_local && display_direct) {
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC, 0);
|
||||
}else {
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.ART, 0);
|
||||
}
|
||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
displayStatusFragment.scrollToTop();
|
||||
break;
|
||||
case 5:
|
||||
if( countPage == 6) {
|
||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
displayStatusFragment.scrollToTop();
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC, 0);
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.ART, 0);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
|
@ -2366,28 +2403,23 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.LOCAL);
|
||||
statusFragment.setArguments(bundle);
|
||||
return statusFragment;
|
||||
}else if (position == 3 && display_global && !display_direct){
|
||||
}else if (position == 3 && display_global && (display_direct && !display_local) || (!display_direct && display_local)){
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
|
||||
statusFragment.setArguments(bundle);
|
||||
return statusFragment;
|
||||
} else if (position == 3 && display_global ){
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
|
||||
statusFragment.setArguments(bundle);
|
||||
return statusFragment;
|
||||
}else if (position == 3 ){
|
||||
} else if (position == 3 && display_art){
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.ART);
|
||||
statusFragment.setArguments(bundle);
|
||||
return statusFragment;
|
||||
}
|
||||
else if (position == 4 && display_global && countPage == 5){
|
||||
else if (position == 4 && display_global && display_local && display_direct){
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
|
||||
statusFragment.setArguments(bundle);
|
||||
return statusFragment;
|
||||
} else if (position == 4 && !display_global && countPage == 5){
|
||||
} else if (position == 4 && display_art){
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.ART);
|
||||
statusFragment.setArguments(bundle);
|
||||
|
|
|
@ -1104,13 +1104,17 @@ public class API {
|
|||
if( apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0){
|
||||
for( Status status: apiResponse.getStatuses()){
|
||||
if( status.getMedia_attachments().size() > 1){
|
||||
String statusSerialized = Helper.statusToStringStorage(status);
|
||||
for(Attachment attachment: status.getMedia_attachments()){
|
||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
||||
attachments.add(attachment);
|
||||
status.setMedia_attachments(attachments);
|
||||
apiResponseReply.getStatuses().add(status);
|
||||
Status newStatus = Helper.restoreStatusFromString(statusSerialized);
|
||||
if( newStatus == null)
|
||||
break;
|
||||
newStatus.setMedia_attachments(attachments);
|
||||
apiResponseReply.getStatuses().add(newStatus);
|
||||
}
|
||||
}else {
|
||||
}else if (status.getMedia_attachments().size() == 1) {
|
||||
apiResponseReply.getStatuses().add(status);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,12 +235,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
private class ViewHolderArt extends RecyclerView.ViewHolder{
|
||||
ImageView art_media, art_pp;
|
||||
TextView art_username, art_acct;
|
||||
LinearLayout art_author;
|
||||
ViewHolderArt(View itemView) {
|
||||
super(itemView);
|
||||
art_media = itemView.findViewById(R.id.art_media);
|
||||
art_pp = itemView.findViewById(R.id.art_pp);
|
||||
art_username = itemView.findViewById(R.id.art_username);
|
||||
art_acct = itemView.findViewById(R.id.art_acct);
|
||||
art_author = itemView.findViewById(R.id.art_author);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,6 +443,12 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
if( type == RetrieveFeedsAsyncTask.Type.ART) {
|
||||
final ViewHolderArt holder = (ViewHolderArt) viewHolder;
|
||||
final Status status = statuses.get(position);
|
||||
|
||||
if( !status.isClickable())
|
||||
Status.transform(context, status);
|
||||
if( !status.isEmojiFound())
|
||||
Status.makeEmojis(context, this, status);
|
||||
|
||||
Glide.with(context)
|
||||
.load(status.getMedia_attachments().get(0).getPreview_url())
|
||||
.into(holder.art_media);
|
||||
|
@ -448,8 +456,46 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
.load(status.getAccount().getAvatar())
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.art_pp);
|
||||
holder.art_username.setText( status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.art_pp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("accountId", status.getAccount().getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
intent.putParcelableArrayListExtra("mediaArray", status.getMedia_attachments());
|
||||
b.putInt("position", 0);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder.art_author.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("status", status);
|
||||
intent.putExtras(b);
|
||||
if (type == RetrieveFeedsAsyncTask.Type.CONTEXT)
|
||||
((Activity) context).finish();
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
if( status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText( status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.art_username.setText( status.getAccount().getUsername());
|
||||
|
||||
holder.art_acct.setText(String.format("@%s", status.getAccount().getAcct()));
|
||||
|
||||
}else if( viewHolder.getItemViewType() == DISPLAYED_STATUS || viewHolder.getItemViewType() == FOCUSED_STATUS || viewHolder.getItemViewType() == COMPACT_STATUS){
|
||||
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||
final Status status = statuses.get(position);
|
||||
|
|
|
@ -411,6 +411,27 @@ public class SettingsFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
boolean display_art = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true);
|
||||
final CheckBox set_display_art = rootView.findViewById(R.id.set_display_art);
|
||||
set_display_art.setChecked(display_art);
|
||||
|
||||
set_display_art.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_DISPLAY_ART, set_display_art.isChecked());
|
||||
editor.apply();
|
||||
if( getActivity() != null)
|
||||
getActivity().recreate();
|
||||
Intent intent = new Intent(context, MainActivity.class);
|
||||
intent.putExtra(INTENT_ACTION, CHANGE_THEME_INTENT);
|
||||
if(getActivity() != null)
|
||||
getActivity().finish();
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
boolean disableGif = sharedpreferences.getBoolean(Helper.SET_DISABLE_GIF, false);
|
||||
final CheckBox set_disable_gif = rootView.findViewById(R.id.set_disable_gif);
|
||||
set_disable_gif.setChecked(disableGif);
|
||||
|
|
|
@ -77,6 +77,12 @@
|
|||
android:text="@string/set_display_global"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_display_art"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_display_art"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<!-- CARRIAGE RETURN AFTER MENTION IN REPLIES -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_capitalize"
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
android:id="@+id/toolbar_title" />
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
app:tabMode="scrollable"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
app:tabGravity="fill"
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:id="@+id/art_media"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal"
|
||||
android:background="#22000000"
|
||||
android:background="#44000000"
|
||||
android:padding="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -22,12 +23,17 @@
|
|||
android:layout_height="50dp" />
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:id="@+id/art_author"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/art_username"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
|
|
|
@ -76,6 +76,12 @@
|
|||
android:text="@string/set_display_global"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/set_display_art"
|
||||
android:layout_width="wrap_content"
|
||||
android:text="@string/set_display_art"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<!-- CARRIAGE RETURN AFTER MENTION IN REPLIES -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_capitalize"
|
||||
|
|
|
@ -685,6 +685,7 @@
|
|||
<string name="tags_stored">The tag has been stored!</string>
|
||||
<string name="tags_renamed">The tag has been changed!</string>
|
||||
<string name="tags_deleted">The tag has been deleted!</string>
|
||||
<string name="set_display_art">Display Art timeline</string>
|
||||
|
||||
<string-array name="filter_expire">
|
||||
<item>Never</item>
|
||||
|
|
Loading…
Reference in New Issue