From 31480d871326aeacff8507ea67443027fc8dbe87 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 14 Jun 2019 21:54:36 +0200 Subject: [PATCH] Added manage connectivity button --- .../email/FragmentOptionsConnection.java | 13 +++++++++++++ .../res/layout/fragment_options_connection.xml | 16 ++++++++++++++-- app/src/main/res/values/strings.xml | 4 +++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java index 282c07f9c4..1b7c8e2f72 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.Network; @@ -33,6 +34,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; +import android.widget.Button; import android.widget.CompoundButton; import android.widget.Spinner; import android.widget.TextView; @@ -49,6 +51,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre private Spinner spDownload; private SwitchCompat swRoaming; private SwitchCompat swRlah; + private Button btnManage; private TextView tvConnectionType; private TextView tvConnectionRoaming; @@ -70,6 +73,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre spDownload = view.findViewById(R.id.spDownload); swRoaming = view.findViewById(R.id.swRoaming); swRlah = view.findViewById(R.id.swRlah); + btnManage = view.findViewById(R.id.btnManage); tvConnectionType = view.findViewById(R.id.tvConnectionType); tvConnectionRoaming = view.findViewById(R.id.tvConnectionRoaming); @@ -117,6 +121,15 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre } }); + final Intent manage = ConnectionHelper.getSettingsIntent(getContext()); + btnManage.setVisibility(manage == null ? View.GONE : View.VISIBLE); + btnManage.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startActivity(manage); + } + }); + PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); tvConnectionType.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/fragment_options_connection.xml b/app/src/main/res/layout/fragment_options_connection.xml index b902ab5d57..768831339d 100644 --- a/app/src/main/res/layout/fragment_options_connection.xml +++ b/app/src/main/res/layout/fragment_options_connection.xml @@ -119,18 +119,30 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swRlah" /> +