Improvements with Friendica and GNU
This commit is contained in:
parent
70010afa92
commit
3c9c0a2057
|
@ -258,7 +258,6 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
social = UpdateAccountInfoAsyncTask.SOCIAL.GNU;
|
||||
else if( account.getSocial().equals("FRIENDICA"))
|
||||
social = UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA;
|
||||
Log.v(Helper.TAG, account.getSocial());
|
||||
countNewStatus = 0;
|
||||
countNewNotifications = 0;
|
||||
|
||||
|
@ -469,6 +468,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
typePosition.put(i, RetrieveFeedsAsyncTask.Type.GNU_LOCAL);
|
||||
i++;
|
||||
}
|
||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||
display_global = false;
|
||||
if( display_global) {
|
||||
tabLayout.addTab(tabPublic);
|
||||
tabPosition.put("global", i);
|
||||
|
@ -590,7 +591,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
countPage++;
|
||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true))
|
||||
countPage++;
|
||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true))
|
||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true) && social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA )
|
||||
countPage++;
|
||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_ART, true)&& social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||
countPage++;
|
||||
|
@ -1124,7 +1125,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
query= query.replaceAll("^#+", "");
|
||||
//It's not a peertube search
|
||||
if(displayPeertube == null){
|
||||
if( social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
if( social != UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
|
||||
Intent intent = new Intent(BaseMainActivity.this, SearchResultActivity.class);
|
||||
intent.putExtra("search", query);
|
||||
startActivity(intent);
|
||||
|
|
|
@ -616,6 +616,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
}
|
||||
});
|
||||
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
||||
toot_content.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
|
|
@ -21,9 +21,11 @@ import android.os.AsyncTask;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.GNUAPI;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
|
||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||
|
@ -59,6 +61,8 @@ public class RetrieveSearchAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
||||
if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
API api = new API(this.contextReference.get());
|
||||
if (!tagsOnly)
|
||||
results = api.search(query);
|
||||
|
@ -85,6 +89,12 @@ public class RetrieveSearchAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
}
|
||||
error = api.getError();
|
||||
}else {
|
||||
GNUAPI gnuapi = new GNUAPI(this.contextReference.get());
|
||||
results = gnuapi.search(query);
|
||||
error = gnuapi.getError();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,9 +59,11 @@ import java.util.regex.Pattern;
|
|||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.activities.HashTagActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.PeertubeActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.helper.CrossActions;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface;
|
||||
|
@ -1087,12 +1089,14 @@ public class Status implements Parcelable{
|
|||
spannableStringT.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View textView) {
|
||||
if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
Intent intent = new Intent(context, HashTagActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("tag", tag.substring(1));
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
|
|
|
@ -68,18 +68,15 @@ public class GNUAPI {
|
|||
|
||||
private Account account;
|
||||
private Context context;
|
||||
private Results results;
|
||||
private Attachment attachment;
|
||||
private List<Account> accounts;
|
||||
private List<Status> statuses;
|
||||
private List<Conversation> conversations;
|
||||
private int tootPerPage, accountPerPage, notificationPerPage;
|
||||
private int actionCode;
|
||||
private String instance;
|
||||
private String prefKeyOauthTokenT;
|
||||
private APIResponse apiResponse;
|
||||
private Error APIError;
|
||||
private List<String> domains;
|
||||
|
||||
public enum accountPrivacy {
|
||||
PUBLIC,
|
||||
|
@ -248,7 +245,7 @@ public class GNUAPI {
|
|||
response = new HttpsConnection(context).get(getAbsoluteUrl("/friendships/show.json"), 60, params, prefKeyOauthTokenT);
|
||||
relationship = parseRelationshipResponse(new JSONObject(response));
|
||||
}else if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
params.put("target_id",accountId);
|
||||
params.put("user_id",accountId);
|
||||
response = new HttpsConnection(context).get(getAbsoluteUrl("/users/show.json"), 60, params, prefKeyOauthTokenT);
|
||||
JSONObject resobj = new JSONObject(response);
|
||||
try {
|
||||
|
@ -610,7 +607,7 @@ public class GNUAPI {
|
|||
if (0 > limit || limit > 80)
|
||||
limit = 80;
|
||||
params.put("limit",String.valueOf(limit));
|
||||
conversations = new ArrayList<>();
|
||||
List<Conversation> conversations = new ArrayList<>();
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/conversations"), 60, params, prefKeyOauthTokenT);
|
||||
|
@ -1572,6 +1569,44 @@ public class GNUAPI {
|
|||
return attachment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves Accounts and feeds when searching *synchronously*
|
||||
*
|
||||
* @param query String search
|
||||
* @return Results
|
||||
*/
|
||||
public Results search(String query) {
|
||||
Results results = new Results();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
|
||||
params.put("q", query);
|
||||
else
|
||||
try {
|
||||
params.put("q", URLEncoder.encode(query, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
params.put("q", query);
|
||||
}
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(getAbsoluteUrl("/users/search.json"), 60, params, prefKeyOauthTokenT);
|
||||
List<Account> accounts = parseAccountResponse(new JSONArray(response));
|
||||
results.setAccounts(accounts);
|
||||
} 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();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Accounts and feeds when searching *synchronously*
|
||||
*
|
||||
|
|
|
@ -831,6 +831,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
});
|
||||
//Click on a conversation
|
||||
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA)
|
||||
if ((getItemViewType(viewHolder.getAdapterPosition()) == DISPLAYED_STATUS || getItemViewType(viewHolder.getAdapterPosition()) == COMPACT_STATUS)) {
|
||||
holder.status_content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue