mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-06-05 21:09:11 +02:00
My videos
This commit is contained in:
@ -29,7 +29,6 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.fedilabtube.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
import app.fedilab.fedilabtube.client.HttpsConnection;
|
||||
@ -84,7 +83,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
LinearLayout connected = findViewById(R.id.connected);
|
||||
LinearLayout not_connected = findViewById(R.id.not_connected);
|
||||
|
||||
if( Helper.isLoggedIn(LoginActivity.this)) {
|
||||
if (Helper.isLoggedIn(LoginActivity.this)) {
|
||||
not_connected.setVisibility(View.GONE);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
@ -93,10 +92,10 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
TextView instanceView = findViewById(R.id.instance);
|
||||
Account account = new AccountDAO(LoginActivity.this, db).getUniqAccount(userId, instance);
|
||||
if( account == null) {
|
||||
if (account == null) {
|
||||
account = new AccountDAO(LoginActivity.this, db).getUniqAccount(userId, Helper.getPeertubeUrl(instance));
|
||||
}
|
||||
if( account != null) {
|
||||
if (account != null) {
|
||||
ImageView profile_picture = findViewById(R.id.profile_picture);
|
||||
TextView username = findViewById(R.id.username);
|
||||
TextView displayname = findViewById(R.id.displayname);
|
||||
@ -120,15 +119,12 @@ public class LoginActivity extends AppCompatActivity {
|
||||
AlertDialog alertDialogLogoutAccount = dialogBuilderLogoutAccount.create();
|
||||
alertDialogLogoutAccount.show();
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
Helper.logoutCurrentUser(LoginActivity.this, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
} else {
|
||||
connected.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
MenuItem uploadItem = menu.findItem(R.id.action_upload);
|
||||
if( Helper.isLoggedIn(MainActivity.this)) {
|
||||
MenuItem myVideosItem = menu.findItem(R.id.action_myvideos);
|
||||
if (Helper.isLoggedIn(MainActivity.this)) {
|
||||
uploadItem.setVisible(true);
|
||||
}else{
|
||||
myVideosItem.setVisible(true);
|
||||
} else {
|
||||
uploadItem.setVisible(false);
|
||||
myVideosItem.setVisible(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -90,16 +92,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (item.getItemId() == R.id.action_change_instance) {
|
||||
showRadioButtonDialog();
|
||||
return true;
|
||||
}
|
||||
if (item.getItemId() == R.id.action_account) {
|
||||
} else if (item.getItemId() == R.id.action_account) {
|
||||
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
if (item.getItemId() == R.id.action_upload) {
|
||||
} else if (item.getItemId() == R.id.action_upload) {
|
||||
Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_myvideos) {
|
||||
Intent intent = new Intent(MainActivity.this, MyVideosActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package app.fedilab.fedilabtube;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import app.fedilab.fedilabtube.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import app.fedilab.fedilabtube.client.APIResponse;
|
||||
import app.fedilab.fedilabtube.fragment.DisplayStatusFragment;
|
||||
import app.fedilab.fedilabtube.interfaces.OnRetrieveFeedsInterface;
|
||||
|
||||
|
||||
public class MyVideosActivity extends AppCompatActivity implements OnRetrieveFeedsInterface {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_search_result);
|
||||
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setTitle(R.string.my_videos);
|
||||
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
DisplayStatusFragment displayStatusFragment = new DisplayStatusFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
|
||||
displayStatusFragment.setArguments(bundle);
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.add(R.id.container, displayStatusFragment).commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRetrieveFeeds(APIResponse apiResponse) {
|
||||
|
||||
}
|
||||
}
|
@ -469,12 +469,12 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee
|
||||
new PostActionAsyncTask(PeertubeActivity.this, PeertubeAPI.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
peertube.setMyRating(newState);
|
||||
int count = Integer.parseInt(peertube_like_count.getText().toString());
|
||||
if( newState.compareTo("none") == 0) {
|
||||
if (newState.compareTo("none") == 0) {
|
||||
count--;
|
||||
if( count - 1 < 0 ) {
|
||||
if (count - 1 < 0) {
|
||||
count = 0;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
peertube_like_count.setText(String.valueOf(count));
|
||||
@ -489,12 +489,12 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee
|
||||
new PostActionAsyncTask(PeertubeActivity.this, PeertubeAPI.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
peertube.setMyRating(newState);
|
||||
int count = Integer.parseInt(peertube_dislike_count.getText().toString());
|
||||
if( newState.compareTo("none") == 0) {
|
||||
if (newState.compareTo("none") == 0) {
|
||||
count--;
|
||||
if( count - 1 < 0 ) {
|
||||
if (count - 1 < 0) {
|
||||
count = 0;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
peertube_dislike_count.setText(String.valueOf(count));
|
||||
@ -778,21 +778,21 @@ public class PeertubeActivity extends AppCompatActivity implements OnRetrievePee
|
||||
Drawable thumbDown = ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_baseline_thumb_down_alt_24);
|
||||
int color = getAttColor(this, android.R.attr.colorControlNormal);
|
||||
|
||||
if( thumbUp != null ) {
|
||||
if (thumbUp != null) {
|
||||
thumbUp.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
DrawableCompat.setTint(thumbUp, color);
|
||||
}
|
||||
if( thumbDown != null ) {
|
||||
if (thumbDown != null) {
|
||||
thumbDown.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
DrawableCompat.setTint(thumbDown, color);
|
||||
}
|
||||
if (peertube.getMyRating() != null && peertube.getMyRating().compareTo("like") == 0) {
|
||||
if( thumbUp != null ) {
|
||||
if (thumbUp != null) {
|
||||
thumbUp.setColorFilter(getResources().getColor(R.color.positive_thumbs), PorterDuff.Mode.SRC_ATOP);
|
||||
DrawableCompat.setTint(thumbUp, getResources().getColor(R.color.positive_thumbs));
|
||||
}
|
||||
}else if (peertube.getMyRating() != null && peertube.getMyRating().compareTo("dislike") == 0) {
|
||||
if( thumbDown != null ) {
|
||||
} else if (peertube.getMyRating() != null && peertube.getMyRating().compareTo("dislike") == 0) {
|
||||
if (thumbDown != null) {
|
||||
thumbDown.setColorFilter(getResources().getColor(R.color.negative_thumbs), PorterDuff.Mode.SRC_ATOP);
|
||||
DrawableCompat.setTint(thumbDown, getResources().getColor(R.color.negative_thumbs));
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class RetrievePeertubeChannelsAsyncTask extends AsyncTask<Void, Void, Voi
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(contextReference.get()));
|
||||
Account account = new AccountDAO(contextReference.get(), db).getUniqAccount(userId, instance);
|
||||
if( account == null) {
|
||||
if (account == null) {
|
||||
account = new AccountDAO(contextReference.get(), db).getUniqAccount(userId, Helper.getPeertubeUrl(instance));
|
||||
}
|
||||
apiResponse = peertubeAPI.getPeertubeChannel(account.getUsername());
|
||||
|
@ -7,7 +7,6 @@ import android.os.Build;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
|
||||
|
||||
import net.gotev.uploadservice.MultipartUploadRequest;
|
||||
import net.gotev.uploadservice.ServerResponse;
|
||||
import net.gotev.uploadservice.UploadInfo;
|
||||
@ -182,7 +181,6 @@ public class HttpsConnection {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String get(String urlConnection) throws IOException, NoSuchAlgorithmException, KeyManagementException, HttpsConnectionException {
|
||||
|
||||
|
||||
@ -300,7 +298,6 @@ public class HttpsConnection {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* Download method which works for http and https connections
|
||||
* @param downloadUrl String download url
|
||||
|
@ -711,7 +711,7 @@ public class PeertubeAPI {
|
||||
public Account verifyCredentials(String token, String instance) {
|
||||
account = new Account();
|
||||
try {
|
||||
String response = new HttpsConnection(context).get("https://"+instance+"/api/v1/users/me", 60, null, token);
|
||||
String response = new HttpsConnection(context).get("https://" + instance + "/api/v1/users/me", 60, null, token);
|
||||
JSONObject accountObject = new JSONObject(response).getJSONObject("account");
|
||||
account = parseAccountResponsePeertube(accountObject);
|
||||
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
|
||||
@ -740,7 +740,7 @@ public class PeertubeAPI {
|
||||
|
||||
String response;
|
||||
try {
|
||||
response = new HttpsConnection(context).get("https://"+instance+"/api/v1/users/me", 60, null, targetedAccount.getToken());
|
||||
response = new HttpsConnection(context).get("https://" + instance + "/api/v1/users/me", 60, null, targetedAccount.getToken());
|
||||
JSONObject accountObject = new JSONObject(response).getJSONObject("account");
|
||||
account = parseAccountResponsePeertube(accountObject);
|
||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException | JSONException e1) {
|
||||
|
@ -13,6 +13,7 @@ import com.google.android.exoplayer2.upstream.cache.CacheDataSink;
|
||||
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
|
||||
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
|
||||
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -27,12 +28,11 @@ public class CacheDataSourceFactory implements DataSource.Factory {
|
||||
super();
|
||||
this.context = context;
|
||||
this.maxFileSize = 5 * 1024 * 1024;
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
DefaultBandwidthMeter.Builder bandwidthMeterBuilder = new DefaultBandwidthMeter.Builder(context);
|
||||
DefaultBandwidthMeter bandwidthMeter = bandwidthMeterBuilder.build();
|
||||
defaultDatasourceFactory = new DefaultDataSourceFactory(this.context,
|
||||
bandwidthMeter,
|
||||
new DefaultHttpDataSourceFactory(null, bandwidthMeter));
|
||||
new DefaultHttpDataSourceFactory(Util.getUserAgent(context, null), bandwidthMeter));
|
||||
}
|
||||
|
||||
public static SimpleCache getInstance(Context context) {
|
||||
|
Reference in New Issue
Block a user