Frontend for upload

This commit is contained in:
stom79 2019-01-07 15:27:06 +01:00
parent 13ece2616d
commit e38f458245
6 changed files with 210 additions and 4 deletions

View File

@ -57,6 +57,7 @@ ext.swipebackLibraryVersion = '1.0.2'
ext.ratethisappLibraryVersion = '1.2.0'
ext.uploadServiceVersion = "3.4.2"
ext.torrentstreamVersion = "2.6.1"
ext.uploadServiceVersion = "3.4.2"
dependencies {
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
@ -86,5 +87,6 @@ dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.exoplayer:exoplayer:2.9.3'
implementation "com.github.TorrentStream:TorrentStream-Android:$torrentstreamVersion"
implementation "net.gotev:uploadservice:$uploadServiceVersion"
playstoreImplementation "io.github.kobakei:ratethisapp:$ratethisappLibraryVersion"
}

View File

@ -24,11 +24,14 @@ import android.support.v4.content.ContextCompat;
import com.evernote.android.job.JobManager;
import com.franmontiel.localechanger.LocaleChanger;
import net.gotev.uploadservice.UploadService;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.BuildConfig;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.jobs.ApplicationJob;
@ -68,7 +71,8 @@ public class MainApplication extends MultiDexApplication {
}
LocaleChanger.initialize(getApplicationContext(), SUPPORTED_LOCALES);
}catch (Exception ignored){ignored.printStackTrace();}
//Initialize upload service
UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;
Toasty.Config.getInstance()
.setErrorColor(ContextCompat.getColor(getApplicationContext(), R.color.toasty_background))
.setInfoColor(ContextCompat.getColor(getApplicationContext(), R.color.toasty_background))

View File

@ -0,0 +1,98 @@
package fr.gouv.etalab.mastodon.activities;
/* Copyright 2019 Thomas Schneider
*
* This file is a part of Mastalab
*
* 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.
*
* Mastalab 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 Mastalab; if not,
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.helper.Helper;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_LIGHT;
public class PeertubeUploadActivity extends BaseActivity{
private final int PICK_IVDEO = 567786;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
switch (theme){
case Helper.THEME_LIGHT:
setTheme(R.style.AppTheme);
break;
case Helper.THEME_DARK:
setTheme(R.style.AppThemeDark);
break;
case Helper.THEME_BLACK:
setTheme(R.style.AppThemeBlack);
break;
default:
setTheme(R.style.AppThemeDark);
}
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBar actionBar = getSupportActionBar();
if( actionBar != null ) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert inflater != null;
@SuppressLint("InflateParams") View view = inflater.inflate(R.layout.simple_bar, null);
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
toolbar_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
toolbar_title.setText(R.string.action_about);
if (theme == THEME_LIGHT){
Toolbar toolbar = actionBar.getCustomView().findViewById(R.id.toolbar);
Helper.colorizeToolbar(toolbar, R.color.black, PeertubeUploadActivity.this);
}
}
setContentView(R.layout.activity_peertube_upload);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IVDEO && resultCode == Activity.RESULT_OK) {
}
}
}

View File

@ -821,15 +821,16 @@ public class PeertubeAPI {
/**
* Retrieves Peertube videos from an instance *synchronously*
* Retrieves Peertube channel from an account *synchronously*
* Peertube channels are dealt like accounts
* @return APIResponse
*/
public APIResponse getPeertubeChannel(String instance, String name) {
public APIResponse getPeertubeChannel(String name) {
List<Account> accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/accounts/%s/video-channels", name), 60, null, null);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/video-channels", name)), 60, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
accounts = parseAccountResponsePeertube(context, instance, jsonArray);
} catch (HttpsConnection.HttpsConnectionException e) {

View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Thomas Schneider
This file is a part of Mastalab
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.
Mastalab 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 Mastalab; if not,
see <http://www.gnu.org/licenses>.
-->
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.PeertubeUploadActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<Button
android:gravity="center"
android:layout_gravity="center_horizontal"
android:id="@+id/set_toot_visibility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:text="@string/file_to_upload" />
<TextView
android:layout_marginTop="20dp"
android:visibility="gone"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- Videos channels -->
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/channel"/>
<Spinner
android:id="@+id/set_upload_channel"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- Videos Privacy -->
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_privacy"/>
<Spinner
android:id="@+id/set_upload_privacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- Videos upload submit -->
<Button
android:layout_marginTop="40dp"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:id="@+id/set_upload_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:text="@string/upload_video" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>

View File

@ -798,6 +798,7 @@
<string name="delete_comment_confirm">Are you sure to delete this comment?</string>
<string name="fullscreen">Full screen video</string>
<string name="set_video_mode">Mode for videos</string>
<string name="file_to_upload">Select the file to upload</string>
<!-- end languages -->