Some fixes

This commit is contained in:
Thomas 2020-11-17 18:10:45 +01:00
parent 9d599e8b57
commit 8cc8b284ce
3 changed files with 36 additions and 12 deletions

View File

@ -8,6 +8,6 @@
<color name="tag_color_text">#FAFAFA</color>
<color name="positive_thumbs">#2b90d9</color>
<color name="negative_thumbs">#F44336</color>
<color name="backgroundDark">#DD000000</color>
<color name="red_1">#F44336</color>
</resources>

View File

@ -28,6 +28,7 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
@ -40,6 +41,7 @@ import android.text.Spanned;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
@ -180,6 +182,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
private videoOrientation videoOrientationType;
private int initialOrientation;
private String currentResolution;
private String currentCaption;
public static void hideKeyboard(Activity activity) {
if (activity != null && activity.getWindow() != null) {
@ -538,6 +541,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
currentResolution = null;
show_more_content = null;
currentCaption = "null";
binding.peertubeDescriptionMore.setVisibility(View.GONE);
if (autoFullscreen && autoPlay) {
openFullscreenDialog();
@ -1633,6 +1637,27 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (MotionEvent.ACTION_UP == event.getAction()) {
Rect viewRectParams = new Rect();
binding.videoParams.getGlobalVisibleRect(viewRectParams);
if (binding.videoParams.getVisibility() == View.VISIBLE && !viewRectParams.contains((int) event.getRawX(), (int) event.getRawY())) {
closeMainMenuOptions();
return true;
}
Rect viewRectParamsSub = new Rect();
binding.videoParamsSubmenu.getGlobalVisibleRect(viewRectParamsSub);
if (binding.videoParamsSubmenu.getVisibility() == View.VISIBLE && !viewRectParamsSub.contains((int) event.getRawX(), (int) event.getRawY())) {
closeSubMenuMenuOptions();
return true;
}
}
return super.dispatchTouchEvent(event);
}
private void updateHistory(long position) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean storeInHistory = sharedpreferences.getBoolean(getString(R.string.set_store_in_history), true);
@ -1720,20 +1745,18 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
case CAPTION:
binding.subMenuTitle.setText(R.string.pickup_captions);
items = new ArrayList<>();
items.add(new MenuItemView(-1, "null", getString(R.string.none)));
items.add(new MenuItemView(-1, "null", getString(R.string.none), currentCaption.compareTo("null") == 0));
int i = 0;
for (Caption caption : captions) {
items.add(new MenuItemView(i, caption.getLanguage().getId(), caption.getLanguage().getLabel()));
items.add(new MenuItemView(i, caption.getLanguage().getId(), caption.getLanguage().getLabel(), currentCaption.compareTo(caption.getLanguage().getId()) == 0));
}
break;
}
if (items != null) {
MenuItemAdapter menuItemAdapter = new MenuItemAdapter(action, items);
menuItemAdapter.itemAction = this;
binding.subMenuRecycler.setAdapter(menuItemAdapter);
binding.subMenuRecycler.setLayoutManager(new LinearLayoutManager(PeertubeActivity.this));
openSubMenuMenuOptions();
}
MenuItemAdapter menuItemAdapter = new MenuItemAdapter(action, items);
menuItemAdapter.itemAction = this;
binding.subMenuRecycler.setAdapter(menuItemAdapter);
binding.subMenuRecycler.setLayoutManager(new LinearLayoutManager(PeertubeActivity.this));
openSubMenuMenuOptions();
}
@Override
@ -1778,6 +1801,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
uri = Uri.parse("https://" + peertubeInstance + captions.get(item.getId()).getCaptionPath());
}
}
currentCaption = item.getStrId();
long newPosition = player.getCurrentPosition();
if (player != null)

View File

@ -50,11 +50,11 @@ public class MenuItemView {
this.selected = false;
}
public MenuItemView(int id, String strId, String label) {
public MenuItemView(int id, String strId, String label, boolean selected) {
this.id = id;
this.strId = strId;
this.label = label;
this.selected = false;
this.selected = selected;
}