Change peertube instance + allow to save quick replies in drafts

This commit is contained in:
tom79 2019-07-13 17:51:05 +02:00
parent 3879a86d6e
commit 27a10a55e6
5 changed files with 42 additions and 6 deletions

View File

@ -737,7 +737,7 @@ public abstract class BaseMainActivity extends BaseActivity
Bundle bundle = new Bundle();
statusFragment = new DisplayStatusFragment();
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
String instance = "peertube.social";
String instance = "peertube.fedilab.app";
if(timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance() != null && timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance().getType().equals("PEERTUBE"))
instance = timelines.get(tabLayout.getSelectedTabPosition()).getRemoteInstance().getHost();
bundle.putString("remote_instance", instance);
@ -2226,7 +2226,7 @@ public abstract class BaseMainActivity extends BaseActivity
bundle.putString("instanceType", "ART");
}else if (tl.getType() == ManageTimelines.Type.PEERTUBE) {
bundle.putString("instanceType", "PEERTUBE");
bundle.putString("remote_instance", "peertube.social");
bundle.putString("remote_instance", "peertube.fedilab.app");
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE);
}else if( tl.getType() == ManageTimelines.Type.INSTANCE){
if( tl.getRemoteInstance().getFilteredWith() == null){

View File

@ -1863,7 +1863,7 @@ public class API {
List<HowToVideo> howToVideos = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://peertube.social/api/v1/video-channels/mastalab_channel/videos", 60, null, null);
String response = httpsConnection.get("https://peertube.fedilab.app/api/v1/video-channels/fedilab_channel/videos", 60, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
howToVideos = parseHowTos(jsonArray);
} catch (HttpsConnection.HttpsConnectionException e) {

View File

@ -116,14 +116,14 @@ public class HowToVideosAdapter extends BaseAdapter implements OnListActionInter
next.setBounds(0,0,(int) (30 * scale + 0.5f),(int) (30 * scale + 0.5f));
holder.how_to_description.setCompoundDrawables(null, null, next, null);
Glide.with(holder.how_to_image.getContext())
.load("https://peertube.social" + howToVideo.getThumbnailPath())
.load("https://peertube.fedilab.app" + howToVideo.getThumbnailPath())
.into(holder.how_to_image);
holder.how_to_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, WebviewActivity.class);
Bundle b = new Bundle();
String finalUrl = "https://peertube.social" + howToVideo.getEmbedPath();
String finalUrl = "https://peertube.fedilab.app" + howToVideo.getEmbedPath();
b.putString("url", finalUrl);
b.putBoolean("peertubeLink", true);
Pattern link = Pattern.compile("(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/videos\\/embed\\/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$");

View File

@ -126,6 +126,7 @@ import app.fedilab.android.client.Entities.Poll;
import app.fedilab.android.client.Entities.PollOptions;
import app.fedilab.android.client.Entities.Relationship;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.StoredStatus;
import app.fedilab.android.client.Entities.TagTimeline;
import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.CustomTextView;
@ -213,6 +214,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
private int stepSpliToot;
private String in_reply_to_status;
private TextView warning_message;
private Status tootReply;
private long currentToId = -1;
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
super();
@ -500,6 +503,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
return;
}
toot_content = null;
toot_cw_content = null;
tootReply = null;
currentToId = -1;
if(apiResponse.getError() == null) {
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
if( display_confirm){
@ -2510,7 +2517,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
toot_cw_content = content_cw;
toot_space_left = holder.toot_space_left;
in_reply_to_status = status.getReblog() != null ? status.getReblog().getId():status.getId();
tootReply = status;
if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK) {
changeDrawableColor(context, R.drawable.emoji_one_category_smileysandpeople, R.color.dark_text);
changeDrawableColor(context, R.drawable.ic_public_toot, R.color.dark_text);
@ -4187,4 +4194,30 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
}
public void storeToot(){
//Nothing to store here....
if (tootReply == null || (toot_content.getText().toString().trim().length() == 0 && toot_cw_content.getText().toString().trim().length() == 0))
return;
Status toot = new Status();
if( toot_cw_content.getText().toString().trim().length() > 0)
toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
toot.setVisibility(visibility);
toot.setContent(toot_content.getText().toString().trim());
toot.setIn_reply_to_id(tootReply.getId());
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
try{
if(currentToId == -1) {
currentToId = new StatusStoredDAO(context, db).insertStatus(toot, tootReply);
}else{
StoredStatus storedStatus = new StatusStoredDAO(context, db).getStatus(currentToId);
if( storedStatus != null ){
new StatusStoredDAO(context, db).updateStatus(currentToId, toot);
}else { //Might have been deleted, so it needs insertion
new StatusStoredDAO(context, db).insertStatus(toot, tootReply);
}
}
}catch (Exception ignored){ }
}
}

View File

@ -794,6 +794,9 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
@Override
public void onStop(){
super.onStop();
if( statusListAdapter != null){
statusListAdapter.storeToot();
}
if( type == RetrieveFeedsAsyncTask.Type.PUBLIC && streamingFederatedIntent != null){
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, false);