diff options
Diffstat (limited to 'app/src/main')
8 files changed, 52 insertions, 17 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt new file mode 100644 index 0000000..685950f --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon | ||
3 | * Copyright (C) 2017-2018 Pacien TRAN-GIRARD | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, either version 3 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | package org.pacien.tincapp.activities | ||
20 | |||
21 | import android.support.annotation.LayoutRes | ||
22 | import android.support.v4.app.Fragment | ||
23 | import android.view.LayoutInflater | ||
24 | import android.view.View | ||
25 | import android.view.ViewGroup | ||
26 | import kotlinx.android.synthetic.main.base_activity.* | ||
27 | |||
28 | /** | ||
29 | * @author pacien | ||
30 | */ | ||
31 | abstract class BaseFragment : Fragment() { | ||
32 | private val rootView by lazy { base_activity_frame!! } | ||
33 | |||
34 | fun inflate(@LayoutRes layout: Int) = layoutInflater.inflate(layout, rootView, false)!! | ||
35 | fun inflate(inflateFunc: (LayoutInflater, ViewGroup?, Boolean) -> View) = inflateFunc(layoutInflater, rootView, false) | ||
36 | } | ||
diff --git a/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt b/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt index e4063bf..c55e889 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt | |||
@@ -18,16 +18,16 @@ | |||
18 | 18 | ||
19 | package org.pacien.tincapp.activities.common | 19 | package org.pacien.tincapp.activities.common |
20 | 20 | ||
21 | import android.support.v4.app.Fragment | ||
22 | import android.support.v4.app.FragmentManager | 21 | import android.support.v4.app.FragmentManager |
23 | import android.support.v4.app.FragmentPagerAdapter | 22 | import android.support.v4.app.FragmentPagerAdapter |
23 | import org.pacien.tincapp.activities.BaseFragment | ||
24 | import org.pacien.tincapp.context.App | 24 | import org.pacien.tincapp.context.App |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * @param pages ordered list of title and fragment pairs | 27 | * @param pages ordered list of title and fragment pairs |
28 | * @author pacien | 28 | * @author pacien |
29 | */ | 29 | */ |
30 | class FragmentListPagerAdapter(private val pages: List<Pair<Int, Fragment>>, | 30 | class FragmentListPagerAdapter(private val pages: List<Pair<Int, BaseFragment>>, |
31 | fragmentManager: FragmentManager) : FragmentPagerAdapter(fragmentManager) { | 31 | fragmentManager: FragmentManager) : FragmentPagerAdapter(fragmentManager) { |
32 | 32 | ||
33 | private val resources by lazy { App.getResources() } | 33 | private val resources by lazy { App.getResources() } |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/PathInfoFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/PathInfoFragment.kt index dae4413..57a6bee 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/configure/PathInfoFragment.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/configure/PathInfoFragment.kt | |||
@@ -18,18 +18,18 @@ | |||
18 | 18 | ||
19 | package org.pacien.tincapp.activities.configure | 19 | package org.pacien.tincapp.activities.configure |
20 | 20 | ||
21 | import android.app.Fragment | ||
22 | import android.os.Bundle | 21 | import android.os.Bundle |
23 | import android.view.LayoutInflater | 22 | import android.view.LayoutInflater |
24 | import android.view.View | 23 | import android.view.View |
25 | import android.view.ViewGroup | 24 | import android.view.ViewGroup |
25 | import org.pacien.tincapp.activities.BaseFragment | ||
26 | import org.pacien.tincapp.context.AppPaths | 26 | import org.pacien.tincapp.context.AppPaths |
27 | import org.pacien.tincapp.databinding.ConfigureToolsPathInfoFragmentBinding | 27 | import org.pacien.tincapp.databinding.ConfigureToolsPathInfoFragmentBinding |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * @author pacien | 30 | * @author pacien |
31 | */ | 31 | */ |
32 | class PathInfoFragment : Fragment() { | 32 | class PathInfoFragment : BaseFragment() { |
33 | private val appPaths = AppPaths | 33 | private val appPaths = AppPaths |
34 | 34 | ||
35 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | 35 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/ToolsFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/ToolsFragment.kt index 0ad2f19..714a7ae 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/configure/ToolsFragment.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/configure/ToolsFragment.kt | |||
@@ -18,13 +18,13 @@ | |||
18 | 18 | ||
19 | package org.pacien.tincapp.activities.configure | 19 | package org.pacien.tincapp.activities.configure |
20 | 20 | ||
21 | import android.app.Fragment | ||
22 | import android.content.Intent | 21 | import android.content.Intent |
23 | import android.os.Bundle | 22 | import android.os.Bundle |
24 | import android.view.LayoutInflater | 23 | import android.view.LayoutInflater |
25 | import android.view.View | 24 | import android.view.View |
26 | import android.view.ViewGroup | 25 | import android.view.ViewGroup |
27 | import org.pacien.tincapp.activities.BaseActivity | 26 | import org.pacien.tincapp.activities.BaseActivity |
27 | import org.pacien.tincapp.activities.BaseFragment | ||
28 | import org.pacien.tincapp.activities.configure.tools.EncryptDecryptPrivateKeysTool | 28 | import org.pacien.tincapp.activities.configure.tools.EncryptDecryptPrivateKeysTool |
29 | import org.pacien.tincapp.activities.configure.tools.GenerateConfigTool | 29 | import org.pacien.tincapp.activities.configure.tools.GenerateConfigTool |
30 | import org.pacien.tincapp.activities.configure.tools.JoinNetworkTool | 30 | import org.pacien.tincapp.activities.configure.tools.JoinNetworkTool |
@@ -33,7 +33,7 @@ import org.pacien.tincapp.databinding.ConfigureToolsFragmentBinding | |||
33 | /** | 33 | /** |
34 | * @author pacien | 34 | * @author pacien |
35 | */ | 35 | */ |
36 | class ToolsFragment : Fragment() { | 36 | class ToolsFragment : BaseFragment() { |
37 | private val parentActivity by lazy { activity as BaseActivity } | 37 | private val parentActivity by lazy { activity as BaseActivity } |
38 | private val generateConfigTool by lazy { GenerateConfigTool(parentActivity) } | 38 | private val generateConfigTool by lazy { GenerateConfigTool(parentActivity) } |
39 | private val joinNetworkTool by lazy { JoinNetworkTool(this, parentActivity) } | 39 | private val joinNetworkTool by lazy { JoinNetworkTool(this, parentActivity) } |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/JoinNetworkTool.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/JoinNetworkTool.kt index 82a4380..6656d86 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/JoinNetworkTool.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/JoinNetworkTool.kt | |||
@@ -18,7 +18,6 @@ | |||
18 | 18 | ||
19 | package org.pacien.tincapp.activities.configure.tools | 19 | package org.pacien.tincapp.activities.configure.tools |
20 | 20 | ||
21 | import android.app.Fragment | ||
22 | import android.content.Intent | 21 | import android.content.Intent |
23 | import android.view.View | 22 | import android.view.View |
24 | import com.google.zxing.integration.android.IntentIntegrator | 23 | import com.google.zxing.integration.android.IntentIntegrator |
@@ -26,6 +25,7 @@ import com.google.zxing.integration.android.IntentResult | |||
26 | import kotlinx.android.synthetic.main.configure_tools_dialog_network_join.view.* | 25 | import kotlinx.android.synthetic.main.configure_tools_dialog_network_join.view.* |
27 | import org.pacien.tincapp.R | 26 | import org.pacien.tincapp.R |
28 | import org.pacien.tincapp.activities.BaseActivity | 27 | import org.pacien.tincapp.activities.BaseActivity |
28 | import org.pacien.tincapp.activities.BaseFragment | ||
29 | import org.pacien.tincapp.commands.Tinc | 29 | import org.pacien.tincapp.commands.Tinc |
30 | import org.pacien.tincapp.commands.TincApp | 30 | import org.pacien.tincapp.commands.TincApp |
31 | import org.pacien.tincapp.databinding.ConfigureToolsDialogNetworkJoinBinding | 31 | import org.pacien.tincapp.databinding.ConfigureToolsDialogNetworkJoinBinding |
@@ -33,8 +33,8 @@ import org.pacien.tincapp.databinding.ConfigureToolsDialogNetworkJoinBinding | |||
33 | /** | 33 | /** |
34 | * @author pacien | 34 | * @author pacien |
35 | */ | 35 | */ |
36 | class JoinNetworkTool(parentFragment: Fragment, private val parentActivity: BaseActivity) : ConfigurationTool(parentActivity) { | 36 | class JoinNetworkTool(parentFragment: BaseFragment, private val parentActivity: BaseActivity) : ConfigurationTool(parentActivity) { |
37 | private val scanner by lazy { IntentIntegrator(parentFragment) } | 37 | private val scanner by lazy { IntentIntegrator.forSupportFragment(parentFragment) } |
38 | private var joinDialog: View? = null | 38 | private var joinDialog: View? = null |
39 | 39 | ||
40 | fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | 40 | fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt index f255f53..2c4bae1 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt | |||
@@ -20,7 +20,6 @@ package org.pacien.tincapp.activities.start | |||
20 | 20 | ||
21 | import android.arch.lifecycle.Observer | 21 | import android.arch.lifecycle.Observer |
22 | import android.os.Bundle | 22 | import android.os.Bundle |
23 | import android.support.v4.app.Fragment | ||
24 | import android.view.LayoutInflater | 23 | import android.view.LayoutInflater |
25 | import android.view.View | 24 | import android.view.View |
26 | import android.view.ViewGroup | 25 | import android.view.ViewGroup |