Extract Select folder (moving) into its own activity
more work needed
This commit is contained in:
parent
52e53f30c0
commit
e1ae4978ec
3 changed files with 66 additions and 2 deletions
|
@ -86,6 +86,7 @@
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".crypto.PgpActivity"
|
<activity android:name=".crypto.PgpActivity"
|
||||||
android:parentActivityName=".PasswordStore"/>
|
android:parentActivityName=".PasswordStore"/>
|
||||||
</application>
|
<activity android:name=".SelectFolderActivity" />
|
||||||
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
63
app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt
Normal file
63
app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
package com.zeapo.pwdstore
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.FragmentManager
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.PersistableBundle
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import com.zeapo.pwdstore.utils.PasswordRepository
|
||||||
|
|
||||||
|
// TODO more work needed, this is just an extraction from PgpHandler
|
||||||
|
|
||||||
|
class SelectFolderActivity : AppCompatActivity() {
|
||||||
|
internal var passwordList: SelectFolderFragment? = null
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
|
||||||
|
super.onCreate(savedInstanceState, persistentState)
|
||||||
|
|
||||||
|
setContentView(R.layout.select_folder_layout)
|
||||||
|
|
||||||
|
val fragmentManager = supportFragmentManager
|
||||||
|
val fragmentTransaction = fragmentManager.beginTransaction()
|
||||||
|
|
||||||
|
|
||||||
|
passwordList = SelectFolderFragment()
|
||||||
|
val args = Bundle()
|
||||||
|
args.putString("Path", PasswordRepository.getRepositoryDirectory(applicationContext).absolutePath)
|
||||||
|
|
||||||
|
passwordList?.arguments = args
|
||||||
|
|
||||||
|
supportActionBar?.show()
|
||||||
|
|
||||||
|
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
|
||||||
|
|
||||||
|
fragmentTransaction.replace(R.id.pgp_handler_linearlayout, passwordList, "PasswordsList")
|
||||||
|
fragmentTransaction.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.pgp_handler_select_folder, menu)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
val id = item.itemId
|
||||||
|
when (id) {
|
||||||
|
android.R.id.home -> {
|
||||||
|
setResult(Activity.RESULT_CANCELED)
|
||||||
|
finish()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.crypto_select -> selectFolder()
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun selectFolder() {
|
||||||
|
intent.putExtra("SELECTED_FOLDER_PATH", passwordList?.currentDir?.absolutePath)
|
||||||
|
setResult(Activity.RESULT_OK, intent)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:pwstore="http://schemas.android.com/apk/res-auto"
|
xmlns:pwstore="http://schemas.android.com/apk/res-auto"
|
||||||
tools:context="com.zeapo.pwdstore.crypto.PgpHandler" >
|
tools:context="com.zeapo.pwdstore.SelectFolderActivity" >
|
||||||
<item android:title="@string/crypto_select"
|
<item android:title="@string/crypto_select"
|
||||||
android:icon="@drawable/ic_done_white_24dp"
|
android:icon="@drawable/ic_done_white_24dp"
|
||||||
pwstore:showAsAction="ifRoom"
|
pwstore:showAsAction="ifRoom"
|
||||||
|
|
Loading…
Reference in a new issue