-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add preference screen, fix- directory sort, minor fix
- Loading branch information
1 parent
c5e0641
commit 49e04ed
Showing
24 changed files
with
600 additions
and
56 deletions.
There are no files selected for viewing
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
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
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/wirelessalien/zipxtract/CustomEditTextPreference.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,40 @@ | ||
/* | ||
* Copyright (C) 2023 WirelessAlien <https://github.com/WirelessAlien> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.wirelessalien.zipxtract | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import androidx.preference.EditTextPreference | ||
|
||
class CustomEditTextPreference(context: Context, attrs: AttributeSet?) : EditTextPreference(context, attrs) { | ||
|
||
private val basePath = "/storage/emulated/0/" | ||
|
||
override fun getText(): String? { | ||
val text = super.getText() | ||
return if (text != null && text.startsWith(basePath)) { | ||
text.removePrefix(basePath) | ||
} else { | ||
text | ||
} | ||
} | ||
|
||
override fun setText(text: String?) { | ||
super.setText(basePath + (text ?: "")) | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/wirelessalien/zipxtract/activity/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,71 @@ | ||
/* | ||
* Copyright (C) 2023 WirelessAlien <https://github.com/WirelessAlien> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.wirelessalien.zipxtract.activity | ||
|
||
import android.os.Bundle | ||
import android.view.MenuItem | ||
import androidx.activity.OnBackPressedCallback | ||
import androidx.activity.OnBackPressedDispatcher | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.google.android.material.appbar.MaterialToolbar | ||
import com.wirelessalien.zipxtract.R | ||
import com.wirelessalien.zipxtract.fragment.SettingsFragment | ||
|
||
|
||
class SettingsActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_settings) | ||
|
||
// Set up the toolbar | ||
val toolbar: MaterialToolbar = findViewById(R.id.toolbar) | ||
toolbar.title = getString(R.string.action_settings) | ||
setSupportActionBar(toolbar) | ||
|
||
// Display the fragment as the main content. | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.fragmentCntainer, SettingsFragment()) | ||
.commit() | ||
|
||
// Add back button to the activity | ||
val actionBar = supportActionBar | ||
if (actionBar != null) { | ||
actionBar.setDisplayHomeAsUpEnabled(true) | ||
actionBar.setHomeButtonEnabled(true) | ||
} | ||
|
||
// Handle back button press | ||
OnBackPressedDispatcher().addCallback(this, object : OnBackPressedCallback(true) { | ||
override fun handleOnBackPressed() { | ||
finishActivity() | ||
} | ||
}) | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
if (item.itemId == android.R.id.home) { | ||
finishActivity() | ||
return true | ||
} | ||
return super.onOptionsItemSelected(item) | ||
} | ||
|
||
private fun finishActivity() { | ||
finish() | ||
} | ||
} |
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
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
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
Oops, something went wrong.