My videos
This commit is contained in:
parent
f7bb3ea9d9
commit
46cd597c0f
|
@ -58,6 +58,11 @@
|
|||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".MyVideosActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".LoginActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M21,3L3,3c-1.11,0 -2,0.89 -2,2v12c0,1.1 0.89,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5c0,-1.11 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12z" />
|
||||
</vector>
|
|
@ -7,13 +7,14 @@
|
|||
<RelativeLayout
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/not_connected"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/step_instance"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -130,9 +131,9 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/connected"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -141,52 +142,57 @@
|
|||
android:paddingEnd="50dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/instance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_width="match_parent"
|
||||
android:textSize="18sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/instance"/>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_marginTop="20dp"
|
||||
android:id="@+id/cardview_profile"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:src="@drawable/ic_launcher_foreground"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/instance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
app:layout_constraintTop_toBottomOf="@id/instance">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
android:padding="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:padding="10dp">
|
||||
|
||||
<ImageView
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:id="@+id/profile_picture"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:id="@+id/profile_picture"
|
||||
android:contentDescription="@string/profile_picture" />
|
||||
android:contentDescription="@string/profile_picture"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginStart="20dp"
|
||||
app:layout_constraintStart_toEndOf="@+id/profile_picture"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:id="@+id/displayname"
|
||||
android:textSize="18sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/profile_picture"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="30dp"
|
||||
app:layout_constraintStart_toEndOf="@+id/profile_picture"
|
||||
app:layout_constraintTop_toTopOf="@+id/displayname"
|
||||
android:id="@+id/username"
|
||||
android:textSize="14sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
app:layout_constraintStart_toEndOf="@+id/profile_picture"
|
||||
app:layout_constraintTop_toTopOf="@+id/displayname" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
|
|
@ -83,12 +83,12 @@
|
|||
android:id="@+id/video_title"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="20dp"
|
||||
android:hint="@string/title_video_peertube"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
android:layout_gravity="center"
|
||||
android:importantForAutofill="no" />
|
||||
android:singleLine="true" />
|
||||
|
||||
<!-- Videos upload submit -->
|
||||
<Button
|
||||
|
|
|
@ -26,4 +26,9 @@
|
|||
android:icon="@drawable/ic_baseline_cloud_upload_24"
|
||||
android:title="@string/upload_video"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_myvideos"
|
||||
android:icon="@drawable/ic_baseline_personal_video_24"
|
||||
android:title="@string/my_videos"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
||||
|
|
Loading…
Reference in New Issue