mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Adjust and Make older APIs recognize the tooltip onClick too
Settings Tooltip is now centered, Just as the heading in `SettingsActivity`
This commit is contained in:
parent
e3816ab399
commit
552bc1002e
4 changed files with 39 additions and 22 deletions
|
@ -62,6 +62,13 @@ class MainActivity : AppCompatActivity(),
|
|||
|
||||
// Start by showing the settings icon
|
||||
showSettingsIcon()
|
||||
|
||||
// As older APIs somehow do not recognize the xml defined onClick
|
||||
findViewById<View>(R.id.settingstooltip).setOnClickListener() {
|
||||
openSettings()
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onStart(){
|
||||
|
@ -75,6 +82,8 @@ class MainActivity : AppCompatActivity(),
|
|||
|
||||
mDetector = GestureDetectorCompat(this, this)
|
||||
mDetector.setOnDoubleTapListener(this)
|
||||
|
||||
windowManager.defaultDisplay.getMetrics(displayMetrics)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -116,7 +125,6 @@ class MainActivity : AppCompatActivity(),
|
|||
|
||||
override fun onFling(e1: MotionEvent, e2: MotionEvent, dX: Float, dY: Float): Boolean {
|
||||
|
||||
windowManager.defaultDisplay.getMetrics(displayMetrics)
|
||||
val width = displayMetrics.widthPixels
|
||||
val height = displayMetrics.heightPixels
|
||||
|
||||
|
@ -139,10 +147,12 @@ class MainActivity : AppCompatActivity(),
|
|||
// Tooltip
|
||||
override fun onSingleTapConfirmed(event: MotionEvent): Boolean {
|
||||
when(settingsIconShown) {
|
||||
true -> hideSettingsIcon()
|
||||
true -> {
|
||||
hideSettingsIcon()
|
||||
}
|
||||
false -> showSettingsIcon()
|
||||
}
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
private fun showSettingsIcon(){
|
||||
|
@ -165,15 +175,15 @@ class MainActivity : AppCompatActivity(),
|
|||
fun settingsIconOnTouch(view: View){ openSettings() }
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
return if (mDetector.onTouchEvent(event)) { true } else { super.onTouchEvent(event) }
|
||||
return if (mDetector.onTouchEvent(event)) { false } else { super.onTouchEvent(event) }
|
||||
}
|
||||
|
||||
/* TODO: Remove those. For now they are necessary
|
||||
* because this inherits from GestureDetector.OnGestureListener */
|
||||
override fun onDoubleTap(event: MotionEvent): Boolean { return true }
|
||||
override fun onDoubleTapEvent(event: MotionEvent): Boolean { return true }
|
||||
override fun onDown(event: MotionEvent): Boolean { return true }
|
||||
override fun onScroll(e1: MotionEvent, e2: MotionEvent, dX: Float, dY: Float): Boolean { return true }
|
||||
override fun onDoubleTap(event: MotionEvent): Boolean { return false }
|
||||
override fun onDoubleTapEvent(event: MotionEvent): Boolean { return false }
|
||||
override fun onDown(event: MotionEvent): Boolean { return false }
|
||||
override fun onScroll(e1: MotionEvent, e2: MotionEvent, dX: Float, dY: Float): Boolean { return false }
|
||||
override fun onShowPress(event: MotionEvent) {}
|
||||
override fun onSingleTapUp(event: MotionEvent): Boolean { return true }
|
||||
override fun onSingleTapUp(event: MotionEvent): Boolean { return false }
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.viewpager.widget.ViewPager
|
||||
import com.finnmglas.launcher.ui.main.SectionsPagerAdapter
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
|
|
|
@ -43,15 +43,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:onClick="settingsIconOnTouch"
|
||||
android:text="@string/fas_settings"
|
||||
android:textColor="#ccc"
|
||||
android:textColor="#999"
|
||||
android:textSize="36sp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.95"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.95"
|
||||
custom:type="solid"/>
|
||||
custom:type="solid" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -14,10 +14,9 @@
|
|||
android:background="@color/colorPrimaryDark"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
@ -28,13 +27,17 @@
|
|||
android:padding="@dimen/appbar_padding"
|
||||
android:text="@string/settings_title"
|
||||
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
|
||||
android:textSize="30sp" />
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.finnmglas.launcher.FontAwesome
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/fa"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center|right"
|
||||
android:id="@+id/close_settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="true"
|
||||
android:onClick="backHome"
|
||||
android:paddingLeft="16sp"
|
||||
|
@ -42,14 +45,18 @@
|
|||
android:text="@string/fa_close_window"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="22sp"
|
||||
custom:type="solid"/>
|
||||
</LinearLayout>
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
custom:type="solid" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimaryDark" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
|
|
Loading…
Add table
Reference in a new issue