My videos

This commit is contained in:
Thomas 2020-06-30 13:33:43 +02:00
parent f7bb3ea9d9
commit 46cd597c0f
13 changed files with 146 additions and 69 deletions

View File

@ -58,6 +58,11 @@
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:label="@string/app_name" android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden" /> android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name=".MyVideosActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity <activity
android:name=".LoginActivity" android:name=".LoginActivity"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"

View File

@ -29,7 +29,6 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import app.fedilab.fedilabtube.asynctasks.UpdateAccountInfoAsyncTask; import app.fedilab.fedilabtube.asynctasks.UpdateAccountInfoAsyncTask;
import app.fedilab.fedilabtube.client.HttpsConnection; import app.fedilab.fedilabtube.client.HttpsConnection;
@ -125,9 +124,6 @@ public class LoginActivity extends AppCompatActivity {
} }
} else { } else {
connected.setVisibility(View.GONE); connected.setVisibility(View.GONE);
} }

View File

@ -76,12 +76,14 @@ public class MainActivity extends AppCompatActivity {
}); });
MenuItem uploadItem = menu.findItem(R.id.action_upload); MenuItem uploadItem = menu.findItem(R.id.action_upload);
MenuItem myVideosItem = menu.findItem(R.id.action_myvideos);
if (Helper.isLoggedIn(MainActivity.this)) { if (Helper.isLoggedIn(MainActivity.this)) {
uploadItem.setVisible(true); uploadItem.setVisible(true);
myVideosItem.setVisible(true);
} else { } else {
uploadItem.setVisible(false); uploadItem.setVisible(false);
myVideosItem.setVisible(false);
} }
return true; return true;
} }
@ -90,16 +92,18 @@ public class MainActivity extends AppCompatActivity {
if (item.getItemId() == R.id.action_change_instance) { if (item.getItemId() == R.id.action_change_instance) {
showRadioButtonDialog(); showRadioButtonDialog();
return true; return true;
} } else if (item.getItemId() == R.id.action_account) {
if (item.getItemId() == R.id.action_account) {
Intent intent = new Intent(MainActivity.this, LoginActivity.class); Intent intent = new Intent(MainActivity.this, LoginActivity.class);
startActivity(intent); startActivity(intent);
return true; return true;
} } else if (item.getItemId() == R.id.action_upload) {
if (item.getItemId() == R.id.action_upload) {
Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class); Intent intent = new Intent(MainActivity.this, PeertubeUploadActivity.class);
startActivity(intent); startActivity(intent);
return true; 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); return super.onOptionsItemSelected(item);
} }

View File

@ -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) {
}
}

View File

@ -7,7 +7,6 @@ import android.os.Build;
import android.text.Html; import android.text.Html;
import android.text.SpannableString; import android.text.SpannableString;
import net.gotev.uploadservice.MultipartUploadRequest; import net.gotev.uploadservice.MultipartUploadRequest;
import net.gotev.uploadservice.ServerResponse; import net.gotev.uploadservice.ServerResponse;
import net.gotev.uploadservice.UploadInfo; import net.gotev.uploadservice.UploadInfo;
@ -182,7 +181,6 @@ public class HttpsConnection {
} }
public String get(String urlConnection) throws IOException, NoSuchAlgorithmException, KeyManagementException, HttpsConnectionException { 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 * Download method which works for http and https connections
* @param downloadUrl String download url * @param downloadUrl String download url

View File

@ -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.CacheDataSource;
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor; import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
import com.google.android.exoplayer2.upstream.cache.SimpleCache; import com.google.android.exoplayer2.upstream.cache.SimpleCache;
import com.google.android.exoplayer2.util.Util;
import java.io.File; import java.io.File;
@ -27,12 +28,11 @@ public class CacheDataSourceFactory implements DataSource.Factory {
super(); super();
this.context = context; this.context = context;
this.maxFileSize = 5 * 1024 * 1024; this.maxFileSize = 5 * 1024 * 1024;
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
DefaultBandwidthMeter.Builder bandwidthMeterBuilder = new DefaultBandwidthMeter.Builder(context); DefaultBandwidthMeter.Builder bandwidthMeterBuilder = new DefaultBandwidthMeter.Builder(context);
DefaultBandwidthMeter bandwidthMeter = bandwidthMeterBuilder.build(); DefaultBandwidthMeter bandwidthMeter = bandwidthMeterBuilder.build();
defaultDatasourceFactory = new DefaultDataSourceFactory(this.context, defaultDatasourceFactory = new DefaultDataSourceFactory(this.context,
bandwidthMeter, bandwidthMeter,
new DefaultHttpDataSourceFactory(null, bandwidthMeter)); new DefaultHttpDataSourceFactory(Util.getUserAgent(context, null), bandwidthMeter));
} }
public static SimpleCache getInstance(Context context) { public static SimpleCache getInstance(Context context) {

View File

@ -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>

View File

@ -7,13 +7,14 @@
<RelativeLayout <RelativeLayout
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
>
<LinearLayout <LinearLayout
android:id="@+id/not_connected" android:id="@+id/not_connected"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/step_instance" android:id="@+id/step_instance"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -130,9 +131,9 @@
<LinearLayout <LinearLayout
android:id="@+id/connected" android:id="@+id/connected"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -141,52 +142,57 @@
android:paddingEnd="50dp"> android:paddingEnd="50dp">
<TextView <TextView
android:id="@+id/instance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
android:layout_width="match_parent"
android:textSize="18sp"
android:layout_height="wrap_content"
android:id="@+id/instance"/>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_marginTop="20dp"
android:id="@+id/cardview_profile" 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" android:src="@drawable/ic_launcher_foreground"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/instance" app:layout_constraintTop_toBottomOf="@id/instance">
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:padding="10dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:padding="10dp">
<ImageView <ImageView
app:layout_constraintStart_toStartOf="parent" android:id="@+id/profile_picture"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="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 <TextView
android:layout_marginStart="20dp"
app:layout_constraintStart_toEndOf="@+id/profile_picture"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/displayname" android:id="@+id/displayname"
android:textSize="18sp"
android:layout_width="wrap_content" 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 <TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="30dp" 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:textSize="14sp"
android:layout_width="wrap_content" app:layout_constraintStart_toEndOf="@+id/profile_picture"
android:layout_height="wrap_content"/> app:layout_constraintTop_toTopOf="@+id/displayname" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View File

@ -83,12 +83,12 @@
android:id="@+id/video_title" android:id="@+id/video_title"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:hint="@string/title_video_peertube" android:hint="@string/title_video_peertube"
android:importantForAutofill="no"
android:inputType="text" android:inputType="text"
android:singleLine="true" android:singleLine="true" />
android:layout_gravity="center"
android:importantForAutofill="no" />
<!-- Videos upload submit --> <!-- Videos upload submit -->
<Button <Button

View File

@ -26,4 +26,9 @@
android:icon="@drawable/ic_baseline_cloud_upload_24" android:icon="@drawable/ic_baseline_cloud_upload_24"
android:title="@string/upload_video" android:title="@string/upload_video"
app:showAsAction="ifRoom" /> 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> </menu>