diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a1fbc910d..0c266fa08 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -227,6 +227,11 @@
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
/>
+
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/CustomSharingActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/CustomSharingActivity.java
new file mode 100644
index 000000000..ea35d405f
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/CustomSharingActivity.java
@@ -0,0 +1,197 @@
+/* Copyright 2017 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 . */
+package fr.gouv.etalab.mastodon.activities;
+
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.drawable.BitmapDrawable;
+import android.media.ThumbnailUtils;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.Toolbar;
+import android.text.Editable;
+import android.text.Html;
+import android.text.TextWatcher;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.bumptech.glide.Glide;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import es.dmoral.toasty.Toasty;
+import fr.gouv.etalab.mastodon.R;
+import fr.gouv.etalab.mastodon.asynctasks.CustomSharingAsyncTask;
+import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountInfoAsyncTask;
+import fr.gouv.etalab.mastodon.asynctasks.UpdateCredentialAsyncTask;
+import fr.gouv.etalab.mastodon.client.API;
+import fr.gouv.etalab.mastodon.client.APIResponse;
+import fr.gouv.etalab.mastodon.client.CustomSharingResponse;
+import fr.gouv.etalab.mastodon.client.Entities.Account;
+import fr.gouv.etalab.mastodon.client.Entities.Error;
+import fr.gouv.etalab.mastodon.client.Entities.Version;
+import fr.gouv.etalab.mastodon.client.Glide.GlideApp;
+import fr.gouv.etalab.mastodon.helper.Helper;
+import fr.gouv.etalab.mastodon.interfaces.OnCustomSharingInterface;
+import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
+import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
+import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
+import fr.gouv.etalab.mastodon.sqlite.Sqlite;
+
+import static fr.gouv.etalab.mastodon.helper.Helper.THEME_LIGHT;
+
+
+/**
+ * Created by Thomas on 27/08/2017.
+ * Edit profile activity
+ */
+
+public class CustomSharingActivity extends BaseActivity implements OnCustomSharingInterface {
+
+ private EditText set_custom_sharing_title, set_custom_sharing_description, set_custom_sharing_keywords;
+ private Button set_custom_sharing_save;
+ private ImageView pp_actionBar;
+ private String title, description, keywords, encodedCustomSharingURL;
+ private String bundle_url, bundle_source, bundle_id, bundle_tags, bundle_content;
+ @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);
+ }
+
+ setContentView(R.layout.activity_custom_sharing);
+
+ ActionBar actionBar = getSupportActionBar();
+ if( actionBar != null) {
+ LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
+ assert inflater != null;
+ @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.simple_action_bar, null);
+ actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
+ TextView title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
+ pp_actionBar = actionBar.getCustomView().findViewById(R.id.pp_actionBar);
+ title.setText(R.string.settings_title_profile);
+ ImageView close_conversation = actionBar.getCustomView().findViewById(R.id.close_conversation);
+ if( close_conversation != null){
+ close_conversation.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+ }
+ if (theme == THEME_LIGHT){
+ Toolbar toolbar = actionBar.getCustomView().findViewById(R.id.toolbar);
+ Helper.colorizeToolbar(toolbar, R.color.black, CustomSharingActivity.this);
+ }
+ }else{
+ setTitle(R.string.settings_title_profile);
+ }
+ SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
+ Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
+ String url = account.getAvatar();
+ if( url.startsWith("/") ){
+ url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar();
+ }
+
+ Helper.loadGiF(getApplicationContext(), url, pp_actionBar);
+ Bundle b = getIntent().getExtras();
+ if(b != null) {
+ bundle_url = b.getParcelable("url");
+ bundle_id = b.getParcelable("id");
+ bundle_source = b.getParcelable("source");
+ bundle_tags = b.getParcelable("tags");
+ bundle_content = b.getParcelable("content");
+ }
+ set_custom_sharing_title = findViewById(R.id.set_custom_sharing_title);
+ set_custom_sharing_description = findViewById(R.id.set_custom_sharing_description);
+ set_custom_sharing_keywords = findViewById(R.id.set_custom_sharing_keywords);
+ set_custom_sharing_save = findViewById(R.id.set_custom_sharing_save);
+ set_custom_sharing_save.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new CustomSharingAsyncTask(getApplicationContext(), encodedCustomSharingURL, CustomSharingActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+ });
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ public void onCustomSharing(CustomSharingResponse customSharingResponse) {
+ set_custom_sharing_save.setEnabled(true);
+ if( customSharingResponse.getError() != null){
+ Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ return;
+ }
+ Toasty.success(getApplicationContext(), getString(R.string.toast_update_credential_ok), Toast.LENGTH_LONG).show();
+ finish();
+ }
+
+}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/CustomSharingAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/CustomSharingAsyncTask.java
new file mode 100644
index 000000000..bf977a9b3
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/CustomSharingAsyncTask.java
@@ -0,0 +1,61 @@
+/* Copyright 2017 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 . */
+package fr.gouv.etalab.mastodon.asynctasks;
+
+
+import android.content.Context;
+import android.os.AsyncTask;
+
+import java.io.ByteArrayInputStream;
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+
+import fr.gouv.etalab.mastodon.client.API;
+import fr.gouv.etalab.mastodon.client.APIResponse;
+import fr.gouv.etalab.mastodon.client.CustomSharing;
+import fr.gouv.etalab.mastodon.client.CustomSharingResponse;
+import fr.gouv.etalab.mastodon.interfaces.OnCustomSharingInterface;
+import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
+
+/**
+ * Created by Curtis on 13/02/2019.
+ * Custom share status metadata to remote content aggregator
+ */
+
+public class CustomSharingAsyncTask extends AsyncTask {
+
+ private String encodedCustomSharingURL;
+ private CustomSharingResponse customSharingResponse;
+ private OnCustomSharingInterface listener;
+ private WeakReference contextReference;
+
+ public CustomSharingAsyncTask(Context context, String encodedCustomSharingURL, OnCustomSharingInterface onCustomSharingInterface){
+ this.contextReference = new WeakReference<>(context);
+ this.encodedCustomSharingURL = encodedCustomSharingURL;
+ this.listener = onCustomSharingInterface;
+ }
+
+ @Override
+ protected Void doInBackground(Void... params) {
+ customSharingResponse = new CustomSharing(this.contextReference.get()).customShare(encodedCustomSharingURL);
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void result) {
+ listener.onCustomSharing(customSharingResponse);
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/CustomSharing.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/CustomSharing.java
new file mode 100644
index 000000000..2fcb96c3c
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/CustomSharing.java
@@ -0,0 +1,145 @@
+package fr.gouv.etalab.mastodon.client;
+/* Copyright 2017 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 . */
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.support.v4.content.LocalBroadcastManager;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import fr.gouv.etalab.mastodon.R;
+import fr.gouv.etalab.mastodon.activities.MainActivity;
+import fr.gouv.etalab.mastodon.asynctasks.RetrieveOpenCollectiveAsyncTask;
+import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
+import fr.gouv.etalab.mastodon.client.Entities.Account;
+import fr.gouv.etalab.mastodon.client.Entities.Application;
+import fr.gouv.etalab.mastodon.client.Entities.Attachment;
+import fr.gouv.etalab.mastodon.client.Entities.Card;
+import fr.gouv.etalab.mastodon.client.Entities.Conversation;
+import fr.gouv.etalab.mastodon.client.Entities.Emojis;
+import fr.gouv.etalab.mastodon.client.Entities.Error;
+import fr.gouv.etalab.mastodon.client.Entities.Filters;
+import fr.gouv.etalab.mastodon.client.Entities.HowToVideo;
+import fr.gouv.etalab.mastodon.client.Entities.Instance;
+import fr.gouv.etalab.mastodon.client.Entities.InstanceNodeInfo;
+import fr.gouv.etalab.mastodon.client.Entities.InstanceSocial;
+import fr.gouv.etalab.mastodon.client.Entities.Mention;
+import fr.gouv.etalab.mastodon.client.Entities.NodeInfo;
+import fr.gouv.etalab.mastodon.client.Entities.Notification;
+import fr.gouv.etalab.mastodon.client.Entities.Peertube;
+import fr.gouv.etalab.mastodon.client.Entities.Relationship;
+import fr.gouv.etalab.mastodon.client.Entities.Results;
+import fr.gouv.etalab.mastodon.client.Entities.Schedule;
+import fr.gouv.etalab.mastodon.client.Entities.Status;
+import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
+import fr.gouv.etalab.mastodon.client.Entities.Tag;
+import fr.gouv.etalab.mastodon.fragments.DisplayNotificationsFragment;
+import fr.gouv.etalab.mastodon.helper.Helper;
+import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
+import fr.gouv.etalab.mastodon.sqlite.Sqlite;
+
+
+/**
+ * Created by Curtis on 13/02/2019.
+ * Manage custom sharing of status metadata to remote content aggregator
+ */
+
+public class CustomSharing {
+
+ private Context context;
+ private Results results;
+ private CustomSharingResponse customSharingResponse;
+ private Error CustomSharingError;
+
+ public CustomSharing(Context context) {
+ this.context = context;
+ if( context == null) {
+ CustomSharingError = new Error();
+ return;
+ }
+ customSharingResponse = new CustomSharingResponse();
+ CustomSharingError = null;
+ }
+
+ /***
+ * pass status metadata to remote content aggregator *synchronously*
+ * @return CustomSharingResponse
+ */
+ public CustomSharingResponse customShare(String encodedCustomSharingURL) {
+ String HTTPResponse = "";
+ try {
+ HTTPResponse = new HttpsConnection(context).get(encodedCustomSharingURL);
+ } catch (HttpsConnection.HttpsConnectionException e) {
+ e.printStackTrace();
+ setError(e.getStatusCode(), e);
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (KeyManagementException e) {
+ e.printStackTrace();
+ }
+ return customSharingResponse;
+ }
+
+ public Error getError(){
+ return CustomSharingError;
+ }
+
+
+ /**
+ * Set the error message
+ * @param statusCode int code
+ * @param error Throwable error
+ */
+ private void setError(int statusCode, Throwable error){
+ CustomSharingError = new Error();
+ CustomSharingError.setStatusCode(statusCode);
+ String message = statusCode + " - " + error.getMessage();
+ try {
+ JSONObject jsonObject = new JSONObject(error.getMessage());
+ String errorM = jsonObject.get("error").toString();
+ message = "Error " + statusCode + " : " + errorM;
+ } catch (JSONException e) {
+ if(error.getMessage().split(".").length > 0) {
+ String errorM = error.getMessage().split(".")[0];
+ message = "Error " + statusCode + " : " + errorM;
+ }
+ }
+ CustomSharingError.setError(message);
+ customSharingResponse.setError(CustomSharingError);
+ }
+}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/CustomSharingResponse.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/CustomSharingResponse.java
new file mode 100644
index 000000000..1874abd64
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/CustomSharingResponse.java
@@ -0,0 +1,202 @@
+package fr.gouv.etalab.mastodon.client;
+/* Copyright 2017 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 . */
+
+import android.content.Context;
+
+import java.util.List;
+
+import fr.gouv.etalab.mastodon.client.Entities.Account;
+import fr.gouv.etalab.mastodon.client.Entities.Conversation;
+import fr.gouv.etalab.mastodon.client.Entities.Emojis;
+import fr.gouv.etalab.mastodon.client.Entities.Error;
+import fr.gouv.etalab.mastodon.client.Entities.Filters;
+import fr.gouv.etalab.mastodon.client.Entities.HowToVideo;
+import fr.gouv.etalab.mastodon.client.Entities.Instance;
+import fr.gouv.etalab.mastodon.client.Entities.Notification;
+import fr.gouv.etalab.mastodon.client.Entities.Peertube;
+import fr.gouv.etalab.mastodon.client.Entities.PeertubeNotification;
+import fr.gouv.etalab.mastodon.client.Entities.Relationship;
+import fr.gouv.etalab.mastodon.client.Entities.Status;
+import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
+
+/**
+ * Created by Thomas on 03/06/2017.
+ * Hydrate response from the API
+ */
+
+public class CustomSharingResponse {
+
+ private List accounts = null;
+ private List statuses = null;
+ private List contexts = null;
+ private List conversations = null;
+ private List notifications = null;
+ private List relationships = null;
+ private List howToVideos = null;
+ private List peertubes = null;
+ private List peertubeNotifications = null;
+ private List filters = null;
+ private List domains = null;
+ private List lists = null;
+ private List emojis = null;
+ private Error error = null;
+ private String since_id, max_id;
+ private Instance instance;
+ private List storedStatuses;
+ public List getAccounts() {
+ return accounts;
+ }
+
+ public void setAccounts(List accounts) {
+ this.accounts = accounts;
+ }
+
+ public List getStatuses() {
+ return statuses;
+ }
+
+ public void setStatuses(List statuses) {
+ this.statuses = statuses;
+ }
+
+ public List getContexts() {
+ return contexts;
+ }
+
+ public void setContexts(List contexts) {
+ this.contexts = contexts;
+ }
+
+ public List getNotifications() {
+ return notifications;
+ }
+
+ public void setNotifications(List notifications) {
+ this.notifications = notifications;
+ }
+
+ public Error getError() {
+ return error;
+ }
+
+ public void setError(Error error) {
+ this.error = error;
+ }
+
+ public String getMax_id() {
+ return max_id;
+ }
+
+ public void setMax_id(String max_id) {
+ this.max_id = max_id;
+ }
+
+ public String getSince_id() {
+ return since_id;
+ }
+
+ public void setSince_id(String since_id) {
+ this.since_id = since_id;
+ }
+
+ public Instance getInstance() {
+ return instance;
+ }
+
+ public void setInstance(Instance instance) {
+ this.instance = instance;
+ }
+
+ public List getRelationships() {
+ return relationships;
+ }
+
+ public void setRelationships(List relationships) {
+ this.relationships = relationships;
+ }
+
+ public List getEmojis() {
+ return emojis;
+ }
+
+ public void setEmojis(List emojis) {
+ this.emojis = emojis;
+ }
+
+ public List getLists() {
+ return lists;
+ }
+
+ public void setLists(List lists) {
+ this.lists = lists;
+ }
+
+ public List getFilters() {
+ return filters;
+ }
+
+ public void setFilters(List filters) {
+ this.filters = filters;
+ }
+
+ public List getDomains() {
+ return domains;
+ }
+
+ public void setDomains(List domains) {
+ this.domains = domains;
+ }
+
+ public List getHowToVideos() {
+ return howToVideos;
+ }
+
+ public void setHowToVideos(List howToVideos) {
+ this.howToVideos = howToVideos;
+ }
+
+ public List getPeertubes() {
+ return peertubes;
+ }
+
+ public void setPeertubes(List peertubes) {
+ this.peertubes = peertubes;
+ }
+
+ public List getConversations() {
+ return conversations;
+ }
+
+ public void setConversations(List conversations) {
+ this.conversations = conversations;
+ }
+
+ public List getStoredStatuses() {
+ return storedStatuses;
+ }
+
+ public void setStoredStatuses(List storedStatuses) {
+ this.storedStatuses = storedStatuses;
+ }
+
+ public List getPeertubeNotifications() {
+ return peertubeNotifications;
+ }
+
+ public void setPeertubeNotifications(List peertubeNotifications) {
+ this.peertubeNotifications = peertubeNotifications;
+ }
+}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java
index f370b928c..bd118419c 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java
@@ -416,6 +416,19 @@ public class Status implements Parcelable{
return tags;
}
+ public String getTagsString() {
+ //iterate through tags and create comma delimited string of tag names
+ String tag_names = "";
+ for (Tag t : tags) {
+ if (tag_names.equals("")) {
+ tag_names = t.getName();
+ } else {
+ tag_names = tag_names + ", " + t.getName();
+ }
+ }
+ return tag_names;
+ }
+
public void setTags(List tags) {
this.tags = tags;
}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
index 54e068b92..0c2687372 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
@@ -59,6 +59,7 @@ import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
+import fr.gouv.etalab.mastodon.activities.CustomSharingActivity;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
@@ -761,6 +762,25 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
return true;
+ case R.id.action_custom_sharing:
+ Intent intentCustomSharing = new Intent(context, CustomSharingActivity.class);
+ Bundle bCustomSharing = new Bundle();
+ if (status.getReblog() != null) {
+ bCustomSharing.putString("url", status.getReblog().getUrl());
+ bCustomSharing.putString("source", status.getReblog().getAccount().getDisplay_name());
+ bCustomSharing.putString("id", status.getReblog().getId());
+ bCustomSharing.putString("tags", status.getReblog().getTagsString());
+ bCustomSharing.putString("content", status.getReblog().getContent());
+ } else {
+ bCustomSharing.putString("url", status.getUrl());
+ bCustomSharing.putString("source", status.getAccount().getDisplay_name());
+ bCustomSharing.putString("id", status.getId());
+ bCustomSharing.putString("tags", status.getTagsString());
+ bCustomSharing.putString("content", status.getContent());
+ }
+ intentCustomSharing.putExtras(bCustomSharing);
+ context.startActivity(intentCustomSharing);
+ return true;
case R.id.action_mention:
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
index da4b6683a..a455dacab 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
@@ -89,6 +89,7 @@ import java.util.regex.Pattern;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
+import fr.gouv.etalab.mastodon.activities.CustomSharingActivity;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
import fr.gouv.etalab.mastodon.activities.PeertubeActivity;
@@ -2093,6 +2094,25 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
return true;
+ case R.id.action_custom_sharing:
+ Intent intentCustomSharing = new Intent(context, CustomSharingActivity.class);
+ Bundle bCustomSharing = new Bundle();
+ if (status.getReblog() != null) {
+ bCustomSharing.putString("url", status.getReblog().getUrl());
+ bCustomSharing.putString("source", status.getReblog().getAccount().getDisplay_name());
+ bCustomSharing.putString("id", status.getReblog().getId());
+ bCustomSharing.putString("tags", status.getReblog().getTagsString());
+ bCustomSharing.putString("content", status.getReblog().getContent());
+ } else {
+ bCustomSharing.putString("url", status.getUrl());
+ bCustomSharing.putString("source", status.getAccount().getDisplay_name());
+ bCustomSharing.putString("id", status.getId());
+ bCustomSharing.putString("tags", status.getTagsString());
+ bCustomSharing.putString("content", status.getContent());
+ }
+ intentCustomSharing.putExtras(bCustomSharing);
+ context.startActivity(intentCustomSharing);
+ return true;
case R.id.action_mention:
// Get a handler that can be used to post to the main thread
final Handler handler = new Handler();
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
index bf9a91cf3..38f7c9ee6 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
@@ -287,6 +287,7 @@ public class Helper {
public static final String SET_FULL_PREVIEW = "set_full_preview";
public static final String SET_COMPACT_MODE = "set_compact_mode";
public static final String SET_SHARE_DETAILS = "set_share_details";
+ public static final String SET_CUSTOM_SHARING = "set_custom_sharing";
public static final String SET_NOTIF_SOUND = "set_notif_sound";
public static final String SET_ENABLE_TIME_SLOT = "set_enable_time_slot";
public static final String SET_KEEP_BACKGROUND_PROCESS = "set_keep_background_process";
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/interfaces/OnCustomSharingInterface.java b/app/src/main/java/fr/gouv/etalab/mastodon/interfaces/OnCustomSharingInterface.java
new file mode 100644
index 000000000..0cfc01f6c
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/interfaces/OnCustomSharingInterface.java
@@ -0,0 +1,26 @@
+/* Copyright 2017 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 . */
+package fr.gouv.etalab.mastodon.interfaces;
+
+
+import fr.gouv.etalab.mastodon.client.CustomSharingResponse;
+
+/**
+ * Created by Curtis on 13/02/2019.
+ * Interface when custom sharing to remote content aggregator occurs
+ */
+public interface OnCustomSharingInterface {
+ void onCustomSharing(CustomSharingResponse customSharingResponse);
+}
diff --git a/app/src/main/res/layout/activity_custom_sharing.xml b/app/src/main/res/layout/activity_custom_sharing.xml
new file mode 100644
index 000000000..a92615394
--- /dev/null
+++ b/app/src/main/res/layout/activity_custom_sharing.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/option_toot.xml b/app/src/main/res/menu/option_toot.xml
index 9c0c88af6..97cba5f16 100644
--- a/app/src/main/res/menu/option_toot.xml
+++ b/app/src/main/res/menu/option_toot.xml
@@ -22,6 +22,10 @@
android:id="@+id/action_share"
android:title="@string/more_action_6"
app:showAsAction="never" />
+