mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-06-05 21:09:11 +02:00
upload+actions with retrofit
This commit is contained in:
@ -47,6 +47,7 @@ import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
|||||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
||||||
import app.fedilab.fedilabtube.drawer.OwnAccountsAdapter;
|
import app.fedilab.fedilabtube.drawer.OwnAccountsAdapter;
|
||||||
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
|
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
|
||||||
|
import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
|
||||||
import app.fedilab.fedilabtube.fragment.DisplayNotificationsFragment;
|
import app.fedilab.fedilabtube.fragment.DisplayNotificationsFragment;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
||||||
@ -178,12 +179,17 @@ public class AccountActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
DisplayAccountsFragment displayAccountsFragment = ((DisplayAccountsFragment) fragment);
|
||||||
displayAccountsFragment.scrollToTop();
|
displayAccountsFragment.scrollToTop();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
if (fragment != null) {
|
||||||
|
DisplayChannelsFragment displayChannelsFragment = ((DisplayChannelsFragment) fragment);
|
||||||
|
displayChannelsFragment.scrollToTop();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -267,27 +273,17 @@ public class AccountActivity extends AppCompatActivity {
|
|||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
|
||||||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
|
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
|
||||||
if (position == 1) {
|
|
||||||
bundle.putSerializable("accountFetch", RetrofitPeertubeAPI.DataType.MUTED);
|
bundle.putSerializable("accountFetch", RetrofitPeertubeAPI.DataType.MUTED);
|
||||||
} else {
|
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
||||||
String instance = Helper.getLiveInstance(AccountActivity.this);
|
|
||||||
Account account = new AccountDAO(AccountActivity.this, db).getUniqAccount(userId, instance);
|
|
||||||
bundle.putString("name", account.getUsername() + "@" + account.getHost());
|
|
||||||
bundle.putSerializable("accountFetch", RetrofitPeertubeAPI.DataType.CHANNEL);
|
|
||||||
}
|
|
||||||
displayAccountsFragment.setArguments(bundle);
|
displayAccountsFragment.setArguments(bundle);
|
||||||
return displayAccountsFragment;
|
return displayAccountsFragment;
|
||||||
|
case 2:
|
||||||
|
return new DisplayChannelsFragment();
|
||||||
default:
|
default:
|
||||||
return new DisplayNotificationsFragment();
|
return new DisplayNotificationsFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -15,7 +15,6 @@ package app.fedilab.fedilabtube;
|
|||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@ -50,12 +49,11 @@ import java.util.Map;
|
|||||||
|
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
||||||
import app.fedilab.fedilabtube.client.entities.Item;
|
import app.fedilab.fedilabtube.client.entities.Item;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
|
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
|
||||||
import app.fedilab.fedilabtube.drawer.PlaylistAdapter;
|
import app.fedilab.fedilabtube.drawer.PlaylistAdapter;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
|
||||||
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
|
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
|
||||||
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
@ -75,6 +73,8 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
private String idChannel;
|
private String idChannel;
|
||||||
private List<Playlist> playlists;
|
private List<Playlist> playlists;
|
||||||
private Playlist playlistToEdit;
|
private Playlist playlistToEdit;
|
||||||
|
private List<ChannelData.Channel> myChannels;
|
||||||
|
private ChannelData.Channel selectedChannel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -160,10 +160,8 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
set_upload_channel = dialogView.findViewById(R.id.set_upload_channel);
|
set_upload_channel = dialogView.findViewById(R.id.set_upload_channel);
|
||||||
set_upload_privacy = dialogView.findViewById(R.id.set_upload_privacy);
|
set_upload_privacy = dialogView.findViewById(R.id.set_upload_privacy);
|
||||||
|
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
||||||
ChannelsVM viewModelC = new ViewModelProvider(AllPlaylistsActivity.this).get(ChannelsVM.class);
|
ChannelsVM viewModelC = new ViewModelProvider(AllPlaylistsActivity.this).get(ChannelsVM.class);
|
||||||
viewModelC.get(RetrofitPeertubeAPI.DataType.CHANNELS_FOR_ACCOUNT, userId).observe(AllPlaylistsActivity.this, this::manageVIewChannels);
|
viewModelC.get(RetrofitPeertubeAPI.DataType.MY_CHANNELS, null).observe(AllPlaylistsActivity.this, this::manageVIewChannels);
|
||||||
|
|
||||||
display_name.setFilters(new InputFilter[]{new InputFilter.LengthFilter(120)});
|
display_name.setFilters(new InputFilter[]{new InputFilter.LengthFilter(120)});
|
||||||
description.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1000)});
|
description.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1000)});
|
||||||
@ -217,8 +215,10 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
playlist = playlistToEdit;
|
playlist = playlistToEdit;
|
||||||
}
|
}
|
||||||
playlist.setId(playlistId);
|
playlist.setId(playlistId);
|
||||||
|
playlist.setUuid(playlistId);
|
||||||
playlist.setDescription(playlistElement.getDescription());
|
playlist.setDescription(playlistElement.getDescription());
|
||||||
playlist.setDisplayName(playlistElement.getDisplayName());
|
playlist.setDisplayName(playlistElement.getDisplayName());
|
||||||
|
playlist.setVideoChannel(selectedChannel);
|
||||||
playlist.setPrivacy(privacyItem);
|
playlist.setPrivacy(privacyItem);
|
||||||
if (playlistToEdit == null) {
|
if (playlistToEdit == null) {
|
||||||
playlists.add(playlist);
|
playlists.add(playlist);
|
||||||
@ -253,7 +253,7 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
public void manageVIewChannels(APIResponse apiResponse) {
|
public void manageVIewChannels(APIResponse apiResponse) {
|
||||||
if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) {
|
if (apiResponse.getError() != null || apiResponse.getChannels() == null || apiResponse.getChannels().size() == 0) {
|
||||||
if (apiResponse.getError() != null && apiResponse.getError().getError() != null)
|
if (apiResponse.getError() != null && apiResponse.getError().getError() != null)
|
||||||
Toasty.error(AllPlaylistsActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
Toasty.error(AllPlaylistsActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
else
|
else
|
||||||
@ -262,16 +262,16 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Populate channels
|
//Populate channels
|
||||||
List<Account> channels = apiResponse.getAccounts();
|
myChannels = apiResponse.getChannels();
|
||||||
String[] channelName = new String[channels.size() + 1];
|
String[] channelName = new String[myChannels.size() + 1];
|
||||||
String[] channelId = new String[channels.size() + 1];
|
String[] channelId = new String[myChannels.size() + 1];
|
||||||
int i = 1;
|
int i = 1;
|
||||||
channelName[0] = "";
|
channelName[0] = "";
|
||||||
channelId[0] = "null";
|
channelId[0] = "null";
|
||||||
|
|
||||||
for (Account account : channels) {
|
for (ChannelData.Channel channel : myChannels) {
|
||||||
channelName[i] = account.getUsername();
|
channelName[i] = channel.getName();
|
||||||
channelId[i] = account.getId();
|
channelId[i] = channel.getId();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,6 +354,7 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
idChannel = channelId[position];
|
idChannel = channelId[position];
|
||||||
|
selectedChannel = myChannels.get(position - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -365,8 +366,8 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
if (playlistToEdit != null) {
|
if (playlistToEdit != null) {
|
||||||
int position = 0;
|
int position = 0;
|
||||||
int k = 1;
|
int k = 1;
|
||||||
for (Account ac : channels) {
|
for (ChannelData.Channel ac : myChannels) {
|
||||||
if (playlistToEdit.getId() != null && ac.getId().compareTo(playlistToEdit.getId()) == 0) {
|
if (playlistToEdit.getVideoChannel() != null && playlistToEdit.getVideoChannel().getId() != null && ac.getId().compareTo(playlistToEdit.getVideoChannel().getId()) == 0) {
|
||||||
position = k;
|
position = k;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -263,9 +263,7 @@ public class InstancePickerActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public void manageVIewInstance(APIResponse apiResponse) {
|
public void manageVIewInstance(APIResponse apiResponse) {
|
||||||
mainLoader.setVisibility(View.GONE);
|
mainLoader.setVisibility(View.GONE);
|
||||||
//Discards 404 - error which can often happen due to toots which have been deleted
|
|
||||||
if (apiResponse.getError() != null) {
|
if (apiResponse.getError() != null) {
|
||||||
if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -"))
|
|
||||||
Toasty.error(InstancePickerActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
Toasty.error(InstancePickerActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ package app.fedilab.fedilabtube;
|
|||||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -35,8 +36,6 @@ import androidx.core.content.ContextCompat;
|
|||||||
import com.google.android.material.textfield.TextInputEditText;
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
@ -153,12 +152,10 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
instance = host = login_instance.getText().toString().trim().toLowerCase();
|
instance = host = login_instance.getText().toString().trim().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Arrays.asList(Helper.openid).contains(host) && !BuildConfig.full_instances) {
|
if (Arrays.asList(Helper.openid).contains(host) && !BuildConfig.full_instances) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).oauthClient(Helper.CLIENT_NAME_VALUE, Helper.WEBSITE_VALUE, Helper.OAUTH_SCOPES_PEERTUBE, Helper.WEBSITE_VALUE);
|
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).oauthClient(null, null, null, null);
|
||||||
if (oauth == null) {
|
if (oauth == null) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
connectionButton.setEnabled(true);
|
connectionButton.setEnabled(true);
|
||||||
@ -190,7 +187,6 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
}).start();
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
|
||||||
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).oauthClient(Helper.CLIENT_NAME_VALUE, Helper.WEBSITE_VALUE, Helper.OAUTH_SCOPES_PEERTUBE, Helper.WEBSITE_VALUE);
|
Oauth oauth = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).oauthClient(Helper.CLIENT_NAME_VALUE, Helper.WEBSITE_VALUE, Helper.OAUTH_SCOPES_PEERTUBE, Helper.WEBSITE_VALUE);
|
||||||
if (oauth == null) {
|
if (oauth == null) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
@ -213,70 +209,20 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
oauthParams.setClient_secret(client_secret);
|
oauthParams.setClient_secret(client_secret);
|
||||||
oauthParams.setGrant_type("password");
|
oauthParams.setGrant_type("password");
|
||||||
oauthParams.setScope("user");
|
oauthParams.setScope("user");
|
||||||
try {
|
|
||||||
oauthParams.setUsername(URLEncoder.encode(login_uid.getText().toString().trim(), "UTF-8"));
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
oauthParams.setUsername(login_uid.getText().toString().trim());
|
oauthParams.setUsername(login_uid.getText().toString().trim());
|
||||||
}
|
|
||||||
try {
|
|
||||||
oauthParams.setPassword(URLEncoder.encode(login_passwd.getText().toString(), "UTF-8"));
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
oauthParams.setPassword(login_passwd.getText().toString());
|
oauthParams.setPassword(login_passwd.getText().toString());
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Token token = null;
|
Token token = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).manageToken(oauthParams);
|
||||||
try {
|
|
||||||
token = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).manageToken(oauthParams);
|
|
||||||
} catch (Error error) {
|
|
||||||
Error.displayError(LoginActivity.this, error);
|
|
||||||
error.printStackTrace();
|
|
||||||
}
|
|
||||||
proceedLogin(token, host);
|
proceedLogin(token, host);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception | Error e) {
|
||||||
|
|
||||||
try {
|
|
||||||
oauthParams.setUsername(URLEncoder.encode(login_uid.getText().toString().toLowerCase().trim(), "UTF-8"));
|
|
||||||
} catch (UnsupportedEncodingException e2) {
|
|
||||||
oauthParams.setUsername(login_uid.getText().toString().toLowerCase().trim());
|
oauthParams.setUsername(login_uid.getText().toString().toLowerCase().trim());
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
Token token = null;
|
Token token = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).manageToken(oauthParams);
|
||||||
try {
|
proceedLogin(token, host);
|
||||||
token = new RetrofitPeertubeAPI(LoginActivity.this, instance, null).manageToken(oauthParams);
|
|
||||||
} catch (Error error) {
|
} catch (Error error) {
|
||||||
Error.displayError(LoginActivity.this, error);
|
Error.displayError(LoginActivity.this, error);
|
||||||
error.printStackTrace();
|
error.printStackTrace();
|
||||||
}
|
}
|
||||||
proceedLogin(token, host);
|
|
||||||
} catch (final Exception e2) {
|
|
||||||
e2.printStackTrace();
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
connectionButton.setEnabled(true);
|
|
||||||
String message;
|
|
||||||
if (e2.getLocalizedMessage() != null && e2.getLocalizedMessage().trim().length() > 0)
|
|
||||||
message = e2.getLocalizedMessage();
|
|
||||||
else if (e2.getMessage() != null && e2.getMessage().trim().length() > 0)
|
|
||||||
message = e2.getMessage();
|
|
||||||
else
|
|
||||||
message = getString(R.string.toast_error);
|
|
||||||
Toasty.error(LoginActivity.this, message, Toast.LENGTH_LONG).show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
runOnUiThread(() -> {
|
|
||||||
connectionButton.setEnabled(true);
|
|
||||||
String message = null;
|
|
||||||
if (e.getLocalizedMessage() != null) {
|
|
||||||
message = e.getMessage();
|
|
||||||
}
|
|
||||||
if (message == null) {
|
|
||||||
message = getString(R.string.toast_error);
|
|
||||||
}
|
|
||||||
Toasty.error(LoginActivity.this, message, Toast.LENGTH_LONG).show();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
@ -284,6 +230,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ApplySharedPref")
|
||||||
private void proceedLogin(Token token, String host) {
|
private void proceedLogin(Token token, String host) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
@ -291,8 +238,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token.getAccess_token());
|
||||||
editor.putString(Helper.PREF_INSTANCE, host);
|
editor.putString(Helper.PREF_INSTANCE, host);
|
||||||
|
editor.commit();
|
||||||
editor.apply();
|
|
||||||
//Update the account with the token;
|
//Update the account with the token;
|
||||||
updateCredential(LoginActivity.this, token.getAccess_token(), client_id, client_secret, token.getRefresh_token(), host);
|
updateCredential(LoginActivity.this, token.getAccess_token(), client_id, client_secret, token.getRefresh_token(), host);
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,6 +74,27 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||||
navView.inflateMenu(R.menu.bottom_nav_menu_connected);
|
navView.inflateMenu(R.menu.bottom_nav_menu_connected);
|
||||||
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
|
String instance = Helper.getLiveInstance(MainActivity.this);
|
||||||
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
Account account = new AccountDAO(MainActivity.this, db).getUniqAccount(userId, instance);
|
||||||
|
if (account != null) {
|
||||||
|
OauthParams oauthParams = new OauthParams();
|
||||||
|
oauthParams.setGrant_type("refresh_token");
|
||||||
|
oauthParams.setClient_id(account.getClient_id());
|
||||||
|
oauthParams.setClient_secret(account.getClient_secret());
|
||||||
|
oauthParams.setRefresh_token(account.getRefresh_token());
|
||||||
|
oauthParams.setAccess_token(account.getToken());
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
|
||||||
|
} catch (Error error) {
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
navView.inflateMenu(R.menu.bottom_nav_menu);
|
navView.inflateMenu(R.menu.bottom_nav_menu);
|
||||||
}
|
}
|
||||||
@ -93,6 +114,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
startInForeground();
|
startInForeground();
|
||||||
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
|
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
|
||||||
if (navHostFragment != null) {
|
if (navHostFragment != null) {
|
||||||
@ -161,27 +183,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
playslistItem.setVisible(true);
|
playslistItem.setVisible(true);
|
||||||
historyItem.setVisible(true);
|
historyItem.setVisible(true);
|
||||||
settingsItem.setVisible(false);
|
settingsItem.setVisible(false);
|
||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
||||||
String instance = Helper.getLiveInstance(MainActivity.this);
|
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
||||||
Account account = new AccountDAO(MainActivity.this, db).getUniqAccount(userId, instance);
|
|
||||||
if (account != null) {
|
|
||||||
OauthParams oauthParams = new OauthParams();
|
|
||||||
oauthParams.setGrant_type("refresh_token");
|
|
||||||
oauthParams.setClient_id(account.getClient_id());
|
|
||||||
oauthParams.setClient_secret(account.getClient_secret());
|
|
||||||
oauthParams.setRefresh_token(account.getRefresh_token());
|
|
||||||
oauthParams.setAccess_token(account.getToken());
|
|
||||||
new Thread(() -> {
|
|
||||||
try {
|
|
||||||
new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
|
|
||||||
} catch (Error error) {
|
|
||||||
|
|
||||||
error.printStackTrace();
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
instanceItem.setVisible(true);
|
instanceItem.setVisible(true);
|
||||||
uploadItem.setVisible(false);
|
uploadItem.setVisible(false);
|
||||||
@ -302,7 +303,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
(dialog, which) -> new Thread(() -> {
|
(dialog, which) -> new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
String newInstance = input.getText().toString().trim();
|
String newInstance = input.getText().toString().trim();
|
||||||
WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(MainActivity.this).getNodeInfo(newInstance);
|
WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(MainActivity.this, newInstance, null).getNodeInfo();
|
||||||
if (instanceNodeInfo.getSoftware() != null && instanceNodeInfo.getSoftware().getName().trim().toLowerCase().compareTo("peertube") == 0) {
|
if (instanceNodeInfo.getSoftware() != null && instanceNodeInfo.getSoftware().getName().trim().toLowerCase().compareTo("peertube") == 0) {
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_INSTANCE, newInstance);
|
editor.putString(Helper.PREF_INSTANCE, newInstance);
|
||||||
|
@ -789,7 +789,7 @@ public class PeertubeActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
public void manageVIewComment(APIResponse apiResponse) {
|
public void manageVIewComment(APIResponse apiResponse) {
|
||||||
if (apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 501)) {
|
if (apiResponse == null || (apiResponse.getError() != null)) {
|
||||||
if (apiResponse == null)
|
if (apiResponse == null)
|
||||||
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
else
|
else
|
||||||
|
@ -57,7 +57,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
|
||||||
import app.fedilab.fedilabtube.client.data.ChannelData.Channel;
|
import app.fedilab.fedilabtube.client.data.ChannelData.Channel;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData.Video;
|
import app.fedilab.fedilabtube.client.data.VideoData.Video;
|
||||||
import app.fedilab.fedilabtube.client.entities.Item;
|
import app.fedilab.fedilabtube.client.entities.Item;
|
||||||
@ -224,12 +223,22 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeEditUploadActivity.this).get(TimelineVM.class);
|
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeEditUploadActivity.this).get(TimelineVM.class);
|
||||||
feedsViewModel.getVideo(videoId).observe(PeertubeEditUploadActivity.this, this::manageVIewVideo);
|
feedsViewModel.getMyVideo(videoId).observe(PeertubeEditUploadActivity.this, this::manageVIewVideo);
|
||||||
channels = new LinkedHashMap<>();
|
channels = new LinkedHashMap<>();
|
||||||
|
|
||||||
setTitle(R.string.edit_video);
|
setTitle(R.string.edit_video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void manageUpdate(APIResponse apiResponse) {
|
||||||
|
set_upload_submit.setEnabled(true);
|
||||||
|
if (apiResponse.getError() != null) {
|
||||||
|
if (apiResponse.getError() != null && apiResponse.getError().getError() != null)
|
||||||
|
Toasty.error(PeertubeEditUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
|
else
|
||||||
|
Toasty.error(PeertubeEditUploadActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
Toasty.info(PeertubeEditUploadActivity.this, getString(R.string.toast_peertube_video_updated), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
public void manageVIewVideo(APIResponse apiResponse) {
|
public void manageVIewVideo(APIResponse apiResponse) {
|
||||||
if (apiResponse.getError() != null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
|
if (apiResponse.getError() != null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
|
||||||
@ -252,7 +261,9 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
privacyToSend = video.getPrivacy();
|
privacyToSend = video.getPrivacy();
|
||||||
categoryToSend = video.getCategory();
|
categoryToSend = video.getCategory();
|
||||||
|
|
||||||
|
if (video.getThumbnailPath() != null) {
|
||||||
Helper.loadGiF(PeertubeEditUploadActivity.this, video.getThumbnailPath(), p_video_preview);
|
Helper.loadGiF(PeertubeEditUploadActivity.this, video.getThumbnailPath(), p_video_preview);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
set_preview.setOnClickListener(v -> {
|
set_preview.setOnClickListener(v -> {
|
||||||
@ -271,7 +282,6 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
startActivityForResult(intent, PICK_IMAGE);
|
startActivityForResult(intent, PICK_IMAGE);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (languageToSend == null) {
|
if (languageToSend == null) {
|
||||||
languageToSend = new ItemStr();
|
languageToSend = new ItemStr();
|
||||||
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
||||||
@ -284,7 +294,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
licenseToSend = new Item();
|
licenseToSend = new Item();
|
||||||
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
|
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
|
||||||
Map.Entry<Integer, String> entryInt = licences.entrySet().iterator().next();
|
Map.Entry<Integer, String> entryInt = licences.entrySet().iterator().next();
|
||||||
licenseToSend.setId(Long.parseLong(String.valueOf(entryInt.getKey())));
|
licenseToSend.setId(entryInt.getKey());
|
||||||
licenseToSend.setLabel(entryInt.getValue());
|
licenseToSend.setLabel(entryInt.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,21 +302,21 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
categoryToSend = new Item();
|
categoryToSend = new Item();
|
||||||
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
|
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||||
Map.Entry<Integer, String> entryInt = categories.entrySet().iterator().next();
|
Map.Entry<Integer, String> entryInt = categories.entrySet().iterator().next();
|
||||||
categoryToSend.setId(Long.parseLong(String.valueOf(entryInt.getKey())));
|
categoryToSend.setId(entryInt.getKey());
|
||||||
categoryToSend.setLabel(entryInt.getValue());
|
categoryToSend.setLabel(entryInt.getValue());
|
||||||
}
|
}
|
||||||
if (privacyToSend == null) {
|
if (privacyToSend == null) {
|
||||||
privacyToSend = new Item();
|
privacyToSend = new Item();
|
||||||
LinkedHashMap<Integer, String> privacies = new LinkedHashMap<>(peertubeInformation.getPrivacies());
|
LinkedHashMap<Integer, String> privacies = new LinkedHashMap<>(peertubeInformation.getPrivacies());
|
||||||
Map.Entry<Integer, String> entryInt = privacies.entrySet().iterator().next();
|
Map.Entry<Integer, String> entryInt = privacies.entrySet().iterator().next();
|
||||||
privacyToSend.setId(Long.parseLong(String.valueOf(entryInt.getKey())));
|
privacyToSend.setId(entryInt.getKey());
|
||||||
privacyToSend.setLabel(entryInt.getValue());
|
privacyToSend.setLabel(entryInt.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
String language = languageToSend.getLabel();
|
String language = languageToSend.getId();
|
||||||
String license = licenseToSend.getLabel();
|
int license = licenseToSend.getId();
|
||||||
String privacy = privacyToSend.getLabel();
|
int privacy = privacyToSend.getId();
|
||||||
String category = categoryToSend.getLabel();
|
int category = categoryToSend.getId();
|
||||||
|
|
||||||
channel = video.getChannel();
|
channel = video.getChannel();
|
||||||
String title = video.getName();
|
String title = video.getName();
|
||||||
@ -326,44 +336,45 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
int languagePosition = 0;
|
int languagePosition = 0;
|
||||||
if (languages.containsValue(language)) {
|
|
||||||
Iterator<Map.Entry<String, String>> it = languages.entrySet().iterator();
|
if (languages.containsKey(language)) {
|
||||||
while (it.hasNext()) {
|
Iterator<Map.Entry<String, String>> itstr = languages.entrySet().iterator();
|
||||||
Map.Entry<String, String> pair = it.next();
|
while (itstr.hasNext()) {
|
||||||
if (pair.getValue().equals(language))
|
Map.Entry<String, String> pair = itstr.next();
|
||||||
|
if (pair.getKey().compareTo(language) == 0)
|
||||||
break;
|
break;
|
||||||
it.remove();
|
itstr.remove();
|
||||||
languagePosition++;
|
languagePosition++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int privacyPosition = 0;
|
int privacyPosition = 0;
|
||||||
if (privacy != null && privacies.containsValue(privacy)) {
|
if (privacies.containsKey(privacy)) {
|
||||||
Iterator<Map.Entry<Integer, String>> it = privacies.entrySet().iterator();
|
Iterator<Map.Entry<Integer, String>> it = privacies.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<Integer, String> pair = it.next();
|
Map.Entry<Integer, String> pair = it.next();
|
||||||
if (pair.getValue().compareTo(privacy) == 0)
|
if (pair.getKey() == privacy)
|
||||||
break;
|
break;
|
||||||
it.remove();
|
it.remove();
|
||||||
privacyPosition++;
|
privacyPosition++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int licensePosition = 0;
|
int licensePosition = 0;
|
||||||
if (license != null && licences.containsValue(license)) {
|
if (licences.containsKey(license)) {
|
||||||
Iterator<Map.Entry<Integer, String>> it = licences.entrySet().iterator();
|
Iterator<Map.Entry<Integer, String>> it = licences.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<Integer, String> pair = it.next();
|
Map.Entry<Integer, String> pair = it.next();
|
||||||
if (pair.getValue().compareTo(license) == 0)
|
if (pair.getKey() == license)
|
||||||
break;
|
break;
|
||||||
it.remove();
|
it.remove();
|
||||||
licensePosition++;
|
licensePosition++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int categoryPosition = 0;
|
int categoryPosition = 0;
|
||||||
if (category != null && categories.containsValue(category)) {
|
if (categories.containsKey(category)) {
|
||||||
Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator();
|
Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<Integer, String> pair = it.next();
|
Map.Entry<Integer, String> pair = it.next();
|
||||||
if (pair.getValue().compareTo(category) == 0)
|
if (pair.getKey() == category)
|
||||||
break;
|
break;
|
||||||
it.remove();
|
it.remove();
|
||||||
categoryPosition++;
|
categoryPosition++;
|
||||||
@ -373,19 +384,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
set_upload_privacy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
set_upload_privacy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
LinkedHashMap<Integer, String> privaciesCheck = new LinkedHashMap<>(peertubeInformation.getPrivacies());
|
updatePrivacyPosition(position);
|
||||||
Iterator<Map.Entry<Integer, String>> it = privaciesCheck.entrySet().iterator();
|
|
||||||
int i = 0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Map.Entry<Integer, String> pair = it.next();
|
|
||||||
if (i == position) {
|
|
||||||
privacyToSend.setId(pair.getKey());
|
|
||||||
privacyToSend.setLabel(pair.getValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
it.remove();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -396,19 +395,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
set_upload_licenses.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
set_upload_licenses.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
LinkedHashMap<Integer, String> licensesCheck = new LinkedHashMap<>(peertubeInformation.getLicences());
|
updateLicensePosition(position);
|
||||||
Iterator<Map.Entry<Integer, String>> it = licensesCheck.entrySet().iterator();
|
|
||||||
int i = 0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Map.Entry<Integer, String> pair = it.next();
|
|
||||||
if (i == position) {
|
|
||||||
licenseToSend.setId(pair.getKey());
|
|
||||||
licenseToSend.setLabel(pair.getValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
it.remove();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -420,19 +407,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
set_upload_categories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
set_upload_categories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
LinkedHashMap<Integer, String> categoriesCheck = new LinkedHashMap<>(peertubeInformation.getCategories());
|
updateCategoryPosition(position);
|
||||||
Iterator<Map.Entry<Integer, String>> it = categoriesCheck.entrySet().iterator();
|
|
||||||
int i = 0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Map.Entry<Integer, String> pair = it.next();
|
|
||||||
if (i == position) {
|
|
||||||
categoryToSend.setId(pair.getKey());
|
|
||||||
categoryToSend.setLabel(pair.getValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
it.remove();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -445,19 +420,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
set_upload_languages.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
set_upload_languages.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
LinkedHashMap<String, String> languagesCheck = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
updateLanguagesPosition(position);
|
||||||
Iterator<Map.Entry<String, String>> it = languagesCheck.entrySet().iterator();
|
|
||||||
int i = 0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Map.Entry<String, String> pair = it.next();
|
|
||||||
if (i == position) {
|
|
||||||
languageToSend.setId(pair.getKey());
|
|
||||||
languageToSend.setLabel(pair.getValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
it.remove();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -469,18 +432,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
set_upload_channel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
set_upload_channel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
LinkedHashMap<String, String> channelsCheck = new LinkedHashMap<>(channels);
|
|
||||||
Iterator<Map.Entry<String, String>> it = channelsCheck.entrySet().iterator();
|
|
||||||
int i = 0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Map.Entry<String, String> pair = it.next();
|
|
||||||
if (i == position) {
|
|
||||||
channelToSendId = pair.getKey();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
it.remove();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -507,27 +459,109 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
videoParams.setCategory((int) finalCategoryToSend.getId());
|
videoParams.setCategory((int) finalCategoryToSend.getId());
|
||||||
videoParams.setLicence(String.valueOf(finalLicenseToSend.getId()));
|
videoParams.setLicence(String.valueOf(finalLicenseToSend.getId()));
|
||||||
videoParams.setLanguage(finalLanguageToSend.getId());
|
videoParams.setLanguage(finalLanguageToSend.getId());
|
||||||
|
|
||||||
videoParams.setChannelId(channelToSendId);
|
videoParams.setChannelId(channelToSendId);
|
||||||
videoParams.setPrivacy((int) finalPrivacyToSend.getId());
|
videoParams.setPrivacy((int) finalPrivacyToSend.getId());
|
||||||
List<String> tags = p_video_tags.getTags();
|
List<String> tags = p_video_tags.getTags();
|
||||||
videoParams.setTags(tags);
|
videoParams.setTags(tags);
|
||||||
set_upload_submit.setEnabled(false);
|
set_upload_submit.setEnabled(false);
|
||||||
MyVideoVM myVideoVM = new ViewModelProvider(PeertubeEditUploadActivity.this).get(MyVideoVM.class);
|
MyVideoVM myVideoVM = new ViewModelProvider(PeertubeEditUploadActivity.this).get(MyVideoVM.class);
|
||||||
myVideoVM.updateVideo(videoId, videoParams, null, null).observe(PeertubeEditUploadActivity.this, this::manageVIewVideo);
|
myVideoVM.updateVideo(videoId, videoParams, null, null).observe(PeertubeEditUploadActivity.this, this::manageUpdate);
|
||||||
});
|
});
|
||||||
|
|
||||||
set_upload_privacy.setSelection(privacyPosition);
|
set_upload_privacy.setSelection(privacyPosition, false);
|
||||||
set_upload_languages.setSelection(languagePosition);
|
updatePrivacyPosition(privacyPosition);
|
||||||
set_upload_licenses.setSelection(licensePosition);
|
set_upload_languages.setSelection(languagePosition, false);
|
||||||
set_upload_categories.setSelection(categoryPosition);
|
updateLanguagesPosition(languagePosition);
|
||||||
|
set_upload_licenses.setSelection(licensePosition, false);
|
||||||
|
updateLicensePosition(licensePosition);
|
||||||
|
set_upload_categories.setSelection(categoryPosition, false);
|
||||||
|
updateCategoryPosition(categoryPosition);
|
||||||
|
|
||||||
List<String> tags = video.getTags();
|
List<String> tags = video.getTags();
|
||||||
if (tags != null && tags.size() > 0) {
|
if (tags != null && tags.size() > 0) {
|
||||||
p_video_tags.setTags(tags.toArray(new String[0]));
|
p_video_tags.setTags(tags.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateUploadChannel(int position) {
|
||||||
|
LinkedHashMap<String, String> channelsCheck = new LinkedHashMap<>(channels);
|
||||||
|
Iterator<Map.Entry<String, String>> it = channelsCheck.entrySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<String, String> pair = it.next();
|
||||||
|
if (i == position) {
|
||||||
|
channelToSendId = pair.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateLanguagesPosition(int position) {
|
||||||
|
LinkedHashMap<String, String> languagesCheck = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
||||||
|
Iterator<Map.Entry<String, String>> it = languagesCheck.entrySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<String, String> pair = it.next();
|
||||||
|
if (i == position) {
|
||||||
|
languageToSend.setId(pair.getKey());
|
||||||
|
languageToSend.setLabel(pair.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCategoryPosition(int position) {
|
||||||
|
LinkedHashMap<Integer, String> categoriesCheck = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||||
|
Iterator<Map.Entry<Integer, String>> it = categoriesCheck.entrySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<Integer, String> pair = it.next();
|
||||||
|
if (i == position) {
|
||||||
|
categoryToSend.setId(pair.getKey());
|
||||||
|
categoryToSend.setLabel(pair.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateLicensePosition(int position) {
|
||||||
|
LinkedHashMap<Integer, String> licensesCheck = new LinkedHashMap<>(peertubeInformation.getLicences());
|
||||||
|
Iterator<Map.Entry<Integer, String>> it = licensesCheck.entrySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<Integer, String> pair = it.next();
|
||||||
|
if (i == position) {
|
||||||
|
licenseToSend.setId(pair.getKey());
|
||||||
|
licenseToSend.setLabel(pair.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePrivacyPosition(int position) {
|
||||||
|
LinkedHashMap<Integer, String> privaciesCheck = new LinkedHashMap<>(peertubeInformation.getPrivacies());
|
||||||
|
Iterator<Map.Entry<Integer, String>> it = privaciesCheck.entrySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<Integer, String> pair = it.next();
|
||||||
|
if (i == position) {
|
||||||
|
privacyToSend.setId(pair.getKey());
|
||||||
|
privacyToSend.setLabel(pair.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
@ -546,7 +580,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
try {
|
try {
|
||||||
String uploadId = UUID.randomUUID().toString();
|
String uploadId = UUID.randomUUID().toString();
|
||||||
new MultipartUploadRequest(PeertubeEditUploadActivity.this, uploadId, "https://" + Helper.getLiveInstance(PeertubeEditUploadActivity.this) + "/api/v1/" + String.format("/videos/%s", video.getId()))
|
new MultipartUploadRequest(PeertubeEditUploadActivity.this, uploadId, "https://" + Helper.getLiveInstance(PeertubeEditUploadActivity.this) + "/api/v1/" + String.format("/videos/%s", video.getId()))
|
||||||
.addFileToUpload(uri.toString().replace("file://", ""), "previewfile")
|
.addFileToUpload(uri.toString().replace("file://", ""), "thumbnailfile")
|
||||||
.setMethod("PUT")
|
.setMethod("PUT")
|
||||||
.addHeader("Authorization", "Bearer " + token)
|
.addHeader("Authorization", "Bearer " + token)
|
||||||
.setNotificationConfig(uploadConfig)
|
.setNotificationConfig(uploadConfig)
|
||||||
@ -598,20 +632,20 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
public void manageVIewChannels(APIResponse apiResponse) {
|
public void manageVIewChannels(APIResponse apiResponse) {
|
||||||
if (apiResponse.getError() != null || apiResponse.getAccounts() == null || apiResponse.getAccounts().size() == 0) {
|
if (apiResponse.getError() != null || apiResponse.getChannels() == null || apiResponse.getChannels().size() == 0) {
|
||||||
if (apiResponse.getError().getError() != null)
|
if (apiResponse.getError() != null && apiResponse.getError().getError() != null)
|
||||||
Toasty.error(PeertubeEditUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
Toasty.error(PeertubeEditUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
else
|
else
|
||||||
Toasty.error(PeertubeEditUploadActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
Toasty.error(PeertubeEditUploadActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Populate channels
|
//Populate channels
|
||||||
List<Account> accounts = apiResponse.getAccounts();
|
List<Channel> channelsReply = apiResponse.getChannels();
|
||||||
String[] channelName = new String[accounts.size()];
|
String[] channelName = new String[channelsReply.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Account account : accounts) {
|
for (Channel channel : channelsReply) {
|
||||||
channels.put(account.getUsername(), account.getId());
|
channels.put(channel.getName(), channel.getId());
|
||||||
channelName[i] = account.getUsername();
|
channelName[i] = channel.getName();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
ArrayAdapter<String> adapterChannel = new ArrayAdapter<>(PeertubeEditUploadActivity.this,
|
ArrayAdapter<String> adapterChannel = new ArrayAdapter<>(PeertubeEditUploadActivity.this,
|
||||||
@ -631,7 +665,8 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
channelPosition++;
|
channelPosition++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_upload_channel.setSelection(channelPosition);
|
set_upload_channel.setSelection(channelPosition, false);
|
||||||
|
updateUploadChannel(channelPosition);
|
||||||
set_upload_submit.setEnabled(true);
|
set_upload_submit.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData.Video;
|
import app.fedilab.fedilabtube.client.data.VideoData.Video;
|
||||||
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
||||||
import app.fedilab.fedilabtube.drawer.PeertubeAdapter;
|
import app.fedilab.fedilabtube.drawer.PeertubeAdapter;
|
||||||
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
@ -93,7 +94,7 @@ public class PlaylistsActivity extends AppCompatActivity {
|
|||||||
if (b != null) {
|
if (b != null) {
|
||||||
playlist = b.getParcelable("playlist");
|
playlist = b.getParcelable("playlist");
|
||||||
} else {
|
} else {
|
||||||
Toasty.error(PlaylistsActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
|
Toasty.error(PlaylistsActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getSupportActionBar() != null)
|
if (getSupportActionBar() != null)
|
||||||
@ -129,7 +130,6 @@ public class PlaylistsActivity extends AppCompatActivity {
|
|||||||
swiped = true;
|
swiped = true;
|
||||||
viewModel.manage(GET_LIST_VIDEOS, playlist, null).observe(PlaylistsActivity.this, apiResponse -> manageVIewPlaylists(PlaylistsVM.action.GET_LIST_VIDEOS, apiResponse));
|
viewModel.manage(GET_LIST_VIDEOS, playlist, null).observe(PlaylistsActivity.this, apiResponse -> manageVIewPlaylists(PlaylistsVM.action.GET_LIST_VIDEOS, apiResponse));
|
||||||
});
|
});
|
||||||
|
|
||||||
viewModel.manage(GET_LIST_VIDEOS, playlist, null).observe(PlaylistsActivity.this, apiResponse -> manageVIewPlaylists(PlaylistsVM.action.GET_LIST_VIDEOS, apiResponse));
|
viewModel.manage(GET_LIST_VIDEOS, playlist, null).observe(PlaylistsActivity.this, apiResponse -> manageVIewPlaylists(PlaylistsVM.action.GET_LIST_VIDEOS, apiResponse));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,9 +147,7 @@ public class PlaylistsActivity extends AppCompatActivity {
|
|||||||
public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
|
public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
|
||||||
mainLoader.setVisibility(View.GONE);
|
mainLoader.setVisibility(View.GONE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
//Discards 404 - error which can often happen due to toots which have been deleted
|
|
||||||
if (apiResponse.getError() != null) {
|
if (apiResponse.getError() != null) {
|
||||||
if (!apiResponse.getError().getError().startsWith("404 -") && !apiResponse.getError().getError().startsWith("501 -"))
|
|
||||||
Toasty.error(PlaylistsActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
Toasty.error(PlaylistsActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
swiped = false;
|
swiped = false;
|
||||||
@ -159,10 +157,14 @@ public class PlaylistsActivity extends AppCompatActivity {
|
|||||||
if (actionType == GET_LIST_VIDEOS) {
|
if (actionType == GET_LIST_VIDEOS) {
|
||||||
|
|
||||||
int previousPosition = this.peertubes.size();
|
int previousPosition = this.peertubes.size();
|
||||||
List<Video> videos = apiResponse.getPeertubes();
|
List<VideoPlaylistData.VideoPlaylist> videoPlaylists = apiResponse.getVideoPlaylist();
|
||||||
|
List<Video> videos = new ArrayList<>();
|
||||||
|
for (VideoPlaylistData.VideoPlaylist v : videoPlaylists) {
|
||||||
|
videos.add(v.getVideo());
|
||||||
|
}
|
||||||
max_id = apiResponse.getMax_id();
|
max_id = apiResponse.getMax_id();
|
||||||
flag_loading = (max_id == null);
|
flag_loading = (max_id == null);
|
||||||
if (!swiped && firstLoad && (videos == null || videos.size() == 0))
|
if (!swiped && firstLoad && videos.size() == 0)
|
||||||
textviewNoAction.setVisibility(View.VISIBLE);
|
textviewNoAction.setVisibility(View.VISIBLE);
|
||||||
else
|
else
|
||||||
textviewNoAction.setVisibility(View.GONE);
|
textviewNoAction.setVisibility(View.GONE);
|
||||||
@ -174,7 +176,7 @@ public class PlaylistsActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
swiped = false;
|
swiped = false;
|
||||||
}
|
}
|
||||||
if (videos != null && videos.size() > 0) {
|
if (videos.size() > 0) {
|
||||||
this.peertubes.addAll(videos);
|
this.peertubes.addAll(videos);
|
||||||
peertubeAdapter.notifyItemRangeInserted(previousPosition, videos.size());
|
peertubeAdapter.notifyItemRangeInserted(previousPosition, videos.size());
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class ShowChannelActivity extends AppCompatActivity {
|
|||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.action_mute) {
|
} else if (item.getItemId() == R.id.action_mute) {
|
||||||
PostActionsVM viewModel = new ViewModelProvider(ShowChannelActivity.this).get(PostActionsVM.class);
|
PostActionsVM viewModel = new ViewModelProvider(ShowChannelActivity.this).get(PostActionsVM.class);
|
||||||
viewModel.post(MUTE, channel.getOwnerAccount() != null ? channel.getOwnerAccount().getAcct() : channel.getAcct(), null).observe(ShowChannelActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse));
|
viewModel.post(MUTE, channel.getOwnerAccount().getAcct(), null).observe(ShowChannelActivity.this, apiResponse -> manageVIewPostActions(MUTE, apiResponse));
|
||||||
} else if (item.getItemId() == R.id.action_report) {
|
} else if (item.getItemId() == R.id.action_report) {
|
||||||
androidx.appcompat.app.AlertDialog.Builder dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(ShowChannelActivity.this);
|
androidx.appcompat.app.AlertDialog.Builder dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(ShowChannelActivity.this);
|
||||||
LayoutInflater inflater1 = getLayoutInflater();
|
LayoutInflater inflater1 = getLayoutInflater();
|
||||||
@ -369,9 +369,9 @@ public class ShowChannelActivity extends AppCompatActivity {
|
|||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
manageChannel();
|
manageChannel();
|
||||||
}
|
}
|
||||||
/*if (channel.getOwnerAccount() != null) {
|
if (channel.getOwnerAccount() != null) {
|
||||||
this.channel.setOwnerAccount(channel.getOwnerAccount());
|
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(channel.getFollowersCount())));
|
||||||
subscriber_count.setVisibility(View.VISIBLE);
|
subscriber_count.setVisibility(View.VISIBLE);
|
||||||
manageNotes(channel);
|
manageNotes(channel);
|
||||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.BlockData.Block;
|
||||||
import app.fedilab.fedilabtube.client.data.CaptionData;
|
import app.fedilab.fedilabtube.client.data.CaptionData;
|
||||||
import app.fedilab.fedilabtube.client.data.ChannelData;
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||||
import app.fedilab.fedilabtube.client.data.CommentData;
|
import app.fedilab.fedilabtube.client.data.CommentData;
|
||||||
@ -25,6 +26,7 @@ import app.fedilab.fedilabtube.client.data.InstanceData;
|
|||||||
import app.fedilab.fedilabtube.client.data.NotificationData;
|
import app.fedilab.fedilabtube.client.data.NotificationData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData.VideoPlaylist;
|
||||||
import app.fedilab.fedilabtube.client.entities.Error;
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
||||||
import app.fedilab.fedilabtube.client.entities.Rating;
|
import app.fedilab.fedilabtube.client.entities.Rating;
|
||||||
@ -40,6 +42,8 @@ public class APIResponse {
|
|||||||
private OverviewVideo overviewVideo = null;
|
private OverviewVideo overviewVideo = null;
|
||||||
private List<VideoData.Video> peertubes = null;
|
private List<VideoData.Video> peertubes = null;
|
||||||
private List<CommentData.Comment> comments = null;
|
private List<CommentData.Comment> comments = null;
|
||||||
|
private List<Block> muted;
|
||||||
|
private List<VideoPlaylist> videoPlaylist;
|
||||||
private List<NotificationData.Notification> peertubeNotifications = null;
|
private List<NotificationData.Notification> peertubeNotifications = null;
|
||||||
private List<PlaylistData.Playlist> playlists = null;
|
private List<PlaylistData.Playlist> playlists = null;
|
||||||
private List<String> domains = null;
|
private List<String> domains = null;
|
||||||
@ -217,4 +221,20 @@ public class APIResponse {
|
|||||||
public void setActionReturn(String actionReturn) {
|
public void setActionReturn(String actionReturn) {
|
||||||
this.actionReturn = actionReturn;
|
this.actionReturn = actionReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Block> getMuted() {
|
||||||
|
return muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMuted(List<Block> muted) {
|
||||||
|
this.muted = muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VideoPlaylist> getVideoPlaylist() {
|
||||||
|
return videoPlaylist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoPlaylist(List<VideoPlaylist> videoPlaylist) {
|
||||||
|
this.videoPlaylist = videoPlaylist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
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.CaptionData;
|
||||||
import app.fedilab.fedilabtube.client.data.ChannelData;
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||||
import app.fedilab.fedilabtube.client.data.CommentData;
|
import app.fedilab.fedilabtube.client.data.CommentData;
|
||||||
@ -25,18 +26,18 @@ import app.fedilab.fedilabtube.client.data.InstanceData;
|
|||||||
import app.fedilab.fedilabtube.client.data.NotificationData;
|
import app.fedilab.fedilabtube.client.data.NotificationData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.entities.CaptionsParams;
|
import app.fedilab.fedilabtube.client.entities.CaptionsParams;
|
||||||
import app.fedilab.fedilabtube.client.entities.ChannelParams;
|
import app.fedilab.fedilabtube.client.entities.ChannelParams;
|
||||||
import app.fedilab.fedilabtube.client.entities.Oauth;
|
import app.fedilab.fedilabtube.client.entities.Oauth;
|
||||||
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
|
|
||||||
import app.fedilab.fedilabtube.client.entities.Rating;
|
import app.fedilab.fedilabtube.client.entities.Rating;
|
||||||
import app.fedilab.fedilabtube.client.entities.Report;
|
import app.fedilab.fedilabtube.client.entities.Report;
|
||||||
import app.fedilab.fedilabtube.client.entities.Token;
|
import app.fedilab.fedilabtube.client.entities.Token;
|
||||||
import app.fedilab.fedilabtube.client.entities.VideoParams;
|
|
||||||
import app.fedilab.fedilabtube.client.entities.WellKnownNodeinfo;
|
import app.fedilab.fedilabtube.client.entities.WellKnownNodeinfo;
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
@ -44,6 +45,7 @@ import retrofit2.http.Field;
|
|||||||
import retrofit2.http.FormUrlEncoded;
|
import retrofit2.http.FormUrlEncoded;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.Header;
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.Multipart;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.PUT;
|
import retrofit2.http.PUT;
|
||||||
import retrofit2.http.Part;
|
import retrofit2.http.Part;
|
||||||
@ -112,7 +114,7 @@ public interface PeertubeService {
|
|||||||
//Timelines Authenticated
|
//Timelines Authenticated
|
||||||
//Subscriber timeline
|
//Subscriber timeline
|
||||||
@GET("users/me/subscriptions/videos?sort=-publishedAt")
|
@GET("users/me/subscriptions/videos?sort=-publishedAt")
|
||||||
Call<VideoData> getSubscriptionVideos(@Query("start") String maxId, @Query("languageOneOf") List<String> languageOneOf);
|
Call<VideoData> getSubscriptionVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("languageOneOf") List<String> languageOneOf);
|
||||||
|
|
||||||
//Overview videos
|
//Overview videos
|
||||||
@GET("overviews/videos")
|
@GET("overviews/videos")
|
||||||
@ -144,29 +146,52 @@ public interface PeertubeService {
|
|||||||
|
|
||||||
//Get notifications
|
//Get notifications
|
||||||
@GET("users/me/notifications")
|
@GET("users/me/notifications")
|
||||||
Call<List<NotificationData.Notification>> getNotifications(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("since_id") String sinceId);
|
Call<NotificationData> getNotifications(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("since_id") String sinceId);
|
||||||
|
|
||||||
//Get/Post/Update/Delete video
|
//Get/Post/Update/Delete video
|
||||||
//Get a video
|
//Get a video
|
||||||
@GET("videos/{id}")
|
@GET("videos/{id}")
|
||||||
Call<VideoData.Video> getVideo(@Path("id") String id);
|
Call<VideoData.Video> getVideo(@Path("id") String id);
|
||||||
|
|
||||||
|
@GET("videos/{id}")
|
||||||
|
Call<VideoData.Video> getMyVideo(@Header("Authorization") String credentials, @Path("id") String id);
|
||||||
|
|
||||||
//Get my video
|
//Get my video
|
||||||
@GET("users/me/videos?sort=-publishedAt")
|
@GET("users/me/videos?sort=-publishedAt")
|
||||||
Call<VideoData> getMyVideo(@Header("Authorization") String credentials, @Query("start") String maxId);
|
Call<VideoData> getMyVideos(@Header("Authorization") String credentials, @Query("start") String maxId);
|
||||||
|
|
||||||
//Get my video
|
//Get my video
|
||||||
@GET("accounts/{name}/videos?sort=-publishedAt")
|
@GET("accounts/{name}/videos?sort=-publishedAt")
|
||||||
Call<VideoData.Video> getVideosForAccount(@Query("start") String maxId);
|
Call<VideoData.Video> getVideosForAccount(@Query("start") String maxId);
|
||||||
|
|
||||||
|
@Multipart
|
||||||
@PUT("videos/{id}")
|
@PUT("videos/{id}")
|
||||||
Call<String> updateVideo(@Header("Authorization") String credentials, @Path("id") String videoId, @Body VideoParams videoParams, @Part MultipartBody.Part thumbnailfile, @Part MultipartBody.Part previewfile);
|
Call<String> updateVideo(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String videoId,
|
||||||
|
@Part("channelId") RequestBody channelId,
|
||||||
|
@Part("name") RequestBody name,
|
||||||
|
@Part("category") int category,
|
||||||
|
@Part("commentsEnabled") boolean commentsEnabled,
|
||||||
|
@Part("description") RequestBody description,
|
||||||
|
@Part("downloadEnabled") boolean downloadEnabled,
|
||||||
|
@Part("language") RequestBody language,
|
||||||
|
@Part("licence") RequestBody licence,
|
||||||
|
@Part("nsfw") boolean nsfw,
|
||||||
|
@Part("privacy") int privacy,
|
||||||
|
@Part("support") RequestBody support,
|
||||||
|
@Part("tags[]") List<RequestBody> tags,
|
||||||
|
@Part("waitTranscoding") boolean waitTranscoding,
|
||||||
|
@Part MultipartBody.Part thumbnailfile,
|
||||||
|
@Part MultipartBody.Part previewfile);
|
||||||
|
|
||||||
@DELETE("videos/{id}")
|
@DELETE("videos/{id}")
|
||||||
Call<String> deleteVideo(@Header("Authorization") String credentials, @Path("id") String videoId);
|
Call<String> deleteVideo(@Header("Authorization") String credentials, @Path("id") String videoId);
|
||||||
|
|
||||||
|
|
||||||
|
@GET("oauth-clients/local")
|
||||||
|
Call<Oauth> getOauthAcad();
|
||||||
|
|
||||||
@GET("oauth-clients/local")
|
@GET("oauth-clients/local")
|
||||||
Call<Oauth> getOauth(@Query("client_name") String client_name, @Query("redirect_uris") String redirect_uris, @Query("scopes") String scopes, @Query("website") String website);
|
Call<Oauth> getOauth(@Query("client_name") String client_name, @Query("redirect_uris") String redirect_uris, @Query("scopes") String scopes, @Query("website") String website);
|
||||||
|
|
||||||
@ -174,20 +199,20 @@ public interface PeertubeService {
|
|||||||
//Post/Update/Delete channel
|
//Post/Update/Delete channel
|
||||||
//Channels for account
|
//Channels for account
|
||||||
@GET("accounts/{accountId}/video-channels")
|
@GET("accounts/{accountId}/video-channels")
|
||||||
Call<List<ChannelData.Channel>> getChannelsForAccount(@Path("accountId") String accountId);
|
Call<ChannelData> getChannelsForAccount(@Path("accountId") String accountId);
|
||||||
|
|
||||||
//Get a channel
|
//Get a channel
|
||||||
@GET("video-channels/{name}")
|
@GET("video-channels/{name}")
|
||||||
Call<ChannelData.Channel> getChannel(@Path("name") String name);
|
Call<ChannelData.Channel> getChannel(@Path("name") String name);
|
||||||
|
|
||||||
@GET("video-channels")
|
@GET("video-channels")
|
||||||
Call<List<ChannelData.Channel>> getMyChannels(@Header("Authorization") String credentials);
|
Call<ChannelData> getAllChannels();
|
||||||
|
|
||||||
@GET("video-channels/{channelHandle}/videos")
|
@GET("video-channels/{channelHandle}/videos")
|
||||||
Call<VideoData> getChannelVideos(@Path("channelHandle") String channelHandle, @Query("start") String maxId);
|
Call<VideoData> getChannelVideos(@Path("channelHandle") String channelHandle, @Query("start") String maxId);
|
||||||
|
|
||||||
@POST("video-channels")
|
@POST("video-channels")
|
||||||
Call<String> addChannel(@Header("Authorization") String credentials, @Body ChannelParams channelParams);
|
Call<ChannelData.ChannelCreation> addChannel(@Header("Authorization") String credentials, @Body ChannelParams channelParams);
|
||||||
|
|
||||||
@PUT("video-channels/{channelHandle}")
|
@PUT("video-channels/{channelHandle}")
|
||||||
Call<String> updateChannel(@Header("Authorization") String credentials, @Path("channelHandle") String channelHandle, @Body ChannelParams channelParams);
|
Call<String> updateChannel(@Header("Authorization") String credentials, @Path("channelHandle") String channelHandle, @Body ChannelParams channelParams);
|
||||||
@ -208,19 +233,36 @@ public interface PeertubeService {
|
|||||||
Call<PlaylistData.Playlist> getPlaylist(@Path("id") String id);
|
Call<PlaylistData.Playlist> getPlaylist(@Path("id") String id);
|
||||||
|
|
||||||
@GET("video-playlists/{id}/videos")
|
@GET("video-playlists/{id}/videos")
|
||||||
Call<List<VideoData.Video>> getVideosPlayList(@Path("id") String id);
|
Call<VideoPlaylistData> getVideosPlayList(@Header("Authorization") String credentials, @Path("id") String id);
|
||||||
|
|
||||||
@GET("users/me/video-playlists/videos-exist")
|
@GET("users/me/video-playlists/videos-exist")
|
||||||
Call<List<PlaylistExist>> getVideoExistsInPlaylist(@Query("videoIds") List<String> videoIds);
|
Call<List<PlaylistExist>> getVideoExistsInPlaylist(@Query("videoIds") List<String> videoIds);
|
||||||
|
|
||||||
|
@Multipart
|
||||||
@POST("video-playlists")
|
@POST("video-playlists")
|
||||||
Call<String> addPlaylist(@Header("Authorization") String credentials, @Body PlaylistParams playlistParams, @Part MultipartBody.Part thumbnailfile);
|
Call<VideoPlaylistData.VideoPlaylistCreation> addPlaylist(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Part("displayName") RequestBody displayName,
|
||||||
|
@Part("description") RequestBody description,
|
||||||
|
@Part("privacy") int privacy,
|
||||||
|
@Part("videoChannelId") RequestBody videoChannelId,
|
||||||
|
@Part MultipartBody.Part thumbnailfile);
|
||||||
|
|
||||||
|
@Multipart
|
||||||
|
@PUT("video-playlists/{id}")
|
||||||
|
Call<String> updatePlaylist(
|
||||||
|
@Header("Authorization") String credentials,
|
||||||
|
@Path("id") String videoId,
|
||||||
|
@Part("displayName") RequestBody displayName,
|
||||||
|
@Part("description") RequestBody description,
|
||||||
|
@Part("privacy") int privacy,
|
||||||
|
@Part("videoChannelId") RequestBody videoChannelId,
|
||||||
|
@Part MultipartBody.Part thumbnailfil);
|
||||||
|
|
||||||
|
|
||||||
@POST("video-playlists/{id}/videos")
|
@POST("video-playlists/{id}/videos")
|
||||||
Call<String> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Query("videoId") String videoId);
|
Call<String> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Query("videoId") String videoId);
|
||||||
|
|
||||||
@PUT("video-playlists/{id}")
|
|
||||||
Call<String> updatePlaylist(@Header("Authorization") String credentials, @Path("id") String videoId, @Body PlaylistParams playlistParams, @Part MultipartBody.Part thumbnailfil);
|
|
||||||
|
|
||||||
@DELETE("video-playlists/{id}")
|
@DELETE("video-playlists/{id}")
|
||||||
Call<String> deletePlaylist(@Header("Authorization") String credentials, @Path("id") String playlistId);
|
Call<String> deletePlaylist(@Header("Authorization") String credentials, @Path("id") String playlistId);
|
||||||
@ -247,8 +289,12 @@ public interface PeertubeService {
|
|||||||
@GET("users/me/subscriptions/exist")
|
@GET("users/me/subscriptions/exist")
|
||||||
Call<List<Map<String, Boolean>>> getSubscriptionsExist(@Header("Authorization") String credentials, @Query("uris") List<String> uris);
|
Call<List<Map<String, Boolean>>> getSubscriptionsExist(@Header("Authorization") String credentials, @Query("uris") List<String> uris);
|
||||||
|
|
||||||
|
@GET("users/me/subscriptions/exist")
|
||||||
|
Call<Map<String, Boolean>> getSubscriptionExists(@Header("Authorization") String credentials, @Query("uris") String uris);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
@POST("users/me/subscriptions")
|
@POST("users/me/subscriptions")
|
||||||
Call<String> follow(@Header("Authorization") String credentials, @Query("uri") String uri);
|
Call<String> follow(@Header("Authorization") String credentials, @Field("uri") String uri);
|
||||||
|
|
||||||
@DELETE("users/me/subscriptions/{subscriptionHandle}")
|
@DELETE("users/me/subscriptions/{subscriptionHandle}")
|
||||||
Call<String> unfollow(@Header("Authorization") String credentials, @Path("subscriptionHandle") String subscriptionHandle);
|
Call<String> unfollow(@Header("Authorization") String credentials, @Path("subscriptionHandle") String subscriptionHandle);
|
||||||
@ -256,10 +302,11 @@ public interface PeertubeService {
|
|||||||
//Mute/Unmute
|
//Mute/Unmute
|
||||||
//Muted accounts
|
//Muted accounts
|
||||||
@GET("users/me/blocklist/accounts")
|
@GET("users/me/blocklist/accounts")
|
||||||
Call<AccountData> getMuted(@Header("Authorization") String credentials, @Query("start") String maxId);
|
Call<BlockData> getMuted(@Header("Authorization") String credentials, @Query("start") String maxId);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
@POST("users/me/blocklist/accounts")
|
@POST("users/me/blocklist/accounts")
|
||||||
Call<String> mute(@Header("Authorization") String credentials, @Query("accountName") String accountName);
|
Call<String> mute(@Header("Authorization") String credentials, @Field("accountName") String accountName);
|
||||||
|
|
||||||
@DELETE("users/me/blocklist/accounts/{accountName}")
|
@DELETE("users/me/blocklist/accounts/{accountName}")
|
||||||
Call<String> unmute(@Header("Authorization") String credentials, @Path("accountName") String accountName);
|
Call<String> unmute(@Header("Authorization") String credentials, @Path("accountName") String accountName);
|
||||||
@ -270,8 +317,9 @@ public interface PeertubeService {
|
|||||||
Call<Rating> getRating(@Header("Authorization") String credentials, @Path("id") String id);
|
Call<Rating> getRating(@Header("Authorization") String credentials, @Path("id") String id);
|
||||||
|
|
||||||
//Like/unlike
|
//Like/unlike
|
||||||
|
@FormUrlEncoded
|
||||||
@PUT("videos/{id}/rate")
|
@PUT("videos/{id}/rate")
|
||||||
Call<String> rate(@Header("Authorization") String credentials, @Path("id") String id, @Query("rating") String rating);
|
Call<String> rate(@Header("Authorization") String credentials, @Path("id") String id, @Field("rating") String rating);
|
||||||
|
|
||||||
|
|
||||||
//Comment
|
//Comment
|
||||||
@ -281,11 +329,13 @@ public interface PeertubeService {
|
|||||||
@GET("videos/{id}/comment-threads/{threadId}")
|
@GET("videos/{id}/comment-threads/{threadId}")
|
||||||
Call<CommentData> getReplies(@Path("id") String id, @Path("threadId") String threadId);
|
Call<CommentData> getReplies(@Path("id") String id, @Path("threadId") String threadId);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
@POST("videos/{id}/comment-threads")
|
@POST("videos/{id}/comment-threads")
|
||||||
Call<String> postComment(@Header("Authorization") String credentials, @Path("id") String id, @Query("text") String text);
|
Call<String> postComment(@Header("Authorization") String credentials, @Path("id") String id, @Field("text") String text);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
@POST("videos/{id}/comments/{commentId}")
|
@POST("videos/{id}/comments/{commentId}")
|
||||||
Call<String> postReply(@Header("Authorization") String credentials, @Path("id") String id, @Path("commentId") String commentId, @Query("text") String text);
|
Call<String> postReply(@Header("Authorization") String credentials, @Path("id") String id, @Path("commentId") String commentId, @Field("text") String text);
|
||||||
|
|
||||||
@DELETE("videos/{id}/comments/{commentId}")
|
@DELETE("videos/{id}/comments/{commentId}")
|
||||||
Call<String> deleteComment(@Header("Authorization") String credentials, @Path("id") String id, @Path("commentId") String commentId);
|
Call<String> deleteComment(@Header("Authorization") String credentials, @Path("id") String id, @Path("commentId") String commentId);
|
||||||
|
@ -37,6 +37,7 @@ import app.fedilab.fedilabtube.BuildConfig;
|
|||||||
import app.fedilab.fedilabtube.MainActivity;
|
import app.fedilab.fedilabtube.MainActivity;
|
||||||
import app.fedilab.fedilabtube.R;
|
import app.fedilab.fedilabtube.R;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
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.CaptionData;
|
||||||
import app.fedilab.fedilabtube.client.data.ChannelData;
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||||
import app.fedilab.fedilabtube.client.data.CommentData;
|
import app.fedilab.fedilabtube.client.data.CommentData;
|
||||||
@ -44,6 +45,7 @@ import app.fedilab.fedilabtube.client.data.InstanceData;
|
|||||||
import app.fedilab.fedilabtube.client.data.NotificationData;
|
import app.fedilab.fedilabtube.client.data.NotificationData;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
||||||
import app.fedilab.fedilabtube.client.entities.AccountCreation;
|
import app.fedilab.fedilabtube.client.entities.AccountCreation;
|
||||||
import app.fedilab.fedilabtube.client.entities.ChannelParams;
|
import app.fedilab.fedilabtube.client.entities.ChannelParams;
|
||||||
import app.fedilab.fedilabtube.client.entities.Error;
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
@ -68,6 +70,7 @@ import app.fedilab.fedilabtube.viewmodel.TimelineVM;
|
|||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -96,7 +99,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
|
|
||||||
public static void updateCredential(Activity activity, String token, String client_id, String client_secret, String refresh_token, String host) {
|
public static void updateCredential(Activity activity, String token, String client_id, String client_secret, String refresh_token, String host) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
AccountData.Account account = null;
|
AccountData.Account account;
|
||||||
String instance;
|
String instance;
|
||||||
if (host.startsWith("tube") || BuildConfig.full_instances) {
|
if (host.startsWith("tube") || BuildConfig.full_instances) {
|
||||||
instance = host;
|
instance = host;
|
||||||
@ -146,6 +149,10 @@ public class RetrofitPeertubeAPI {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getToken() {
|
||||||
|
return "Bearer " + token;
|
||||||
|
}
|
||||||
|
|
||||||
private PeertubeService init() {
|
private PeertubeService init() {
|
||||||
Retrofit retrofit = new Retrofit.Builder()
|
Retrofit retrofit = new Retrofit.Builder()
|
||||||
.baseUrl(finalUrl)
|
.baseUrl(finalUrl)
|
||||||
@ -176,7 +183,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Call<Token> refreshTokenCall = null;
|
Call<Token> refreshTokenCall = null;
|
||||||
if (oauthParams.getGrant_type().compareTo("password") == 0) {
|
if (oauthParams.getGrant_type().compareTo("password") == 0) {
|
||||||
refreshTokenCall = peertubeService.createToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getGrant_type(), oauthParams.getUsername(), oauthParams.getPassword());
|
refreshTokenCall = peertubeService.createToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getGrant_type(), oauthParams.getUsername(), oauthParams.getPassword());
|
||||||
}else if (oauthParams.getGrant_type().compareTo("refresh_token") == 0) {
|
} else if (oauthParams.getGrant_type().compareTo("refresh_token") == 0) {
|
||||||
refreshTokenCall = peertubeService.refreshToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getRefresh_token(), oauthParams.getGrant_type());
|
refreshTokenCall = peertubeService.refreshToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getRefresh_token(), oauthParams.getGrant_type());
|
||||||
}
|
}
|
||||||
if (refreshTokenCall != null) {
|
if (refreshTokenCall != null) {
|
||||||
@ -190,7 +197,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, tokenReply.getAccess_token());
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, tokenReply.getAccess_token());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
SQLiteDatabase db = Sqlite.getInstance(_context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(_context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
new AccountDAO(_context, db).updateAccountToken(oauthParams.getExternalAuthToken(), tokenReply);
|
new AccountDAO(_context, db).updateAccountToken(tokenReply);
|
||||||
}
|
}
|
||||||
return tokenReply;
|
return tokenReply;
|
||||||
} else {
|
} else {
|
||||||
@ -220,20 +227,13 @@ public class RetrofitPeertubeAPI {
|
|||||||
public APIResponse getNotifications(String max_id, String since_id) {
|
public APIResponse getNotifications(String max_id, String since_id) {
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<List<NotificationData.Notification>> notificationsCall = peertubeService.getNotifications(token, max_id, since_id);
|
Call<NotificationData> notificationsCall = peertubeService.getNotifications("Bearer " + token, max_id, since_id);
|
||||||
try {
|
try {
|
||||||
Response<List<NotificationData.Notification>> response = notificationsCall.execute();
|
Response<NotificationData> response = notificationsCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setPeertubeNotifications(response.body());
|
apiResponse.setPeertubeNotifications(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -259,14 +259,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setCaptionText(response.body());
|
apiResponse.setCaptionText(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -294,14 +287,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setPeertubes(response.body().data);
|
apiResponse.setPeertubes(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -320,10 +306,10 @@ public class RetrofitPeertubeAPI {
|
|||||||
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null;
|
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null;
|
||||||
switch (timelineType) {
|
switch (timelineType) {
|
||||||
case MY_VIDEOS:
|
case MY_VIDEOS:
|
||||||
videoCall = peertubeService.getMyVideo(token, max_id);
|
videoCall = peertubeService.getMyVideos(getToken(), max_id);
|
||||||
break;
|
break;
|
||||||
case SUBSCRIBTIONS:
|
case SUBSCRIBTIONS:
|
||||||
videoCall = peertubeService.getSubscriptionVideos(max_id, filter);
|
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, filter);
|
||||||
break;
|
break;
|
||||||
case MOST_LIKED:
|
case MOST_LIKED:
|
||||||
videoCall = peertubeService.getMostLikedVideos(max_id, filter);
|
videoCall = peertubeService.getMostLikedVideos(max_id, filter);
|
||||||
@ -347,14 +333,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setPeertubes(response.body().data);
|
apiResponse.setPeertubes(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -382,14 +361,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setOverviewVideo(response.body());
|
apiResponse.setOverviewVideo(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -400,28 +372,48 @@ public class RetrofitPeertubeAPI {
|
|||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if users via their uris are following the authenticated user
|
||||||
|
*
|
||||||
|
* @param uris List<String>
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse isFollowing(String uris) {
|
||||||
|
APIResponse apiResponse = new APIResponse();
|
||||||
|
PeertubeService peertubeService = init();
|
||||||
|
Call<Map<String, Boolean>> followingCall = peertubeService.getSubscriptionExists(getToken(), uris);
|
||||||
|
try {
|
||||||
|
Response<Map<String, Boolean>> response = followingCall.execute();
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
List<Map<String, Boolean>> relations = new ArrayList<>();
|
||||||
|
relations.add(response.body());
|
||||||
|
apiResponse.setRelationships(relations);
|
||||||
|
} else {
|
||||||
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if users via their uris are following the authenticated user
|
* Check if users via their uris are following the authenticated user
|
||||||
*
|
*
|
||||||
* @param uris List<String>
|
* @param uris List<String>
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse isFollowing(List<String> uris) {
|
public APIResponse areFollowing(List<String> uris) {
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<List<Map<String, Boolean>>> followingCall = peertubeService.getSubscriptionsExist(token, uris);
|
Call<List<Map<String, Boolean>>> followingCall = peertubeService.getSubscriptionsExist(getToken(), uris);
|
||||||
try {
|
try {
|
||||||
Response<List<Map<String, Boolean>>> response = followingCall.execute();
|
Response<List<Map<String, Boolean>>> response = followingCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setRelationships(response.body());
|
apiResponse.setRelationships(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -445,13 +437,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setCaptions(response.body().data);
|
apiResponse.setCaptions(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -476,7 +462,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -493,7 +479,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -510,7 +496,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -527,7 +513,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -544,7 +530,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -565,7 +551,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -595,14 +581,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
try {
|
try {
|
||||||
Response<InstanceData> response = instancesCall.execute();
|
Response<InstanceData> response = instancesCall.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
} else {
|
} else {
|
||||||
InstanceData instanceData = response.body();
|
InstanceData instanceData = response.body();
|
||||||
if (instanceData != null) {
|
if (instanceData != null) {
|
||||||
@ -633,14 +612,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setPeertubes(response.body().data);
|
apiResponse.setPeertubes(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -667,7 +639,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -684,21 +656,14 @@ public class RetrofitPeertubeAPI {
|
|||||||
|
|
||||||
public APIResponse report(Report report) {
|
public APIResponse report(Report report) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<String> report1 = peertubeService.report(token, report);
|
Call<String> report1 = peertubeService.report(getToken(), report);
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Response<String> response = report1.execute();
|
Response<String> response = report1.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -729,21 +694,36 @@ public class RetrofitPeertubeAPI {
|
|||||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), previewfile);
|
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), previewfile);
|
||||||
bodyPreviewfile = MultipartBody.Part.createFormData("image", previewfile.getName(), requestFile);
|
bodyPreviewfile = MultipartBody.Part.createFormData("image", previewfile.getName(), requestFile);
|
||||||
}
|
}
|
||||||
Call<String> upload = peertubeService.updateVideo(token, videoId, videoParams, bodyThumbnail, bodyPreviewfile);
|
RequestBody channelId = RequestBody.create(MediaType.parse("text/plain"), videoParams.getChannelId());
|
||||||
|
RequestBody description = RequestBody.create(MediaType.parse("text/plain"), videoParams.getDescription());
|
||||||
|
RequestBody language = RequestBody.create(MediaType.parse("text/plain"), videoParams.getLanguage());
|
||||||
|
RequestBody license = RequestBody.create(MediaType.parse("text/plain"), videoParams.getLicence());
|
||||||
|
RequestBody name = RequestBody.create(MediaType.parse("text/plain"), videoParams.getName());
|
||||||
|
|
||||||
|
List<RequestBody> tags = null;
|
||||||
|
if( videoParams.getTags() != null && videoParams.getTags().size() >0 ) {
|
||||||
|
tags = new ArrayList<>();
|
||||||
|
for (String tag : videoParams.getTags()) {
|
||||||
|
tags.add(RequestBody.create(MediaType.parse("text/plain"), tag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RequestBody support = null;
|
||||||
|
if (videoParams.getSupport() != null) {
|
||||||
|
support = RequestBody.create(MediaType.parse("text/plain"), videoParams.getSupport());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Call<String> upload = peertubeService.updateVideo(getToken(), videoId,
|
||||||
|
channelId, name, videoParams.getCategory(), videoParams.isCommentsEnabled(), description, videoParams.isDownloadEnabled(), language, license, videoParams.isNsfw(),
|
||||||
|
videoParams.getPrivacy(), support, tags, videoParams.isWaitTranscoding()
|
||||||
|
, bodyThumbnail, bodyPreviewfile);
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Response<String> response = upload.execute();
|
Response<String> response = upload.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn("ok");
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -763,14 +743,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(accountCreation.getEmail());
|
apiResponse.setActionReturn(accountCreation.getEmail());
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -787,25 +760,25 @@ public class RetrofitPeertubeAPI {
|
|||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
switch (actionType) {
|
switch (actionType) {
|
||||||
case FOLLOW:
|
case FOLLOW:
|
||||||
postCall = peertubeService.follow(token, id);
|
postCall = peertubeService.follow(getToken(), id);
|
||||||
break;
|
break;
|
||||||
case UNFOLLOW:
|
case UNFOLLOW:
|
||||||
postCall = peertubeService.unfollow(token, id);
|
postCall = peertubeService.unfollow(getToken(), id);
|
||||||
break;
|
break;
|
||||||
case MUTE:
|
case MUTE:
|
||||||
postCall = peertubeService.mute(token, id);
|
postCall = peertubeService.mute(getToken(), id);
|
||||||
break;
|
break;
|
||||||
case UNMUTE:
|
case UNMUTE:
|
||||||
postCall = peertubeService.unmute(token, id);
|
postCall = peertubeService.unmute(getToken(), id);
|
||||||
break;
|
break;
|
||||||
case RATEVIDEO:
|
case RATEVIDEO:
|
||||||
postCall = peertubeService.rate(token, id, element);
|
postCall = peertubeService.rate(getToken(), id, element);
|
||||||
break;
|
break;
|
||||||
case PEERTUBEDELETEVIDEO:
|
case PEERTUBEDELETEVIDEO:
|
||||||
postCall = peertubeService.deleteVideo(token, id);
|
postCall = peertubeService.deleteVideo(getToken(), id);
|
||||||
break;
|
break;
|
||||||
case DELETE_CHANNEL:
|
case DELETE_CHANNEL:
|
||||||
postCall = peertubeService.deleteChannel(token, id);
|
postCall = peertubeService.deleteChannel(getToken(), id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (postCall != null) {
|
if (postCall != null) {
|
||||||
@ -814,14 +787,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -834,41 +800,50 @@ public class RetrofitPeertubeAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get accounts data
|
* Get muted accounts
|
||||||
*
|
*
|
||||||
* @param accountDataType AccountDataType (type of requested data)
|
|
||||||
* @param maxId String (pagination)
|
* @param maxId String (pagination)
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse getAccountData(DataType accountDataType, String maxId) {
|
public APIResponse getMuted(String maxId) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<AccountData> accountDataCall = null;
|
Call<BlockData> accountDataCall = peertubeService.getMuted("Bearer " + token, maxId);
|
||||||
switch (accountDataType) {
|
APIResponse apiResponse = new APIResponse();
|
||||||
case SUBSCRIBER:
|
if (accountDataCall != null) {
|
||||||
accountDataCall = peertubeService.getSubscription("Bearer " + token, maxId);
|
try {
|
||||||
break;
|
Response<BlockData> response = accountDataCall.execute();
|
||||||
case MUTED:
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
accountDataCall = peertubeService.getMuted("Bearer " + token, maxId);
|
apiResponse.setMuted(response.body().getData());
|
||||||
break;
|
} 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 subscriptions data
|
||||||
|
*
|
||||||
|
* @param maxId String (pagination)
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse getSubscribtions(String maxId) {
|
||||||
|
PeertubeService peertubeService = init();
|
||||||
|
Call<AccountData> accountDataCall = peertubeService.getSubscription("Bearer " + token, maxId);
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
if (accountDataCall != null) {
|
if (accountDataCall != null) {
|
||||||
try {
|
try {
|
||||||
Response<AccountData> response = accountDataCall.execute();
|
Response<AccountData> response = accountDataCall.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
Error error = new Error();
|
apiResponse.setAccounts(response.body().data);
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
} else {
|
|
||||||
AccountData accountData = response.body();
|
|
||||||
if (accountData != null) {
|
|
||||||
apiResponse.setAccounts(accountData.data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -894,23 +869,21 @@ public class RetrofitPeertubeAPI {
|
|||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
if (apiAction == ChannelsVM.action.CREATE_CHANNEL) {
|
if (apiAction == ChannelsVM.action.CREATE_CHANNEL) {
|
||||||
Call<String> stringCall = peertubeService.addChannel(token, channelParams);
|
Call<ChannelData.ChannelCreation> stringCall = peertubeService.addChannel(getToken(), channelParams);
|
||||||
Response<String> response = stringCall.execute();
|
Response<ChannelData.ChannelCreation> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body().getVideoChannel().getId());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (apiAction == ChannelsVM.action.UPDATE_CHANNEL) {
|
} else if (apiAction == ChannelsVM.action.UPDATE_CHANNEL) {
|
||||||
Call<String> stringCall = peertubeService.updateChannel(token, channelId, channelParams);
|
Call<String> stringCall = peertubeService.updateChannel(getToken(), channelId, channelParams);
|
||||||
Response<String> response = stringCall.execute();
|
Response<String> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -930,7 +903,12 @@ public class RetrofitPeertubeAPI {
|
|||||||
public Oauth oauthClient(String client_name, String redirect_uris, String scopes, String website) {
|
public Oauth oauthClient(String client_name, String redirect_uris, String scopes, String website) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
try {
|
try {
|
||||||
Call<Oauth> oauth = peertubeService.getOauth(client_name, redirect_uris, scopes, website);
|
Call<Oauth> oauth;
|
||||||
|
if (BuildConfig.full_instances) {
|
||||||
|
oauth = peertubeService.getOauth(client_name, redirect_uris, scopes, website);
|
||||||
|
} else {
|
||||||
|
oauth = peertubeService.getOauthAcad();
|
||||||
|
}
|
||||||
Response<Oauth> response = oauth.execute();
|
Response<Oauth> response = oauth.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
return response.body();
|
return response.body();
|
||||||
@ -944,10 +922,9 @@ public class RetrofitPeertubeAPI {
|
|||||||
/**
|
/**
|
||||||
* Get NodeInfo
|
* Get NodeInfo
|
||||||
*
|
*
|
||||||
* @param instance String
|
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public WellKnownNodeinfo.NodeInfo getNodeInfo(String instance) {
|
public WellKnownNodeinfo.NodeInfo getNodeInfo() {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
try {
|
try {
|
||||||
Call<WellKnownNodeinfo> wellKnownNodeinfoCall = peertubeService.getWellKnownNodeinfo();
|
Call<WellKnownNodeinfo> wellKnownNodeinfoCall = peertubeService.getWellKnownNodeinfo();
|
||||||
@ -979,25 +956,14 @@ public class RetrofitPeertubeAPI {
|
|||||||
switch (accountDataType) {
|
switch (accountDataType) {
|
||||||
case MY_CHANNELS:
|
case MY_CHANNELS:
|
||||||
case CHANNELS_FOR_ACCOUNT:
|
case CHANNELS_FOR_ACCOUNT:
|
||||||
Call<List<ChannelData.Channel>> channelDataCall;
|
Call<ChannelData> channelDataCall = peertubeService.getChannelsForAccount(element);
|
||||||
if (accountDataType == DataType.MY_CHANNELS) {
|
|
||||||
channelDataCall = peertubeService.getMyChannels(token);
|
|
||||||
} else {
|
|
||||||
channelDataCall = peertubeService.getChannelsForAccount(element);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
Response<List<ChannelData.Channel>> response = channelDataCall.execute();
|
Response<ChannelData> response = channelDataCall.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
Error error = new Error();
|
|
||||||
error.setStatusCode(response.code());
|
apiResponse.setChannels(response.body().data);
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
} else {
|
|
||||||
apiResponse.setChannels(response.body());
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -1011,14 +977,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
try {
|
try {
|
||||||
Response<ChannelData.Channel> response = channelCall.execute();
|
Response<ChannelData.Channel> response = channelCall.execute();
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
Error error = new Error();
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
error.setStatusCode(response.code());
|
|
||||||
if (response.errorBody() != null) {
|
|
||||||
error.setError(response.message());
|
|
||||||
} else {
|
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
|
||||||
}
|
|
||||||
apiResponse.setError(error);
|
|
||||||
} else {
|
} else {
|
||||||
ChannelData.Channel channelData = response.body();
|
ChannelData.Channel channelData = response.body();
|
||||||
if (channelData != null) {
|
if (channelData != null) {
|
||||||
@ -1056,24 +1015,25 @@ public class RetrofitPeertubeAPI {
|
|||||||
body = MultipartBody.Part.createFormData("image", thumbnail.getName(), requestFile);
|
body = MultipartBody.Part.createFormData("image", thumbnail.getName(), requestFile);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
RequestBody displayName = RequestBody.create(MediaType.parse("text/plain"), playlistParams.getDisplayName());
|
||||||
|
RequestBody description = RequestBody.create(MediaType.parse("text/plain"), playlistParams.getDescription());
|
||||||
|
RequestBody channelId = RequestBody.create(MediaType.parse("text/plain"), playlistParams.getVideoChannelId());
|
||||||
if (apiAction == PlaylistsVM.action.CREATE_PLAYLIST) {
|
if (apiAction == PlaylistsVM.action.CREATE_PLAYLIST) {
|
||||||
Call<String> stringCall = peertubeService.addPlaylist(token, playlistParams, body);
|
Call<VideoPlaylistData.VideoPlaylistCreation> stringCall = peertubeService.addPlaylist(getToken(), displayName, description, playlistParams.getPrivacy(), channelId, body);
|
||||||
Response<String> response = stringCall.execute();
|
Response<VideoPlaylistData.VideoPlaylistCreation> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body().getVideoPlaylist().getId());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (apiAction == PlaylistsVM.action.UPDATE_PLAYLIST) {
|
} else if (apiAction == PlaylistsVM.action.UPDATE_PLAYLIST) {
|
||||||
Call<String> stringCall = peertubeService.updatePlaylist(token, playlistId, playlistParams, body);
|
Call<String> stringCall = peertubeService.updatePlaylist(getToken(), playlistId, displayName, description, playlistParams.getPrivacy(), channelId, body);
|
||||||
Response<String> response = stringCall.execute();
|
Response<String> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -1107,55 +1067,48 @@ public class RetrofitPeertubeAPI {
|
|||||||
playlists.add(response.body());
|
playlists.add(response.body());
|
||||||
apiResponse.setPlaylists(playlists);
|
apiResponse.setPlaylists(playlists);
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type == PlaylistsVM.action.GET_PLAYLISTS) {
|
} else if (type == PlaylistsVM.action.GET_PLAYLISTS) {
|
||||||
Call<PlaylistData> playlistsCall = peertubeService.getPlaylistsForAccount(token, acct);
|
Call<PlaylistData> playlistsCall = peertubeService.getPlaylistsForAccount(getToken(), acct);
|
||||||
Response<PlaylistData> response = playlistsCall.execute();
|
Response<PlaylistData> response = playlistsCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setPlaylists(response.body().data);
|
apiResponse.setPlaylists(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
assert response.errorBody() != null;
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
Error error = generateError(response.code(), response.errorBody().string());
|
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} else if (type == PlaylistsVM.action.GET_LIST_VIDEOS) {
|
} else if (type == PlaylistsVM.action.GET_LIST_VIDEOS) {
|
||||||
Call<List<VideoData.Video>> videosPlayList = peertubeService.getVideosPlayList(playlistId);
|
Call<VideoPlaylistData> videosPlayList = peertubeService.getVideosPlayList(getToken(), playlistId);
|
||||||
Response<List<VideoData.Video>> response = videosPlayList.execute();
|
Response<VideoPlaylistData> response = videosPlayList.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setPeertubes(response.body());
|
apiResponse.setVideoPlaylist(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} else if (type == PlaylistsVM.action.DELETE_PLAYLIST) {
|
} else if (type == PlaylistsVM.action.DELETE_PLAYLIST) {
|
||||||
Call<String> stringCall = peertubeService.deletePlaylist(token, playlistId);
|
Call<String> stringCall = peertubeService.deletePlaylist(getToken(), playlistId);
|
||||||
Response<String> response = stringCall.execute();
|
Response<String> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} else if (type == PlaylistsVM.action.ADD_VIDEOS) {
|
} else if (type == PlaylistsVM.action.ADD_VIDEOS) {
|
||||||
Call<String> stringCall = peertubeService.addVideoInPlaylist(token, playlistId, videoId);
|
Call<String> stringCall = peertubeService.addVideoInPlaylist(getToken(), playlistId, videoId);
|
||||||
Response<String> response = stringCall.execute();
|
Response<String> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} else if (type == PlaylistsVM.action.DELETE_VIDEOS) {
|
} else if (type == PlaylistsVM.action.DELETE_VIDEOS) {
|
||||||
Call<String> stringCall = peertubeService.deleteVideoInPlaylist(token, playlistId, videoId);
|
Call<String> stringCall = peertubeService.deleteVideoInPlaylist(getToken(), playlistId, videoId);
|
||||||
Response<String> response = stringCall.execute();
|
Response<String> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,6 +1121,24 @@ public class RetrofitPeertubeAPI {
|
|||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setError(APIResponse apiResponse, int responseCode, ResponseBody errorBody) {
|
||||||
|
Error error;
|
||||||
|
if (errorBody != null) {
|
||||||
|
try {
|
||||||
|
error = generateError(responseCode, errorBody.string());
|
||||||
|
} catch (IOException e) {
|
||||||
|
error = new Error();
|
||||||
|
error.setStatusCode(responseCode);
|
||||||
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error = new Error();
|
||||||
|
error.setStatusCode(responseCode);
|
||||||
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
|
}
|
||||||
|
apiResponse.setError(error);
|
||||||
|
}
|
||||||
|
|
||||||
public APIResponse getComments(CommentVM.action type, String videoId, String forCommentId) {
|
public APIResponse getComments(CommentVM.action type, String videoId, String forCommentId) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
|
|
||||||
@ -1179,8 +1150,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setComments(response.body().data);
|
apiResponse.setComments(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} else if (type == CommentVM.action.GET_REPLIES) {
|
} else if (type == CommentVM.action.GET_REPLIES) {
|
||||||
Call<CommentData> commentsCall = peertubeService.getReplies(videoId, forCommentId);
|
Call<CommentData> commentsCall = peertubeService.getReplies(videoId, forCommentId);
|
||||||
@ -1188,8 +1158,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setComments(response.body().data);
|
apiResponse.setComments(response.body().data);
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -1216,22 +1185,20 @@ public class RetrofitPeertubeAPI {
|
|||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
if (type == ActionType.ADD_COMMENT) {
|
if (type == ActionType.ADD_COMMENT) {
|
||||||
Call<String> stringCall = peertubeService.postComment(token, videoId, text);
|
Call<String> stringCall = peertubeService.postComment(getToken(), videoId, text);
|
||||||
Response<String> response = stringCall.execute();
|
Response<String> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} else if (type == ActionType.REPLY) {
|
} else if (type == ActionType.REPLY) {
|
||||||
Call<String> stringCall = peertubeService.postReply(token, videoId, toCommentId, text);
|
Call<String> stringCall = peertubeService.postReply(getToken(), videoId, toCommentId, text);
|
||||||
Response<String> response = stringCall.execute();
|
Response<String> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body());
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -1261,8 +1228,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
playlists.add(response.body());
|
playlists.add(response.body());
|
||||||
apiResponse.setPlaylists(playlists);
|
apiResponse.setPlaylists(playlists);
|
||||||
} else {
|
} else {
|
||||||
Error error = generateError(response.code(), response.message());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
apiResponse.setError(error);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
@ -1292,7 +1258,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
*/
|
*/
|
||||||
public APIResponse getRating(String id) {
|
public APIResponse getRating(String id) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<Rating> rating = peertubeService.getRating(token, id);
|
Call<Rating> rating = peertubeService.getRating(getToken(), id);
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Response<Rating> response = rating.execute();
|
Response<Rating> response = rating.execute();
|
||||||
@ -1302,7 +1268,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
@ -1322,9 +1288,14 @@ public class RetrofitPeertubeAPI {
|
|||||||
* @param id String id
|
* @param id String id
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse getVideos(String id) {
|
public APIResponse getVideos(String id, boolean myVideo) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
Call<VideoData.Video> video = peertubeService.getVideo(id);
|
Call<VideoData.Video> video;
|
||||||
|
if (myVideo) {
|
||||||
|
video = peertubeService.getMyVideo(getToken(), id);
|
||||||
|
} else {
|
||||||
|
video = peertubeService.getVideo(id);
|
||||||
|
}
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Response<VideoData.Video> response = video.execute();
|
Response<VideoData.Video> response = video.execute();
|
||||||
@ -1336,7 +1307,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.setStatusCode(response.code());
|
error.setStatusCode(response.code());
|
||||||
if (response.errorBody() != null) {
|
if (response.errorBody() != null) {
|
||||||
error.setError(response.message());
|
error.setError(response.errorBody().string());
|
||||||
} else {
|
} else {
|
||||||
error.setError(_context.getString(R.string.toast_error));
|
error.setError(_context.getString(R.string.toast_error));
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class AccountData {
|
|||||||
public List<Account> data;
|
public List<Account> data;
|
||||||
|
|
||||||
public static class Account implements Parcelable {
|
public static class Account implements Parcelable {
|
||||||
public static final Parcelable.Creator<Account> CREATOR = new Parcelable.Creator<Account>() {
|
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
||||||
@Override
|
@Override
|
||||||
public Account createFromParcel(Parcel source) {
|
public Account createFromParcel(Parcel source) {
|
||||||
return new Account(source);
|
return new Account(source);
|
||||||
@ -63,12 +63,16 @@ public class AccountData {
|
|||||||
private boolean hostRedundancyAllowed;
|
private boolean hostRedundancyAllowed;
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
private String id;
|
private String id;
|
||||||
|
@SerializedName("name")
|
||||||
|
private String name;
|
||||||
@SerializedName("username")
|
@SerializedName("username")
|
||||||
private String username;
|
private String username;
|
||||||
@SerializedName("updatedAt")
|
@SerializedName("updatedAt")
|
||||||
private Date updatedAt;
|
private Date updatedAt;
|
||||||
@SerializedName("url")
|
@SerializedName("url")
|
||||||
private String url;
|
private String url;
|
||||||
|
@SerializedName("userId")
|
||||||
|
private String userId;
|
||||||
private String token;
|
private String token;
|
||||||
private String client_id;
|
private String client_id;
|
||||||
private String client_secret;
|
private String client_secret;
|
||||||
@ -89,10 +93,12 @@ public class AccountData {
|
|||||||
this.host = in.readString();
|
this.host = in.readString();
|
||||||
this.hostRedundancyAllowed = in.readByte() != 0;
|
this.hostRedundancyAllowed = in.readByte() != 0;
|
||||||
this.id = in.readString();
|
this.id = in.readString();
|
||||||
|
this.name = in.readString();
|
||||||
this.username = in.readString();
|
this.username = in.readString();
|
||||||
long tmpUpdatedAt = in.readLong();
|
long tmpUpdatedAt = in.readLong();
|
||||||
this.updatedAt = tmpUpdatedAt == -1 ? null : new Date(tmpUpdatedAt);
|
this.updatedAt = tmpUpdatedAt == -1 ? null : new Date(tmpUpdatedAt);
|
||||||
this.url = in.readString();
|
this.url = in.readString();
|
||||||
|
this.userId = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Avatar getAvatar() {
|
public Avatar getAvatar() {
|
||||||
@ -168,11 +174,11 @@ public class AccountData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return name != null ? name : username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String name) {
|
public void setUsername(String name) {
|
||||||
this.username = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getUpdatedAt() {
|
public Date getUpdatedAt() {
|
||||||
@ -200,10 +206,9 @@ public class AccountData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getAcct() {
|
public String getAcct() {
|
||||||
return username + "@" + host;
|
return name + "@" + host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getToken() {
|
public String getToken() {
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
@ -236,6 +241,14 @@ public class AccountData {
|
|||||||
this.refresh_token = refresh_token;
|
this.refresh_token = refresh_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
@ -252,9 +265,11 @@ public class AccountData {
|
|||||||
dest.writeString(this.host);
|
dest.writeString(this.host);
|
||||||
dest.writeByte(this.hostRedundancyAllowed ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.hostRedundancyAllowed ? (byte) 1 : (byte) 0);
|
||||||
dest.writeString(this.id);
|
dest.writeString(this.id);
|
||||||
|
dest.writeString(this.name);
|
||||||
dest.writeString(this.username);
|
dest.writeString(this.username);
|
||||||
dest.writeLong(this.updatedAt != null ? this.updatedAt.getTime() : -1);
|
dest.writeLong(this.updatedAt != null ? this.updatedAt.getTime() : -1);
|
||||||
dest.writeString(this.url);
|
dest.writeString(this.url);
|
||||||
|
dest.writeString(this.userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.data;
|
||||||
|
/* 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>. */
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BlockData {
|
||||||
|
|
||||||
|
@SerializedName("total")
|
||||||
|
public int total;
|
||||||
|
@SerializedName("data")
|
||||||
|
public List<Block> data;
|
||||||
|
|
||||||
|
public int getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(int total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Block> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(List<Block> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public static class Block {
|
||||||
|
@SerializedName("blockedAccount")
|
||||||
|
private AccountData.Account blockedAccount;
|
||||||
|
@SerializedName("byAccount")
|
||||||
|
private AccountData.Account byAccount;
|
||||||
|
@SerializedName("createdAt")
|
||||||
|
private Date createdAt;
|
||||||
|
|
||||||
|
public AccountData.Account getBlockedAccount() {
|
||||||
|
return blockedAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockedAccount(AccountData.Account blockedAccount) {
|
||||||
|
this.blockedAccount = blockedAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountData.Account getByAccount() {
|
||||||
|
return byAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setByAccount(AccountData.Account byAccount) {
|
||||||
|
this.byAccount = byAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Date createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -24,6 +24,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.entities.Avatar;
|
import app.fedilab.fedilabtube.client.entities.Avatar;
|
||||||
|
import app.fedilab.fedilabtube.client.entities.ItemStr;
|
||||||
import app.fedilab.fedilabtube.client.entities.ViewsPerDay;
|
import app.fedilab.fedilabtube.client.entities.ViewsPerDay;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -268,4 +269,17 @@ public class ChannelData {
|
|||||||
dest.writeString(this.acct);
|
dest.writeString(this.acct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ChannelCreation {
|
||||||
|
@SerializedName("videoChannel")
|
||||||
|
private ItemStr videoChannel;
|
||||||
|
|
||||||
|
public ItemStr getVideoChannel() {
|
||||||
|
return videoChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoChannel(ItemStr videoChannel) {
|
||||||
|
this.videoChannel = videoChannel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,145 @@
|
|||||||
|
package app.fedilab.fedilabtube.client.data;
|
||||||
|
/* 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>. */
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class VideoPlaylistData {
|
||||||
|
|
||||||
|
@SerializedName("total")
|
||||||
|
public int total;
|
||||||
|
@SerializedName("data")
|
||||||
|
public List<VideoPlaylist> data;
|
||||||
|
|
||||||
|
public int getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(int total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VideoPlaylist> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(List<VideoPlaylist> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VideoPlaylist {
|
||||||
|
@SerializedName("id")
|
||||||
|
private String id;
|
||||||
|
@SerializedName("position")
|
||||||
|
private String position;
|
||||||
|
@SerializedName("startTimestamp")
|
||||||
|
private long startTimestamp;
|
||||||
|
@SerializedName("stopTimestamp")
|
||||||
|
private long stopTimestamp;
|
||||||
|
@SerializedName("type")
|
||||||
|
private int type;
|
||||||
|
@SerializedName("video")
|
||||||
|
private VideoData.Video video;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(String position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStartTimestamp() {
|
||||||
|
return startTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTimestamp(long startTimestamp) {
|
||||||
|
this.startTimestamp = startTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStopTimestamp() {
|
||||||
|
return stopTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStopTimestamp(long stopTimestamp) {
|
||||||
|
this.stopTimestamp = stopTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VideoData.Video getVideo() {
|
||||||
|
return video;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideo(VideoData.Video video) {
|
||||||
|
this.video = video;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VideoPlaylistCreation {
|
||||||
|
@SerializedName("videoPlaylist")
|
||||||
|
private VideoPlaylistCreationItem videoPlaylist;
|
||||||
|
|
||||||
|
public VideoPlaylistCreationItem getVideoPlaylist() {
|
||||||
|
return videoPlaylist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoPlaylist(VideoPlaylistCreationItem videoPlaylist) {
|
||||||
|
this.videoPlaylist = videoPlaylist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VideoPlaylistCreationItem {
|
||||||
|
@SerializedName("id")
|
||||||
|
String id;
|
||||||
|
@SerializedName("uuid")
|
||||||
|
String uuid;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(String uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,7 +33,7 @@ public class Item implements Parcelable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
private long id;
|
private int id;
|
||||||
@SerializedName("label")
|
@SerializedName("label")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@ -41,15 +41,15 @@ public class Item implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Item(Parcel in) {
|
protected Item(Parcel in) {
|
||||||
this.id = in.readLong();
|
this.id = in.readInt();
|
||||||
this.label = in.readString();
|
this.label = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(long id) {
|
public void setId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class Item implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeLong(this.id);
|
dest.writeInt(this.id);
|
||||||
dest.writeString(this.label);
|
dest.writeString(this.label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ package app.fedilab.fedilabtube.client.entities;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -51,6 +53,15 @@ public class VideoParams {
|
|||||||
@SerializedName("waitTranscoding")
|
@SerializedName("waitTranscoding")
|
||||||
private boolean waitTranscoding;
|
private boolean waitTranscoding;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "channelId: " + channelId + "\nname: " + name + "\ncategory: " + category + "\ncommentsEnabled: " + commentsEnabled
|
||||||
|
+ "\ndescription: " + description + "\ndownloadEnabled: " + downloadEnabled + "\nlanguage: " + language
|
||||||
|
+ "\nlicence: " + licence + "\nnsfw: " + nsfw + "\noriginallyPublishedAt: " + originallyPublishedAt
|
||||||
|
+ "\nprivacy: " + privacy + "\nsupport: " + support + "\ntags: " + tags + "\nwaitTranscoding: " + waitTranscoding;
|
||||||
|
}
|
||||||
|
|
||||||
public String getChannelId() {
|
public String getChannelId() {
|
||||||
return channelId;
|
return channelId;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class AccountsHorizontalListAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
holder.account_dn.setText(account.getUsername().replace("@", ""));
|
holder.account_dn.setText(account.getUsername().replace("@", ""));
|
||||||
|
|
||||||
//Profile picture
|
//Profile picture
|
||||||
Helper.loadGiF(context, account.getAvatar().getPath(), holder.account_pp, 270);
|
Helper.loadGiF(context, account.getAvatar() != null ? account.getAvatar().getPath() : null, holder.account_pp, 270);
|
||||||
|
|
||||||
if (account.isSelected()) {
|
if (account.isSelected()) {
|
||||||
holder.main_container.setBackgroundColor(ColorUtils.setAlphaComponent(ContextCompat.getColor(context, Helper.getColorAccent()), 50));
|
holder.main_container.setBackgroundColor(ColorUtils.setAlphaComponent(ContextCompat.getColor(context, Helper.getColorAccent()), 50));
|
||||||
|
@ -16,14 +16,10 @@ package app.fedilab.fedilabtube.drawer;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.util.Linkify;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -40,7 +36,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.R;
|
import app.fedilab.fedilabtube.R;
|
||||||
import app.fedilab.fedilabtube.ShowChannelActivity;
|
import app.fedilab.fedilabtube.ShowAccountActivity;
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
||||||
@ -52,7 +48,6 @@ import es.dmoral.toasty.Toasty;
|
|||||||
public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
public AllAccountsRemoved allAccountsRemoved;
|
public AllAccountsRemoved allAccountsRemoved;
|
||||||
public EditAlertDialog editAlertDialog;
|
|
||||||
private List<Account> accounts;
|
private List<Account> accounts;
|
||||||
private Context context;
|
private Context context;
|
||||||
private AccountsListAdapter accountsListAdapter;
|
private AccountsListAdapter accountsListAdapter;
|
||||||
@ -79,26 +74,19 @@ public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
if (type == RetrofitPeertubeAPI.DataType.MUTED) {
|
if (type == RetrofitPeertubeAPI.DataType.MUTED) {
|
||||||
holder.account_action.setOnClickListener(v -> {
|
holder.account_action.setOnClickListener(v -> {
|
||||||
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
|
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
|
||||||
viewModel.post(RetrofitPeertubeAPI.ActionType.UNMUTE, account.getId(), null).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.UNMUTE, apiResponse));
|
viewModel.post(RetrofitPeertubeAPI.ActionType.UNMUTE, account.getAcct(), null).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.UNMUTE, apiResponse, account.getAcct()));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
holder.account_action.hide();
|
holder.account_action.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.account_dn.setText(account.getDisplayName());
|
holder.account_dn.setText(account.getDisplayName());
|
||||||
holder.account_ac.setText(String.format("@%s", account.getUsername()));
|
holder.account_ac.setText(String.format("@%s", account.getAcct()));
|
||||||
if (account.getDescription() == null) {
|
if (account.getDescription() == null) {
|
||||||
account.setDescription("");
|
account.setDescription("");
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
||||||
holder.account_ds.setText(Html.fromHtml(account.getDescription(), Html.FROM_HTML_MODE_LEGACY));
|
|
||||||
else
|
|
||||||
holder.account_ds.setText(Html.fromHtml(account.getDescription()));
|
|
||||||
holder.account_ds.setAutoLinkMask(Linkify.WEB_URLS);
|
|
||||||
holder.account_fgc.setText(Helper.withSuffix(account.getFollowingCount()));
|
|
||||||
holder.account_frc.setText(Helper.withSuffix(account.getFollowersCount()));
|
|
||||||
//Profile picture
|
//Profile picture
|
||||||
Helper.loadGiF(context, account.getAvatar().getPath(), holder.account_pp);
|
Helper.loadGiF(context, account.getAvatar() != null ? account.getAvatar().getPath() : null, holder.account_pp);
|
||||||
//Follow button
|
//Follow button
|
||||||
if (type == RetrofitPeertubeAPI.DataType.MUTED) {
|
if (type == RetrofitPeertubeAPI.DataType.MUTED) {
|
||||||
holder.account_action.show();
|
holder.account_action.show();
|
||||||
@ -106,7 +94,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.account_pp.setOnClickListener(v -> {
|
holder.account_pp.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, ShowChannelActivity.class);
|
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putParcelable("channel", account);
|
b.putParcelable("channel", account);
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
@ -126,25 +114,21 @@ public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
return accounts.size();
|
return accounts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, APIResponse apiResponse) {
|
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, APIResponse apiResponse, String elementTargeted) {
|
||||||
if (apiResponse.getError() != null) {
|
if (apiResponse.getError() != null) {
|
||||||
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (statusAction == RetrofitPeertubeAPI.ActionType.UNMUTE) {
|
if (statusAction == RetrofitPeertubeAPI.ActionType.UNMUTE) {
|
||||||
Account tmpAccount = null;
|
|
||||||
int position = 0;
|
int position = 0;
|
||||||
for (Account account : accounts) {
|
for (Account account : accounts) {
|
||||||
if (account.getId().equals(apiResponse.getTargetedId())) {
|
if (account.getAcct().equals(elementTargeted)) {
|
||||||
tmpAccount = account;
|
accounts.remove(position);
|
||||||
|
accountsListAdapter.notifyItemRemoved(position);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
position++;
|
position++;
|
||||||
}
|
}
|
||||||
if (tmpAccount != null) {
|
|
||||||
accounts.remove(position);
|
|
||||||
accountsListAdapter.notifyItemRemoved(position);
|
|
||||||
}
|
|
||||||
if (accounts.size() == 0) {
|
if (accounts.size() == 0) {
|
||||||
allAccountsRemoved.onAllAccountsRemoved();
|
allAccountsRemoved.onAllAccountsRemoved();
|
||||||
}
|
}
|
||||||
@ -156,19 +140,11 @@ public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
void onAllAccountsRemoved();
|
void onAllAccountsRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface EditAlertDialog {
|
|
||||||
void show(Account account);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ViewHolder extends RecyclerView.ViewHolder {
|
private static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
ImageView account_pp;
|
ImageView account_pp;
|
||||||
TextView account_ac;
|
TextView account_ac;
|
||||||
TextView account_dn;
|
TextView account_dn;
|
||||||
TextView account_ds;
|
|
||||||
TextView account_fgc;
|
|
||||||
TextView account_frc;
|
|
||||||
ImageButton more_actions;
|
|
||||||
LinearLayout account_info;
|
|
||||||
FloatingActionButton account_action;
|
FloatingActionButton account_action;
|
||||||
LinearLayout account_container;
|
LinearLayout account_container;
|
||||||
|
|
||||||
@ -177,12 +153,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||||||
account_pp = itemView.findViewById(R.id.account_pp);
|
account_pp = itemView.findViewById(R.id.account_pp);
|
||||||
account_dn = itemView.findViewById(R.id.account_dn);
|
account_dn = itemView.findViewById(R.id.account_dn);
|
||||||
account_ac = itemView.findViewById(R.id.account_ac);
|
account_ac = itemView.findViewById(R.id.account_ac);
|
||||||
account_ds = itemView.findViewById(R.id.account_ds);
|
|
||||||
account_fgc = itemView.findViewById(R.id.account_fgc);
|
|
||||||
account_frc = itemView.findViewById(R.id.account_frc);
|
|
||||||
account_action = itemView.findViewById(R.id.account_action);
|
account_action = itemView.findViewById(R.id.account_action);
|
||||||
account_info = itemView.findViewById(R.id.account_info);
|
|
||||||
more_actions = itemView.findViewById(R.id.more_actions);
|
|
||||||
account_container = itemView.findViewById(R.id.account_container);
|
account_container = itemView.findViewById(R.id.account_container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,9 @@ package app.fedilab.fedilabtube.drawer;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.util.Linkify;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -70,19 +67,13 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
final ViewHolder holder = (ViewHolder) viewHolder;
|
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||||
final Channel channel = channels.get(position);
|
final Channel channel = channels.get(position);
|
||||||
holder.account_dn.setText(channel.getDisplayName());
|
holder.account_dn.setText(channel.getDisplayName());
|
||||||
holder.account_ac.setText(channel.getName());
|
holder.account_ac.setText(String.format("@%s", channel.getAcct()));
|
||||||
if (channel.getDescription() == null) {
|
if (channel.getDescription() == null) {
|
||||||
channel.setDescription("");
|
channel.setDescription("");
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
||||||
holder.account_ds.setText(Html.fromHtml(channel.getDescription(), Html.FROM_HTML_MODE_LEGACY));
|
|
||||||
else
|
|
||||||
holder.account_ds.setText(Html.fromHtml(channel.getDescription()));
|
|
||||||
holder.account_ds.setAutoLinkMask(Linkify.WEB_URLS);
|
|
||||||
holder.account_fgc.setText(Helper.withSuffix(channel.getFollowingCount()));
|
|
||||||
holder.account_frc.setText(Helper.withSuffix(channel.getFollowersCount()));
|
|
||||||
//Profile picture
|
//Profile picture
|
||||||
Helper.loadGiF(context, channel.getAvatar().getPath(), holder.account_pp);
|
Helper.loadGiF(context, channel.getAvatar() != null ? channel.getAvatar().getPath() : null, holder.account_pp);
|
||||||
|
|
||||||
|
|
||||||
holder.more_actions.setOnClickListener(view -> {
|
holder.more_actions.setOnClickListener(view -> {
|
||||||
@ -164,11 +155,7 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
ImageView account_pp;
|
ImageView account_pp;
|
||||||
TextView account_ac;
|
TextView account_ac;
|
||||||
TextView account_dn;
|
TextView account_dn;
|
||||||
TextView account_ds;
|
|
||||||
TextView account_fgc;
|
|
||||||
TextView account_frc;
|
|
||||||
ImageButton more_actions;
|
ImageButton more_actions;
|
||||||
LinearLayout account_info;
|
|
||||||
LinearLayout account_container;
|
LinearLayout account_container;
|
||||||
|
|
||||||
ViewHolder(View itemView) {
|
ViewHolder(View itemView) {
|
||||||
@ -176,10 +163,6 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
account_pp = itemView.findViewById(R.id.account_pp);
|
account_pp = itemView.findViewById(R.id.account_pp);
|
||||||
account_dn = itemView.findViewById(R.id.account_dn);
|
account_dn = itemView.findViewById(R.id.account_dn);
|
||||||
account_ac = itemView.findViewById(R.id.account_ac);
|
account_ac = itemView.findViewById(R.id.account_ac);
|
||||||
account_ds = itemView.findViewById(R.id.account_ds);
|
|
||||||
account_fgc = itemView.findViewById(R.id.account_fgc);
|
|
||||||
account_frc = itemView.findViewById(R.id.account_frc);
|
|
||||||
account_info = itemView.findViewById(R.id.account_info);
|
|
||||||
more_actions = itemView.findViewById(R.id.more_actions);
|
more_actions = itemView.findViewById(R.id.more_actions);
|
||||||
account_container = itemView.findViewById(R.id.account_container);
|
account_container = itemView.findViewById(R.id.account_container);
|
||||||
}
|
}
|
||||||
|
@ -34,19 +34,24 @@ import app.fedilab.fedilabtube.PeertubeActivity;
|
|||||||
import app.fedilab.fedilabtube.PeertubeEditUploadActivity;
|
import app.fedilab.fedilabtube.PeertubeEditUploadActivity;
|
||||||
import app.fedilab.fedilabtube.R;
|
import app.fedilab.fedilabtube.R;
|
||||||
import app.fedilab.fedilabtube.ShowChannelActivity;
|
import app.fedilab.fedilabtube.ShowChannelActivity;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
|
||||||
|
|
||||||
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private List<VideoData.Video> peertubes;
|
private List<VideoData.Video> videos;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
private boolean myVideos;
|
||||||
|
|
||||||
public PeertubeAdapter(List<VideoData.Video> peertubes) {
|
public PeertubeAdapter(List<VideoData.Video> videos, boolean myVideos) {
|
||||||
this.peertubes = peertubes;
|
this.videos = videos;
|
||||||
|
this.myVideos = myVideos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PeertubeAdapter(List<VideoData.Video> videos) {
|
||||||
|
this.videos = videos;
|
||||||
|
this.myVideos = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -62,39 +67,42 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
|
|
||||||
|
|
||||||
final PeertubeAdapter.ViewHolder holder = (PeertubeAdapter.ViewHolder) viewHolder;
|
final PeertubeAdapter.ViewHolder holder = (PeertubeAdapter.ViewHolder) viewHolder;
|
||||||
final VideoData.Video peertube = peertubes.get(position);
|
final VideoData.Video video = videos.get(position);
|
||||||
|
|
||||||
Account account = peertube.getAccount();
|
|
||||||
|
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, "");
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, "");
|
||||||
|
|
||||||
boolean ownVideos = peertube.getAccount().getHost().compareTo(Helper.getLiveInstance(context)) == 0 && userId != null && peertube.getAccount().getId() != null && peertube.getAccount().getId().compareTo(userId) == 0;
|
assert userId != null;
|
||||||
|
|
||||||
if (peertube.getChannel() == null) {
|
|
||||||
holder.peertube_account_name.setText(account.getAcct());
|
boolean ownVideos;
|
||||||
Helper.loadGiF(context, account.getAvatar().getPath(), holder.peertube_profile);
|
if (myVideos) {
|
||||||
|
ownVideos = true;
|
||||||
} else {
|
} else {
|
||||||
holder.peertube_account_name.setText(peertube.getChannel().getAcct());
|
ownVideos = video.getAccount() != null && video.getAccount().getId() != null && video.getAccount().getHost().compareTo(Helper.getLiveInstance(context)) == 0 && video.getAccount().getId().compareTo(userId) == 0;
|
||||||
Helper.loadGiF(context, peertube.getChannel().getAvatar() != null ? peertube.getChannel().getAvatar().getPath() : null, holder.peertube_profile);
|
|
||||||
}
|
}
|
||||||
holder.peertube_title.setText(peertube.getName());
|
|
||||||
holder.peertube_duration.setText(Helper.secondsToString(peertube.getDuration()));
|
|
||||||
holder.peertube_date.setText(String.format(" - %s", Helper.dateDiff(context, peertube.getCreatedAt())));
|
|
||||||
holder.peertube_views.setText(context.getString(R.string.number_view_video, Helper.withSuffix(peertube.getViews())));
|
|
||||||
|
|
||||||
Helper.loadGiF(context, peertube.getThumbnailPath(), holder.peertube_video_image);
|
holder.peertube_account_name.setText(video.getChannel().getAcct());
|
||||||
|
Helper.loadGiF(context, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.peertube_profile);
|
||||||
|
|
||||||
|
holder.peertube_title.setText(video.getName());
|
||||||
|
holder.peertube_duration.setText(Helper.secondsToString(video.getDuration()));
|
||||||
|
holder.peertube_date.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt())));
|
||||||
|
holder.peertube_views.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews())));
|
||||||
|
|
||||||
|
Helper.loadGiF(context, video.getThumbnailPath(), holder.peertube_video_image);
|
||||||
|
|
||||||
//For Overview Videos: boolean values for displaying title is managed in the fragment
|
//For Overview Videos: boolean values for displaying title is managed in the fragment
|
||||||
if (peertube.isHasTitle()) {
|
if (video.isHasTitle()) {
|
||||||
holder.header_title.setVisibility(View.VISIBLE);
|
holder.header_title.setVisibility(View.VISIBLE);
|
||||||
switch (peertube.getTitleType()) {
|
switch (video.getTitleType()) {
|
||||||
case TAG:
|
case TAG:
|
||||||
holder.header_title.setText(String.format("#%s", peertube.getTitle()));
|
holder.header_title.setText(String.format("#%s", video.getTitle()));
|
||||||
break;
|
break;
|
||||||
case CHANNEL:
|
case CHANNEL:
|
||||||
case CATEGORY:
|
case CATEGORY:
|
||||||
holder.header_title.setText(String.format("%s", peertube.getTitle()));
|
holder.header_title.setText(String.format("%s", video.getTitle()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -105,7 +113,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
holder.peertube_profile.setOnClickListener(v -> {
|
holder.peertube_profile.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, ShowChannelActivity.class);
|
Intent intent = new Intent(context, ShowChannelActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putParcelable("channel", peertube.getChannel());
|
b.putParcelable("channel", video.getChannel());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -116,7 +124,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
holder.bottom_container.setOnClickListener(v -> {
|
holder.bottom_container.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("video_id", peertube.getUuid());
|
b.putString("video_id", video.getUuid());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -124,7 +132,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
holder.bottom_container.setOnClickListener(v -> {
|
holder.bottom_container.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, PeertubeEditUploadActivity.class);
|
Intent intent = new Intent(context, PeertubeEditUploadActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("video_id", peertube.getUuid());
|
b.putString("video_id", video.getUuid());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -132,7 +140,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
holder.peertube_video_image.setOnClickListener(v -> {
|
holder.peertube_video_image.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("video_id", peertube.getUuid());
|
b.putString("video_id", video.getUuid());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -146,7 +154,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return peertubes.size();
|
return videos.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,8 +34,10 @@ import java.util.List;
|
|||||||
import app.fedilab.fedilabtube.LoginActivity;
|
import app.fedilab.fedilabtube.LoginActivity;
|
||||||
import app.fedilab.fedilabtube.PeertubeActivity;
|
import app.fedilab.fedilabtube.PeertubeActivity;
|
||||||
import app.fedilab.fedilabtube.R;
|
import app.fedilab.fedilabtube.R;
|
||||||
|
import app.fedilab.fedilabtube.ShowAccountActivity;
|
||||||
import app.fedilab.fedilabtube.ShowChannelActivity;
|
import app.fedilab.fedilabtube.ShowChannelActivity;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||||
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
||||||
import app.fedilab.fedilabtube.client.data.NotificationData.Notification;
|
import app.fedilab.fedilabtube.client.data.NotificationData.Notification;
|
||||||
import app.fedilab.fedilabtube.client.entities.Actor;
|
import app.fedilab.fedilabtube.client.entities.Actor;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
@ -68,8 +70,9 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
|
|
||||||
|
|
||||||
AccountData.Account accountAction = null;
|
AccountData.Account accountAction = null;
|
||||||
|
ChannelData.Channel channelAction = null;
|
||||||
if (notification.getActorFollow() != null) {
|
if (notification.getActorFollow() != null) {
|
||||||
String profileUrl = notification.getActorFollow().getFollower().getAvatar().getPath();
|
String profileUrl = notification.getActorFollow().getFollower().getAvatar() != null ? notification.getActorFollow().getFollower().getAvatar().getPath() : null;
|
||||||
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
||||||
Actor accountActionFollow = notification.getActorFollow().getFollower();
|
Actor accountActionFollow = notification.getActorFollow().getFollower();
|
||||||
String type = notification.getActorFollow().getFollowing().getType();
|
String type = notification.getActorFollow().getFollowing().getType();
|
||||||
@ -91,7 +94,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
} else if (notification.getComment() != null) { //Comment Notification
|
} else if (notification.getComment() != null) { //Comment Notification
|
||||||
String profileUrl = notification.getComment().getAccount().getAvatar().getPath();
|
String profileUrl = notification.getComment().getAccount().getAvatar() != null ? notification.getComment().getAccount().getAvatar().getPath() : null;
|
||||||
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
||||||
accountAction = notification.getComment().getAccount();
|
accountAction = notification.getComment().getAccount();
|
||||||
String message = context.getString(R.string.peertube_comment_on_video, accountAction.getDisplayName(), accountAction.getUsername());
|
String message = context.getString(R.string.peertube_comment_on_video, accountAction.getDisplayName(), accountAction.getUsername());
|
||||||
@ -110,9 +113,10 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
String profileUrl = notification.getVideo().getAccount().getAvatar().getPath();
|
String profileUrl = notification.getVideo() != null && notification.getVideo().getChannel().getAvatar() != null ? notification.getVideo().getChannel().getAvatar().getPath() : null;
|
||||||
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
Helper.loadGiF(context, profileUrl, holder.peertube_notif_pp);
|
||||||
accountAction = notification.getVideo().getAccount();
|
|
||||||
|
|
||||||
String message = "";
|
String message = "";
|
||||||
if (notification.getVideo() != null) {
|
if (notification.getVideo() != null) {
|
||||||
|
|
||||||
@ -123,7 +127,8 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
} else if (notification.getType() == LoginActivity.MY_VIDEO_IMPORT_SUCCESS) {
|
} else if (notification.getType() == LoginActivity.MY_VIDEO_IMPORT_SUCCESS) {
|
||||||
message = context.getString(R.string.peertube_video_import_success, notification.getVideo().getName());
|
message = context.getString(R.string.peertube_video_import_success, notification.getVideo().getName());
|
||||||
} else if (notification.getType() == LoginActivity.NEW_VIDEO_FROM_SUBSCRIPTION) {
|
} else if (notification.getType() == LoginActivity.NEW_VIDEO_FROM_SUBSCRIPTION) {
|
||||||
message = context.getString(R.string.peertube_video_from_subscription, accountAction.getDisplayName(), notification.getVideo().getName());
|
channelAction = notification.getVideo().getChannel();
|
||||||
|
message = context.getString(R.string.peertube_video_from_subscription, channelAction.getDisplayName(), notification.getVideo().getName());
|
||||||
} else if (notification.getType() == LoginActivity.BLACKLIST_ON_MY_VIDEO) {
|
} else if (notification.getType() == LoginActivity.BLACKLIST_ON_MY_VIDEO) {
|
||||||
message = context.getString(R.string.peertube_video_blacklist, notification.getVideo().getName());
|
message = context.getString(R.string.peertube_video_blacklist, notification.getVideo().getName());
|
||||||
} else if (notification.getType() == LoginActivity.UNBLACKLIST_ON_MY_VIDEO) {
|
} else if (notification.getType() == LoginActivity.UNBLACKLIST_ON_MY_VIDEO) {
|
||||||
@ -146,11 +151,18 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
holder.peertube_notif_date.setText(Helper.dateDiff(context, notification.getCreatedAt()));
|
holder.peertube_notif_date.setText(Helper.dateDiff(context, notification.getCreatedAt()));
|
||||||
|
|
||||||
AccountData.Account finalAccountAction = accountAction;
|
AccountData.Account finalAccountAction = accountAction;
|
||||||
|
ChannelData.Channel finalChannelAction = channelAction;
|
||||||
holder.peertube_notif_pp.setOnClickListener(v -> {
|
holder.peertube_notif_pp.setOnClickListener(v -> {
|
||||||
if (finalAccountAction != null) {
|
|
||||||
Intent intent = new Intent(context, ShowChannelActivity.class);
|
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("channelId", finalAccountAction.getUsername() + "@" + finalAccountAction.getHost());
|
Intent intent = null;
|
||||||
|
if (finalAccountAction != null) {
|
||||||
|
intent = new Intent(context, ShowAccountActivity.class);
|
||||||
|
b.putString("channel", finalAccountAction.getAcct());
|
||||||
|
} else if (finalChannelAction != null) {
|
||||||
|
intent = new Intent(context, ShowChannelActivity.class);
|
||||||
|
b.putParcelable("channel", finalChannelAction);
|
||||||
|
}
|
||||||
|
if (intent != null) {
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,6 @@ import androidx.lifecycle.LifecycleOwner;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.lifecycle.ViewModelStoreOwner;
|
import androidx.lifecycle.ViewModelStoreOwner;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.AllPlaylistsActivity;
|
import app.fedilab.fedilabtube.AllPlaylistsActivity;
|
||||||
@ -42,6 +40,7 @@ import app.fedilab.fedilabtube.PlaylistsActivity;
|
|||||||
import app.fedilab.fedilabtube.R;
|
import app.fedilab.fedilabtube.R;
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
||||||
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
||||||
|
|
||||||
|
|
||||||
@ -94,11 +93,7 @@ public class PlaylistAdapter extends BaseAdapter {
|
|||||||
holder = (ViewHolder) convertView.getTag();
|
holder = (ViewHolder) convertView.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playlist.getOwnerAccount() != null) {
|
Helper.loadGiF(context, playlist.getThumbnailPath(), holder.preview_playlist);
|
||||||
Glide.with(context)
|
|
||||||
.load("https://" + playlist.getOwnerAccount() + playlist.getThumbnailPath())
|
|
||||||
.into(holder.preview_playlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.preview_title.setText(playlist.getDisplayName());
|
holder.preview_title.setText(playlist.getDisplayName());
|
||||||
if (playlist.getDescription() != null && playlist.getDescription().trim().compareTo("null") != 0 && playlist.getDescription().length() > 0) {
|
if (playlist.getDescription() != null && playlist.getDescription().trim().compareTo("null") != 0 && playlist.getDescription().length() > 0) {
|
||||||
|
@ -37,7 +37,8 @@ import java.util.List;
|
|||||||
import app.fedilab.fedilabtube.R;
|
import app.fedilab.fedilabtube.R;
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData;
|
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
||||||
|
import app.fedilab.fedilabtube.client.data.BlockData;
|
||||||
import app.fedilab.fedilabtube.drawer.AccountsListAdapter;
|
import app.fedilab.fedilabtube.drawer.AccountsListAdapter;
|
||||||
import app.fedilab.fedilabtube.viewmodel.AccountsVM;
|
import app.fedilab.fedilabtube.viewmodel.AccountsVM;
|
||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
@ -49,7 +50,7 @@ public class DisplayAccountsFragment extends Fragment implements AccountsListAda
|
|||||||
private Context context;
|
private Context context;
|
||||||
private AccountsListAdapter accountsListAdapter;
|
private AccountsListAdapter accountsListAdapter;
|
||||||
private String max_id;
|
private String max_id;
|
||||||
private List<AccountData.Account> accounts;
|
private List<Account> accounts;
|
||||||
private RelativeLayout mainLoader, nextElementLoader, textviewNoAction;
|
private RelativeLayout mainLoader, nextElementLoader, textviewNoAction;
|
||||||
private boolean firstLoad;
|
private boolean firstLoad;
|
||||||
private SwipeRefreshLayout swipeRefreshLayout;
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
@ -124,6 +125,12 @@ public class DisplayAccountsFragment extends Fragment implements AccountsListAda
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (getActivity() != null && getActivity() != null) {
|
||||||
|
View action_button = getActivity().findViewById(R.id.action_button);
|
||||||
|
if (action_button != null) {
|
||||||
|
action_button.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,7 +172,15 @@ public class DisplayAccountsFragment extends Fragment implements AccountsListAda
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
flag_loading = (apiResponse.getMax_id() == null);
|
flag_loading = (apiResponse.getMax_id() == null);
|
||||||
List<AccountData.Account> accounts = apiResponse.getAccounts();
|
List<Account> accounts = apiResponse.getAccounts();
|
||||||
|
if (accountFetch == RetrofitPeertubeAPI.DataType.MUTED) {
|
||||||
|
accounts = new ArrayList<>();
|
||||||
|
List<BlockData.Block> blockList = apiResponse.getMuted();
|
||||||
|
for (BlockData.Block block : blockList) {
|
||||||
|
accounts.add(block.getBlockedAccount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!swiped && firstLoad && (accounts == null || accounts.size() == 0))
|
if (!swiped && firstLoad && (accounts == null || accounts.size() == 0))
|
||||||
textviewNoAction.setVisibility(View.VISIBLE);
|
textviewNoAction.setVisibility(View.VISIBLE);
|
||||||
else
|
else
|
||||||
|
@ -84,7 +84,6 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||||||
|
|
||||||
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
|
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
|
||||||
|
|
||||||
|
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
action_button = getActivity().findViewById(R.id.action_button);
|
action_button = getActivity().findViewById(R.id.action_button);
|
||||||
action_button.setVisibility(View.VISIBLE);
|
action_button.setVisibility(View.VISIBLE);
|
||||||
@ -103,20 +102,29 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||||||
channelListAdapter.editAlertDialog = this;
|
channelListAdapter.editAlertDialog = this;
|
||||||
lv_channels.setAdapter(channelListAdapter);
|
lv_channels.setAdapter(channelListAdapter);
|
||||||
|
|
||||||
|
|
||||||
final LinearLayoutManager mLayoutManager;
|
final LinearLayoutManager mLayoutManager;
|
||||||
mLayoutManager = new LinearLayoutManager(context);
|
mLayoutManager = new LinearLayoutManager(context);
|
||||||
lv_channels.setLayoutManager(mLayoutManager);
|
lv_channels.setLayoutManager(mLayoutManager);
|
||||||
|
|
||||||
swipeRefreshLayout.setOnRefreshListener(this::pullToRefresh);
|
swipeRefreshLayout.setOnRefreshListener(this::pullToRefresh);
|
||||||
ChannelsVM viewModel = new ViewModelProvider(this).get(ChannelsVM.class);
|
ChannelsVM viewModel = new ViewModelProvider(this).get(ChannelsVM.class);
|
||||||
|
if (name != null) {
|
||||||
viewModel.get(RetrofitPeertubeAPI.DataType.CHANNELS_FOR_ACCOUNT, name).observe(DisplayChannelsFragment.this.requireActivity(), this::manageViewChannels);
|
viewModel.get(RetrofitPeertubeAPI.DataType.CHANNELS_FOR_ACCOUNT, name).observe(DisplayChannelsFragment.this.requireActivity(), this::manageViewChannels);
|
||||||
|
} else {
|
||||||
|
viewModel.get(RetrofitPeertubeAPI.DataType.MY_CHANNELS, null).observe(DisplayChannelsFragment.this.requireActivity(), this::manageViewChannels);
|
||||||
|
}
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (getActivity() != null && getActivity() != null) {
|
||||||
|
View action_button = getActivity().findViewById(R.id.action_button);
|
||||||
|
if (action_button != null) {
|
||||||
|
action_button.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,7 +138,6 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||||||
super.onCreate(saveInstance);
|
super.onCreate(saveInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
@ -181,7 +188,11 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||||||
swiped = true;
|
swiped = true;
|
||||||
swipeRefreshLayout.setRefreshing(true);
|
swipeRefreshLayout.setRefreshing(true);
|
||||||
ChannelsVM viewModel = new ViewModelProvider(this).get(ChannelsVM.class);
|
ChannelsVM viewModel = new ViewModelProvider(this).get(ChannelsVM.class);
|
||||||
|
if (name != null) {
|
||||||
viewModel.get(RetrofitPeertubeAPI.DataType.CHANNELS_FOR_ACCOUNT, name).observe(DisplayChannelsFragment.this.requireActivity(), this::manageViewChannels);
|
viewModel.get(RetrofitPeertubeAPI.DataType.CHANNELS_FOR_ACCOUNT, name).observe(DisplayChannelsFragment.this.requireActivity(), this::manageViewChannels);
|
||||||
|
} else {
|
||||||
|
viewModel.get(RetrofitPeertubeAPI.DataType.MY_CHANNELS, null).observe(DisplayChannelsFragment.this.requireActivity(), this::manageViewChannels);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -223,10 +234,11 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||||||
channelCreation.setDescription(description.getText().toString().trim());
|
channelCreation.setDescription(description.getText().toString().trim());
|
||||||
}
|
}
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
APIResponse apiResponse;
|
||||||
if (oldChannelValues == null) {
|
if (oldChannelValues == null) {
|
||||||
new RetrofitPeertubeAPI(context).createOrUpdateChannel(ChannelsVM.action.CREATE_CHANNEL, null, channelCreation);
|
apiResponse = new RetrofitPeertubeAPI(context).createOrUpdateChannel(ChannelsVM.action.CREATE_CHANNEL, null, channelCreation);
|
||||||
} else {
|
} else {
|
||||||
new RetrofitPeertubeAPI(context).createOrUpdateChannel(ChannelsVM.action.UPDATE_CHANNEL, channelCreation.getName() + "@" + Helper.getLiveInstance(context), channelCreation);
|
apiResponse = new RetrofitPeertubeAPI(context).createOrUpdateChannel(ChannelsVM.action.UPDATE_CHANNEL, channelCreation.getName() + "@" + Helper.getLiveInstance(context), channelCreation);
|
||||||
}
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
@ -235,6 +247,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
|
|||||||
return;
|
return;
|
||||||
if (oldChannelValues == null) {
|
if (oldChannelValues == null) {
|
||||||
ChannelData.Channel channel = new ChannelData.Channel();
|
ChannelData.Channel channel = new ChannelData.Channel();
|
||||||
|
channel.setId(apiResponse.getActionReturn());
|
||||||
channel.setName(channelCreation.getName());
|
channel.setName(channelCreation.getName());
|
||||||
channel.setDisplayName(channelCreation.getDisplayName());
|
channel.setDisplayName(channelCreation.getDisplayName());
|
||||||
channel.setDescription(channelCreation.getDescription());
|
channel.setDescription(channelCreation.getDescription());
|
||||||
|
@ -196,8 +196,8 @@ public class DisplayOverviewFragment extends Fragment implements AccountsHorizon
|
|||||||
//hide loaders
|
//hide loaders
|
||||||
mainLoader.setVisibility(View.GONE);
|
mainLoader.setVisibility(View.GONE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
//handle other API error but discards 404 - error which can often happen due to toots which have been deleted
|
//handle other API error
|
||||||
if (this.peertubes == null || apiResponse == null || apiResponse.getOverviewVideo() == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError().getStatusCode() != 501)) {
|
if (this.peertubes == null || apiResponse == null || apiResponse.getOverviewVideo() == null || (apiResponse.getError() != null)) {
|
||||||
if (apiResponse == null || apiResponse.getError() == null)
|
if (apiResponse == null || apiResponse.getError() == null)
|
||||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
else {
|
else {
|
||||||
|
@ -68,7 +68,7 @@ import es.dmoral.toasty.Toasty;
|
|||||||
|
|
||||||
import static android.content.Context.MODE_PRIVATE;
|
import static android.content.Context.MODE_PRIVATE;
|
||||||
import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
|
import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
|
||||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.DataType.CHANNELS_FOR_ACCOUNT;
|
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.DataType.MY_CHANNELS;
|
||||||
|
|
||||||
|
|
||||||
public class DisplayPlaylistsFragment extends Fragment {
|
public class DisplayPlaylistsFragment extends Fragment {
|
||||||
@ -135,7 +135,7 @@ public class DisplayPlaylistsFragment extends Fragment {
|
|||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
ChannelsVM viewModelC = new ViewModelProvider(this).get(ChannelsVM.class);
|
ChannelsVM viewModelC = new ViewModelProvider(this).get(ChannelsVM.class);
|
||||||
viewModelC.get(CHANNELS_FOR_ACCOUNT, userId).observe(DisplayPlaylistsFragment.this.requireActivity(), this::manageVIewChannels);
|
viewModelC.get(MY_CHANNELS, null).observe(DisplayPlaylistsFragment.this.requireActivity(), this::manageVIewChannels);
|
||||||
|
|
||||||
display_name.setFilters(new InputFilter[]{new InputFilter.LengthFilter(120)});
|
display_name.setFilters(new InputFilter[]{new InputFilter.LengthFilter(120)});
|
||||||
description.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1000)});
|
description.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1000)});
|
||||||
|
@ -131,7 +131,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
mainLoader.setVisibility(View.VISIBLE);
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
|
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, type == TimelineVM.TimelineType.MY_VIDEOS);
|
||||||
lv_status.setAdapter(peertubeAdapater);
|
lv_status.setAdapter(peertubeAdapater);
|
||||||
|
|
||||||
accountsHorizontalListAdapter = new AccountsHorizontalListAdapter(this.accounts, this);
|
accountsHorizontalListAdapter = new AccountsHorizontalListAdapter(this.accounts, this);
|
||||||
@ -295,8 +295,8 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
//hide loaders
|
//hide loaders
|
||||||
mainLoader.setVisibility(View.GONE);
|
mainLoader.setVisibility(View.GONE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
//handle other API error but discards 404 - error which can often happen due to toots which have been deleted
|
//handle other API error
|
||||||
if (this.peertubes == null || apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 && apiResponse.getError().getStatusCode() != 501)) {
|
if (this.peertubes == null || apiResponse == null || (apiResponse.getError() != null)) {
|
||||||
if (apiResponse == null)
|
if (apiResponse == null)
|
||||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||||
else {
|
else {
|
||||||
@ -318,7 +318,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
|||||||
this.peertubes.addAll(apiResponse.getPeertubes());
|
this.peertubes.addAll(apiResponse.getPeertubes());
|
||||||
//If no item were inserted previously the adapter is created
|
//If no item were inserted previously the adapter is created
|
||||||
if (previousPosition == 0) {
|
if (previousPosition == 0) {
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, type == TimelineVM.TimelineType.MY_VIDEOS);
|
||||||
lv_status.setAdapter(peertubeAdapater);
|
lv_status.setAdapter(peertubeAdapater);
|
||||||
} else
|
} else
|
||||||
peertubeAdapater.notifyItemRangeInserted(previousPosition, apiResponse.getPeertubes().size());
|
peertubeAdapater.notifyItemRangeInserted(previousPosition, apiResponse.getPeertubes().size());
|
||||||
|
@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.sqlite;
|
|||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
@ -132,22 +133,27 @@ public class AccountDAO {
|
|||||||
/**
|
/**
|
||||||
* Update an Account token in database
|
* Update an Account token in database
|
||||||
*
|
*
|
||||||
* @param oldToken String
|
|
||||||
* @param token Token
|
* @param token Token
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public int updateAccountToken(String oldToken, Token token) {
|
public int updateAccountToken(Token token) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
|
|
||||||
|
|
||||||
if (token.getRefresh_token() != null) {
|
if (token.getRefresh_token() != null) {
|
||||||
values.put(Sqlite.COL_REFRESH_TOKEN, token.getRefresh_token());
|
values.put(Sqlite.COL_REFRESH_TOKEN, token.getRefresh_token());
|
||||||
}
|
}
|
||||||
if (token.getAccess_token() != null)
|
if (token.getAccess_token() != null)
|
||||||
values.put(Sqlite.COL_OAUTHTOKEN, token.getAccess_token());
|
values.put(Sqlite.COL_OAUTHTOKEN, token.getAccess_token());
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
|
String instance = Helper.getLiveInstance(context);
|
||||||
|
try {
|
||||||
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||||
values, Sqlite.COL_OAUTHTOKEN + " = ? ",
|
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_INSTANCE + " =?",
|
||||||
new String[]{oldToken});
|
new String[]{userId, instance});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,9 +46,15 @@ public class AccountsVM extends AndroidViewModel {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||||
APIResponse apiResponse = retrofitPeertubeAPI.getAccountData(dataType, element);
|
APIResponse apiResponse = new APIResponse();
|
||||||
|
if (dataType == RetrofitPeertubeAPI.DataType.SUBSCRIBER) {
|
||||||
|
apiResponse = retrofitPeertubeAPI.getSubscribtions(element);
|
||||||
|
} else if (dataType == RetrofitPeertubeAPI.DataType.MUTED) {
|
||||||
|
apiResponse = retrofitPeertubeAPI.getMuted(element);
|
||||||
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
APIResponse finalApiResponse = apiResponse;
|
||||||
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(finalApiResponse);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -16,6 +16,8 @@ package app.fedilab.fedilabtube.viewmodel;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
|
||||||
@ -26,6 +28,12 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
|
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
|
import app.fedilab.fedilabtube.client.data.AccountData;
|
||||||
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
||||||
|
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||||
|
|
||||||
|
import static android.content.Context.MODE_PRIVATE;
|
||||||
|
|
||||||
|
|
||||||
public class ChannelsVM extends AndroidViewModel {
|
public class ChannelsVM extends AndroidViewModel {
|
||||||
@ -44,9 +52,18 @@ public class ChannelsVM extends AndroidViewModel {
|
|||||||
private void getChannels(RetrofitPeertubeAPI.DataType type, String element) {
|
private void getChannels(RetrofitPeertubeAPI.DataType type, String element) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
String finalElement = element;
|
||||||
try {
|
try {
|
||||||
|
if (type == RetrofitPeertubeAPI.DataType.MY_CHANNELS) {
|
||||||
|
SharedPreferences sharedpreferences = _mContext.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
SQLiteDatabase db = Sqlite.getInstance(_mContext.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
|
String instance = Helper.getLiveInstance(_mContext);
|
||||||
|
AccountData.Account account = new AccountDAO(_mContext, db).getAccountByToken(token);
|
||||||
|
finalElement = account.getUsername() + "@" + account.getHost();
|
||||||
|
}
|
||||||
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||||
APIResponse apiResponse = retrofitPeertubeAPI.getChannelData(type, element);
|
APIResponse apiResponse = retrofitPeertubeAPI.getChannelData(type, finalElement);
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
|
@ -87,7 +87,7 @@ public class PlaylistsVM extends AndroidViewModel {
|
|||||||
apiResponse = new APIResponse();
|
apiResponse = new APIResponse();
|
||||||
apiResponse.setPlaylists(new ArrayList<>());
|
apiResponse.setPlaylists(new ArrayList<>());
|
||||||
} else {
|
} else {
|
||||||
apiResponse = new RetrofitPeertubeAPI(_mContext).playlistAction(apiAction, playlist!=null?playlist.getId():null, videoId, account.getAcct());
|
apiResponse = new RetrofitPeertubeAPI(_mContext).playlistAction(apiAction, playlist != null ? playlist.getUuid() : null, videoId, account.getAcct());
|
||||||
}
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
if (apiResponse != null) {
|
if (apiResponse != null) {
|
||||||
|
@ -48,7 +48,12 @@ public class RelationshipVM extends AndroidViewModel {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(_mContext);
|
||||||
APIResponse apiResponse = api.isFollowing(uris);
|
APIResponse apiResponse;
|
||||||
|
if (uris.size() == 1) {
|
||||||
|
apiResponse = api.isFollowing(uris.get(0));
|
||||||
|
} else {
|
||||||
|
apiResponse = api.areFollowing(uris);
|
||||||
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
|
@ -51,7 +51,13 @@ public class TimelineVM extends AndroidViewModel {
|
|||||||
|
|
||||||
public LiveData<APIResponse> getVideo(String videoId) {
|
public LiveData<APIResponse> getVideo(String videoId) {
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
getSingle(videoId);
|
getSingle(videoId, false);
|
||||||
|
return apiResponseMutableLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<APIResponse> getMyVideo(String videoId) {
|
||||||
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
|
getSingle(videoId, true);
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,13 +82,13 @@ public class TimelineVM extends AndroidViewModel {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getSingle(String videoId) {
|
private void getSingle(String videoId, boolean myVideo) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||||
APIResponse apiResponse = retrofitPeertubeAPI.getVideos(videoId);
|
APIResponse apiResponse = retrofitPeertubeAPI.getVideos(videoId, myVideo);
|
||||||
if (Helper.isLoggedIn(_mContext)) {
|
if (Helper.isLoggedIn(_mContext) && !myVideo) {
|
||||||
if (apiResponse.getPeertubes() != null && apiResponse.getPeertubes().size() > 0 && apiResponse.getPeertubes().get(0) != null) {
|
if (apiResponse.getPeertubes() != null && apiResponse.getPeertubes().size() > 0 && apiResponse.getPeertubes().get(0) != null) {
|
||||||
APIResponse response = new RetrofitPeertubeAPI(_mContext).getRating(videoId);
|
APIResponse response = new RetrofitPeertubeAPI(_mContext).getRating(videoId);
|
||||||
if (response != null)
|
if (response != null)
|
||||||
|
@ -156,5 +156,14 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
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>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -51,68 +51,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp" />
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/account_info"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:baselineAligned="false"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="@string/following" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/account_fgc"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="@string/followers" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/account_frc"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/account_ds"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:autoLink="web" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
see <http://www.gnu.org/licenses>.
|
see <http://www.gnu.org/licenses>.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/main_container"
|
android:id="@+id/main_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -52,68 +51,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textSize="16sp"
|
android:ellipsize="end"
|
||||||
android:visibility="gone" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/account_info"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:baselineAligned="false"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="@string/following" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/account_fgc"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="@string/followers" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/account_frc"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/account_ds"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
android:autoLink="web" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -125,6 +64,6 @@
|
|||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:contentDescription="@string/display_more"
|
android:contentDescription="@string/display_more"
|
||||||
android:src="@drawable/ic_baseline_more_vert_24"
|
android:src="@drawable/ic_baseline_more_vert_24"
|
||||||
android:visibility="gone" />
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Reference in New Issue
Block a user