Improve top bar
This commit is contained in:
parent
6fea7bbe54
commit
795cec2a73
|
@ -90,6 +90,7 @@ import app.fedilab.android.activities.FollowRequestActivity;
|
|||
import app.fedilab.android.activities.InstanceActivity;
|
||||
import app.fedilab.android.activities.InstanceHealthActivity;
|
||||
import app.fedilab.android.activities.LoginActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.MastodonListActivity;
|
||||
import app.fedilab.android.activities.PartnerShipActivity;
|
||||
import app.fedilab.android.activities.ProfileActivity;
|
||||
|
@ -251,7 +252,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, account.token);
|
||||
editor.commit();
|
||||
Intent mainActivity = new Intent(this, BaseMainActivity.class);
|
||||
Intent mainActivity = new Intent(this, MainActivity.class);
|
||||
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.OPEN_NOTIFICATION);
|
||||
startActivity(mainActivity);
|
||||
finish();
|
||||
|
@ -456,7 +457,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
editor.commit();
|
||||
//The user is now aut
|
||||
//The user is now authenticated, it will be redirected to MainActivity
|
||||
Intent mainActivity = new Intent(this, BaseMainActivity.class);
|
||||
Intent mainActivity = new Intent(this, MainActivity.class);
|
||||
startActivity(mainActivity);
|
||||
finish();
|
||||
headerMainBinding.ownerAccounts.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
editor.commit();
|
||||
//The user is now authenticated, it will be redirected to MainActivity
|
||||
Runnable myRunnable = () -> {
|
||||
Intent mainActivity = new Intent(activity, BaseMainActivity.class);
|
||||
Intent mainActivity = new Intent(activity, MainActivity.class);
|
||||
activity.startActivity(mainActivity);
|
||||
activity.finish();
|
||||
};
|
||||
|
|
|
@ -124,6 +124,7 @@ import app.fedilab.android.BaseMainActivity;
|
|||
import app.fedilab.android.MainApplication;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.LoginActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.WebviewActivity;
|
||||
import app.fedilab.android.broadcastreceiver.ToastMessage;
|
||||
import app.fedilab.android.client.entities.api.Attachment;
|
||||
|
@ -906,7 +907,7 @@ public class Helper {
|
|||
BaseMainActivity.currentToken = newAccount.token;
|
||||
BaseMainActivity.currentInstance = newAccount.instance;
|
||||
editor.commit();
|
||||
Intent changeAccount = new Intent(activity, BaseMainActivity.class);
|
||||
Intent changeAccount = new Intent(activity, MainActivity.class);
|
||||
changeAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
activity.startActivity(changeAccount);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.client.endpoints.MastodonNotificationsService;
|
||||
import app.fedilab.android.client.entities.api.Notification;
|
||||
import app.fedilab.android.client.entities.api.Notifications;
|
||||
|
@ -283,7 +284,7 @@ public class NotificationsHelper {
|
|||
}
|
||||
if (message != null) {
|
||||
//Some others notification
|
||||
final Intent intent = new Intent(context, BaseMainActivity.class);
|
||||
final Intent intent = new Intent(context, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
|
||||
intent.putExtra(Helper.PREF_KEY_ID, account.user_id);
|
||||
|
|
|
@ -52,6 +52,7 @@ import app.fedilab.android.client.entities.app.RemoteInstance;
|
|||
import app.fedilab.android.client.entities.app.TagTimeline;
|
||||
import app.fedilab.android.client.entities.app.Timeline;
|
||||
import app.fedilab.android.databinding.ActivityMainBinding;
|
||||
import app.fedilab.android.databinding.TabCustomViewBinding;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonConversation;
|
||||
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonTimeline;
|
||||
|
@ -149,9 +150,13 @@ public class PinnedTimelineHelper {
|
|||
//Small hack to hide first tabs (they represent the item of the bottom menu)
|
||||
int toRemove = itemToRemoveInBottomMenu(activity);
|
||||
List<String> tabTitle = new ArrayList<>();
|
||||
List<RemoteInstance.InstanceType> tabTypeRemote = new ArrayList<>();
|
||||
List<Timeline.TimeLineEnum> tabType = new ArrayList<>();
|
||||
for (int i = 0; i < (BOTTOM_TIMELINE_COUNT - toRemove); i++) {
|
||||
activityMainBinding.tabLayout.addTab(activityMainBinding.tabLayout.newTab());
|
||||
tabTitle.add("");
|
||||
tabType.add(Timeline.TimeLineEnum.HOME);
|
||||
tabTypeRemote.add(RemoteInstance.InstanceType.MASTODON);
|
||||
((ViewGroup) activityMainBinding.tabLayout.getChildAt(0)).getChildAt(i).setVisibility(View.GONE);
|
||||
}
|
||||
List<PinnedTimeline> pinnedTimelineVisibleList = new ArrayList<>();
|
||||
|
@ -166,9 +171,6 @@ public class PinnedTimelineHelper {
|
|||
break;
|
||||
case TAG:
|
||||
name = pinnedTimeline.tagTimeline.name;
|
||||
if (!name.startsWith("#")) {
|
||||
name = "#" + name;
|
||||
}
|
||||
break;
|
||||
case REMOTE:
|
||||
name = pinnedTimeline.remoteInstance.host;
|
||||
|
@ -177,8 +179,13 @@ public class PinnedTimelineHelper {
|
|||
TextView tv = (TextView) LayoutInflater.from(activity).inflate(R.layout.custom_tab_instance, new LinearLayout(activity), false);
|
||||
tv.setText(name);
|
||||
tabTitle.add(name);
|
||||
tabType.add(pinnedTimeline.type);
|
||||
if (pinnedTimeline.type == Timeline.TimeLineEnum.REMOTE) {
|
||||
tabTypeRemote.add(pinnedTimeline.remoteInstance.type);
|
||||
} else {
|
||||
tabTypeRemote.add(null);
|
||||
}
|
||||
tab.setCustomView(tv);
|
||||
|
||||
activityMainBinding.tabLayout.addTab(tab);
|
||||
pinnedTimelineVisibleList.add(pinnedTimeline);
|
||||
}
|
||||
|
@ -225,7 +232,42 @@ public class PinnedTimelineHelper {
|
|||
}
|
||||
});
|
||||
new TabLayoutMediator(activityMainBinding.tabLayout, activityMainBinding.viewPager,
|
||||
(tab, position) -> tab.setText(tabTitle.get(position))
|
||||
(tab, position) -> {
|
||||
TabCustomViewBinding tabCustomViewBinding = TabCustomViewBinding.inflate(activity.getLayoutInflater());
|
||||
tabCustomViewBinding.title.setText(tabTitle.get(position));
|
||||
switch (tabType.get(position)) {
|
||||
case LIST:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_tl_list);
|
||||
break;
|
||||
case TAG:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_tl_tag);
|
||||
break;
|
||||
case REMOTE:
|
||||
switch (tabTypeRemote.get(position)) {
|
||||
case PIXELFED:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.pixelfed);
|
||||
break;
|
||||
case MASTODON:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.mastodon_icon_item);
|
||||
break;
|
||||
|
||||
case MISSKEY:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.misskey);
|
||||
break;
|
||||
case NITTER:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.nitter);
|
||||
break;
|
||||
case GNU:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.ic_gnu_social);
|
||||
break;
|
||||
case PEERTUBE:
|
||||
tabCustomViewBinding.icon.setImageResource(R.drawable.peertube_icon);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
tab.setCustomView(tabCustomViewBinding.getRoot());
|
||||
}
|
||||
).attach();
|
||||
|
||||
activityMainBinding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class TimelineHelper {
|
|||
}
|
||||
|
||||
//If there are filters:
|
||||
if (BaseMainActivity.mainFilters != null && BaseMainActivity.mainFilters.size() > 0) {
|
||||
if (BaseMainActivity.mainFilters != null && BaseMainActivity.mainFilters.size() > 0 && statuses != null && statuses.size() > 0) {
|
||||
for (Filter filter : BaseMainActivity.mainFilters) {
|
||||
if (filter.irreversible) { //Dealt by the server
|
||||
continue;
|
||||
|
|
|
@ -76,20 +76,16 @@ public class AccountFollowRequestAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||
holderFollow.binding.acceptButton.setVisibility(View.VISIBLE);
|
||||
holderFollow.binding.title.setText(R.string.follow_request);
|
||||
AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
|
||||
holderFollow.binding.acceptButton.setOnClickListener(v -> {
|
||||
accountsVM.acceptFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id)
|
||||
holderFollow.binding.acceptButton.setOnClickListener(v -> accountsVM.acceptFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id)
|
||||
.observe((LifecycleOwner) context, relationShip -> {
|
||||
accountList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
});
|
||||
});
|
||||
holderFollow.binding.rejectButton.setOnClickListener(v -> {
|
||||
accountsVM.rejectFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id)
|
||||
}));
|
||||
holderFollow.binding.rejectButton.setOnClickListener(v -> accountsVM.rejectFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id)
|
||||
.observe((LifecycleOwner) context, relationShip -> {
|
||||
accountList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
});
|
||||
});
|
||||
}));
|
||||
holderFollow.binding.avatar.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ProfileActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:autoMirrored="true"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z" />
|
||||
</vector>
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,10L20,8h-4L16,4h-2v4h-4L10,4L8,4v4L4,8v2h4v4L4,14v2h4v4h2v-4h4v4h2v-4h4v-2h-4v-4h4zM14,14h-4v-4h4v4z" />
|
||||
</vector>
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="4dp"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="150dp"
|
||||
android:singleLine="true"
|
||||
android:textSize="16sp" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
Loading…
Reference in New Issue