UI changes

This commit is contained in:
Thomas 2022-09-12 15:51:27 +02:00
parent b9001ccd7c
commit 16de400fc1
4 changed files with 92 additions and 48 deletions

View file

@ -60,6 +60,7 @@ import app.fedilab.android.client.entities.app.RemoteInstance;
import app.fedilab.android.client.entities.app.TagTimeline; import app.fedilab.android.client.entities.app.TagTimeline;
import app.fedilab.android.client.entities.app.Timeline; import app.fedilab.android.client.entities.app.Timeline;
import app.fedilab.android.databinding.ActivityMainBinding; import app.fedilab.android.databinding.ActivityMainBinding;
import app.fedilab.android.databinding.TabCustomDefaultViewBinding;
import app.fedilab.android.databinding.TabCustomViewBinding; import app.fedilab.android.databinding.TabCustomViewBinding;
import app.fedilab.android.exception.DBException; import app.fedilab.android.exception.DBException;
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonConversation; import app.fedilab.android.ui.fragment.timeline.FragmentMastodonConversation;
@ -250,60 +251,66 @@ public class PinnedTimelineHelper {
name = pinnedTimeline.remoteInstance.host; name = pinnedTimeline.remoteInstance.host;
break; break;
} }
TabCustomViewBinding tabCustomViewBinding = TabCustomViewBinding.inflate(activity.getLayoutInflater()); if (pinnedTimeline.type == Timeline.TimeLineEnum.LIST || pinnedTimeline.type == Timeline.TimeLineEnum.TAG || pinnedTimeline.type == Timeline.TimeLineEnum.REMOTE) {
tabCustomViewBinding.title.setText(name); TabCustomViewBinding tabCustomViewBinding = TabCustomViewBinding.inflate(activity.getLayoutInflater());
switch (pinnedTimeline.type) { tabCustomViewBinding.title.setText(name);
case LIST: switch (pinnedTimeline.type) {
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_tl_list); case LIST:
break; tabCustomViewBinding.icon.setImageResource(R.drawable.ic_tl_list);
case TAG: break;
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_tl_tag); case TAG:
break; tabCustomViewBinding.icon.setImageResource(R.drawable.ic_tl_tag);
case REMOTE: break;
switch (pinnedTimeline.remoteInstance.type) { case REMOTE:
case PIXELFED: switch (pinnedTimeline.remoteInstance.type) {
tabCustomViewBinding.icon.setImageResource(R.drawable.pixelfed); case PIXELFED:
break; tabCustomViewBinding.icon.setImageResource(R.drawable.pixelfed);
case MASTODON: break;
tabCustomViewBinding.icon.setImageResource(R.drawable.mastodon_icon_item); case MASTODON:
break; tabCustomViewBinding.icon.setImageResource(R.drawable.mastodon_icon_item);
break;
case MISSKEY: case MISSKEY:
tabCustomViewBinding.icon.setImageResource(R.drawable.misskey); tabCustomViewBinding.icon.setImageResource(R.drawable.misskey);
break; break;
case NITTER: case NITTER:
tabCustomViewBinding.icon.setImageResource(R.drawable.nitter); tabCustomViewBinding.icon.setImageResource(R.drawable.nitter);
break; break;
case GNU: case GNU:
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_gnu_social); tabCustomViewBinding.icon.setImageResource(R.drawable.ic_gnu_social);
break; break;
case PEERTUBE: case PEERTUBE:
tabCustomViewBinding.icon.setImageResource(R.drawable.peertube_icon); tabCustomViewBinding.icon.setImageResource(R.drawable.peertube_icon);
break; break;
} }
break; break;
case HOME: }
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_baseline_home_24); tab.setCustomView(tabCustomViewBinding.getRoot());
break; } else {
case LOCAL: TabCustomDefaultViewBinding tabCustomDefaultViewBinding = TabCustomDefaultViewBinding.inflate(activity.getLayoutInflater());
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_baseline_supervisor_account_24); switch (pinnedTimeline.type) {
break; case HOME:
case PUBLIC: tabCustomDefaultViewBinding.icon.setImageResource(R.drawable.ic_baseline_home_24);
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_baseline_public_24); break;
break; case LOCAL:
case NOTIFICATION: tabCustomDefaultViewBinding.icon.setImageResource(R.drawable.ic_baseline_supervisor_account_24);
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_baseline_notifications_24); break;
break; case PUBLIC:
case DIRECT: tabCustomDefaultViewBinding.icon.setImageResource(R.drawable.ic_baseline_public_24);
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_baseline_mail_24); break;
break; case NOTIFICATION:
tabCustomDefaultViewBinding.icon.setImageResource(R.drawable.ic_baseline_notifications_24);
break;
case DIRECT:
tabCustomDefaultViewBinding.icon.setImageResource(R.drawable.ic_baseline_mail_24);
break;
}
tab.setCustomView(tabCustomDefaultViewBinding.getRoot());
} }
tab.setCustomView(tabCustomViewBinding.getRoot());
activityMainBinding.tabLayout.addTab(tab); activityMainBinding.tabLayout.addTab(tab);
pinnedTimelineVisibleList.add(pinnedTimeline); pinnedTimelineVisibleList.add(pinnedTimeline);
} }
} }
LinearLayout tabStrip = (LinearLayout) activityMainBinding.tabLayout.getChildAt(0); LinearLayout tabStrip = (LinearLayout) activityMainBinding.tabLayout.getChildAt(0);
int finalToRemove = toRemove; int finalToRemove = toRemove;
for (int i = 0; i < tabStrip.getChildCount(); i++) { for (int i = 0; i < tabStrip.getChildCount(); i++) {

View file

@ -110,6 +110,26 @@ public class ReorderTabAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
holder.binding.icon.setImageResource(R.drawable.ic_baseline_view_list_24); holder.binding.icon.setImageResource(R.drawable.ic_baseline_view_list_24);
holder.binding.text.setText(pinned.pinnedTimelines.get(position).mastodonList.title); holder.binding.text.setText(pinned.pinnedTimelines.get(position).mastodonList.title);
break; break;
case HOME:
holder.binding.icon.setImageResource(R.drawable.ic_baseline_home_24);
holder.binding.text.setText(R.string.home_menu);
break;
case LOCAL:
holder.binding.icon.setImageResource(R.drawable.ic_baseline_supervisor_account_24);
holder.binding.text.setText(R.string.local_menu);
break;
case PUBLIC:
holder.binding.icon.setImageResource(R.drawable.ic_baseline_public_24);
holder.binding.text.setText(R.string.v_public);
break;
case NOTIFICATION:
holder.binding.icon.setImageResource(R.drawable.ic_baseline_notifications_24);
holder.binding.text.setText(R.string.notifications);
break;
case DIRECT:
holder.binding.icon.setImageResource(R.drawable.ic_baseline_mail_24);
holder.binding.text.setText(R.string.v_direct);
break;
} }

View file

@ -63,6 +63,12 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen
editor.putFloat(getString(R.string.SET_FONT_SCALE), scale); editor.putFloat(getString(R.string.SET_FONT_SCALE), scale);
recreate = true; recreate = true;
} }
if (key.compareToIgnoreCase(getString(R.string.SET_USE_SINGLE_TOPBAR)) == 0) {
recreate = true;
}
if (key.compareToIgnoreCase(getString(R.string.SET_TIMELINES_IN_A_LIST)) == 0) {
recreate = true;
}
editor.apply(); editor.apply();
} }
} }

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>