-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert settings and about activities to Kotlin
- Loading branch information
1 parent
4d6176d
commit 751b95b
Showing
4 changed files
with
93 additions
and
100 deletions.
There are no files selected for viewing
55 changes: 0 additions & 55 deletions
55
app/src/main/java/tk/wasdennnoch/scoop/ui/AboutActivity.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
app/src/main/java/tk/wasdennnoch/scoop/ui/AboutActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package tk.wasdennnoch.scoop.ui | ||
|
||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.os.Bundle | ||
import android.view.MenuItem | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.content.pm.PackageInfoCompat | ||
import androidx.core.net.toUri | ||
import tk.wasdennnoch.scoop.R | ||
import tk.wasdennnoch.scoop.databinding.ActivityAboutBinding | ||
|
||
class AboutActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val binding = ActivityAboutBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
setSupportActionBar(binding.aboutToolbar.toolbar) | ||
supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||
|
||
binding.aboutCredits.text = getString( | ||
R.string.about_author, | ||
"@MrWasdennnoch (XDA), @paphonb (XDA), @TacoTheDank (GitHub)" | ||
) | ||
|
||
try { | ||
val pInfo = packageManager.getPackageInfo(packageName, 0) | ||
binding.aboutVersion.text = String.format( | ||
getString(R.string.about_version), | ||
pInfo.versionName, | ||
PackageInfoCompat.getLongVersionCode(pInfo) | ||
) | ||
} catch (e: PackageManager.NameNotFoundException) { | ||
// No. | ||
} | ||
|
||
binding.aboutUpdates.setOnClickListener { | ||
val i = Intent( | ||
Intent.ACTION_VIEW, | ||
"https://github.com/TacoTheDank/Scoop/releases".toUri() | ||
) | ||
startActivity(i) | ||
} | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
if (item.itemId == android.R.id.home) { | ||
finish() | ||
return true | ||
} | ||
return super.onOptionsItemSelected(item) | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
app/src/main/java/tk/wasdennnoch/scoop/ui/SettingsActivity.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
app/src/main/java/tk/wasdennnoch/scoop/ui/SettingsActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package tk.wasdennnoch.scoop.ui | ||
|
||
import android.os.Bundle | ||
import android.view.MenuItem | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.commit | ||
import androidx.fragment.app.replace | ||
import androidx.preference.PreferenceFragmentCompat | ||
import tk.wasdennnoch.scoop.R | ||
import tk.wasdennnoch.scoop.databinding.ActivitySettingsBinding | ||
|
||
class SettingsActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val binding = ActivitySettingsBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
setSupportActionBar(binding.settingsToolbar.toolbar) | ||
supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||
|
||
supportFragmentManager.commit { | ||
replace<SettingsFragment>(R.id.settings_container) | ||
} | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
if (item.itemId == android.R.id.home) { | ||
finish() | ||
return true | ||
} | ||
return super.onOptionsItemSelected(item) | ||
} | ||
|
||
class SettingsFragment : PreferenceFragmentCompat() { | ||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
addPreferencesFromResource(R.xml.preferences) | ||
} | ||
} | ||
} |