diff options
author | Parménides GV <parmegv@sdf.org> | 2014-12-09 18:57:35 +0100 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2014-12-09 18:57:35 +0100 |
commit | 062e4c4597f947816282b1c9c5e63c034549f057 (patch) | |
tree | f66170fd661f658beca3f941b6ee7b097bcd842d /app/src | |
parent | e980e1f888f29806ab0933495fdb0dd383c944e7 (diff) |
Final refactoring for this bug.
Removed the sign up dialog, log in one is enough with the third button I
added some time ago to sign up.
Removed classes we don't need due to the libraries I have recently
introduced.
Diffstat (limited to 'app/src')
18 files changed, 199 insertions, 674 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java index 2e3fb8f1..63185d12 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -455,7 +455,7 @@ n * @param provider_main_url @Override public void login() { Intent ask_login = new Intent(); - ask_login.putExtra(LogInDialog.TAG, LogInDialog.TAG); + ask_login.putExtra(SessionDialog.TAG, SessionDialog.TAG); ask_login.putExtra(Provider.KEY, selected_provider); setResult(RESULT_OK, ask_login); setting_up_provider = false; diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java index 52a424f4..9ac5ff66 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java @@ -172,8 +172,8 @@ public class ProviderAPI extends IntentService { Bundle session_id_bundle = new Bundle(); int progress = 0; - String username = (String) task.get(SessionDialogInterface.USERNAME); - String password = (String) task.get(SessionDialogInterface.PASSWORD); + String username = (String) task.get(SessionDialog.USERNAME); + String password = (String) task.get(SessionDialog.PASSWORD); if(validUserLoginData(username, password)) { session_id_bundle = register(username, password); @@ -181,12 +181,12 @@ public class ProviderAPI extends IntentService { } else { if(!wellFormedPassword(password)) { session_id_bundle.putBoolean(RESULT_KEY, false); - session_id_bundle.putString(SessionDialogInterface.USERNAME, username); - session_id_bundle.putBoolean(SessionDialogInterface.PASSWORD_INVALID_LENGTH, true); + session_id_bundle.putString(SessionDialog.USERNAME, username); + session_id_bundle.putBoolean(SessionDialog.PASSWORD_INVALID_LENGTH, true); } if(username.isEmpty()) { session_id_bundle.putBoolean(RESULT_KEY, false); - session_id_bundle.putBoolean(SessionDialogInterface.USERNAME_MISSING, true); + session_id_bundle.putBoolean(SessionDialog.USERNAME_MISSING, true); } } @@ -205,8 +205,8 @@ public class ProviderAPI extends IntentService { if(api_result.has(ERRORS)) result = authFailedNotification(api_result, username); else { - result.putString(SessionDialogInterface.USERNAME, username); - result.putString(SessionDialogInterface.PASSWORD, password); + result.putString(SessionDialog.USERNAME, username); + result.putString(SessionDialog.PASSWORD, password); result.putBoolean(RESULT_KEY, true); } @@ -222,20 +222,20 @@ public class ProviderAPI extends IntentService { Bundle result = new Bundle(); int progress = 0; - String username = (String) task.get(SessionDialogInterface.USERNAME); - String password = (String) task.get(SessionDialogInterface.PASSWORD); + String username = (String) task.get(SessionDialog.USERNAME); + String password = (String) task.get(SessionDialog.PASSWORD); if(validUserLoginData(username, password)) { result = authenticate(username, password); broadcast_progress(progress++); } else { if(!wellFormedPassword(password)) { result.putBoolean(RESULT_KEY, false); - result.putString(SessionDialogInterface.USERNAME, username); - result.putBoolean(SessionDialogInterface.PASSWORD_INVALID_LENGTH, true); + result.putString(SessionDialog.USERNAME, username); + result.putBoolean(SessionDialog.PASSWORD_INVALID_LENGTH, true); } if(username.isEmpty()) { result.putBoolean(RESULT_KEY, false); - result.putBoolean(SessionDialogInterface.USERNAME_MISSING, true); + result.putBoolean(SessionDialog.USERNAME_MISSING, true); } } @@ -265,7 +265,7 @@ public class ProviderAPI extends IntentService { } } else { result.putBoolean(RESULT_KEY, false); - result.putString(SessionDialogInterface.USERNAME, username); + result.putString(SessionDialog.USERNAME, username); result.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_srp_math_error_user_message)); } } catch (JSONException e) { @@ -296,7 +296,7 @@ public class ProviderAPI extends IntentService { } catch(JSONException e) {} if(!username.isEmpty()) - user_notification_bundle.putString(SessionDialogInterface.USERNAME, username); + user_notification_bundle.putString(SessionDialog.USERNAME, username); user_notification_bundle.putBoolean(RESULT_KEY, false); return user_notification_bundle; diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index b84b834c..c7691ed4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -40,6 +40,8 @@ import org.json.JSONObject; import java.net.MalformedURLException; import java.net.URL; +import butterknife.ButterKnife; +import butterknife.InjectView; import de.blinkt.openvpn.activities.LogWindow; import se.leap.bitmaskclient.eip.Constants; import se.leap.bitmaskclient.eip.EIP; @@ -52,7 +54,7 @@ import se.leap.bitmaskclient.eip.EipStatus; * @author Sean Leonard <meanderingcode@aetherislands.net> * @author parmegv */ -public class Dashboard extends Activity implements LogInDialog.LogInDialogInterface, SignUpDialog.SignUpDialogInterface, ProviderAPIResultReceiver.Receiver { +public class Dashboard extends Activity implements SessionDialog.LogInDialogInterface, ProviderAPIResultReceiver.Receiver { protected static final int CONFIGURE_LEAP = 0; protected static final int SWITCH_PROVIDER = 1; @@ -70,12 +72,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf protected static SharedPreferences preferences; private FragmentManagerEnhanced fragment_manager; - private ProgressBar mProgressBar; - private TextView status_message; - public ProviderAPIResultReceiver providerAPI_result_receiver; + @InjectView(R.id.providerName) + TextView provider_name; + EipServiceFragment eip_fragment; private Provider provider; private static boolean authed_eip; + public ProviderAPIResultReceiver providerAPI_result_receiver; @Override protected void onSaveInstanceState(Bundle outState) { @@ -91,8 +94,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf app = this; PRNGFixes.apply(); - - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); @@ -157,7 +158,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf } buildDashboard(false); invalidateOptionsMenu(); - if (data.hasExtra(LogInDialog.TAG)) { + if (data.hasExtra(SessionDialog.TAG)) { logInDialog(Bundle.EMPTY); } } else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) { @@ -200,24 +201,21 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * service dependent UI elements to include. */ private void buildDashboard(boolean hide_and_turn_on_eip) { - setContentView(R.layout.client_dashboard); - - TextView providerNameTV = (TextView) findViewById(R.id.providerName); - providerNameTV.setText(provider.getDomain()); - providerNameTV.setTextSize(28); - - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); + setContentView(R.layout.dashboard); + ButterKnife.inject(this); + + provider_name.setText(provider.getDomain()); if ( provider.hasEIP()){ fragment_manager.removePreviousFragment(EipServiceFragment.TAG); - EipServiceFragment eip_fragment = new EipServiceFragment(); + eip_fragment = new EipServiceFragment(); if (hide_and_turn_on_eip) { preferences.edit().remove(Dashboard.START_ON_BOOT).apply(); Bundle arguments = new Bundle(); arguments.putBoolean(EipServiceFragment.START_ON_BOOT, true); - eip_fragment.setArguments(arguments); + if(eip_fragment != null) eip_fragment.setArguments(arguments); } fragment_manager.replace(R.id.servicesCollection, eip_fragment, EipServiceFragment.TAG); @@ -279,10 +277,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf return true; case R.id.switch_provider: if (provider.hasEIP()){ - if (preferences.getBoolean(Constants.AUTHED_EIP, false)){ - logOut(); - } - eipStop(); + if (preferences.getBoolean(Constants.AUTHED_EIP, false)) { + logOut(); + } + eip_fragment.stopEIP(); } preferences.edit().clear().apply(); startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); @@ -302,10 +300,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf } - private Intent prepareProviderAPICommand() { - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - status_message = (TextView) findViewById(R.id.status_message); - + private Intent prepareProviderAPICommand() { providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); providerAPI_result_receiver.setReceiver(this); @@ -319,12 +314,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * Shows the log in dialog. */ public void logInDialog(Bundle resultData) { - FragmentTransaction transaction = fragment_manager.removePreviousFragment(LogInDialog.TAG); + FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); - DialogFragment newFragment = LogInDialog.newInstance(); + DialogFragment newFragment = SessionDialog.newInstance(); if(resultData != null && !resultData.isEmpty()) newFragment.setArguments(resultData); - newFragment.show(transaction, LogInDialog.TAG); + newFragment.show(transaction, SessionDialog.TAG); } @Override @@ -334,12 +329,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf if(parameters == null) parameters = new Bundle(); - parameters.putString(SessionDialogInterface.USERNAME, username); - parameters.putString(SessionDialogInterface.PASSWORD, password); - - mProgressBar.setVisibility(ProgressBar.VISIBLE); - status_message.setText(R.string.authenticating_message); + parameters.putString(SessionDialog.USERNAME, username); + parameters.putString(SessionDialog.PASSWORD, password); + if(eip_fragment != null) { + eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); + eip_fragment.status_message.setText(R.string.authenticating_message); + } provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); provider_API_command.setAction(ProviderAPI.SRP_AUTH); startService(provider_API_command); @@ -354,12 +350,11 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf */ public void logOut() { Intent provider_API_command = prepareProviderAPICommand(); - - if(mProgressBar == null) mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - mProgressBar.setVisibility(ProgressBar.VISIBLE); - if(status_message == null) status_message = (TextView) findViewById(R.id.status_message); - status_message.setText(R.string.logout_message); - + if(eip_fragment != null) { + + eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); + eip_fragment.status_message.setText(R.string.logout_message); + } provider_API_command.setAction(ProviderAPI.LOG_OUT); startService(provider_API_command); } @@ -368,13 +363,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * Shows the sign up dialog. */ public void signUpDialog(Bundle resultData) { - FragmentTransaction transaction = fragment_manager.removePreviousFragment(SignUpDialog.TAG); + FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); - DialogFragment newFragment = SignUpDialog.newInstance(); + DialogFragment newFragment = SessionDialog.newInstance(); if(resultData != null && !resultData.isEmpty()) { newFragment.setArguments(resultData); } - newFragment.show(transaction, SignUpDialog.TAG); + newFragment.show(transaction, SessionDialog.TAG); } @Override @@ -384,12 +379,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf if(parameters == null) parameters = new Bundle(); - parameters.putString(SessionDialogInterface.USERNAME, username); - parameters.putString(SessionDialogInterface.PASSWORD, password); - - mProgressBar.setVisibility(ProgressBar.VISIBLE); - status_message.setText(R.string.signingup_message); - + parameters.putString(SessionDialog.USERNAME, username); + parameters.putString(SessionDialog.PASSWORD, password); + if(eip_fragment != null) { + eip_fragment.progress_bar.setVisibility(ProgressBar.VISIBLE); + eip_fragment.status_message.setText(R.string.signingup_message); + } provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); provider_API_command.setAction(ProviderAPI.SRP_REGISTER); startService(provider_API_command); @@ -418,8 +413,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf public void onReceiveResult(int resultCode, Bundle resultData) { Log.d(TAG, "onReceiveResult"); if(resultCode == ProviderAPI.SRP_REGISTRATION_SUCCESSFUL) { - String username = resultData.getString(SessionDialogInterface.USERNAME); - String password = resultData.getString(SessionDialogInterface.PASSWORD); + String username = resultData.getString(SessionDialog.USERNAME); + String password = resultData.getString(SessionDialog.PASSWORD); logIn(username, password); } else if(resultCode == ProviderAPI.SRP_REGISTRATION_FAILED) { changeStatusMessage(resultCode); @@ -477,8 +472,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf String request = resultData.getString(Constants.REQUEST_TAG); if(request.equalsIgnoreCase(Constants.ACTION_UPDATE_EIP_SERVICE)) { if(resultCode == Activity.RESULT_OK) { - if(authed_eip) - eipStart(); + if(authed_eip && eip_fragment != null) eip_fragment.startEipFromScratch(); } } } @@ -493,17 +487,16 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf protected void onReceiveResult(int resultCode, Bundle resultData){ super.onReceiveResult(resultCode, resultData); String request = resultData.getString(Constants.REQUEST_TAG); - if(status_message == null) status_message = (TextView) findViewById(R.id.status_message); - if (request.equalsIgnoreCase(Constants.ACTION_IS_EIP_RUNNING)){ + if (request.equalsIgnoreCase(Constants.ACTION_IS_EIP_RUNNING)){ if (resultCode == Activity.RESULT_OK){ switch(previous_result_code){ - case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.SRP_AUTHENTICATION_FAILED: status_message.setText(R.string.authentication_failed_message); break; - case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: status_message.setText(R.string.authed_secured_status); break; - case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.LOGOUT_SUCCESSFUL: status_message.setText(R.string.logged_out_message); break; - case ProviderAPI.LOGOUT_FAILED: status_message.setText(R.string.log_out_failed_message); break; + case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; + case ProviderAPI.SRP_AUTHENTICATION_FAILED: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; + case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.authed_secured_status); break; + case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; + case ProviderAPI.LOGOUT_SUCCESSFUL: eip_fragment.status_message.setText(R.string.logged_out_message); break; + case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; } } @@ -511,13 +504,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf switch(previous_result_code){ - case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: status_message.setText(R.string.succesful_authentication_message); break; - case ProviderAPI.SRP_AUTHENTICATION_FAILED: status_message.setText(R.string.authentication_failed_message); break; - case ProviderAPI.SRP_REGISTRATION_FAILED: status_message.setText(R.string.registration_failed_message); break; + case ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL: eip_fragment.status_message.setText(R.string.succesful_authentication_message); break; + case ProviderAPI.SRP_AUTHENTICATION_FAILED: eip_fragment.status_message.setText(R.string.authentication_failed_message); break; + case ProviderAPI.SRP_REGISTRATION_FAILED: eip_fragment.status_message.setText(R.string.registration_failed_message); break; case ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE: break; - case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; - case ProviderAPI.LOGOUT_SUCCESSFUL: status_message.setText(R.string.logged_out_message); break; - case ProviderAPI.LOGOUT_FAILED: status_message.setText(R.string.log_out_failed_message); break; + case ProviderAPI.INCORRECTLY_DOWNLOADED_CERTIFICATE: eip_fragment.status_message.setText(R.string.incorrectly_downloaded_certificate_message); break; + case ProviderAPI.LOGOUT_SUCCESSFUL: eip_fragment.status_message.setText(R.string.logged_out_message); break; + case ProviderAPI.LOGOUT_FAILED: eip_fragment.status_message.setText(R.string.log_out_failed_message); break; } } } @@ -528,11 +521,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf } private void hideProgressBar() { - if(mProgressBar == null) - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - - mProgressBar.setProgress(0); - mProgressBar.setVisibility(ProgressBar.GONE); + if(eip_fragment != null) { + eip_fragment.progress_bar.setProgress(0); + eip_fragment.progress_bar.setVisibility(ProgressBar.GONE); + } } /** @@ -559,20 +551,4 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf eip_intent.putExtra(Constants.RECEIVER_TAG, eip_receiver); startService(eip_intent); } - - private void eipStop(){ - EipServiceFragment eipFragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(EipServiceFragment.TAG); - eipFragment.stopEIP(); - } - - private void eipStart() { - EipServiceFragment eipFragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(EipServiceFragment.TAG); - eipFragment.startEipFromScratch(); - } - - protected void showProgressBar() { - if(mProgressBar == null) - mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); - mProgressBar.setVisibility(ProgressBar.VISIBLE); - } } diff --git a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java index 592a9552..a8ffda72 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipServiceFragment.java @@ -12,19 +12,22 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CompoundButton; +import android.widget.ProgressBar; import android.widget.Switch; import android.widget.TextView; import java.util.Observable; import java.util.Observer; +import butterknife.ButterKnife; +import butterknife.InjectView; +import butterknife.OnCheckedChanged; import de.blinkt.openvpn.activities.DisconnectVPN; import se.leap.bitmaskclient.eip.Constants; import se.leap.bitmaskclient.eip.EIP; import se.leap.bitmaskclient.eip.EipStatus; -public class EipServiceFragment extends Fragment implements Observer, CompoundButton.OnCheckedChangeListener { +public class EipServiceFragment extends Fragment implements Observer { public static String TAG = "se.leap.bitmask.EipServiceFragment"; @@ -33,9 +36,13 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu protected static final String STATUS_MESSAGE = TAG + ".status_message"; public static final String START_ON_BOOT = "start on boot"; - private View eipFragment; - private static Switch eipSwitch; - private TextView status_message; + private View view; + @InjectView(R.id.eipSwitch) + Switch eip_switch; + @InjectView(R.id.status_message) + TextView status_message; + @InjectView(R.id.eipProgress) + ProgressBar progress_bar; private static Activity parent_activity; private static EIPReceiver mEIPReceiver; @@ -57,35 +64,27 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - - eipFragment = inflater.inflate(R.layout.eip_service_fragment, container, false); - View eipDetail = eipFragment.findViewById(R.id.eipDetail); - eipDetail.setVisibility(View.VISIBLE); - - View eipSettings = eipFragment.findViewById(R.id.eipSettings); - eipSettings.setVisibility(View.GONE); // FIXME too! + view = inflater.inflate(R.layout.eip_service_fragment, container, false); + ButterKnife.inject(this, view); if (eip_status.isConnecting()) - eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE); - - status_message = (TextView) eipFragment.findViewById(R.id.status_message); + eip_switch.setVisibility(View.VISIBLE); - eipSwitch = (Switch) eipFragment.findViewById(R.id.eipSwitch); - Log.d(TAG, "onCreateView, eipSwitch is checked? " + eipSwitch.isChecked()); - eipSwitch.setOnCheckedChangeListener(this); - - if(getArguments() != null && getArguments().containsKey(START_ON_BOOT) && getArguments().getBoolean(START_ON_BOOT)) + Log.d(TAG, "onCreateView, eip_switch is checked? " + eip_switch.isChecked()); + + Bundle arguments = getArguments(); + if(arguments != null && arguments.containsKey(START_ON_BOOT) && arguments.getBoolean(START_ON_BOOT)) startEipFromScratch(); if (savedInstanceState != null) { - setStatusMessage(savedInstanceState.getString(STATUS_MESSAGE)); + status_message.setText(savedInstanceState.getString(STATUS_MESSAGE)); if(savedInstanceState.getBoolean(IS_PENDING)) eip_status.setConnecting(); else if(savedInstanceState.getBoolean(IS_CONNECTED)) { eip_status.setConnectedOrDisconnected(); } } - return eipFragment; + return view; } @Override @@ -106,22 +105,16 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu protected void saveEipStatus() { boolean eip_is_on = false; Log.d(TAG, "saveEipStatus"); - if(eipSwitch.isChecked()) { + if(eip_switch.isChecked()) { eip_is_on = true; } if(parent_activity != null) Dashboard.preferences.edit().putBoolean(Dashboard.START_ON_BOOT, eip_is_on).commit(); } - - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (buttonView.equals(eipSwitch)){ - handleSwitch(isChecked); - } - } - - private void handleSwitch(boolean isChecked) { + + @OnCheckedChanged(R.id.eipSwitch) + void handleSwitch(boolean isChecked) { if(isChecked) handleSwitchOn(); else @@ -175,31 +168,30 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu .setNegativeButton(parent_activity.getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - eipSwitch.setChecked(true); + eip_switch.setChecked(true); } }) .show(); } public void startEipFromScratch() { - eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE); + progress_bar.setVisibility(View.VISIBLE); + eip_switch.setVisibility(View.VISIBLE); String status = parent_activity.getString(R.string.eip_status_start_pending); - setStatusMessage(status); + status_message.setText(status); - if(!eipSwitch.isChecked()) { - eipSwitch.setChecked(true); + if(!eip_switch.isChecked()) { + eip_switch.setChecked(true); saveEipStatus(); } eipCommand(Constants.ACTION_START_EIP); } protected void stopEIP() { - View eipProgressBar = parent_activity.findViewById(R.id.eipProgress); - if(eipProgressBar != null) - eipProgressBar.setVisibility(View.GONE); - + hideProgressBar(); + String status = parent_activity.getString(R.string.eip_state_not_connected); - setStatusMessage(status); + status_message.setText(status); eipCommand(Constants.ACTION_STOP_EIP); } @@ -247,26 +239,26 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu hideProgressBar(); Log.d(TAG, "setConnectedUi? " + eip_status.isConnected()); adjustSwitch(); - setStatusMessage(parent_activity.getString(R.string.eip_state_connected)); + status_message.setText(parent_activity.getString(R.string.eip_state_connected)); } private void setDisconnectedUI(){ hideProgressBar(); adjustSwitch(); - setStatusMessage(parent_activity.getString(R.string.eip_state_not_connected)); + status_message.setText(parent_activity.getString(R.string.eip_state_not_connected)); } private void adjustSwitch() { if(eip_status.isConnected() || eip_status.isConnecting()) { - Log.d(TAG, "adjustSwitch, isConnected || isConnecting, is checked? " + eipSwitch.isChecked()); - if(!eipSwitch.isChecked()) { - eipSwitch.setChecked(true); + Log.d(TAG, "adjustSwitch, isConnected || isConnecting, is checked? " + eip_switch.isChecked()); + if(!eip_switch.isChecked()) { + eip_switch.setChecked(true); } } else { Log.d(TAG, "adjustSwitch, !isConnected && !isConnecting? " + eip_status.toString()); - if(eipSwitch.isChecked()) { - eipSwitch.setChecked(false); + if(eip_switch.isChecked()) { + eip_switch.setChecked(false); } } } @@ -275,8 +267,8 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu int localizedResId = eip_status.getLocalizedResId(); String logmessage = eip_status.getLogMessage(); String prefix = parent_activity.getString(localizedResId); - - setStatusMessage(prefix + " " + logmessage); + + status_message.setText(prefix + " " + logmessage); adjustSwitch(); } @@ -287,8 +279,8 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu } private void hideProgressBar() { - if(parent_activity != null && parent_activity.findViewById(R.id.eipProgress) != null) - parent_activity.findViewById(R.id.eipProgress).setVisibility(View.GONE); + if(progress_bar != null) + progress_bar.setVisibility(View.GONE); } protected class EIPReceiver extends ResultReceiver { @@ -307,10 +299,10 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu switch (resultCode){ case Activity.RESULT_OK: Log.d(TAG, "Action start eip = Result OK"); - eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE); + progress_bar.setVisibility(View.VISIBLE); break; case Activity.RESULT_CANCELED: - eipFragment.findViewById(R.id.eipProgress).setVisibility(View.GONE); + progress_bar.setVisibility(View.GONE); break; } } else if (request.equals(Constants.ACTION_STOP_EIP)) { @@ -337,9 +329,8 @@ public class EipServiceFragment extends Fragment implements Observer, CompoundBu case Activity.RESULT_CANCELED: Dashboard dashboard = (Dashboard) parent_activity; - dashboard.showProgressBar(); - String status = parent_activity.getString(R.string.updating_certificate_message); - setStatusMessage(status); + progress_bar.setVisibility(View.VISIBLE); + status_message.setText(getString(R.string.updating_certificate_message)); if(LeapSRPSession.getToken().isEmpty() && !Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false)) { dashboard.logInDialog(Bundle.EMPTY); } else { diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java deleted file mode 100644 index 875b76d7..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderListFragment.java +++ /dev/null @@ -1,216 +0,0 @@ -/**
- * Copyright (c) 2013 LEAP Encryption Access Project and contributers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package se.leap.bitmaskclient;
-
-import android.app.Activity;
-import android.app.ListFragment;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ListView;
-
-import butterknife.ButterKnife;
-import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
-
-/**
- * A list fragment representing a list of Providers. This fragment
- * also supports tablet devices by allowing list items to be given an
- * 'activated' state upon selection.
- * <p>
- * Activities containing this fragment MUST implement the {@link Callbacks}
- * interface.
- */
-public class ProviderListFragment extends ListFragment {
-
- public static String TAG = "provider_list_fragment";
- public static String SHOW_ALL_PROVIDERS = "show_all_providers";
- public static String TOP_PADDING = "top padding from providerlistfragment";
- private ProviderListAdapter content_adapter;
-
- /**
- * The serialization (saved instance state) Bundle key representing the
- * activated item position. Only used on tablets.
- */
- private static final String STATE_ACTIVATED_POSITION = "activated_position";
-
- /**
- * The fragment's current callback object, which is notified of list item
- * clicks.
- */
- private Callbacks mCallbacks = sDummyCallbacks;
-
- /**
- * The current activated item position. Only used on tablets.
- */
- private int mActivatedPosition = ListView.INVALID_POSITION;
-
- /**
- * A callback interface that all activities containing this fragment must
- * implement. This mechanism allows activities to be notified of item
- * selections.
- */
- public interface Callbacks {
- /**
- * Callback for when an item has been selected.
- */
- public void onItemSelected(String id);
- }
-
- /**
- * A dummy implementation of the {@link Callbacks} interface that does
- * nothing. Used only when this fragment is not attached to an activity.
- */
- private static Callbacks sDummyCallbacks = new Callbacks() {
- @Override
- public void onItemSelected(String id) {
- }
- };
-
- /**
- * Mandatory empty constructor for the fragment manager to instantiate the
- * fragment (e.g. upon screen orientation changes).
- */
- public ProviderListFragment() {
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.provider_list_fragment, container, false);
- ButterKnife.inject(this, view);
- return view;
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- // Restore the previously serialized activated item position.
- if (savedInstanceState != null
- && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
- setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
- }
- if(getArguments() != null && getArguments().containsKey(TOP_PADDING)) {
- int topPadding = getArguments().getInt(TOP_PADDING);
- View current_view = getView();
- current_view.setPadding(current_view.getPaddingLeft(), topPadding, current_view.getPaddingRight(), current_view.getPaddingBottom());
- }
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
-
- // Activities containing this fragment must implement its callbacks.
- if (!(activity instanceof Callbacks)) {
- throw new IllegalStateException("Activity must implement fragment's callbacks.");
- }
-
- mCallbacks = (Callbacks) activity;
- }
-
- @Override
- public void onDetach() {
- super.onDetach();
-
- // Reset the active callbacks interface to the dummy implementation.
- mCallbacks = sDummyCallbacks;
- }
-
- @Override
- public void onListItemClick(ListView listView, View view, int position, long id) {
- super.onListItemClick(listView, view, position, id);
-
- // Notify the active callbacks interface (the activity, if the
- // fragment is attached to one) that an item has been selected.
- mCallbacks.onItemSelected(ProviderListContent.ITEMS.get(position).name());
-
- for(int item_position = 0; item_position < listView.getCount(); item_position++) {
- if(item_position != position)
- content_adapter.hide(item_position);
- }
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- if (mActivatedPosition != ListView.INVALID_POSITION) {
- // Serialize and persist the activated item position.
- outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
- }
- }
-
- public void notifyAdapter() {
- content_adapter.notifyDataSetChanged();
- }
- /**
- * Turns on activate-on-click mode. When this mode is on, list items will be
- * given the 'activated' state when touched.
- */
- public void setActivateOnItemClick(boolean activateOnItemClick) {
- // When setting CHOICE_MODE_SINGLE, ListView will automatically
- // give items the 'activated' state when touched.
- getListView().setChoiceMode(activateOnItemClick
- ? ListView.CHOICE_MODE_SINGLE
- : ListView.CHOICE_MODE_NONE);
- }
-
- private void setActivatedPosition(int position) {
- if (position == ListView.INVALID_POSITION) {
- getListView().setItemChecked(mActivatedPosition, false);
- } else {
- getListView().setItemChecked(position, true);
- }
-
- mActivatedPosition = position;
- }
-
- public void removeLastItem() {
- content_adapter.remove(content_adapter.getItem(content_adapter.getCount()-1));
- content_adapter.notifyDataSetChanged();
- }
-
- public void addItem(Provider provider) {
- content_adapter.add(provider);
- content_adapter.notifyDataSetChanged();
- }
-
- public void hideAllBut(int position) {
- int real_count = content_adapter.getCount();
- for(int i = 0; i < real_count;)
- if(i != position) {
- content_adapter.hide(i);
- position--;
- real_count--;
- } else {
- i++;
- }
- }
-
- /**
- * @return a new instance of this ListFragment.
- */
- public static ProviderListFragment newInstance() {
- return new ProviderListFragment();
- }
-}
diff --git a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java index 5263392e..9676faa8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java @@ -26,6 +26,9 @@ import android.view.View; import android.widget.EditText; import android.widget.TextView; +import butterknife.ButterKnife; +import butterknife.InjectView; + /** * Implements the log in dialog, currently without progress dialog. * @@ -36,45 +39,56 @@ import android.widget.TextView; * @author parmegv * */ -public class LogInDialog extends SessionDialogInterface { +public class SessionDialog extends DialogFragment{ - final public static String TAG = LogInDialog.class.getSimpleName(); + final public static String TAG = SessionDialog.class.getSimpleName(); + + final public static String USERNAME = "username"; + final public static String PASSWORD = "password"; + final public static String USERNAME_MISSING = "username missing"; + final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length"; + + @InjectView(R.id.user_message) + TextView user_message; + @InjectView(R.id.username_entered) + EditText username_field; + @InjectView(R.id.password_entered) + EditText password_field; - private static LogInDialog dialog; + private static SessionDialog dialog; private static boolean is_eip_pending = false; public AlertDialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); - View log_in_dialog_view = inflater.inflate(R.layout.log_in_dialog, null); - - final TextView user_message = (TextView)log_in_dialog_view.findViewById(R.id.user_message); - final EditText username_field = (EditText)log_in_dialog_view.findViewById(R.id.username_entered); - final EditText password_field = (EditText)log_in_dialog_view.findViewById(R.id.password_entered); + View view = inflater.inflate(R.layout.session_dialog, null); + ButterKnife.inject(this, view); if(!username_field.getText().toString().isEmpty() && password_field.isFocusable()) { password_field.requestFocus(); } - if (getArguments() != null) { - is_eip_pending = getArguments().getBoolean(EipServiceFragment.IS_PENDING, false); - if (getArguments().containsKey(PASSWORD_INVALID_LENGTH)) - password_field.setError(getResources().getString(R.string.error_not_valid_password_user_message)); - if (getArguments().containsKey(USERNAME)) { - String username = getArguments().getString(USERNAME); + + Bundle arguments = getArguments(); + if (arguments != null) { + is_eip_pending = arguments.getBoolean(EipServiceFragment.IS_PENDING, false); + if (arguments.containsKey(PASSWORD_INVALID_LENGTH)) + password_field.setError(getString(R.string.error_not_valid_password_user_message)); + if (arguments.containsKey(USERNAME)) { + String username = arguments.getString(USERNAME); username_field.setText(username); } - if (getArguments().containsKey(USERNAME_MISSING)) { - username_field.setError(getResources().getString(R.string.username_ask)); + if (arguments.containsKey(USERNAME_MISSING)) { + username_field.setError(getString(R.string.username_ask)); } - if(getArguments().containsKey(getResources().getString(R.string.user_message))) - user_message.setText(getArguments().getString(getResources().getString(R.string.user_message))); + if(arguments.containsKey(getString(R.string.user_message))) + user_message.setText(arguments.getString(getString(R.string.user_message))); else user_message.setVisibility(View.GONE); } - builder.setView(log_in_dialog_view) + builder.setView(view) .setPositiveButton(R.string.login_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { String username = username_field.getText().toString(); @@ -99,9 +113,10 @@ public class LogInDialog extends SessionDialogInterface { return builder.create(); } + /** - * Interface used to communicate LogInDialog with Dashboard. + * Interface used to communicate SessionDialog with Dashboard. * * @author parmegv * @@ -119,7 +134,7 @@ public class LogInDialog extends SessionDialogInterface { */ public static DialogFragment newInstance() { if(dialog == null) - dialog = new LogInDialog(); + dialog = new SessionDialog(); return dialog; } diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java deleted file mode 100644 index 66b86ccd..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/SessionDialogInterface.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2013 LEAP Encryption Access Project and contributers - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient; - -import android.app.Activity; -import android.app.DialogFragment; -import android.content.DialogInterface; - -/** - * @author parmegv - */ -public abstract class SessionDialogInterface extends DialogFragment { - final public static String USERNAME = "username"; - final public static String PASSWORD = "password"; - final public static String USERNAME_MISSING = "username missing"; - final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length"; - - @Override - public void onAttach(Activity activity) { super.onAttach(activity); } - - @Override - public void onCancel(DialogInterface dialog) { super.onCancel(dialog); } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java deleted file mode 100644 index f6d6cc3f..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2013 LEAP Encryption Access Project and contributers - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - package se.leap.bitmaskclient; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.DialogFragment; -import android.content.DialogInterface; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.EditText; -import android.widget.TextView; - -/** - * Implements the sign up dialog, currently without progress dialog. - * - * It returns to the previous fragment when finished, and sends username and password to the registration method. - * - * It also notifies the user if the password is not valid. - * - * @author parmegv - * - */ -public class SignUpDialog extends SessionDialogInterface { - - final public static String TAG = SignUpDialog.class.getSimpleName(); - - private static SignUpDialog dialog; - private static boolean is_eip_pending = false; - - public AlertDialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - LayoutInflater inflater = getActivity().getLayoutInflater(); - View log_in_dialog_view = inflater.inflate(R.layout.log_in_dialog, null); - - final TextView user_message = (TextView)log_in_dialog_view.findViewById(R.id.user_message); - final EditText username_field = (EditText)log_in_dialog_view.findViewById(R.id.username_entered); - final EditText password_field = (EditText)log_in_dialog_view.findViewById(R.id.password_entered); - - if(!username_field.getText().toString().isEmpty() && password_field.isFocusable()) { - password_field.requestFocus(); - } - if (getArguments() != null) { - is_eip_pending = getArguments().getBoolean(EipServiceFragment.IS_PENDING, false); - if (getArguments().containsKey(PASSWORD_INVALID_LENGTH)) - password_field.setError(getResources().getString(R.string.error_not_valid_password_user_message)); - if(getArguments().containsKey(USERNAME_MISSING)) - username_field.setError(getResources().getString(R.string.username_ask)); - if(getArguments().containsKey(USERNAME)) { - String username = getArguments().getString(USERNAME); - username_field.setText(username); - } - if(getArguments().containsKey(getResources().getString(R.string.user_message))) - user_message.setText(getArguments().getString(getResources().getString(R.string.user_message))); - else - user_message.setVisibility(View.GONE); - } - - builder.setView(log_in_dialog_view) - .setPositiveButton(R.string.signup_button, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - String username = username_field.getText().toString(); - String password = password_field.getText().toString(); - dialog.dismiss(); - interface_with_Dashboard.signUp(username, password); - } - }) - .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - interface_with_Dashboard.cancelLoginOrSignup(); - } - }); - - return builder.create(); - } - - /** - * Interface used to communicate SignUpDialog with Dashboard. - * - * @author parmegv - * - */ - public interface SignUpDialogInterface { - public void signUp(String username, String password); - public void cancelLoginOrSignup(); - } - - SignUpDialogInterface interface_with_Dashboard; - - /** - * @return a new instance of this DialogFragment. - */ - public static DialogFragment newInstance() { - if(dialog == null) - dialog = new SignUpDialog(); - return dialog; - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - try { - interface_with_Dashboard = (SignUpDialogInterface) activity; - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() - + " must implement SignUpDialogListener"); - } - } - - @Override - public void onCancel(DialogInterface dialog) { - if(is_eip_pending) - interface_with_Dashboard.cancelLoginOrSignup(); - super.onCancel(dialog); - } -} diff --git a/app/src/main/res/layout-xlarge/client_dashboard.xml b/app/src/main/res/layout-xlarge/dashboard.xml index bd644e1e..bd644e1e 100644 --- a/app/src/main/res/layout-xlarge/client_dashboard.xml +++ b/app/src/main/res/layout-xlarge/dashboard.xml diff --git a/app/src/main/res/layout-xlarge/eip_service_fragment.xml b/app/src/main/res/layout-xlarge/eip_service_fragment.xml index d217e1a1..38b6aca3 100644 --- a/app/src/main/res/layout-xlarge/eip_service_fragment.xml +++ b/app/src/main/res/layout-xlarge/eip_service_fragment.xml @@ -37,39 +37,20 @@ android:layout_marginLeft="15dp" android:layout_marginRight="15dp" /> - <RelativeLayout - android:id="@+id/eipDetail" - android:layout_width="match_parent" + <TextView + android:id="@+id/status_message" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentRight="true" android:layout_below="@+id/eipLabel" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="10dp" - android:visibility="gone" > - - <ImageView - android:id="@+id/eipSettings" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:layout_margin="10dp" - android:contentDescription="@string/eip_settings_button_description" - android:src="@drawable/ic_sysbar_quicksettings" /> - - <TextView - android:id="@+id/status_message" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_centerVertical="true" - android:clickable="true" - android:text="@string/eip_state_not_connected" - android:textSize="16sp" /> + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:clickable="true" + android:text="@string/eip_state_not_connected" + android:textSize="16sp" /> - </RelativeLayout> </RelativeLayout> diff --git a/app/src/main/res/layout-xlarge/provider_list_fragment.xml b/app/src/main/res/layout-xlarge/provider_list_fragment.xml deleted file mode 100644 index 59dd37d1..00000000 --- a/app/src/main/res/layout-xlarge/provider_list_fragment.xml +++ /dev/null @@ -1,16 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:paddingLeft="12dp"
- android:paddingRight="12dp"
- android:paddingTop="12dp" >
-
- <ListView
- android:id="@id/android:list"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1"
- android:drawSelectorOnTop="false" />
-
-</LinearLayout> diff --git a/app/src/main/res/layout-xlarge/log_in_dialog.xml b/app/src/main/res/layout-xlarge/session_dialog.xml index 3a9eebb8..3a9eebb8 100644 --- a/app/src/main/res/layout-xlarge/log_in_dialog.xml +++ b/app/src/main/res/layout-xlarge/session_dialog.xml diff --git a/app/src/main/res/layout/client_dashboard.xml b/app/src/main/res/layout/dashboard.xml index f33ac285..67a1122f 100644 --- a/app/src/main/res/layout/client_dashboard.xml +++ b/app/src/main/res/layout/dashboard.xml @@ -25,6 +25,7 @@ android:id="@+id/providerName" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textSize="28sp" android:layout_marginLeft="10dp" android:ellipsize="marquee" android:fadingEdge="horizontal" diff --git a/app/src/main/res/layout/eip_service_fragment.xml b/app/src/main/res/layout/eip_service_fragment.xml index be2aa791..64d22147 100644 --- a/app/src/main/res/layout/eip_service_fragment.xml +++ b/app/src/main/res/layout/eip_service_fragment.xml @@ -22,8 +22,8 @@ android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="10dp" /> - - <ProgressBar + + <ProgressBar android:id="@+id/eipProgress" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -34,38 +34,18 @@ android:layout_marginLeft="15dp" android:layout_marginRight="15dp" /> - <RelativeLayout - android:id="@+id/eipDetail" - android:layout_width="match_parent" + <TextView + android:id="@+id/status_message" + android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" - android:layout_alignParentRight="true" - android:layout_below="@+id/eipLabel" + android:layout_below="@id/eipProgress" + android:layout_centerVertical="true" + android:paddingTop="5dp" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" - android:paddingTop="10dp" - android:visibility="gone" > - - <ImageView - android:id="@+id/eipSettings" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:layout_margin="10dp" - android:contentDescription="@string/eip_settings_button_description" - android:src="@drawable/ic_sysbar_quicksettings" /> - - <TextView - android:id="@+id/status_message" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_centerVertical="true" - android:clickable="true" - android:text="@string/eip_state_not_connected" /> - - </RelativeLayout> + android:clickable="true" + android:text="@string/eip_state_not_connected" /> </RelativeLayout> diff --git a/app/src/main/res/layout/provider_list_fragment.xml b/app/src/main/res/layout/provider_list_fragment.xml deleted file mode 100644 index 70dbae0d..00000000 --- a/app/src/main/res/layout/provider_list_fragment.xml +++ /dev/null @@ -1,15 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:paddingLeft="8dp"
- android:paddingRight="8dp" >
-
- <ListView
- android:id="@id/android:list"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1"
- android:drawSelectorOnTop="false" />
-
-</LinearLayout> diff --git a/app/src/main/res/layout/log_in_dialog.xml b/app/src/main/res/layout/session_dialog.xml index c8a2f0a8..62215ae8 100644 --- a/app/src/main/res/layout/log_in_dialog.xml +++ b/app/src/main/res/layout/session_dialog.xml @@ -4,13 +4,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" - tools:context=".LogInDialog" > + tools:context=".SessionDialog" > <TextView android:id="@+id/user_message" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" + android:visibility="gone" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText diff --git a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java index 42736444..c90ce481 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -58,7 +58,6 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download @Inject ProviderListAdapter adapter; private ProviderManager provider_manager; - private ProviderListFragment provider_list_fragment; private Intent mConfigState = new Intent(); private Provider selected_provider; @@ -162,10 +161,6 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download initProviderList(); } - private void putProviderListFragment() { - fragment_manager.replace(R.id.configuration_wizard_layout, provider_list_fragment, ProviderListFragment.TAG); - } - @Override protected void onDestroy() { super.onDestroy(); @@ -463,7 +458,7 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download public void login() { Intent ask_login = new Intent(); ask_login.putExtra(Provider.KEY, selected_provider); - ask_login.putExtra(LogInDialog.TAG, LogInDialog.TAG); + ask_login.putExtra(SessionDialog.TAG, SessionDialog.TAG); setResult(RESULT_OK, ask_login); setting_up_provider = false; finish(); diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java index fc74b702..f5f27247 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java @@ -32,6 +32,7 @@ import org.apache.http.client.ClientProtocolException; import org.json.*; import se.leap.bitmaskclient.R; +import se.leap.bitmaskclient.SessionDialog; import se.leap.bitmaskclient.eip.*; /** @@ -169,8 +170,8 @@ public class ProviderAPI extends IntentService { Bundle session_id_bundle = new Bundle(); int progress = 0; - String username = (String) task.get(SessionDialogInterface.USERNAME); - String password = (String) task.get(SessionDialogInterface.PASSWORD); + String username = (String) task.get(SessionDialog.USERNAME); + String password = (String) task.get(SessionDialog.PASSWORD); if(validUserLoginData(username, password)) { session_id_bundle = register(username, password); @@ -178,12 +179,12 @@ public class ProviderAPI extends IntentService { } else { if(!wellFormedPassword(password)) { session_id_bundle.putBoolean(RESULT_KEY, false); - session_id_bundle.putString(SessionDialogInterface.USERNAME, username); - session_id_bundle.putBoolean(SessionDialogInterface.PASSWORD_INVALID_LENGTH, true); + session_id_bundle.putString(SessionDialog.USERNAME, username); + session_id_bundle.putBoolean(SessionDialog.PASSWORD_INVALID_LENGTH, true); } if(username.isEmpty()) { session_id_bundle.putBoolean(RESULT_KEY, false); - session_id_bundle.putBoolean(SessionDialogInterface.USERNAME_MISSING, true); + session_id_bundle.putBoolean(SessionDialog.USERNAME_MISSING, true); } } @@ -202,8 +203,8 @@ public class ProviderAPI extends IntentService { if(api_result.has(ERRORS)) result = authFailedNotification(api_result, username); else { - result.putString(SessionDialogInterface.USERNAME, username); - result.putString(SessionDialogInterface.PASSWORD, password); + result.putString(SessionDialog.USERNAME, username); + result.putString(SessionDialog.PASSWORD, password); result.putBoolean(RESULT_KEY, true); } @@ -220,20 +221,20 @@ public class ProviderAPI extends IntentService { Bundle result = new Bundle(); int progress = 0; - String username = (String) task.get(SessionDialogInterface.USERNAME); - String password = (String) task.get(SessionDialogInterface.PASSWORD); + String username = (String) task.get(SessionDialog.USERNAME); + String password = (String) task.get(SessionDialog.PASSWORD); if(validUserLoginData(username, password)) { result = authenticate(username, password); broadcast_progress(progress++); } else { if(!wellFormedPassword(password)) { result.putBoolean(RESULT_KEY, false); - result.putString(SessionDialogInterface.USERNAME, username); - result.putBoolean(SessionDialogInterface.PASSWORD_INVALID_LENGTH, true); + result.putString(SessionDialog.USERNAME, username); + result.putBoolean(SessionDialog.PASSWORD_INVALID_LENGTH, true); } if(username.isEmpty()) { result.putBoolean(RESULT_KEY, false); - result.putBoolean(SessionDialogInterface.USERNAME_MISSING, true); + result.putBoolean(SessionDialog.USERNAME_MISSING, true); } } @@ -262,7 +263,7 @@ public class ProviderAPI extends IntentService { } } else { result.putBoolean(RESULT_KEY, false); - result.putString(SessionDialogInterface.USERNAME, username); + result.putString(SessionDialog.USERNAME, username); result.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_srp_math_error_user_message)); } } catch (JSONException e) { @@ -293,7 +294,7 @@ public class ProviderAPI extends IntentService { } catch(JSONException e) {} if(!username.isEmpty()) - user_notification_bundle.putString(SessionDialogInterface.USERNAME, username); + user_notification_bundle.putString(SessionDialog.USERNAME, username); user_notification_bundle.putBoolean(RESULT_KEY, false); return user_notification_bundle; |