Manage accounts
This commit is contained in:
parent
b4e7c3f8e2
commit
9510678a9f
|
@ -58,6 +58,11 @@
|
|||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".ShowAccountActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".AccountActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
|
|
|
@ -14,9 +14,6 @@ package app.fedilab.fedilabtube;
|
|||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
|
@ -26,8 +23,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -36,7 +31,6 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
@ -48,45 +42,34 @@ import com.google.android.material.tabs.TabLayout;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.fedilabtube.client.APIResponse;
|
||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||
import app.fedilab.fedilabtube.client.data.ChannelData.Channel;
|
||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
|
||||
import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
|
||||
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.AccountsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.RelationshipVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY;
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.FOLLOW;
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE;
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT;
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW;
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.DataType.CHANNEL;
|
||||
import static app.fedilab.fedilabtube.helper.Helper.getLiveInstance;
|
||||
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
|
||||
|
||||
|
||||
public class ShowAccountActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
private Button account_follow;
|
||||
private ViewPager mPager;
|
||||
private TabLayout tabLayout;
|
||||
private TextView account_note, subscriber_count;
|
||||
private Map<String, Boolean> relationship;
|
||||
private ImageView account_pp;
|
||||
private TextView account_dn;
|
||||
private Channel channel;
|
||||
private action doAction;
|
||||
private String channelAcct;
|
||||
private AccountData.Account account;
|
||||
private String accountAcct;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -94,15 +77,13 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_show_account);
|
||||
setTitle("");
|
||||
Bundle b = getIntent().getExtras();
|
||||
account_follow = findViewById(R.id.account_follow);
|
||||
subscriber_count = findViewById(R.id.subscriber_count);
|
||||
account_follow.setEnabled(false);
|
||||
account_pp = findViewById(R.id.account_pp);
|
||||
account_dn = findViewById(R.id.account_dn);
|
||||
account_pp.setBackgroundResource(R.drawable.account_pp_border);
|
||||
if (b != null) {
|
||||
channel = b.getParcelable("channel");
|
||||
channelAcct = b.getString("channelId");
|
||||
account = b.getParcelable("account");
|
||||
accountAcct = b.getString("accountAcct");
|
||||
} else {
|
||||
Toasty.error(ShowAccountActivity.this, getString(R.string.toast_error_loading_account), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -114,11 +95,9 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
tabLayout = findViewById(R.id.account_tabLayout);
|
||||
account_note = findViewById(R.id.account_note);
|
||||
|
||||
|
||||
ChannelsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(ChannelsVM.class);
|
||||
|
||||
manageChannel();
|
||||
viewModel.get(CHANNEL, channelAcct == null ? channel.getName() + "@" + channel.getHost() : channelAcct).observe(ShowAccountActivity.this, this::manageViewAccounts);
|
||||
manageAccount();
|
||||
AccountsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(AccountsVM.class);
|
||||
viewModel.getAccount(accountAcct == null ? account.getUsername() + "@" + account.getHost() : accountAcct).observe(ShowAccountActivity.this, this::manageViewAccounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,7 +116,7 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
return true;
|
||||
} else if (item.getItemId() == R.id.action_mute) {
|
||||
PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
|
||||
viewModel.post(MUTE, channel.getOwnerAccount() != null ? channel.getOwnerAccount().getAcct() : channel.getAcct(), null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse));
|
||||
viewModel.post(MUTE, accountAcct == null ? account.getUsername() + "@" + account.getHost() : accountAcct, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse));
|
||||
} else if (item.getItemId() == R.id.action_report) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ShowAccountActivity.this);
|
||||
LayoutInflater inflater1 = getLayoutInflater();
|
||||
|
@ -150,7 +129,7 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
Toasty.info(ShowAccountActivity.this, getString(R.string.report_comment_size), Toasty.LENGTH_LONG).show();
|
||||
} else {
|
||||
PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
|
||||
viewModel.post(REPORT_ACCOUNT, channel.getId(), report_content.getText().toString()).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(REPORT_ACCOUNT, apiResponse));
|
||||
viewModel.post(REPORT_ACCOUNT, account.getId(), report_content.getText().toString()).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(REPORT_ACCOUNT, apiResponse));
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
@ -160,30 +139,18 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void manageChannel() {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
private void manageAccount() {
|
||||
|
||||
String accountIdRelation = channel.getAcct();
|
||||
if (isLoggedIn(ShowAccountActivity.this)) {
|
||||
RelationshipVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(RelationshipVM.class);
|
||||
List<String> uids = new ArrayList<>();
|
||||
uids.add(accountIdRelation);
|
||||
viewModel.get(uids).observe(ShowAccountActivity.this, this::manageVIewRelationship);
|
||||
}
|
||||
|
||||
setTitle(channel.getAcct());
|
||||
|
||||
setTitle(account.getAcct());
|
||||
|
||||
mPager = findViewById(R.id.account_viewpager);
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.channels)));
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.videos)));
|
||||
mPager.setOffscreenPageLimit(1);
|
||||
|
||||
mPager.setOffscreenPageLimit(2);
|
||||
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
mPager.setAdapter(mPagerAdapter);
|
||||
ViewGroup.LayoutParams params = tabLayout.getLayoutParams();
|
||||
params.height = 0;
|
||||
tabLayout.setLayoutParams(params);
|
||||
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
@ -222,111 +189,26 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
switch (tab.getPosition()) {
|
||||
case 0:
|
||||
if (fragment != null) {
|
||||
DisplayVideosFragment displayVideosFragment = ((DisplayVideosFragment) fragment);
|
||||
displayVideosFragment.scrollToTop();
|
||||
DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment);
|
||||
displayChannelsFragment.scrollToTop();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (fragment != null) {
|
||||
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
||||
displayAccountsFragment.scrollToTop();
|
||||
DisplayVideosFragment displayVideosFragment = ((DisplayVideosFragment) fragment);
|
||||
displayVideosFragment.scrollToTop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
account_dn.setText(channel.getDisplayName());
|
||||
account_dn.setText(account.getDisplayName());
|
||||
|
||||
|
||||
manageNotes(channel);
|
||||
Helper.loadGiF(ShowAccountActivity.this, channel.getAvatar() != null ? channel.getAvatar().getPath() : null, account_pp);
|
||||
//Follow button
|
||||
String target = channel.getAcct();
|
||||
|
||||
account_follow.setOnClickListener(v -> {
|
||||
if (doAction == action.NOTHING) {
|
||||
Toasty.info(ShowAccountActivity.this, getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show();
|
||||
} else if (doAction == action.FOLLOW) {
|
||||
account_follow.setEnabled(false);
|
||||
PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
|
||||
viewModel.post(FOLLOW, target, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(FOLLOW, apiResponse));
|
||||
} else if (doAction == action.UNFOLLOW) {
|
||||
boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true);
|
||||
if (confirm_unfollow) {
|
||||
AlertDialog.Builder unfollowConfirm = new AlertDialog.Builder(ShowAccountActivity.this);
|
||||
unfollowConfirm.setTitle(getString(R.string.unfollow_confirm));
|
||||
unfollowConfirm.setMessage(channel.getAcct());
|
||||
unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
account_follow.setEnabled(false);
|
||||
PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
|
||||
viewModel.post(UNFOLLOW, target, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(UNFOLLOW, apiResponse));
|
||||
dialog.dismiss();
|
||||
});
|
||||
unfollowConfirm.show();
|
||||
} else {
|
||||
account_follow.setEnabled(false);
|
||||
PostActionsVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(PostActionsVM.class);
|
||||
viewModel.post(UNFOLLOW, target, null).observe(ShowAccountActivity.this, apiResponse -> manageVIewPostActions(UNFOLLOW, apiResponse));
|
||||
manageNotes(account);
|
||||
Helper.loadGiF(ShowAccountActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, account_pp);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void manageVIewRelationship(APIResponse apiResponse) {
|
||||
|
||||
if (apiResponse.getError() != null) {
|
||||
Toasty.error(ShowAccountActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
this.relationship = apiResponse.getRelationships();
|
||||
manageButtonVisibility();
|
||||
|
||||
invalidateOptionsMenu();
|
||||
|
||||
}
|
||||
|
||||
//Manages the visibility of the button
|
||||
private void manageButtonVisibility() {
|
||||
if (relationship == null)
|
||||
return;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
int[][] states = new int[][]{
|
||||
new int[]{android.R.attr.state_enabled}, // enabled
|
||||
new int[]{-android.R.attr.state_enabled}, // disabled
|
||||
new int[]{-android.R.attr.state_checked}, // unchecked
|
||||
new int[]{android.R.attr.state_pressed} // pressed
|
||||
};
|
||||
|
||||
int[] colors = new int[]{
|
||||
ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent()),
|
||||
ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent()),
|
||||
ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent()),
|
||||
ContextCompat.getColor(ShowAccountActivity.this, Helper.getColorAccent())
|
||||
};
|
||||
account_follow.setBackgroundTintList(new ColorStateList(states, colors));
|
||||
}
|
||||
account_follow.setEnabled(true);
|
||||
|
||||
boolean isFollowing = relationship.get(channel.getAcct());
|
||||
if (isFollowing) {
|
||||
account_follow.setText(R.string.action_unfollow);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowAccountActivity.this, R.color.red_1)));
|
||||
}
|
||||
doAction = action.UNFOLLOW;
|
||||
} else {
|
||||
account_follow.setText(R.string.action_follow);
|
||||
doAction = action.FOLLOW;
|
||||
}
|
||||
account_follow.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
@ -344,47 +226,31 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
Toasty.error(ShowAccountActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
String target = channel.getAcct();
|
||||
//IF action is unfollow or mute, sends an intent to remove statuses
|
||||
if (statusAction == RetrofitPeertubeAPI.ActionType.UNFOLLOW) {
|
||||
Bundle b = new Bundle();
|
||||
b.putString("receive_action", apiResponse.getTargetedId());
|
||||
Intent intentBC = new Intent(Helper.RECEIVE_ACTION);
|
||||
intentBC.putExtras(b);
|
||||
}
|
||||
if (statusAction == RetrofitPeertubeAPI.ActionType.UNFOLLOW || statusAction == RetrofitPeertubeAPI.ActionType.FOLLOW) {
|
||||
RelationshipVM viewModel = new ViewModelProvider(ShowAccountActivity.this).get(RelationshipVM.class);
|
||||
List<String> uris = new ArrayList<>();
|
||||
uris.add(target);
|
||||
viewModel.get(uris).observe(ShowAccountActivity.this, this::manageVIewRelationship);
|
||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.MUTE) {
|
||||
if (statusAction == RetrofitPeertubeAPI.ActionType.MUTE) {
|
||||
Toasty.info(ShowAccountActivity.this, getString(R.string.muted_done), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void manageViewAccounts(APIResponse apiResponse) {
|
||||
if (apiResponse.getChannels() != null && apiResponse.getChannels().size() == 1) {
|
||||
Channel channel = apiResponse.getChannels().get(0);
|
||||
if (this.channel == null) {
|
||||
this.channel = channel;
|
||||
manageChannel();
|
||||
if (apiResponse.getAccounts() != null && apiResponse.getAccounts().size() == 1) {
|
||||
AccountData.Account account = apiResponse.getAccounts().get(0);
|
||||
if (this.account == null) {
|
||||
this.account = account;
|
||||
manageAccount();
|
||||
}
|
||||
if (channel.getOwnerAccount() != null) {
|
||||
this.channel.setOwnerAccount(channel.getOwnerAccount());
|
||||
}
|
||||
subscriber_count.setText(getString(R.string.followers_count, Helper.withSuffix(channel.getFollowersCount())));
|
||||
subscriber_count.setText(getString(R.string.followers_count, Helper.withSuffix(account.getFollowersCount())));
|
||||
subscriber_count.setVisibility(View.VISIBLE);
|
||||
manageNotes(channel);
|
||||
manageNotes(account);
|
||||
}
|
||||
}
|
||||
|
||||
private void manageNotes(Channel channel) {
|
||||
if (channel.getDescription() != null && channel.getDescription().compareTo("null") != 0 && channel.getDescription().trim().length() > 0) {
|
||||
private void manageNotes(AccountData.Account account) {
|
||||
if (account.getDescription() != null && account.getDescription().compareTo("null") != 0 && account.getDescription().trim().length() > 0) {
|
||||
SpannableString spannableString;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
spannableString = new SpannableString(Html.fromHtml(channel.getDescription(), FROM_HTML_MODE_LEGACY));
|
||||
spannableString = new SpannableString(Html.fromHtml(account.getDescription(), FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
spannableString = new SpannableString(Html.fromHtml(channel.getDescription()));
|
||||
spannableString = new SpannableString(Html.fromHtml(account.getDescription()));
|
||||
|
||||
account_note.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
account_note.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
@ -394,11 +260,6 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
public enum action {
|
||||
FOLLOW,
|
||||
UNFOLLOW,
|
||||
NOTHING
|
||||
}
|
||||
|
||||
/**
|
||||
* Pager adapter for the 2 fragments
|
||||
|
@ -414,25 +275,24 @@ public class ShowAccountActivity extends AppCompatActivity {
|
|||
public Fragment getItem(int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
if (position == 0) {
|
||||
DisplayChannelsFragment displayChannelsFragment = new DisplayChannelsFragment();
|
||||
bundle.putString("name", account.getAcct());
|
||||
bundle.putBoolean("myChannels", false);
|
||||
displayChannelsFragment.setArguments(bundle);
|
||||
return displayChannelsFragment;
|
||||
}
|
||||
DisplayVideosFragment displayVideosFragment = new DisplayVideosFragment();
|
||||
bundle = new Bundle();
|
||||
bundle.putSerializable("type", TimelineVM.TimelineType.USER_VIDEOS);
|
||||
bundle.putString("channelId", channel.getAcct());
|
||||
bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.ACCOUNT_VIDEOS);
|
||||
bundle.putString("channelId", account.getAcct());
|
||||
bundle.putString("peertube_instance", account.getHost());
|
||||
displayVideosFragment.setArguments(bundle);
|
||||
return displayVideosFragment;
|
||||
}
|
||||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
|
||||
bundle.putString("targetedid", channel.getId());
|
||||
bundle.putString("instance", getLiveInstance(ShowAccountActivity.this));
|
||||
bundle.putString("name", channel.getAcct());
|
||||
displayAccountsFragment.setArguments(bundle);
|
||||
return displayAccountsFragment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ShowChannelActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_show_account);
|
||||
setContentView(R.layout.activity_show_channel);
|
||||
setTitle("");
|
||||
Bundle b = getIntent().getExtras();
|
||||
account_follow = findViewById(R.id.account_follow);
|
||||
|
@ -417,7 +417,7 @@ public class ShowChannelActivity extends AppCompatActivity {
|
|||
public Fragment getItem(int position) {
|
||||
DisplayVideosFragment displayVideosFragment = new DisplayVideosFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.USER_VIDEOS);
|
||||
bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.CHANNEL_VIDEOS);
|
||||
bundle.putString("channelId", channel.getAcct());
|
||||
bundle.putString("peertube_instance", channel.getHost());
|
||||
bundle.putBoolean("sepia_search", sepiaSearch);
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
|
||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||
import app.fedilab.fedilabtube.client.data.BlockData;
|
||||
import app.fedilab.fedilabtube.client.data.CaptionData;
|
||||
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||
|
@ -165,7 +166,7 @@ public interface PeertubeService {
|
|||
|
||||
//Get my video
|
||||
@GET("accounts/{name}/videos?sort=-publishedAt")
|
||||
Call<VideoData.Video> getVideosForAccount(@Query("start") String maxId, @Query("count") String count);
|
||||
Call<VideoData> getVideosForAccount(@Path("name") String name, @Query("start") String maxId, @Query("count") String count);
|
||||
|
||||
@Multipart
|
||||
@PUT("videos/{id}")
|
||||
|
@ -228,6 +229,11 @@ public interface PeertubeService {
|
|||
@GET("video-playlists")
|
||||
Call<PlaylistData> getPlaylists();
|
||||
|
||||
|
||||
//Get a single account
|
||||
@GET("accounts/{accountHandle}")
|
||||
Call<AccountData.Account> getAccount(@Path("accountHandle") String accountHandle);
|
||||
|
||||
//Get/Post/Update/Delete playlist
|
||||
@GET("accounts/{accountHandle}/video-playlists")
|
||||
Call<PlaylistData> getPlaylistsForAccount(@Header("Authorization") String credentials, @Path("accountHandle") String accountHandle);
|
||||
|
|
|
@ -320,6 +320,9 @@ public class RetrofitPeertubeAPI {
|
|||
case MY_VIDEOS:
|
||||
videoCall = peertubeService.getMyVideos(getToken(), max_id, count);
|
||||
break;
|
||||
case ACCOUNT_VIDEOS:
|
||||
videoCall = peertubeService.getVideosForAccount(forAccount, max_id, count);
|
||||
break;
|
||||
case SUBSCRIBTIONS:
|
||||
if (forAccount == null) {
|
||||
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, count, filter);
|
||||
|
@ -844,6 +847,38 @@ public class RetrofitPeertubeAPI {
|
|||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get single account by its handle
|
||||
*
|
||||
* @param accountHandle String
|
||||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getAccount(String accountHandle) {
|
||||
PeertubeService peertubeService = init();
|
||||
Call<AccountData.Account> accountDataCall = peertubeService.getAccount(accountHandle);
|
||||
APIResponse apiResponse = new APIResponse();
|
||||
if (accountDataCall != null) {
|
||||
try {
|
||||
Response<AccountData.Account> response = accountDataCall.execute();
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
List<AccountData.Account> accountList = new ArrayList<>();
|
||||
accountList.add(response.body());
|
||||
apiResponse.setAccounts(accountList);
|
||||
} else {
|
||||
setError(apiResponse, response.code(), response.errorBody());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Error error = new Error();
|
||||
error.setError(_context.getString(R.string.toast_error));
|
||||
apiResponse.setError(error);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return apiResponse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get muted accounts
|
||||
*
|
||||
|
|
|
@ -46,12 +46,14 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
|
||||
public AllChannelRemoved allChannelRemoved;
|
||||
public EditAlertDialog editAlertDialog;
|
||||
private List<Channel> channels;
|
||||
private final List<Channel> channels;
|
||||
private Context context;
|
||||
private final boolean myChannel;
|
||||
|
||||
|
||||
public ChannelListAdapter(List<Channel> channels) {
|
||||
public ChannelListAdapter(List<Channel> channels, boolean myChannel) {
|
||||
this.channels = channels;
|
||||
this.myChannel = myChannel;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -75,7 +77,9 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
//Profile picture
|
||||
Helper.loadGiF(context, channel.getAvatar() != null ? channel.getAvatar().getPath() : null, holder.account_pp);
|
||||
|
||||
|
||||
if( !this.myChannel) {
|
||||
holder.more_actions.setVisibility(View.GONE);
|
||||
}
|
||||
holder.more_actions.setOnClickListener(view -> {
|
||||
PopupMenu popup = new PopupMenu(context, holder.more_actions);
|
||||
popup.getMenuInflater()
|
||||
|
@ -84,8 +88,8 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
popup.getMenu().findItem(R.id.action_delete).setEnabled(false);
|
||||
}
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_delete:
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_delete) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(context.getString(R.string.delete_channel) + ": " + channel.getName());
|
||||
builder.setMessage(context.getString(R.string.action_channel_confirm_delete));
|
||||
|
@ -107,12 +111,10 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
})
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
|
||||
.show();
|
||||
break;
|
||||
case R.id.action_edit:
|
||||
} else if (itemId == R.id.action_edit) {
|
||||
if (context instanceof AccountActivity) {
|
||||
editAlertDialog.show(channel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -68,7 +68,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||
Notification notification = notifications.get(position);
|
||||
//Follow Notification
|
||||
|
||||
|
||||
holder.peertube_notif_pp.setVisibility(View.VISIBLE);
|
||||
AccountData.Account accountAction = null;
|
||||
ChannelData.Channel channelAction = null;
|
||||
if (notification.getActorFollow() != null) {
|
||||
|
@ -77,7 +77,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||
Actor accountActionFollow = notification.getActorFollow().getFollower();
|
||||
String type = notification.getActorFollow().getFollowing().getType();
|
||||
String message;
|
||||
if (type != null && type.equals("account")) {
|
||||
if (type != null && type.compareTo("channel") == 0) {
|
||||
message = context.getString(R.string.peertube_follow_channel, notification.getActorFollow().getFollower().getDisplayName(), notification.getActorFollow().getFollowing().getDisplayName());
|
||||
} else {
|
||||
message = context.getString(R.string.peertube_follow_account, accountActionFollow.getDisplayName());
|
||||
|
@ -86,13 +86,12 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||
holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
holder.peertube_notif_message.setText(Html.fromHtml(message));
|
||||
holder.peertube_notif_pp.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ShowChannelActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("channelId", accountActionFollow.getName() + "@" + accountActionFollow.getHost());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
Actor actor = notification.getActorFollow().getFollower();
|
||||
accountAction = new AccountData.Account();
|
||||
accountAction.setAvatar(actor.getAvatar());
|
||||
accountAction.setDisplayName(actor.getDisplayName());
|
||||
accountAction.setHost(actor.getHost());
|
||||
accountAction.setUsername(actor.getName());
|
||||
} else if (notification.getComment() != null) { //Comment Notification
|
||||
String profileUrl = notification.getComment().getAccount().getAvatar() != null ? notification.getComment().getAccount().getAvatar().getPath() : null;
|
||||
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
||||
|
@ -117,10 +116,9 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||
} else {
|
||||
String profileUrl = notification.getVideo() != null && notification.getVideo().getChannel().getAvatar() != null ? notification.getVideo().getChannel().getAvatar().getPath() : null;
|
||||
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
||||
|
||||
|
||||
String message = "";
|
||||
boolean myVideo = false;
|
||||
holder.peertube_notif_pp.setVisibility(View.INVISIBLE);
|
||||
if (notification.getVideo() != null) {
|
||||
if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_PUBLISHED) {
|
||||
message = context.getString(R.string.peertube_video_published, notification.getVideo().getName());
|
||||
|
@ -134,8 +132,10 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||
} else if (notification.getType() == DisplayNotificationsFragment.NEW_VIDEO_FROM_SUBSCRIPTION) {
|
||||
channelAction = notification.getVideo().getChannel();
|
||||
message = context.getString(R.string.peertube_video_from_subscription, channelAction.getDisplayName(), notification.getVideo().getName());
|
||||
holder.peertube_notif_pp.setVisibility(View.VISIBLE);
|
||||
} else if (notification.getType() == DisplayNotificationsFragment.BLACKLIST_ON_MY_VIDEO) {
|
||||
message = context.getString(R.string.peertube_video_blacklist, notification.getVideo().getName());
|
||||
|
||||
} else if (notification.getType() == DisplayNotificationsFragment.UNBLACKLIST_ON_MY_VIDEO) {
|
||||
message = context.getString(R.string.peertube_video_unblacklist, notification.getVideo().getName());
|
||||
}
|
||||
|
@ -172,7 +172,6 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||
}
|
||||
}
|
||||
holder.peertube_notif_date.setText(Helper.dateDiff(context, notification.getCreatedAt()));
|
||||
|
||||
AccountData.Account finalAccountAction = accountAction;
|
||||
ChannelData.Channel finalChannelAction = channelAction;
|
||||
holder.peertube_notif_pp.setOnClickListener(v -> {
|
||||
|
@ -180,7 +179,8 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||
Intent intent = null;
|
||||
if (finalAccountAction != null) {
|
||||
intent = new Intent(context, ShowAccountActivity.class);
|
||||
b.putString("channel", finalAccountAction.getAcct());
|
||||
b.putParcelable("account", finalAccountAction);
|
||||
b.putString("accountAcct", finalAccountAction.getUsername()+"@"+finalAccountAction.getHost());
|
||||
} else if (finalChannelAction != null) {
|
||||
intent = new Intent(context, ShowChannelActivity.class);
|
||||
b.putParcelable("channel", finalChannelAction);
|
||||
|
|
|
@ -67,6 +67,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||
private RecyclerView lv_channels;
|
||||
private View rootView;
|
||||
private FloatingActionButton action_button;
|
||||
private boolean myChannels;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -76,8 +77,10 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||
context = getContext();
|
||||
Bundle bundle = this.getArguments();
|
||||
channels = new ArrayList<>();
|
||||
myChannels = true;
|
||||
if (bundle != null) {
|
||||
name = bundle.getString("name", null);
|
||||
myChannels = bundle.getBoolean("myChannels", true);
|
||||
}
|
||||
|
||||
swiped = false;
|
||||
|
@ -86,9 +89,11 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||
|
||||
if (getActivity() != null) {
|
||||
action_button = getActivity().findViewById(R.id.action_button);
|
||||
if( action_button != null) {
|
||||
action_button.setVisibility(View.VISIBLE);
|
||||
action_button.setOnClickListener(view -> manageAlert(null));
|
||||
}
|
||||
}
|
||||
|
||||
lv_channels = rootView.findViewById(R.id.lv_elements);
|
||||
lv_channels.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
|
||||
|
@ -97,7 +102,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||
mainLoader.setVisibility(View.VISIBLE);
|
||||
nextElementLoader.setVisibility(View.GONE);
|
||||
channelListAdapter = new ChannelListAdapter(this.channels);
|
||||
channelListAdapter = new ChannelListAdapter(this.channels, myChannels);
|
||||
channelListAdapter.allChannelRemoved = this;
|
||||
channelListAdapter.editAlertDialog = this;
|
||||
lv_channels.setAdapter(channelListAdapter);
|
||||
|
@ -170,7 +175,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||
textviewNoAction.setVisibility(View.GONE);
|
||||
|
||||
if (swiped) {
|
||||
channelListAdapter = new ChannelListAdapter(this.channels);
|
||||
channelListAdapter = new ChannelListAdapter(this.channels, myChannels);
|
||||
channelListAdapter.allChannelRemoved = DisplayChannelsFragment.this;
|
||||
channelListAdapter.editAlertDialog = DisplayChannelsFragment.this;
|
||||
lv_channels.setAdapter(channelListAdapter);
|
||||
|
@ -267,12 +272,16 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||
}
|
||||
channelListAdapter.notifyItemChanged(position);
|
||||
}
|
||||
if( action_button != null) {
|
||||
action_button.setEnabled(true);
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
}).start();
|
||||
alertDialog.dismiss();
|
||||
if( action_button != null) {
|
||||
action_button.setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
Toasty.error(context, context.getString(R.string.error_display_name_channel), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
playlistId = bundle.getString("playlistId", null);
|
||||
}
|
||||
max_id = "0";
|
||||
forAccount = null;
|
||||
forAccount = type== TimelineVM.TimelineType.ACCOUNT_VIDEOS?channelId: null;
|
||||
lv_status = rootView.findViewById(R.id.lv_status);
|
||||
RecyclerView lv_accounts = rootView.findViewById(R.id.lv_accounts);
|
||||
Button display_all = rootView.findViewById(R.id.display_all);
|
||||
|
@ -497,7 +497,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
*/
|
||||
private void loadTimeline(String max_id) {
|
||||
if (search_peertube == null) { //Not a Peertube search
|
||||
if (type == TimelineVM.TimelineType.USER_VIDEOS) {
|
||||
if (type == TimelineVM.TimelineType.CHANNEL_VIDEOS) {
|
||||
viewModelFeeds.getVideosInChannel(sepiaSearch?remoteInstance:null, channelId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
|
||||
} else if (type == TimelineVM.TimelineType.VIDEOS_IN_PLAYLIST) {
|
||||
viewModelFeeds.loadVideosInPlaylist(playlistId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
|
||||
|
@ -523,9 +523,9 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||
|
||||
static class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private int spanCount;
|
||||
private int spacing;
|
||||
private boolean includeEdge;
|
||||
private final int spanCount;
|
||||
private final int spacing;
|
||||
private final boolean includeEdge;
|
||||
|
||||
public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
|
||||
this.spanCount = spanCount;
|
||||
|
|
|
@ -41,6 +41,12 @@ public class AccountsVM extends AndroidViewModel {
|
|||
return apiResponseMutableLiveData;
|
||||
}
|
||||
|
||||
public LiveData<APIResponse> getAccount(String acct) {
|
||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||
loadAccount(acct);
|
||||
return apiResponseMutableLiveData;
|
||||
}
|
||||
|
||||
private void loadAccounts(RetrofitPeertubeAPI.DataType dataType, String element) {
|
||||
Context _mContext = getApplication().getApplicationContext();
|
||||
new Thread(() -> {
|
||||
|
@ -62,4 +68,18 @@ public class AccountsVM extends AndroidViewModel {
|
|||
}).start();
|
||||
}
|
||||
|
||||
private void loadAccount(String acct) {
|
||||
Context _mContext = getApplication().getApplicationContext();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||
APIResponse apiResponse = retrofitPeertubeAPI.getAccount(acct);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||
mainHandler.post(myRunnable);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,8 @@ public class TimelineVM extends AndroidViewModel {
|
|||
|
||||
|
||||
public enum TimelineType {
|
||||
USER_VIDEOS,
|
||||
CHANNEL_VIDEOS,
|
||||
ACCOUNT_VIDEOS,
|
||||
SUBSCRIBTIONS,
|
||||
MY_VIDEOS,
|
||||
LOCAL,
|
||||
|
|
|
@ -83,34 +83,10 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/account_follow"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/account_pp"
|
||||
app:layout_constraintTop_toBottomOf="@id/account_dn" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/account_follow"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:contentDescription="@string/make_an_action"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/subscriber_count"
|
||||
app:layout_constraintTop_toBottomOf="@id/account_dn" />
|
||||
|
||||
<Button
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:contentDescription="@string/edit_profile"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_baseline_edit_24"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/subscriber_count"
|
||||
app:layout_constraintTop_toBottomOf="@id/account_dn" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
@ -135,11 +111,8 @@
|
|||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/account_tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -157,14 +130,4 @@
|
|||
android:layout_marginTop="5dp"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/action_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin_button"
|
||||
android:src="@drawable/ic_baseline_add_24"
|
||||
android:tint="@android:color/white"
|
||||
android:visibility="gone" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -0,0 +1,170 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2020 Thomas Schneider
|
||||
|
||||
This file is a part of TubeLab
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".ShowChannelActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
app:theme="@style/ThemeOverlay.AppCompat.ActionBar">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:expandedTitleMarginEnd="64dp"
|
||||
app:expandedTitleMarginStart="48dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/top_banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/account_pp"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/account_pp_border"
|
||||
android:contentDescription="@string/profile_picture"
|
||||
android:padding="2dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_dn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/subscriber_count"
|
||||
app:layout_constraintStart_toEndOf="@+id/account_pp"
|
||||
app:layout_constraintTop_toTopOf="@+id/account_pp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subscriber_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/account_follow"
|
||||
app:layout_constraintStart_toEndOf="@+id/account_pp"
|
||||
app:layout_constraintTop_toBottomOf="@id/account_dn" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/account_follow"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:contentDescription="@string/make_an_action"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/subscriber_count"
|
||||
app:layout_constraintTop_toBottomOf="@id/account_dn" />
|
||||
|
||||
<Button
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:contentDescription="@string/edit_profile"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_baseline_edit_24"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/subscriber_count"
|
||||
app:layout_constraintTop_toBottomOf="@id/account_dn" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/top_banner"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_note"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center"
|
||||
android:padding="10dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textIsSelectable="true"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/account_tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabGravity="fill"
|
||||
app:tabMode="fixed"
|
||||
app:tabSelectedTextColor="?colorAccent"
|
||||
app:tabTextColor="@android:color/white" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/account_viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/action_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin_button"
|
||||
android:src="@drawable/ic_baseline_add_24"
|
||||
android:tint="@android:color/white"
|
||||
android:visibility="gone" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue