diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f63e144..ad808b1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -105,6 +105,11 @@
android:configChanges="orientation|screenSize"
android:label="@string/sepia_search"
android:windowSoftInputMode="stateAlwaysHidden" />
+
{
DisplayVideosFragment displayVideosFragment = null;
int itemId = item.getItemId();
if (itemId == R.id.navigation_subscription) {
displayVideosFragment = subscriptionFragment;
- setTitle(R.string.subscriptions);
+ setTitleCustom(R.string.subscriptions);
} else if (itemId == R.id.navigation_trending) {
- setTitle(R.string.title_trending);
+ setTitleCustom(R.string.title_trending);
displayVideosFragment = trendingFragment;
} else if (itemId == R.id.navigation_most_liked) {
- setTitle(R.string.title_most_liked);
+ setTitleCustom(R.string.title_most_liked);
displayVideosFragment = mostLikedFragment;
} else if (itemId == R.id.navigation_recently_added) {
- setTitle(R.string.title_recently_added);
+ setTitleCustom(R.string.title_recently_added);
displayVideosFragment = recentFragment;
} else if (itemId == R.id.navigation_local) {
- setTitle(R.string.title_local);
+ setTitleCustom(R.string.title_local);
displayVideosFragment = locaFragment;
} else if (itemId == R.id.navigation_discover) {
- setTitle(R.string.title_discover);
+ setTitleCustom(R.string.title_discover);
fm.beginTransaction().hide(active).show(overviewFragment).commit();
active = overviewFragment;
return true;
@@ -117,6 +121,13 @@ public class MainActivity extends AppCompatActivity {
}
};
+
+ private void setTitleCustom(int titleRId) {
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ TextView mTitle = toolbar.findViewById(R.id.toolbar_title);
+ mTitle.setText(getString(titleRId));
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -125,10 +136,15 @@ public class MainActivity extends AppCompatActivity {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
+
BottomNavigationView navView = findViewById(R.id.nav_view);
navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
+ if( getSupportActionBar() != null) {
+ getSupportActionBar().setDisplayShowTitleEnabled(false);
+ }
+
Fragment fragment = getSupportFragmentManager().findFragmentByTag("5");
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
@@ -192,9 +208,19 @@ public class MainActivity extends AppCompatActivity {
}
});
- setTitle(R.string.title_discover);
+ setTitleCustom(R.string.title_discover);
if (Helper.isLoggedIn(MainActivity.this)) {
+
+ if( BuildConfig.full_instances) {
+ ImageButton instances = toolbar.findViewById(R.id.instances);
+ instances.setVisibility(View.VISIBLE);
+ instances.setOnClickListener(v->{
+ Intent intent = new Intent(MainActivity.this, ManageInstancesActivity.class);
+ startActivity(intent);
+ overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
+ });
+ }
navView.inflateMenu(R.menu.bottom_nav_menu_connected);
new Thread(() -> {
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
@@ -369,7 +395,7 @@ public class MainActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_change_instance) {
if (BuildConfig.full_instances) {
- showRadioButtonDialogFullInstances();
+ showRadioButtonDialogFullInstances(MainActivity.this);
} else {
showRadioButtonDialog();
}
@@ -494,12 +520,12 @@ public class MainActivity extends AppCompatActivity {
}
@SuppressLint("ApplySharedPref")
- private void showRadioButtonDialogFullInstances() {
- final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
- AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
+ public static void showRadioButtonDialogFullInstances(Activity activity) {
+ final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ AlertDialog.Builder alt_bld = new AlertDialog.Builder(activity);
alt_bld.setTitle(R.string.instance_choice);
- String instance = Helper.getLiveInstance(MainActivity.this);
- final EditText input = new EditText(MainActivity.this);
+ String instance = Helper.getLiveInstance(activity);
+ final EditText input = new EditText(activity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
@@ -510,17 +536,18 @@ public class MainActivity extends AppCompatActivity {
(dialog, which) -> new Thread(() -> {
try {
String newInstance = input.getText().toString().trim();
- WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(MainActivity.this, newInstance, null).getNodeInfo();
+ WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(activity, newInstance, null).getNodeInfo();
if (instanceNodeInfo.getSoftware() != null && instanceNodeInfo.getSoftware().getName().trim().toLowerCase().compareTo("peertube") == 0) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_INSTANCE, newInstance);
editor.commit();
- runOnUiThread(() -> {
+ activity.runOnUiThread(() -> {
dialog.dismiss();
- recreate();
+ Intent intent = new Intent(activity, MainActivity.class);
+ activity.startActivity(intent);
});
} else {
- runOnUiThread(() -> Toasty.error(MainActivity.this, getString(R.string.not_valide_instance), Toast.LENGTH_LONG).show());
+ activity.runOnUiThread(() -> Toasty.error(activity, activity.getString(R.string.not_valide_instance), Toast.LENGTH_LONG).show());
}
} catch (Exception e) {
e.printStackTrace();
@@ -529,8 +556,8 @@ public class MainActivity extends AppCompatActivity {
}).start());
alt_bld.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
alt_bld.setNeutralButton(R.string.help, (dialog, which) -> {
- Intent intent = new Intent(MainActivity.this, InstancePickerActivity.class);
- startActivityForResult(intent, PICK_INSTANCE);
+ Intent intent = new Intent(activity, InstancePickerActivity.class);
+ activity.startActivityForResult(intent, PICK_INSTANCE);
});
AlertDialog alert = alt_bld.create();
alert.show();
@@ -547,7 +574,8 @@ public class MainActivity extends AppCompatActivity {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_INSTANCE, String.valueOf(data.getData()));
editor.commit();
- recreate();
+
+ finish();
}
}
}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/ManageInstancesActivity.java b/app/src/main/java/app/fedilab/fedilabtube/ManageInstancesActivity.java
new file mode 100644
index 0000000..c35582d
--- /dev/null
+++ b/app/src/main/java/app/fedilab/fedilabtube/ManageInstancesActivity.java
@@ -0,0 +1,87 @@
+package app.fedilab.fedilabtube;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of TubeLab
+ *
+ * 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.
+ *
+ * TubeLab 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 TubeLab; if not,
+ * see . */
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.view.MenuItem;
+import android.view.View;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+
+import app.fedilab.fedilabtube.databinding.ActivityManageInstancesBinding;
+import app.fedilab.fedilabtube.helper.Helper;
+
+import static app.fedilab.fedilabtube.MainActivity.PICK_INSTANCE;
+import static app.fedilab.fedilabtube.MainActivity.showRadioButtonDialogFullInstances;
+
+
+public class ManageInstancesActivity extends AppCompatActivity {
+
+ private ActivityManageInstancesBinding binding;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ binding = ActivityManageInstancesBinding.inflate(getLayoutInflater());
+ View view = binding.getRoot();
+ setContentView(view);
+ if (getSupportActionBar() != null) {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+ }
+
+ binding.actionButton.setOnClickListener(v-> showRadioButtonDialogFullInstances(ManageInstancesActivity.this));
+
+ }
+
+ @Override
+ public void onBackPressed() {
+ super.onBackPressed();
+ overridePendingTransition( R.anim.slide_out_up, R.anim.slide_in_up_down );
+ }
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ overridePendingTransition( R.anim.slide_out_up, R.anim.slide_in_up_down );
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ @SuppressLint("ApplySharedPref")
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == PICK_INSTANCE && resultCode == Activity.RESULT_OK) {
+ if (data != null && data.getData() != null) {
+ final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putString(Helper.PREF_INSTANCE, String.valueOf(data.getData()));
+ editor.commit();
+ Intent intent = new Intent(ManageInstancesActivity.this, MainActivity.class);
+ startActivity(intent);
+ finish();
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
index f57d698..65d1f1a 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java
@@ -38,6 +38,7 @@ import android.os.Looper;
import android.support.v4.media.session.MediaSessionCompat;
import android.text.Html;
import android.text.Spanned;
+import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@@ -246,7 +247,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.myPp);
- Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.myPpReply);
}
TorrentOptions torrentOptions = new TorrentOptions.Builder()
@@ -298,7 +298,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
});
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
- binding.writeCommentContainerReply.setVisibility(View.GONE);
binding.writeCommentContainer.setVisibility(View.GONE);
}
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
@@ -382,8 +381,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
comments = new ArrayList<>();
binding.closeReply.setOnClickListener(v -> closeCommentThread());
+ binding.closePost.setOnClickListener(v -> closePostComment());
- commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube));
+ commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube), false);
commentListAdapter.allCommentRemoved = PeertubeActivity.this;
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
binding.peertubeComments.setLayoutManager(mLayoutManager);
@@ -419,6 +419,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
+ binding.postCommentButton.setOnClickListener(v-> openPostComment(null, 0));
}
@@ -459,7 +460,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
- public void manageVIewCommentReply(APIResponse apiResponse) {
+ public void manageVIewCommentReply(Comment comment, APIResponse apiResponse) {
if (apiResponse == null || apiResponse.getError() != null || apiResponse.getCommentThreadData() == null) {
if (apiResponse == null || apiResponse.getError() == null)
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
@@ -469,7 +470,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
List commentThreadDataList = apiResponse.getCommentThreadData().getChildren();
commentsThread = generateCommentReply(commentThreadDataList, new ArrayList<>());
- commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube));
+ comment.setInReplyToCommentId(null);
+ comment.setTotalReplies(0);
+ commentsThread.add(0, comment);
+ commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube), true);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
binding.peertubeReply.setLayoutManager(mLayoutManager);
binding.peertubeReply.setNestedScrollingEnabled(false);
@@ -742,24 +746,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
binding.writeCommentContainer.setVisibility(View.GONE);
- binding.writeCommentContainerReply.setVisibility(View.GONE);
}
- binding.send.setOnClickListener(v -> {
- if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
- String comment = binding.addCommentWrite.getText().toString();
- if (comment.trim().length() > 0) {
- PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
- viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, comment).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
- binding.addCommentWrite.setText("");
- }
- } else {
- if (sepiaSearch) {
- Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
- } else {
- Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
- }
- }
- });
binding.peertubePlaylist.setOnClickListener(v -> {
PlaylistsVM viewModelOwnerPlaylist = new ViewModelProvider(PeertubeActivity.this).get(PlaylistsVM.class);
@@ -770,13 +757,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
- binding.writeCommentContainerReply.setVisibility(View.VISIBLE);
binding.writeCommentContainer.setVisibility(View.VISIBLE);
}
binding.peertubeComments.setVisibility(View.VISIBLE);
} else {
binding.peertubeComments.setVisibility(View.GONE);
- binding.writeCommentContainerReply.setVisibility(View.GONE);
binding.writeCommentContainer.setVisibility(View.GONE);
binding.noActionText.setText(getString(R.string.comment_no_allowed_peertube));
binding.noAction.setVisibility(View.VISIBLE);
@@ -1193,9 +1178,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
@Override
public void onBackPressed() {
- if (binding.replyThread.getVisibility() == View.VISIBLE) {
+ if(binding.postComment.getVisibility() == View.VISIBLE){
+ closePostComment();
+ } else if (binding.replyThread.getVisibility() == View.VISIBLE) {
closeCommentThread();
- } else {
+ } else {
if (playInMinimized && player != null) {
enterVideoMode();
} else {
@@ -1285,24 +1272,18 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
fullScreenDialog.show();
}
- public void openCommentThread(Comment comment, int position) {
+
+
+
+
+ public void openCommentThread(Comment comment) {
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
binding.peertubeReply.setVisibility(View.GONE);
- commentViewModel.getRepliesComment(videoUuid, comment.getId()).observe(PeertubeActivity.this, this::manageVIewCommentReply);
+ commentViewModel.getRepliesComment(videoUuid, comment.getId()).observe(PeertubeActivity.this, apiResponse->manageVIewCommentReply(comment, apiResponse));
+
- Account account = comment.getAccount();
- Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.commentAccountProfile);
- binding.commentAccountDisplayname.setText(account.getDisplayName());
- binding.commentAccountUsername.setText(account.getAcct());
- Spanned commentSpan;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- commentSpan = Html.fromHtml(comment.getText(), Html.FROM_HTML_MODE_COMPACT);
- else
- commentSpan = Html.fromHtml(comment.getText());
- binding.commentContent.setText(commentSpan);
- binding.commentDate.setText(Helper.dateDiff(PeertubeActivity.this, comment.getCreatedAt()));
binding.replyThread.setVisibility(View.VISIBLE);
TranslateAnimation animate = new TranslateAnimation(
binding.peertubeInformationContainer.getWidth(),
@@ -1324,26 +1305,33 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
});
animate.setDuration(500);
- binding.addCommentWriteReply.setText(String.format("@%s ", comment.getAccount().getAcct()));
- binding.addCommentWriteReply.setSelection(binding.addCommentWriteReply.getText().length());
binding.replyThread.startAnimation(animate);
- binding.sendReply.setOnClickListener(null);
- binding.sendReply.setOnClickListener(v -> {
- if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
- String commentView = binding.addCommentWriteReply.getText().toString();
+ }
+
+ private void sendComment(Comment comment, int position) {
+ if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
+ if( comment == null) {
+ String commentStr = binding.addCommentWrite.getText().toString();
+ if (commentStr.trim().length() > 0) {
+ PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
+ viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, commentStr).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
+ binding.addCommentWrite.setText("");
+ }
+ }else{
+ String commentView = binding.addCommentWrite.getText().toString();
if (commentView.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
viewModelComment.comment(REPLY, peertube.getId(), comment.getId(), commentView).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(REPLY, position, apiResponse1));
- binding.addCommentWriteReply.setText("");
- }
- } else {
- if (sepiaSearch) {
- Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
- } else {
- Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
+ binding.addCommentWrite.setText("");
}
}
- });
+ } else {
+ if (sepiaSearch) {
+ Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
+ } else {
+ Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
+ }
+ }
}
private void closeCommentThread() {
@@ -1371,6 +1359,86 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
binding.replyThread.startAnimation(animate);
}
+
+ public void openPostComment(Comment comment, int position) {
+ if( comment != null) {
+ binding.replyContent.setVisibility(View.VISIBLE);
+ Account account = comment.getAccount();
+ Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.commentAccountProfile);
+ binding.commentAccountDisplayname.setText(account.getDisplayName());
+ binding.commentAccountUsername.setText(account.getAcct());
+ Spanned commentSpan;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ commentSpan = Html.fromHtml(comment.getText(), Html.FROM_HTML_MODE_COMPACT);
+ else
+ commentSpan = Html.fromHtml(comment.getText());
+ binding.commentContent.setText(commentSpan);
+ binding.commentDate.setText(Helper.dateDiff(PeertubeActivity.this, comment.getCreatedAt()));
+ }else{
+ binding.replyContent.setVisibility(View.GONE);
+ }
+ binding.postComment.setVisibility(View.VISIBLE);
+ DisplayMetrics displayMetrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
+ int height = displayMetrics.heightPixels;
+ TranslateAnimation animateComment = new TranslateAnimation(
+ 0,
+ 0,
+ height,
+ binding.mediaVideo.getHeight());
+ animateComment.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ binding.peertubeInformationContainer.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+ }
+ });
+ animateComment.setDuration(500);
+ binding.postComment.startAnimation(animateComment);
+ if( comment != null) {
+ binding.addCommentWrite.setText(String.format("@%s ", comment.getAccount().getAcct()));
+ binding.addCommentWrite.setSelection(binding.addCommentWrite.getText().length());
+ }
+
+ binding.send.setOnClickListener(null);
+ binding.send.setOnClickListener(v-> sendComment(comment, position));
+ }
+
+ private void closePostComment() {
+ DisplayMetrics displayMetrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
+ int height = displayMetrics.heightPixels;
+ binding.peertubeInformationContainer.setVisibility(View.VISIBLE);
+ TranslateAnimation animateComment = new TranslateAnimation(
+ 0,
+ 0,
+ binding.mediaVideo.getHeight(),
+ height);
+ animateComment.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ binding.postComment.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+ }
+ });
+ animateComment.setDuration(500);
+ binding.postComment.startAnimation(animateComment);
+ }
+
@SuppressWarnings({"unused", "RedundantSuppression"})
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int position, APIResponse apiResponse) {
diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java
index 27b648e..1a1ff61 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java
@@ -33,6 +33,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -41,7 +42,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.PopupMenu;
-import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
@@ -59,15 +59,14 @@ import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.CommentData.Comment;
import app.fedilab.fedilabtube.client.entities.Report;
+import app.fedilab.fedilabtube.helper.CommentDecorationHelper;
import app.fedilab.fedilabtube.helper.EmojiHelper;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
import es.dmoral.toasty.Toasty;
-import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY;
-import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
public class CommentListAdapter extends RecyclerView.Adapter {
@@ -78,11 +77,13 @@ public class CommentListAdapter extends RecyclerView.Adapter comments, boolean isVideoOwner) {
+ public CommentListAdapter(List comments, boolean isVideoOwner, boolean isThread) {
this.comments = comments;
commentListAdapter = this;
this.isVideoOwner = isVideoOwner;
+ this.isThread = isThread;
}
@Override
@@ -120,6 +121,19 @@ public class CommentListAdapter extends RecyclerView.Adapter {
PopupMenu popup = new PopupMenu(context, holder.more_actions);
popup.getMenuInflater()
@@ -224,9 +238,10 @@ public class CommentListAdapter extends RecyclerView.Adapter ((PeertubeActivity) context).openCommentThread(comment, i));
- holder.comment_content.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment, i));
+
+ if (context instanceof PeertubeActivity && !isThread) {
+ holder.main_container.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
+ holder.comment_content.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
}
if (comment.getTotalReplies() > 0) {
holder.number_of_replies.setVisibility(View.VISIBLE);
@@ -269,33 +284,13 @@ public class CommentListAdapter extends RecyclerView.Adapter {
- comment.setReplyViewOpen(!comment.isReplyViewOpen());
- notifyItemChanged(i);
- });
-
- holder.send_reply.setOnClickListener(null);
- holder.send_reply.setOnClickListener(v -> {
- if (isLoggedIn(context)) {
- String commentView = holder.add_comment_write_reply.getText().toString();
- if (commentView.trim().length() > 0) {
- PostActionsVM viewModelComment = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
- viewModelComment.comment(REPLY, comment.getVideoId(), comment.getId(), commentView).observe((LifecycleOwner) context, apiResponse1 -> manageVIewPostActions(REPLY, (int) holder.main_container.getTag(), apiResponse1));
- holder.add_comment_write_reply.setText("");
- comment.setReplyViewOpen(false);
- notifyItemChanged(i);
- }
- }
- });
+ holder.post_reply_button.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i));
+ holder.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i));
}
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int i, APIResponse apiResponse) {
@@ -361,13 +356,12 @@ public class CommentListAdapter extends RecyclerView.Adapter. */
+import java.util.List;
+
+import app.fedilab.fedilabtube.client.data.CommentData;
+
+public class CommentDecorationHelper {
+
+ public static int getIndentation(String replyToCommentId, List comments){
+ return numberOfIndentation(0, replyToCommentId, comments);
+ }
+
+ private static int numberOfIndentation(int currentIdentation, String replyToCommentId, List comments) {
+
+ String targetedComment = null;
+ for(CommentData.Comment comment: comments) {
+ if( replyToCommentId.compareTo(comment.getId()) == 0) {
+ targetedComment = comment.getInReplyToCommentId();
+ break;
+ }
+ }
+ if ( targetedComment != null) {
+ currentIdentation++;
+ return numberOfIndentation(currentIdentation, targetedComment, comments);
+ }else{
+ return Math.min(currentIdentation, 5);
+ }
+ }
+}
diff --git a/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java b/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java
index eff33b5..f3efd37 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/sqlite/Sqlite.java
@@ -21,7 +21,7 @@ import android.database.sqlite.SQLiteOpenHelper;
public class Sqlite extends SQLiteOpenHelper {
- public static final int DB_VERSION = 1;
+ public static final int DB_VERSION = 2;
public static final String DB_NAME = "mastodon_etalab_db";
/***
* List of tables to manage users and data
@@ -83,6 +83,14 @@ public class Sqlite extends SQLiteOpenHelper {
+ COL_CACHE + " TEXT NOT NULL, "
+ COL_DATE + " TEXT NOT NULL)";
+ static final String COL_USER_INSTANCE = "USER_INSTANCE";
+ static final String TABLE_BOOKMARKED_INSTANCES = "BOOKMARKED_INSTANCES";
+ private final String CREATE_TABLE_STORED_INSTANCES = "CREATE TABLE "
+ + TABLE_BOOKMARKED_INSTANCES + "("
+ + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ + COL_INSTANCE + " TEXT NOT NULL, "
+ + COL_USER_ID + " TEXT NOT NULL, "
+ + COL_USER_INSTANCE + " TEXT NOT NULL)";
public Sqlite(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
@@ -101,17 +109,22 @@ public class Sqlite extends SQLiteOpenHelper {
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_USER_ACCOUNT);
db.execSQL(CREATE_TABLE_PEERTUBE_FAVOURITES);
+ db.execSQL(CREATE_TABLE_STORED_INSTANCES);
}
@Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-
+ switch (oldVersion) {
+ case 2:
+ db.execSQL("DROP TABLE IF EXISTS " +TABLE_BOOKMARKED_INSTANCES);
+ }
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch (oldVersion) {
case 1:
+ db.execSQL(CREATE_TABLE_STORED_INSTANCES);
}
}
diff --git a/app/src/main/res/anim/slide_in_up.xml b/app/src/main/res/anim/slide_in_up.xml
new file mode 100644
index 0000000..e54c8ca
--- /dev/null
+++ b/app/src/main/res/anim/slide_in_up.xml
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/slide_in_up_down.xml b/app/src/main/res/anim/slide_in_up_down.xml
new file mode 100644
index 0000000..40e7688
--- /dev/null
+++ b/app/src/main/res/anim/slide_in_up_down.xml
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/anim/slide_out_up.xml b/app/src/main/res/anim/slide_out_up.xml
new file mode 100644
index 0000000..9bd4cfa
--- /dev/null
+++ b/app/src/main/res/anim/slide_out_up.xml
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_baseline_public_24.xml b/app/src/main/res/drawable/ic_baseline_public_24.xml
index 2c9d4e3..19fb425 100644
--- a/app/src/main/res/drawable/ic_baseline_public_24.xml
+++ b/app/src/main/res/drawable/ic_baseline_public_24.xml
@@ -1,10 +1,10 @@
-
+ android:viewportHeight="24"
+ android:tint="?attr/colorControlNormal">
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 2bbecf5..eb561aa 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -43,7 +43,22 @@
app:popupTheme="@style/popupTheme"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true"
- />
+ >
+
+
+
diff --git a/app/src/main/res/layout/activity_manage_instances.xml b/app/src/main/res/layout/activity_manage_instances.xml
new file mode 100644
index 0000000..de115d9
--- /dev/null
+++ b/app/src/main/res/layout/activity_manage_instances.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_peertube.xml b/app/src/main/res/layout/activity_peertube.xml
index f32c535..3726c61 100644
--- a/app/src/main/res/layout/activity_peertube.xml
+++ b/app/src/main/res/layout/activity_peertube.xml
@@ -244,80 +244,13 @@
android:textColor="?attr/colorAccent"
android:layout_marginTop="2dp" />
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+ android:text="@string/send_comment"/>
+
-
diff --git a/app/src/main/res/layout/drawer_comment.xml b/app/src/main/res/layout/drawer_comment.xml
index 12adf1c..d6dfc9e 100644
--- a/app/src/main/res/layout/drawer_comment.xml
+++ b/app/src/main/res/layout/drawer_comment.xml
@@ -28,14 +28,23 @@
+
@@ -71,7 +81,7 @@
android:gravity="end"
android:maxLines="1"
android:textSize="12sp"
- app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/more_actions"
app:layout_constraintTop_toTopOf="parent" />
@@ -106,7 +116,7 @@
-
-
-
-
-
-
-
-
-
-
-
+ android:gravity="center"
+ android:visibility="gone"
+ android:layout_height="wrap_content"
+ android:text="@string/add_public_reply"
+ android:textColor="?attr/colorAccent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/comment_content" />