mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Clean up code in the Choose Activity
This branch now does way more than just fixing the back screen issue. It became more of a cleanup branch to be merged into master ^^
This commit is contained in:
parent
b8d1880fbc
commit
12357583c6
4 changed files with 26 additions and 29 deletions
|
@ -1,6 +1,5 @@
|
||||||
package com.finnmglas.launcher
|
package com.finnmglas.launcher
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
@ -18,11 +17,8 @@ class ChooseActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val UNINSTALL_REQUEST_CODE = 1
|
val UNINSTALL_REQUEST_CODE = 1
|
||||||
|
|
||||||
fun backHome(view: View) {
|
/** Activity Lifecycle functions */
|
||||||
finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n") // I do not care
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -36,13 +32,13 @@ class ChooseActivity : AppCompatActivity() {
|
||||||
val forApp = bundle.getString("forApp") // which app we choose
|
val forApp = bundle.getString("forApp") // which app we choose
|
||||||
|
|
||||||
if (action == "launch")
|
if (action == "launch")
|
||||||
heading.text = "Launch Apps"
|
heading.text = getString(R.string.choose_title_launch)
|
||||||
else if (action == "pick") {
|
else if (action == "pick") {
|
||||||
heading.text = "Choose App"
|
heading.text = getString(R.string.choose_title)
|
||||||
subheading.text = forApp
|
subheading.text = forApp // TODO: make translatable
|
||||||
}
|
}
|
||||||
else if (action == "uninstall")
|
else if (action == "uninstall")
|
||||||
heading.text = "Uninstall Apps"
|
heading.text = getString(R.string.choose_title_remove)
|
||||||
|
|
||||||
/* Build Layout */
|
/* Build Layout */
|
||||||
|
|
||||||
|
@ -95,28 +91,21 @@ class ChooseActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
requestCode: Int,
|
|
||||||
resultCode: Int,
|
|
||||||
data: Intent?
|
|
||||||
) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
if (requestCode == UNINSTALL_REQUEST_CODE) {
|
if (requestCode == UNINSTALL_REQUEST_CODE) {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
Toast.makeText(
|
Toast.makeText(this, getString(R.string.choose_removed_toast), Toast.LENGTH_LONG).show()
|
||||||
this,
|
|
||||||
"Removed the selected application",
|
|
||||||
Toast.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
finish()
|
finish()
|
||||||
} else if (resultCode == Activity.RESULT_FIRST_USER) {
|
} else if (resultCode == Activity.RESULT_FIRST_USER) {
|
||||||
Toast.makeText(
|
Toast.makeText(this, getString(R.string.choose_not_removed_toast), Toast.LENGTH_LONG).show()
|
||||||
this,
|
|
||||||
"Can't remove this app",
|
|
||||||
Toast.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** onClick functions */
|
||||||
|
|
||||||
|
fun backHome(view: View) { finish() }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.GestureDetectorCompat
|
import androidx.core.view.GestureDetectorCompat
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
@ -33,7 +32,7 @@ class MainActivity : AppCompatActivity(),
|
||||||
|
|
||||||
// get device dimensions
|
// get device dimensions
|
||||||
private val displayMetrics = DisplayMetrics()
|
private val displayMetrics = DisplayMetrics()
|
||||||
private var clockTimer = Timer();
|
private var clockTimer = Timer()
|
||||||
|
|
||||||
/** Activity Lifecycle functions */
|
/** Activity Lifecycle functions */
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
android:id="@+id/heading"
|
android:id="@+id/heading"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Choose App"
|
android:text="@string/choose_title"
|
||||||
android:textColor="#cccccc"
|
android:textColor="#cccccc"
|
||||||
android:textSize="36sp"
|
android:textSize="36sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
@ -55,11 +55,10 @@
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:onClick="backHome"
|
android:onClick="backHome"
|
||||||
android:text="Back to Settings"
|
android:text="@string/choose_back_settings"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|
|
@ -24,6 +24,16 @@
|
||||||
|
|
||||||
<string name="settings_footer_by">By</string>
|
<string name="settings_footer_by">By</string>
|
||||||
|
|
||||||
|
<!-- Choose Activity -->
|
||||||
|
<string name="choose_title">Choose App</string>
|
||||||
|
<string name="choose_title_launch">Launch Apps</string>
|
||||||
|
<string name="choose_title_remove">Uninstall Apps</string>
|
||||||
|
|
||||||
|
<string name="choose_back_settings">Back to Settings</string>
|
||||||
|
|
||||||
|
<string name="choose_removed_toast">Removed the selected application</string>
|
||||||
|
<string name="choose_not_removed_toast">Unable to remove application</string>
|
||||||
|
|
||||||
<!-- Errors, Exceptions (Alerts, Toasts ...) -->
|
<!-- Errors, Exceptions (Alerts, Toasts ...) -->
|
||||||
<string name="none_found">None found</string>
|
<string name="none_found">None found</string>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue