Skip to content

Commit

Permalink
Merge upstream pull request tasomaniac#89 from 1fexd:feature/89-doubl…
Browse files Browse the repository at this point in the history
…e-tap-for-just-once
  • Loading branch information
buttercookie42 committed Dec 23, 2023
2 parents 67fd93e + 4e1bc0a commit a05991e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
*/
package com.tasomaniac.openwith.resolver;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand Down Expand Up @@ -77,7 +80,7 @@ protected void onStart() {
super.onStart();
}

@Override
@SuppressLint("ClickableViewAccessibility") @Override
public void displayData(IntentResolverResult result) {
setContentView(result.getFilteredItem() != null ? R.layout.resolver_list_with_default : R.layout.resolver_list);
setupList(result, result.getShowExtended());
Expand All @@ -86,6 +89,24 @@ public void displayData(IntentResolverResult result) {
rdl.setOnDismissedListener(this::finish);
findViewById(R.id.button_always).setOnClickListener(v -> listener.onActionButtonClick(true));
findViewById(R.id.button_once).setOnClickListener(v -> listener.onActionButtonClick(false));

if(result.getFilteredItem() != null){
GestureDetector gDetector = new GestureDetector(getBaseContext(), new GestureDetector.SimpleOnGestureListener() {

@Override
public boolean onDown(MotionEvent e) {
return true;
}

@Override
public boolean onDoubleTap(MotionEvent e) {
listener.onActionButtonClick(false);
return true;
}
});

findViewById(R.id.preferred_item).setOnTouchListener((v, event) -> gDetector.onTouchEvent(event));
}
}

private void setupList(IntentResolverResult data, boolean shouldDisplayExtendedInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
app:layout_alwaysShow="true">

<LinearLayout
android:id="@+id/preferred_item"
android:layout_width="match_parent"
android:layout_height="64dp"
android:orientation="horizontal">
Expand Down

0 comments on commit a05991e

Please sign in to comment.