Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Haptic Feedback #172

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions app/src/main/java/app/olauncher/ui/AppDrawerAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.olauncher.ui

import android.view.HapticFeedbackConstants
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -113,14 +114,30 @@ class AppDrawerAdapter(
otherProfileIndicator.visibility = View.GONE
else otherProfileIndicator.visibility = View.VISIBLE

appTitle.setOnClickListener { listener(appModel) }
appTitle.setOnClickListener {
withClickHapticFeedback(
itemView,
listener(appModel)
)
}
appTitle.setOnLongClickListener {
itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
appHideLayout.visibility = View.VISIBLE
true
}

appInfo.setOnClickListener { appInfoListener(appModel) }
appInfo.setOnClickListener {
withClickHapticFeedback(
itemView,
appInfoListener(appModel)
)
}
appHideLayout.setOnClickListener { appHideLayout.visibility = View.GONE }
}

private fun withClickHapticFeedback(view: View, listener: Unit) {
view.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
return listener
}
}
}
6 changes: 3 additions & 3 deletions app/src/main/java/app/olauncher/ui/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import android.annotation.SuppressLint
import android.app.admin.DevicePolicyManager
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.Vibrator
import android.os.*
import android.provider.Settings
import android.view.*
import android.widget.TextView
Expand Down Expand Up @@ -61,6 +59,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
}

override fun onClick(view: View) {
view.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
when (view.id) {
R.id.lock -> {
}
Expand All @@ -79,6 +78,7 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener
}

override fun onLongClick(view: View): Boolean {
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
when (view.id) {
R.id.homeApp1 -> showAppList(Constants.FLAG_SET_HOME_APP_1, prefs.appName1.isNotEmpty(), true)
R.id.homeApp2 -> showAppList(Constants.FLAG_SET_HOME_APP_2, prefs.appName2.isNotEmpty(), true)
Expand Down