summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/fr/gouv/etalab/mastodon
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2019-01-07 15:27:06 +0100
committerstom79 <tschneider.ac@gmail.com>2019-01-07 15:27:06 +0100
commite38f4582459c723ec79b784325c13e624cb0c66f (patch)
treefa490291670b88f1f9a255e44d7586820ead4a0f /app/src/main/java/fr/gouv/etalab/mastodon
parent13ece2616dc4e1b1b95235c62ff5436f02fba06b (diff)
Frontend for upload
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/MainApplication.java6
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeUploadActivity.java98
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java7
3 files changed, 107 insertions, 4 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MainApplication.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MainApplication.java
index 1dee4a6c6..a491d4b02 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MainApplication.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MainApplication.java
@@ -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))
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeUploadActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeUploadActivity.java
new file mode 100644
index 000000000..4b3cc00ea
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeUploadActivity.java
@@ -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) {
+
+ }
+ }
+}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java
index 9e0ecf134..a35f9cef4 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java
@@ -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) {