mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Add code for a settings activity
This commit is contained in:
parent
88079de6bc
commit
20f2c6ccab
3 changed files with 73 additions and 4 deletions
|
@ -23,10 +23,10 @@
|
||||||
<activity android:name=".ChooseActivity"
|
<activity android:name=".ChooseActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
tools:ignore="LockedOrientationActivity">
|
tools:ignore="LockedOrientationActivity">
|
||||||
<intent-filter>
|
</activity>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<activity android:name=".SettingsActivity"
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
android:screenOrientation="portrait"
|
||||||
</intent-filter>
|
tools:ignore="LockedOrientationActivity">
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
59
app/src/main/java/com/finnmglas/launcher/SettingsActivity.kt
Normal file
59
app/src/main/java/com/finnmglas/launcher/SettingsActivity.kt
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
package com.finnmglas.launcher
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.content.pm.ResolveInfo
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.DisplayMetrics
|
||||||
|
import android.view.KeyEvent
|
||||||
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
|
import android.view.WindowManager
|
||||||
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.MotionEventCompat
|
||||||
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
import kotlin.math.abs
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.concurrent.fixedRateTimer
|
||||||
|
|
||||||
|
|
||||||
|
class SettingsActivity : AppCompatActivity() {
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
if(requestCode == 5000)
|
||||||
|
{
|
||||||
|
val value = data?.getStringExtra("value")
|
||||||
|
val forApp = data?.getStringExtra("forApp") ?: return
|
||||||
|
|
||||||
|
if (forApp == "downApp") downApp = value.toString()
|
||||||
|
else if (forApp == "upApp") upApp = value.toString()
|
||||||
|
else if (forApp == "leftApp") leftApp = value.toString()
|
||||||
|
else if (forApp == "rightApp") rightApp = value.toString()
|
||||||
|
else if (forApp == "volumeDownApp") volumeDownApp = value.toString()
|
||||||
|
else if (forApp == "volumeUpApp") volumeUpApp = value.toString()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun chooseApp() {
|
||||||
|
val intent = Intent(this, ChooseActivity::class.java)
|
||||||
|
intent.putExtra("action", "pick") // why choose an app
|
||||||
|
intent.putExtra("forApp", "downApp") // which app we choose
|
||||||
|
startActivityForResult(intent, 5000)
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n") // I do not care
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||||
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_settings)
|
||||||
|
}
|
||||||
|
}
|
10
app/src/main/res/layout/activity_settings.xml
Normal file
10
app/src/main/res/layout/activity_settings.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorPrimaryDark"
|
||||||
|
tools:context=".SettingsActivity">
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Add table
Reference in a new issue