- Added Custom Sharing feature to allow Mastodon/Misskey status metadata to be shared to remote content aggregator
This commit is contained in:
parent
51e8531e24
commit
db4d67af11
|
@ -227,6 +227,11 @@
|
|||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
/>
|
||||
<activity android:name=".activities.CustomSharingActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
/>
|
||||
<activity android:name=".activities.InstanceHealthActivity"
|
||||
android:theme="@style/Base.V7.Theme.AppCompat.Dialog"
|
||||
android:excludeFromRecents="true"/>
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses>. */
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses>. */
|
||||
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<Void, Void, Void> {
|
||||
|
||||
private String encodedCustomSharingURL;
|
||||
private CustomSharingResponse customSharingResponse;
|
||||
private OnCustomSharingInterface listener;
|
||||
private WeakReference<Context> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses>. */
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses>. */
|
||||
|
||||
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<Account> accounts = null;
|
||||
private List<Status> statuses = null;
|
||||
private List<Context> contexts = null;
|
||||
private List<Conversation> conversations = null;
|
||||
private List<Notification> notifications = null;
|
||||
private List<Relationship> relationships = null;
|
||||
private List<HowToVideo> howToVideos = null;
|
||||
private List<Peertube> peertubes = null;
|
||||
private List<PeertubeNotification> peertubeNotifications = null;
|
||||
private List<Filters> filters = null;
|
||||
private List<String> domains = null;
|
||||
private List<fr.gouv.etalab.mastodon.client.Entities.List> lists = null;
|
||||
private List<Emojis> emojis = null;
|
||||
private Error error = null;
|
||||
private String since_id, max_id;
|
||||
private Instance instance;
|
||||
private List<StoredStatus> storedStatuses;
|
||||
public List<Account> getAccounts() {
|
||||
return accounts;
|
||||
}
|
||||
|
||||
public void setAccounts(List<Account> accounts) {
|
||||
this.accounts = accounts;
|
||||
}
|
||||
|
||||
public List<Status> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public void setStatuses(List<Status> statuses) {
|
||||
this.statuses = statuses;
|
||||
}
|
||||
|
||||
public List<Context> getContexts() {
|
||||
return contexts;
|
||||
}
|
||||
|
||||
public void setContexts(List<Context> contexts) {
|
||||
this.contexts = contexts;
|
||||
}
|
||||
|
||||
public List<Notification> getNotifications() {
|
||||
return notifications;
|
||||
}
|
||||
|
||||
public void setNotifications(List<Notification> 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<Relationship> getRelationships() {
|
||||
return relationships;
|
||||
}
|
||||
|
||||
public void setRelationships(List<Relationship> relationships) {
|
||||
this.relationships = relationships;
|
||||
}
|
||||
|
||||
public List<Emojis> getEmojis() {
|
||||
return emojis;
|
||||
}
|
||||
|
||||
public void setEmojis(List<Emojis> emojis) {
|
||||
this.emojis = emojis;
|
||||
}
|
||||
|
||||
public List<fr.gouv.etalab.mastodon.client.Entities.List> getLists() {
|
||||
return lists;
|
||||
}
|
||||
|
||||
public void setLists(List<fr.gouv.etalab.mastodon.client.Entities.List> lists) {
|
||||
this.lists = lists;
|
||||
}
|
||||
|
||||
public List<Filters> getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setFilters(List<Filters> filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
public List<String> getDomains() {
|
||||
return domains;
|
||||
}
|
||||
|
||||
public void setDomains(List<String> domains) {
|
||||
this.domains = domains;
|
||||
}
|
||||
|
||||
public List<HowToVideo> getHowToVideos() {
|
||||
return howToVideos;
|
||||
}
|
||||
|
||||
public void setHowToVideos(List<HowToVideo> howToVideos) {
|
||||
this.howToVideos = howToVideos;
|
||||
}
|
||||
|
||||
public List<Peertube> getPeertubes() {
|
||||
return peertubes;
|
||||
}
|
||||
|
||||
public void setPeertubes(List<Peertube> peertubes) {
|
||||
this.peertubes = peertubes;
|
||||
}
|
||||
|
||||
public List<Conversation> getConversations() {
|
||||
return conversations;
|
||||
}
|
||||
|
||||
public void setConversations(List<Conversation> conversations) {
|
||||
this.conversations = conversations;
|
||||
}
|
||||
|
||||
public List<StoredStatus> getStoredStatuses() {
|
||||
return storedStatuses;
|
||||
}
|
||||
|
||||
public void setStoredStatuses(List<StoredStatus> storedStatuses) {
|
||||
this.storedStatuses = storedStatuses;
|
||||
}
|
||||
|
||||
public List<PeertubeNotification> getPeertubeNotifications() {
|
||||
return peertubeNotifications;
|
||||
}
|
||||
|
||||
public void setPeertubeNotifications(List<PeertubeNotification> peertubeNotifications) {
|
||||
this.peertubeNotifications = peertubeNotifications;
|
||||
}
|
||||
}
|
|
@ -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<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses>. */
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2019 Curtis Rock
|
||||
|
||||
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>.
|
||||
-->
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/swipeContainer"
|
||||
android:paddingLeft="@dimen/drawer_padding"
|
||||
android:paddingRight="@dimen/drawer_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="@dimen/fab_margin"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<!-- Profile SETTINGS -->
|
||||
<TextView
|
||||
android:text="Custom Sharing"
|
||||
style="?attr/shapeBorder"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<EditText
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/set_custom_sharing_title"
|
||||
android:minLines="4"
|
||||
android:lines="4"
|
||||
android:maxLines="5"
|
||||
android:hint="Title..."
|
||||
/>
|
||||
|
||||
|
||||
<!-- Description -->
|
||||
<EditText
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/set_custom_sharing_description"
|
||||
android:minLines="4"
|
||||
android:lines="4"
|
||||
android:maxLines="5"
|
||||
android:hint="Description..."
|
||||
/>
|
||||
|
||||
|
||||
<!-- Keywords -->
|
||||
<EditText
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/set_custom_sharing_keywords"
|
||||
android:minLines="4"
|
||||
android:lines="4"
|
||||
android:maxLines="5"
|
||||
android:hint="Keywords..."
|
||||
/>
|
||||
|
||||
|
||||
<Button
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/set_custom_sharing_save"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:maxWidth="150dp"
|
||||
android:text="Submit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
@ -22,6 +22,10 @@
|
|||
android:id="@+id/action_share"
|
||||
android:title="@string/more_action_6"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_custom_sharing"
|
||||
android:title="Custom Sharing"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_copy_link"
|
||||
android:title="@string/copy_link"
|
||||
|
|
Loading…
Reference in New Issue