aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org
diff options
context:
space:
mode:
authorpacien2018-08-22 00:46:07 +0200
committerpacien2018-08-22 00:46:07 +0200
commit2571919913f44772c40929c24c7949a2eecdec3a (patch)
tree8a21ee6f3c46c6e6188b0f8292b0dd8ede856ca8 /app/src/main/java/org
parenteac7a9365fc713fa46411577940f25ca0b7ff526 (diff)
downloadtincapp-2571919913f44772c40929c24c7949a2eecdec3a.tar.gz
Use custom base fragment and switch to embedded qr-code scanner
Diffstat (limited to 'app/src/main/java/org')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt36
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/common/FragmentListPagerAdapter.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/PathInfoFragment.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/ToolsFragment.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/tools/JoinNetworkTool.kt6
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/start/NetworkListFragment.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/NetworkInfoFragment.kt4
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt7
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
19package org.pacien.tincapp.activities
20
21import android.support.annotation.LayoutRes
22import android.support.v4.app.Fragment
23import android.view.LayoutInflater
24import android.view.View
25import android.view.ViewGroup
26import kotlinx.android.synthetic.main.base_activity.*
27
28/**
29 * @author pacien
30 */
31abstract 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
19package org.pacien.tincapp.activities.common 19package org.pacien.tincapp.activities.common
20 20
21import android.support.v4.app.Fragment
22import android.support.v4.app.FragmentManager 21import android.support.v4.app.FragmentManager
23import android.support.v4.app.FragmentPagerAdapter 22import android.support.v4.app.FragmentPagerAdapter
23import org.pacien.tincapp.activities.BaseFragment
24import org.pacien.tincapp.context.App 24import 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 */
30class FragmentListPagerAdapter(private val pages: List<Pair<Int, Fragment>>, 30class 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
19package org.pacien.tincapp.activities.configure 19package org.pacien.tincapp.activities.configure
20 20
21import android.app.Fragment
22import android.os.Bundle 21import android.os.Bundle
23import android.view.LayoutInflater 22import android.view.LayoutInflater
24import android.view.View 23import android.view.View
25import android.view.ViewGroup 24import android.view.ViewGroup
25import org.pacien.tincapp.activities.BaseFragment
26import org.pacien.tincapp.context.AppPaths 26import org.pacien.tincapp.context.AppPaths
27import org.pacien.tincapp.databinding.ConfigureToolsPathInfoFragmentBinding 27import org.pacien.tincapp.databinding.ConfigureToolsPathInfoFragmentBinding
28 28
29/** 29/**
30 * @author pacien 30 * @author pacien
31 */ 31 */
32class PathInfoFragment : Fragment() { 32class 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
19package org.pacien.tincapp.activities.configure 19package org.pacien.tincapp.activities.configure
20 20
21import android.app.Fragment
22import android.content.Intent 21import android.content.Intent
23import android.os.Bundle 22import android.os.Bundle
24import android.view.LayoutInflater 23import android.view.LayoutInflater
25import android.view.View 24import android.view.View
26import android.view.ViewGroup 25import android.view.ViewGroup
27import org.pacien.tincapp.activities.BaseActivity 26import org.pacien.tincapp.activities.BaseActivity
27import org.pacien.tincapp.activities.BaseFragment
28import org.pacien.tincapp.activities.configure.tools.EncryptDecryptPrivateKeysTool 28import org.pacien.tincapp.activities.configure.tools.EncryptDecryptPrivateKeysTool
29import org.pacien.tincapp.activities.configure.tools.GenerateConfigTool 29import org.pacien.tincapp.activities.configure.tools.GenerateConfigTool
30import org.pacien.tincapp.activities.configure.tools.JoinNetworkTool 30import 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 */
36class ToolsFragment : Fragment() { 36class 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
19package org.pacien.tincapp.activities.configure.tools 19package org.pacien.tincapp.activities.configure.tools
20 20
21import android.app.Fragment
22import android.content.Intent 21import android.content.Intent
23import android.view.View 22import android.view.View
24import com.google.zxing.integration.android.IntentIntegrator 23import com.google.zxing.integration.android.IntentIntegrator
@@ -26,6 +25,7 @@ import com.google.zxing.integration.android.IntentResult
26import kotlinx.android.synthetic.main.configure_tools_dialog_network_join.view.* 25import kotlinx.android.synthetic.main.configure_tools_dialog_network_join.view.*
27import org.pacien.tincapp.R 26import org.pacien.tincapp.R
28import org.pacien.tincapp.activities.BaseActivity 27import org.pacien.tincapp.activities.BaseActivity
28import org.pacien.tincapp.activities.BaseFragment
29import org.pacien.tincapp.commands.Tinc 29import org.pacien.tincapp.commands.Tinc
30import org.pacien.tincapp.commands.TincApp 30import org.pacien.tincapp.commands.TincApp
31import org.pacien.tincapp.databinding.ConfigureToolsDialogNetworkJoinBinding 31import 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 */
36class JoinNetworkTool(parentFragment: Fragment, private val parentActivity: BaseActivity) : ConfigurationTool(parentActivity) { 36class 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
21import android.arch.lifecycle.Observer 21import android.arch.lifecycle.Observer
22import android.os.Bundle 22import android.os.Bundle
23import android.support.v4.app.Fragment