mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Implement a settings menu and connect the chooser to it
This commit is contained in:
parent
e2915dcfe7
commit
44c31dd3a3
4 changed files with 197 additions and 6 deletions
|
@ -3,11 +3,12 @@ package com.finnmglas.launcher
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.View.OnLongClickListener
|
||||
import android.view.View.OnTouchListener
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
@ -18,6 +19,7 @@ import java.util.*
|
|||
import kotlin.concurrent.fixedRateTimer
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
var upApp = "org.mozilla.firefox"
|
||||
var downApp = "com.samsung.android.app.galaxyfinder"
|
||||
var rightApp = "com.samsung.android.email.provider"
|
||||
|
@ -49,7 +51,7 @@ class MainActivity : AppCompatActivity() {
|
|||
applicationContext.startActivity(intent2)
|
||||
overridePendingTransition(0,0)
|
||||
} else {
|
||||
Toast.makeText(this, "Package '$packageName' not found.", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, "Package '$packageName' not found. Change your Settings.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,10 +40,17 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun chooseApp() {
|
||||
fun chooseDownApp(view: View) {chooseApp("downApp")}
|
||||
fun chooseUpApp(view: View) {chooseApp("upApp")}
|
||||
fun chooseLeftApp(view: View) {chooseApp("leftApp")}
|
||||
fun chooseRightApp(view: View) {chooseApp("rightApp")}
|
||||
fun chooseVolumeDownApp(view: View) {chooseApp("volumeDownApp")}
|
||||
fun chooseVolumeUpApp(view: View) {chooseApp("volumeUpApp")}
|
||||
|
||||
fun chooseApp(forAction :String) {
|
||||
val intent = Intent(this, ChooseActivity::class.java)
|
||||
intent.putExtra("action", "pick") // why choose an app
|
||||
intent.putExtra("forApp", "downApp") // which app we choose
|
||||
intent.putExtra("forApp", forAction) // which app we choose
|
||||
startActivityForResult(intent, 5000)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorPrimaryDark"
|
||||
android:longClickable="false"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
|
@ -13,7 +14,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center_vertical"
|
||||
android:onClick="launchCalendar"
|
||||
android:textColor="#fff"
|
||||
android:textColor="#ccc"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -27,7 +28,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center_vertical"
|
||||
android:onClick="launchClock"
|
||||
android:textColor="#fff"
|
||||
android:textColor="#ccc"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -7,4 +7,185 @@
|
|||
android:background="?attr/colorPrimaryDark"
|
||||
tools:context=".SettingsActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/heading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Settings"
|
||||
android:textColor="#cccccc"
|
||||
android:textSize="36sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.100000024" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sub_head_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Actions"
|
||||
android:textColor="#999"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias=".1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.189" />
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/actionschooser"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/sub_head_1"
|
||||
app:layout_constraintVertical_bias="0.120000005">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_up"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Swipe Up"
|
||||
android:textColor="#ccc"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_choose_up"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseUpApp"
|
||||
android:text="Choose App" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_down"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Swipe Down"
|
||||
android:textColor="#ccc"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_choose_down"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseDownApp"
|
||||
android:text="Choose App" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Swipe Left"
|
||||
android:textColor="#ccc"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_choose_left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseLeftApp"
|
||||
android:text="Choose App" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Swipe Right"
|
||||
android:textColor="#ccc"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_choose_right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseRightApp"
|
||||
android:text="Choose App" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_vol_up"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Volume Up"
|
||||
android:textColor="#ccc"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_choose_volume_up"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseVolumeUpApp"
|
||||
android:text="Choose App" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_vol_down"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Volume Down "
|
||||
android:textColor="#ccc"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_choose_volume_down"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="chooseVolumeDownApp"
|
||||
android:text="Choose App" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
|
||||
enter image description here
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sub_head_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="About"
|
||||
android:textColor="#999"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/actionschooser"
|
||||
app:layout_constraintVertical_bias="0.65" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Add table
Reference in a new issue