Add a double click application

That can be opened by clicking twice.

Closes #34

Also:
+ adjust text color in tutorial
+ some other small adjustments
This commit is contained in:
Finn M Glas 2020-05-27 14:33:55 +02:00
parent 2b4a2c6757
commit b906d7b86d
No known key found for this signature in database
GPG key ID: 25037A2E81AB459C
9 changed files with 40 additions and 7 deletions

View file

@ -8,7 +8,6 @@ import android.view.WindowManager
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.finnmglas.launcher.choose.AppsRecyclerAdapter import com.finnmglas.launcher.choose.AppsRecyclerAdapter
import com.finnmglas.launcher.extern.* import com.finnmglas.launcher.extern.*
import kotlinx.android.synthetic.main.activity_choose.* import kotlinx.android.synthetic.main.activity_choose.*

View file

@ -177,6 +177,11 @@ class MainActivity : AppCompatActivity(),
override fun onLongPress(event: MotionEvent) { openSettings() } override fun onLongPress(event: MotionEvent) { openSettings() }
override fun onDoubleTap(event: MotionEvent): Boolean {
launchApp(doubleClickApp, this)
return false
}
// Tooltip // Tooltip
override fun onSingleTapConfirmed(event: MotionEvent): Boolean { override fun onSingleTapConfirmed(event: MotionEvent): Boolean {
when(settingsIconShown) { when(settingsIconShown) {
@ -213,7 +218,6 @@ class MainActivity : AppCompatActivity(),
/* TODO: Remove those. For now they are necessary /* TODO: Remove those. For now they are necessary
* because this inherits from GestureDetector.OnGestureListener */ * because this inherits from GestureDetector.OnGestureListener */
override fun onDoubleTap(event: MotionEvent): Boolean { return false }
override fun onDoubleTapEvent(event: MotionEvent): Boolean { return false } override fun onDoubleTapEvent(event: MotionEvent): Boolean { return false }
override fun onDown(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 onScroll(e1: MotionEvent, e2: MotionEvent, dX: Float, dY: Float): Boolean { return false }

View file

@ -29,6 +29,7 @@ var rightApp = ""
var leftApp = "" var leftApp = ""
var volumeUpApp = "" var volumeUpApp = ""
var volumeDownApp = "" var volumeDownApp = ""
var doubleClickApp = ""
var calendarApp = "" var calendarApp = ""
var clockApp = "" var clockApp = ""
@ -40,10 +41,10 @@ var vibrantColor = 0
/** REQUEST CODES */ /** REQUEST CODES */
val REQUEST_PICK_IMAGE = 1 const val REQUEST_PICK_IMAGE = 1
val REQUEST_CHOOSE_APP = 2 const val REQUEST_CHOOSE_APP = 2
val REQUEST_UNINSTALL = 3 const val REQUEST_UNINSTALL = 3
val REQUEST_PERMISSION_STORAGE = 4 const val REQUEST_PERMISSION_STORAGE = 4
/** Animate */ /** Animate */
@ -210,6 +211,8 @@ fun loadSettings(sharedPref : SharedPreferences){
volumeUpApp = sharedPref.getString("action_volumeUpApp", "").toString() volumeUpApp = sharedPref.getString("action_volumeUpApp", "").toString()
volumeDownApp = sharedPref.getString("action_volumeDownApp", "").toString() volumeDownApp = sharedPref.getString("action_volumeDownApp", "").toString()
doubleClickApp = sharedPref.getString("action_doubleClickApp", "").toString()
calendarApp = sharedPref.getString("action_calendarApp", "").toString() calendarApp = sharedPref.getString("action_calendarApp", "").toString()
clockApp = sharedPref.getString("action_clockApp", "").toString() clockApp = sharedPref.getString("action_clockApp", "").toString()

View file

@ -41,6 +41,7 @@ class SettingsFragmentApps : Fragment() {
setButtonColor(fragment_settings_apps_choose_right_btn, vibrantColor) setButtonColor(fragment_settings_apps_choose_right_btn, vibrantColor)
setButtonColor(fragment_settings_apps_choose_vol_up_btn, vibrantColor) setButtonColor(fragment_settings_apps_choose_vol_up_btn, vibrantColor)
setButtonColor(fragment_settings_apps_choose_vol_down_btn, vibrantColor) setButtonColor(fragment_settings_apps_choose_vol_down_btn, vibrantColor)
setButtonColor(fragment_settings_apps_choose_double_click_btn, vibrantColor)
setButtonColor(fragment_settings_apps_btn, vibrantColor) setButtonColor(fragment_settings_apps_btn, vibrantColor)
setButtonColor(fragment_settings_apps_install_btn, vibrantColor) setButtonColor(fragment_settings_apps_install_btn, vibrantColor)
@ -53,6 +54,7 @@ class SettingsFragmentApps : Fragment() {
fragment_settings_apps_choose_right_btn.setOnClickListener{ chooseApp("rightApp") } fragment_settings_apps_choose_right_btn.setOnClickListener{ chooseApp("rightApp") }
fragment_settings_apps_choose_vol_up_btn.setOnClickListener{ chooseApp("volumeUpApp")} fragment_settings_apps_choose_vol_up_btn.setOnClickListener{ chooseApp("volumeUpApp")}
fragment_settings_apps_choose_vol_down_btn.setOnClickListener{ chooseApp("volumeDownApp")} fragment_settings_apps_choose_vol_down_btn.setOnClickListener{ chooseApp("volumeDownApp")}
fragment_settings_apps_choose_double_click_btn.setOnClickListener { chooseApp("doubleClickApp") }
// App management buttons // App management buttons
fragment_settings_apps_btn.setOnClickListener{ fragment_settings_apps_btn.setOnClickListener{

View file

@ -65,7 +65,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:onClick="clickAnywhere" android:onClick="clickAnywhere"
android:textColor="#ccc"
android:textSize="64sp" android:textSize="64sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View file

@ -157,6 +157,29 @@
</TableRow> </TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/fragment_settings_apps_choose_double_click_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:text="@string/settings_choose_double_click"
android:textSize="20sp" />
<Button
android:id="@+id/fragment_settings_apps_choose_double_click_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_choose_btn"
android:textAllCaps="false" />
</TableRow>
</TableLayout> </TableLayout>
<Button <Button

View file

@ -21,6 +21,7 @@
<string name="settings_choose_right">Rechtswischen</string> <string name="settings_choose_right">Rechtswischen</string>
<string name="settings_choose_vol_up">Lautstärke +</string> <string name="settings_choose_vol_up">Lautstärke +</string>
<string name="settings_choose_vol_down">Lautstärke -</string> <string name="settings_choose_vol_down">Lautstärke -</string>
<string name="settings_choose_double_click">Doppelklick</string>
<string name="settings_choose_btn">App wählen</string> <string name="settings_choose_btn">App wählen</string>
<string name="settings_select_launcher">Launcher wählen</string> <string name="settings_select_launcher">Launcher wählen</string>

View file

@ -21,6 +21,7 @@
<string name="settings_choose_right">Balayez droit</string> <string name="settings_choose_right">Balayez droit</string>
<string name="settings_choose_vol_up">Monter volume</string> <string name="settings_choose_vol_up">Monter volume</string>
<string name="settings_choose_vol_down">Baisser volume</string> <string name="settings_choose_vol_down">Baisser volume</string>
<string name="settings_choose_double_click">Double clic</string>
<string name="settings_choose_btn">Choisir App</string> <string name="settings_choose_btn">Choisir App</string>
<string name="settings_select_launcher">Choisir Launcher</string> <string name="settings_select_launcher">Choisir Launcher</string>

View file

@ -29,6 +29,7 @@
<string name="settings_choose_right">Swipe Right</string> <string name="settings_choose_right">Swipe Right</string>
<string name="settings_choose_vol_up">Volume Up</string> <string name="settings_choose_vol_up">Volume Up</string>
<string name="settings_choose_vol_down">Volume Down</string> <string name="settings_choose_vol_down">Volume Down</string>
<string name="settings_choose_double_click">Double Click</string>
<string name="settings_choose_btn">Choose App</string> <string name="settings_choose_btn">Choose App</string>
<string name="settings_select_launcher">Select Launcher</string> <string name="settings_select_launcher">Select Launcher</string>