diff options
| author | Arne Schwabe <arne@rfc2549.org> | 2014-12-08 14:38:10 +0100 | 
|---|---|---|
| committer | Arne Schwabe <arne@rfc2549.org> | 2014-12-08 14:38:10 +0100 | 
| commit | 895166541f3a6a7f24dd61f1f0e39ee41c0359ed (patch) | |
| tree | 8846be49039d85a3b68d0d7b86b334b340c38fc4 | |
| parent | e7eb5a1d53fef812be6c713a4584f73791ccb347 (diff) | |
Fix custom connection options, always refresh generated configuration
--HG--
extra : rebase_source : 881a458e406e97ff21eaf516f561a4bd62e331f4
3 files changed, 44 insertions, 44 deletions
| diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java index 4474c669..6aef0bb1 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java @@ -76,6 +76,18 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.          return new ConnectionsHolder(card);      } +    static abstract class OnTextChangedWatcher implements TextWatcher { +        @Override +        public void beforeTextChanged(CharSequence s, int start, int count, int after) { + +        } + +        @Override +        public void onTextChanged(CharSequence s, int start, int before, int count) { + +        } +    } +      @Override      public void onBindViewHolder(final ConnectionsAdapter.ConnectionsHolder cH, final int i) {          final Connection connection = mConnections[i]; @@ -136,42 +148,28 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.                  }          ); -        cH.mServerNameView.addTextChangedListener(new TextWatcher() { -            @Override -            public void beforeTextChanged(CharSequence s, int start, int count, int after) { - -            } - -            @Override -            public void onTextChanged(CharSequence s, int start, int before, int count) { - -            } - +        cH.mServerNameView.addTextChangedListener(new OnTextChangedWatcher() {              @Override              public void afterTextChanged(Editable s) {                  connection.mServerName = s.toString();              } -        }); - -        cH.mPortNumberView.addTextChangedListener(new TextWatcher() { -            @Override -            public void beforeTextChanged(CharSequence s, int start, int count, int after) { -            } +        }); +        cH.mPortNumberView.addTextChangedListener(new OnTextChangedWatcher() {              @Override -            public void onTextChanged(CharSequence s, int start, int before, int count) { - +            public void afterTextChanged(Editable s) { +                connection.mServerPort = s.toString();              } +        }); +        cH.mCustomOptionText.addTextChangedListener(new OnTextChangedWatcher() {              @Override              public void afterTextChanged(Editable s) { -                connection.mServerPort = s.toString(); +                connection.mCustomConfiguration = s.toString();              }          }); - -      }      private void removeRemote(int idx) { diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java index eb77173c..c81db0bc 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java @@ -11,23 +11,15 @@ import android.os.Bundle;  import android.support.annotation.Nullable;  import android.support.v7.widget.LinearLayoutManager;  import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.StaggeredGridLayoutManager;  import android.view.LayoutInflater;  import android.view.Menu;  import android.view.MenuInflater;  import android.view.MenuItem;  import android.view.View;  import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.CheckBox;  import android.widget.Checkable; -import android.widget.GridView;  import android.widget.ImageButton; -import android.widget.Switch;  import android.widget.TextView; -import android.widget.Toast; - -import org.w3c.dom.Text;  import de.blinkt.openvpn.R;  import de.blinkt.openvpn.VpnProfile; diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/ShowConfigFragment.java b/main/src/main/java/de/blinkt/openvpn/fragments/ShowConfigFragment.java index 93af34af..037ab457 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/ShowConfigFragment.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/ShowConfigFragment.java @@ -24,14 +24,13 @@ import de.blinkt.openvpn.core.ProfileManager;  public class ShowConfigFragment extends Fragment {  	private String configtext; -	public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)  +    private TextView mConfigView; + +    public android.view.View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)  	{ -		String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID"); -		final VpnProfile vp = ProfileManager.get(getActivity(),profileUUID);  		View v=inflater.inflate(R.layout.viewconfig, container,false); -		final TextView cv = (TextView) v.findViewById(R.id.configview); +		mConfigView = (TextView) v.findViewById(R.id.configview); -		int check=vp.checkProfile(getActivity());          ImageButton fabButton = (ImageButton) v.findViewById(R.id.share_config);          if (fabButton!=null) @@ -42,16 +41,7 @@ public class ShowConfigFragment extends Fragment {                  }              }); -		if(check!=R.string.no_error_found) { -			cv.setText(check); -			configtext = getString(check); -		} -		else { -			// Run in own Thread since Keystore does not like to be queried from the main thread -			cv.setText("Generating config..."); -			startGenConfig(vp, cv); -		}  		return v;  	} @@ -104,4 +94,24 @@ public class ShowConfigFragment extends Fragment {  			return super.onOptionsItemSelected(item);  		}  	} + +    @Override +    public void onResume() { +        super.onResume(); + +        String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID"); +        final VpnProfile vp = ProfileManager.get(getActivity(),profileUUID); +        int check=vp.checkProfile(getActivity()); + +        if(check!=R.string.no_error_found) { +            mConfigView.setText(check); +            configtext = getString(check); +        } +        else { +            // Run in own Thread since Keystore does not like to be queried from the main thread + +            mConfigView.setText("Generating config..."); +            startGenConfig(vp, mConfigView); +        } +    }  } | 
