From 8b44284c7fae76e7e402387500acab7b64a7dad3 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 21 Aug 2018 22:39:07 +0200 Subject: Remove side gutters on large screens --- .../org/pacien/tincapp/activities/BaseActivity.kt | 20 +++++++++++++------- .../activities/configure/ConfigureActivity.kt | 3 +-- .../tincapp/activities/start/ConnectionStarter.kt | 4 ++-- .../activities/status/nodes/NodeListFragment.kt | 4 ++-- .../tincapp/activities/viewlog/ViewLogActivity.kt | 3 +-- 5 files changed, 19 insertions(+), 15 deletions(-) (limited to 'app/src/main/java/org/pacien') diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt index a51d401..d9d549b 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt @@ -26,7 +26,7 @@ import android.support.design.widget.Snackbar import android.support.v7.app.AlertDialog import android.support.v7.app.AppCompatActivity import android.view.* -import kotlinx.android.synthetic.main.base.* +import kotlinx.android.synthetic.main.base_activity.* import org.pacien.tincapp.R import org.pacien.tincapp.context.App import org.pacien.tincapp.context.AppInfo @@ -37,11 +37,12 @@ import org.pacien.tincapp.context.CrashRecorder * @author pacien */ abstract class BaseActivity : AppCompatActivity() { + private val rootView by lazy { base_activity_frame!! } private var active = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.base) + super.setContentView(R.layout.base_activity) } override fun onCreateOptionsMenu(m: Menu): Boolean { @@ -69,6 +70,10 @@ abstract class BaseActivity : AppCompatActivity() { super.onStop() } + override fun setContentView(layoutResID: Int) { + layoutInflater.inflate(layoutResID, rootView) + } + override fun getSupportActionBar() = super.getSupportActionBar()!! fun startActivityChooser(target: Intent, title: String) { @@ -76,7 +81,8 @@ abstract class BaseActivity : AppCompatActivity() { startActivity(intentChooser) } - fun aboutDialog(@Suppress("UNUSED_PARAMETER") i: MenuItem) { + @Suppress("UNUSED_PARAMETER") + fun aboutDialog(m: MenuItem) { AlertDialog.Builder(this) .setTitle(resources.getString(R.string.app_name)) .setMessage(resources.getString(R.string.app_short_desc) + "\n\n" + @@ -112,11 +118,11 @@ abstract class BaseActivity : AppCompatActivity() { .show() } - fun inflate(@LayoutRes layout: Int) = layoutInflater.inflate(layout, main_content, false)!! - fun inflate(inflateFunc: (LayoutInflater, ViewGroup, Boolean) -> View) = inflateFunc(layoutInflater, main_content, false) + fun inflate(@LayoutRes layout: Int) = layoutInflater.inflate(layout, rootView, false)!! + fun inflate(inflateFunc: (LayoutInflater, ViewGroup?, Boolean) -> View) = inflateFunc(layoutInflater, rootView, false) - fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() - fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() + fun notify(@StringRes msg: Int) = Snackbar.make(base_activity_frame, msg, Snackbar.LENGTH_LONG).show() + fun notify(msg: String) = Snackbar.make(base_activity_frame, msg, Snackbar.LENGTH_LONG).show() fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) .setTitle(R.string.title_error).setMessage(msg) diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/ConfigureActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/ConfigureActivity.kt index 9c9be70..c215f70 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/configure/ConfigureActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/configure/ConfigureActivity.kt @@ -19,7 +19,6 @@ package org.pacien.tincapp.activities.configure import android.os.Bundle -import kotlinx.android.synthetic.main.base.* import org.pacien.tincapp.R import org.pacien.tincapp.activities.BaseActivity @@ -30,6 +29,6 @@ class ConfigureActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) supportActionBar.setDisplayHomeAsUpEnabled(true) - layoutInflater.inflate(R.layout.configure_activity, main_content) + setContentView(R.layout.configure_activity) } } diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt index 9e7e59d..06046e9 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt @@ -20,7 +20,7 @@ package org.pacien.tincapp.activities.start import android.net.VpnService import android.support.v7.app.AlertDialog -import kotlinx.android.synthetic.main.base.* +import kotlinx.android.synthetic.main.base_activity.* import kotlinx.android.synthetic.main.dialog_decrypt_keys.view.* import org.pacien.tincapp.R import org.pacien.tincapp.service.TincVpnService @@ -52,7 +52,7 @@ class ConnectionStarter(private val parentActivity: StartActivity) { } private fun askForPassphrase() { - val dialogView = parentActivity.layoutInflater.inflate(R.layout.dialog_decrypt_keys, parentActivity.main_content, false) + val dialogView = parentActivity.layoutInflater.inflate(R.layout.dialog_decrypt_keys, parentActivity.base_activity_frame, false) AlertDialog.Builder(parentActivity) .setTitle(R.string.title_unlock_private_keys) diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt index 1111de7..cf1c1bc 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/nodes/NodeListFragment.kt @@ -26,7 +26,7 @@ import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import kotlinx.android.synthetic.main.base.* +import kotlinx.android.synthetic.main.base_activity.* import kotlinx.android.synthetic.main.status_node_info_dialog.view.* import kotlinx.android.synthetic.main.status_node_list_fragment.* import org.pacien.tincapp.R @@ -67,7 +67,7 @@ class NodeListFragment : Fragment() { showNodeInfo(nodeInfo.name) private fun showNodeInfo(nodeName: String) { - val dialogTextView = layoutInflater.inflate(R.layout.status_node_info_dialog, main_content, false) + val dialogTextView = layoutInflater.inflate(R.layout.status_node_info_dialog, base_activity_frame, false) AlertDialog.Builder(context!!) .setTitle(R.string.status_node_info_dialog_title) diff --git a/app/src/main/java/org/pacien/tincapp/activities/viewlog/ViewLogActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/viewlog/ViewLogActivity.kt index a4e2216..dfe6d1b 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/viewlog/ViewLogActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/viewlog/ViewLogActivity.kt @@ -26,7 +26,6 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.widget.ScrollView -import kotlinx.android.synthetic.main.base.* import kotlinx.android.synthetic.main.view_log_activity.* import org.pacien.tincapp.R import org.pacien.tincapp.activities.BaseActivity @@ -42,7 +41,7 @@ class ViewLogActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) supportActionBar.setDisplayHomeAsUpEnabled(true) - layoutInflater.inflate(R.layout.view_log_activity, main_content) + setContentView(R.layout.view_log_activity) enableLogging(viewModel.logging) } -- cgit v1.2.3