mirror of
https://github.com/etesync/android
synced 2025-05-12 20:08:50 +00:00
Add kotlin extensions, enable R8 and fix errors.
This commit is contained in:
parent
693157f71e
commit
4bf36e7ad3
@ -143,9 +143,13 @@ dependencies {
|
|||||||
def supportVersion = '1.0.0'
|
def supportVersion = '1.0.0'
|
||||||
implementation "androidx.legacy:legacy-support-core-ui:$supportVersion"
|
implementation "androidx.legacy:legacy-support-core-ui:$supportVersion"
|
||||||
implementation "androidx.core:core:$supportVersion"
|
implementation "androidx.core:core:$supportVersion"
|
||||||
implementation "androidx.fragment:fragment:$supportVersion"
|
|
||||||
implementation "androidx.appcompat:appcompat:1.1.0"
|
implementation "androidx.appcompat:appcompat:1.1.0"
|
||||||
implementation "androidx.cardview:cardview:1.0.0"
|
implementation "androidx.cardview:cardview:1.0.0"
|
||||||
|
// KTX extensions
|
||||||
|
implementation "androidx.core:core-ktx:1.3.1"
|
||||||
|
implementation "androidx.fragment:fragment-ktx:1.2.5"
|
||||||
|
|
||||||
|
|
||||||
implementation 'com.google.android.material:material:1.2.0-beta01'
|
implementation 'com.google.android.material:material:1.2.0-beta01'
|
||||||
implementation "androidx.legacy:legacy-preference-v14:$supportVersion"
|
implementation "androidx.legacy:legacy-preference-v14:$supportVersion"
|
||||||
implementation 'com.github.yukuku:ambilwarna:2.0.1'
|
implementation 'com.github.yukuku:ambilwarna:2.0.1'
|
||||||
|
@ -32,7 +32,7 @@ import com.etesync.syncadapter.R
|
|||||||
class AccountListFragment : ListFragment(), LoaderManager.LoaderCallbacks<Array<Account>>, AdapterView.OnItemClickListener {
|
class AccountListFragment : ListFragment(), LoaderManager.LoaderCallbacks<Array<Account>>, AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
listAdapter = AccountListAdapter(context!!)
|
listAdapter = AccountListAdapter(requireContext())
|
||||||
|
|
||||||
return inflater.inflate(R.layout.account_list, container, false)
|
return inflater.inflate(R.layout.account_list, container, false)
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ class AccountListFragment : ListFragment(), LoaderManager.LoaderCallbacks<Array<
|
|||||||
// loader
|
// loader
|
||||||
|
|
||||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Array<Account>> {
|
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Array<Account>> {
|
||||||
return AccountLoader(context!!)
|
return AccountLoader(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLoadFinished(loader: Loader<Array<Account>>, accounts: Array<Account>) {
|
override fun onLoadFinished(loader: Loader<Array<Account>>, accounts: Array<Account>) {
|
||||||
|
@ -106,13 +106,13 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
|
|||||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
val member = listAdapter?.getItem(position) as JournalManager.Member
|
val member = listAdapter?.getItem(position) as JournalManager.Member
|
||||||
|
|
||||||
AlertDialog.Builder(activity!!)
|
AlertDialog.Builder(requireActivity())
|
||||||
.setIcon(R.drawable.ic_info_dark)
|
.setIcon(R.drawable.ic_info_dark)
|
||||||
.setTitle(R.string.collection_members_remove_title)
|
.setTitle(R.string.collection_members_remove_title)
|
||||||
.setMessage(getString(R.string.collection_members_remove, member.user))
|
.setMessage(getString(R.string.collection_members_remove, member.user))
|
||||||
.setPositiveButton(android.R.string.yes) { dialog, which ->
|
.setPositiveButton(android.R.string.yes) { dialog, which ->
|
||||||
val frag = RemoveMemberFragment.newInstance(account, info, member.user!!)
|
val frag = RemoveMemberFragment.newInstance(account, info, member.user!!)
|
||||||
frag.show(fragmentManager!!, null)
|
frag.show(requireFragmentManager(), null)
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.no) { dialog, which -> }.show()
|
.setNegativeButton(android.R.string.no) { dialog, which -> }.show()
|
||||||
}
|
}
|
||||||
|
@ -108,9 +108,9 @@ class ImportActivity : BaseActivity(), SelectImportMethod, ResultFragment.OnImpo
|
|||||||
// This makes sure that the container activity has implemented
|
// This makes sure that the container activity has implemented
|
||||||
// the callback interface. If not, it throws an exception
|
// the callback interface. If not, it throws an exception
|
||||||
try {
|
try {
|
||||||
mSelectImportMethod = activity as SelectImportMethod?
|
mSelectImportMethod = activity as SelectImportMethod
|
||||||
} catch (e: ClassCastException) {
|
} catch (e: ClassCastException) {
|
||||||
throw ClassCastException(activity!!.toString() + " must implement MyInterface ")
|
throw ClassCastException(activity.toString() + " must implement MyInterface ")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class ResultFragment : DialogFragment() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
result = arguments!!.getSerializable(KEY_RESULT) as ImportResult
|
result = requireArguments().getSerializable(KEY_RESULT) as ImportResult
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDismiss(dialog: DialogInterface) {
|
override fun onDismiss(dialog: DialogInterface) {
|
||||||
@ -32,7 +32,7 @@ class ResultFragment : DialogFragment() {
|
|||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
if (result!!.isFailed) {
|
if (result!!.isFailed) {
|
||||||
return AlertDialog.Builder(activity!!)
|
return AlertDialog.Builder(requireActivity())
|
||||||
.setTitle(R.string.import_dialog_failed_title)
|
.setTitle(R.string.import_dialog_failed_title)
|
||||||
.setIcon(R.drawable.ic_error_dark)
|
.setIcon(R.drawable.ic_error_dark)
|
||||||
.setMessage(getString(R.string.import_dialog_failed_body, result!!.e!!.localizedMessage))
|
.setMessage(getString(R.string.import_dialog_failed_body, result!!.e!!.localizedMessage))
|
||||||
|
@ -88,7 +88,7 @@ class ListEntriesFragment : ListFragment(), AdapterView.OnItemClickListener {
|
|||||||
|
|
||||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
val entry = listAdapter?.getItem(position) as EntryEntity
|
val entry = listAdapter?.getItem(position) as EntryEntity
|
||||||
startActivity(JournalItemActivity.newIntent(context!!, account, info, entry.content))
|
startActivity(JournalItemActivity.newIntent(requireContext(), account, info, entry.content))
|
||||||
}
|
}
|
||||||
|
|
||||||
internal inner class EntriesListAdapter(context: Context) : ArrayAdapter<EntryEntity>(context, R.layout.journal_viewer_list_item) {
|
internal inner class EntriesListAdapter(context: Context) : ArrayAdapter<EntryEntity>(context, R.layout.journal_viewer_list_item) {
|
||||||
|
@ -42,19 +42,19 @@ class DetectConfigurationFragment : DialogFragment(), LoaderManager.LoaderCallba
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Configuration> {
|
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Configuration> {
|
||||||
return ServerConfigurationLoader(context!!, args!!.getParcelable(ARG_LOGIN_CREDENTIALS) as LoginCredentials)
|
return ServerConfigurationLoader(requireContext(), args!!.getParcelable(ARG_LOGIN_CREDENTIALS) as LoginCredentials)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLoadFinished(loader: Loader<Configuration>, data: Configuration?) {
|
override fun onLoadFinished(loader: Loader<Configuration>, data: Configuration?) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
if (data.isFailed)
|
if (data.isFailed)
|
||||||
// no service found: show error message
|
// no service found: show error message
|
||||||
fragmentManager!!.beginTransaction()
|
requireFragmentManager().beginTransaction()
|
||||||
.add(NothingDetectedFragment.newInstance(data.error!!.localizedMessage), null)
|
.add(NothingDetectedFragment.newInstance(data.error!!.localizedMessage), null)
|
||||||
.commitAllowingStateLoss()
|
.commitAllowingStateLoss()
|
||||||
else
|
else
|
||||||
// service found: continue
|
// service found: continue
|
||||||
fragmentManager!!.beginTransaction()
|
requireFragmentManager().beginTransaction()
|
||||||
.replace(android.R.id.content, EncryptionDetailsFragment.newInstance(data))
|
.replace(android.R.id.content, EncryptionDetailsFragment.newInstance(data))
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commitAllowingStateLoss()
|
.commitAllowingStateLoss()
|
||||||
@ -76,7 +76,7 @@ class DetectConfigurationFragment : DialogFragment(), LoaderManager.LoaderCallba
|
|||||||
.setMessage(R.string.login_wrong_username_or_password)
|
.setMessage(R.string.login_wrong_username_or_password)
|
||||||
.setNeutralButton(R.string.login_view_logs) { dialog, which ->
|
.setNeutralButton(R.string.login_view_logs) { dialog, which ->
|
||||||
val intent = DebugInfoActivity.newIntent(context, this::class.toString())
|
val intent = DebugInfoActivity.newIntent(context, this::class.toString())
|
||||||
intent.putExtra(DebugInfoActivity.KEY_LOGS, arguments!!.getString(KEY_LOGS))
|
intent.putExtra(DebugInfoActivity.KEY_LOGS, requireArguments().getString(KEY_LOGS))
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
.setPositiveButton(android.R.string.ok) { dialog, which ->
|
.setPositiveButton(android.R.string.ok) { dialog, which ->
|
||||||
|
Loading…
Reference in New Issue
Block a user