// Path: app/src/main/java/wseemann/media/romote/utils/ViewUtils.java
// public class ViewUtils {
// 
//     private ViewUtils() {
// 
//     }
// 
//     public static void provideHapticFeedback(View view, int vibrateDurationMs) {
//         if (PreferenceUtils.shouldProvideHapticFeedback(view.getContext())) {
//             Vibrator vibe = (Vibrator) view.getContext().getSystemService(Context.VIBRATOR_SERVICE);
//             vibe.vibrate(vibrateDurationMs);
//         }
//     }
// }


import android.content.Context;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import wseemann.media.romote.utils.ViewUtils;
/*
 * ServeStream: A HTTP stream browser/player for Android
 * Copyright 2010 William Seemann
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package wseemann.media.romote.view;



/**
 * A button that will repeatedly call a 'listener' method
 * as long as the button is pressed.
 */
public class RepeatingImageButton extends Button {

    private static final int VIBRATE_DURATION_MS = 100;

    private View.OnClickListener mClickListener;

    private long mStartTime;
    private int mRepeatCount;
    private RepeatListener mListener;
    private long mInterval = 500;
    
    public RepeatingImageButton(Context context) {
        this(context, null);
    }

    public RepeatingImageButton(Context context, AttributeSet attrs) {
        this(context, attrs, android.R.attr.buttonStyle);
    }

    public RepeatingImageButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setFocusable(true);
        setLongClickable(true);
        super.setOnClickListener((View view) -> {
// Path: app/src/main/java/wseemann/media/romote/utils/ViewUtils.java
// public class ViewUtils {
// 
//     private ViewUtils() {
// 
//     }
// 
//     public static void provideHapticFeedback(View view, int vibrateDurationMs) {
//         if (PreferenceUtils.shouldProvideHapticFeedback(view.getContext())) {
//             Vibrator vibe = (Vibrator) view.getContext().getSystemService(Context.VIBRATOR_SERVICE);
//             vibe.vibrate(vibrateDurationMs);
//         }
//     }
// }


// Path: app/src/main/java/wseemann/media/romote/view/RepeatingImageButton.java
import android.content.Context;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import wseemann.media.romote.utils.ViewUtils;

/*
 * ServeStream: A HTTP stream browser/player for Android
 * Copyright 2010 William Seemann
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package wseemann.media.romote.view;



/**
 * A button that will repeatedly call a 'listener' method
 * as long as the button is pressed.
 */
public class RepeatingImageButton extends Button {

    private static final int VIBRATE_DURATION_MS = 100;

    private View.OnClickListener mClickListener;

    private long mStartTime;
    private int mRepeatCount;
    private RepeatListener mListener;
    private long mInterval = 500;
    
    public RepeatingImageButton(Context context) {
        this(context, null);
    }

    public RepeatingImageButton(Context context, AttributeSet attrs) {
        this(context, attrs, android.R.attr.buttonStyle);
    }

    public RepeatingImageButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setFocusable(true);
        setLongClickable(true);
        super.setOnClickListener((View view) -> {
            ViewUtils.provideHapticFeedback(view, VIBRATE_DURATION_MS);