summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2019-01-09 17:30:18 +0100
committerstom79 <tschneider.ac@gmail.com>2019-01-09 17:30:18 +0100
commit15f0d4f3ecd154c110db43d651d4888521f782d4 (patch)
treeee80b4bd70ab8621579c3115967833133e8073bb
parent13759865b1e838bd9807f3c285ca74076145f22e (diff)
Some fixes
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java2
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeEditUploadActivity.java32
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeUploadActivity.java2
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java9
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/client/PeertubeAPI.java56
5 files changed, 96 insertions, 5 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
index 6ffbf67f4..d2241745c 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
@@ -2036,7 +2036,7 @@ public abstract class BaseMainActivity extends BaseActivity
} else if (id == R.id.nav_my_video) {
bundle = new Bundle();
DisplayStatusFragment fragment = new DisplayStatusFragment();
- bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.USER);
+ bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.MYVIDEOS);
bundle.putString("instanceType","PEERTUBE");
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeEditUploadActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeEditUploadActivity.java
index 2c4158a0f..7f4775099 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeEditUploadActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeEditUploadActivity.java
@@ -152,7 +152,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
//Get params from the API
- LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
+ LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
LinkedHashMap<Integer, String> privacies = new LinkedHashMap<>(peertubeInformation.getPrivacies());
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
@@ -236,6 +236,8 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
new RetrievePeertubeSingleAsyncTask(PeertubeEditUploadActivity.this, peertubeInstance, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
channels = new LinkedHashMap<>();
+
+
}
@@ -268,6 +270,34 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
privacyToSend = peertube.getPrivacy();
categoryToSend = peertube.getCategory();
+
+ if( languageToSend == null){
+ LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
+ Map.Entry<String,String> entryString = languages.entrySet().iterator().next();
+ languageToSend = new HashMap<>();
+ languageToSend.put(entryString.getKey(), entryString.getValue());
+ }
+
+ if( licenseToSend == null){
+ LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
+ Map.Entry<Integer,String> entryInt = licences.entrySet().iterator().next();
+ licenseToSend = new HashMap<>();
+ licenseToSend.put(entryInt.getKey(), entryInt.getValue());
+ }
+
+ if( categoryToSend == null){
+ LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
+ Map.Entry<Integer,String> entryInt = categories.entrySet().iterator().next();
+ categoryToSend = new HashMap<>();
+ categoryToSend.put(entryInt.getKey(), entryInt.getValue());
+ }
+ if( privacyToSend == null){
+ LinkedHashMap<Integer, String> privacies = new LinkedHashMap<>(peertubeInformation.getPrivacies());
+ Map.Entry<Integer,String> entryInt = privacies.entrySet().iterator().next();
+ privacyToSend = new HashMap<>();
+ privacyToSend.put(entryInt.getKey(), entryInt.getValue());
+ }
+
String language = null;
if( languageToSend != null) {
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
index 62961e32f..4b8415eb7 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeUploadActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeUploadActivity.java
@@ -376,7 +376,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
videoID = response.getJSONObject("video").get("id").toString();
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.VIDEO_ID, videoID);
- editor.apply();
+ editor.commit();
} catch (JSONException e) {
e.printStackTrace();
}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java
index 658dfb4a7..21e899a3a 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveFeedsAsyncTask.java
@@ -85,7 +85,8 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
PRECENTLYADDED,
PMYVIDEOS,
PLOCAL,
- CHANNEL
+ CHANNEL,
+ MYVIDEOS
}
@@ -214,8 +215,12 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
apiResponse = peertubeAPI.getVideos(targetedID, max_id);
}
break;
- case CHANNEL:
+ case MYVIDEOS:
PeertubeAPI peertubeAPI = new PeertubeAPI(this.contextReference.get());
+ apiResponse = peertubeAPI.getMyVideos(max_id);
+ break;
+ case CHANNEL:
+ peertubeAPI = new PeertubeAPI(this.contextReference.get());
apiResponse = peertubeAPI.getVideosChannel(targetedID, max_id);
break;
case ONESTATUS:
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 7ad38ab5a..52d4fbf22 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
@@ -489,6 +489,62 @@ public class PeertubeAPI {
}
+ /**
+ * Retrieves videos for the account *synchronously*
+ *
+ * @param max_id String id max
+ * @return APIResponse
+ */
+ public APIResponse getMyVideos(String max_id) {
+ return getMyVideos(max_id, null, tootPerPage);
+ }
+
+
+
+ /**
+ * Retrieves status for the account *synchronously*
+ *
+ * @param max_id String id max
+ * @param since_id String since the id
+ * @param limit int limit - max value 40
+ * @return APIResponse
+ */
+ @SuppressWarnings("SameParameterValue")
+ private APIResponse getMyVideos(String max_id, String since_id, int limit) {
+
+ HashMap<String, String> params = new HashMap<>();
+ if (max_id != null)
+ params.put("start", max_id);
+ if (since_id != null)
+ params.put("since_id", since_id);
+ if (0 < limit || limit > 40)
+ limit = 40;
+ params.put("count", String.valueOf(limit));
+ List<Peertube> peertubes = new ArrayList<>();
+ try {
+
+ HttpsConnection httpsConnection = new HttpsConnection(context);
+ String response = httpsConnection.get(getAbsoluteUrl("/users/me/videos"), 60, params, prefKeyOauthTokenT);
+
+ JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
+ peertubes = parsePeertube(jsonArray);
+
+ } catch (HttpsConnection.HttpsConnectionException e) {
+ setError(e.getStatusCode(), e);
+ e.printStackTrace();
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (KeyManagementException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ apiResponse.setPeertubes(peertubes);
+ return apiResponse;
+ }
+
/**
* Retrieves status for the account *synchronously*