Loading app/src/main/java/net/fabiszewski/ulogger/ProviderPreferenceDialogFragment.java +14 −7 Original line number Diff line number Diff line Loading @@ -66,13 +66,17 @@ public class ProviderPreferenceDialogFragment extends ListPreferenceDialogWithMe protected void onPrepareDialogBuilder(@NonNull AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); preference = (ListPreference) getPreference(); final Context context = getContext(); if (context == null) { return; } preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (Logger.DEBUG) { Log.d(TAG, "[preference changed: " + newValue + "]"); } int providersMask = Integer.valueOf((String) newValue); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(SettingsActivity.KEY_USE_GPS, (providersMask & VALUE_GPS) == VALUE_GPS); editor.putBoolean(SettingsActivity.KEY_USE_NET, (providersMask & VALUE_NET) == VALUE_NET); Loading @@ -84,7 +88,7 @@ public class ProviderPreferenceDialogFragment extends ListPreferenceDialogWithMe entries = preference.getEntries(); entryValues = preference.getEntryValues(); int defaultValue = VALUE_ALL; LocationManager locManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); LocationManager locManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); missingProviders = new ArrayList<>(); final boolean existsGPS = locManager != null && locManager.getAllProviders().contains(LocationManager.GPS_PROVIDER); final boolean existsNet = locManager != null && locManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER); Loading Loading @@ -130,12 +134,15 @@ public class ProviderPreferenceDialogFragment extends ListPreferenceDialogWithMe @SuppressLint("PrivateResource") private int getSingleChoiceLayoutResource() { int resId = android.R.layout.select_dialog_singlechoice; final TypedArray typedArray = getContext().obtainStyledAttributes(null, R.styleable.AlertDialog, final Context context = getContext(); if (context != null) { final TypedArray typedArray = context.obtainStyledAttributes(null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0); if (typedArray != null) { resId = typedArray.getResourceId(R.styleable.AlertDialog_singleChoiceItemLayout, resId); typedArray.recycle(); } } return resId; } Loading app/src/main/java/net/fabiszewski/ulogger/UrlPreferenceDialogFragment.java +23 −20 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ package net.fabiszewski.ulogger; import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.text.InputType; import android.view.View; Loading @@ -35,11 +36,12 @@ public class UrlPreferenceDialogFragment extends EditTextPreferenceDialogFragmen super.onStart(); final AlertDialog dialog = (AlertDialog) getDialog(); if (dialog != null) { final EditText editText = dialog.findViewById(android.R.id.edit); Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE); if (editText != null && positiveButton != null) { positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText editText = dialog.findViewById(android.R.id.edit); final String url = editText.getText().toString().trim(); if (url.isEmpty() || WebHelper.isValidURL(url)) { editText.setError(null); Loading @@ -47,16 +49,17 @@ public class UrlPreferenceDialogFragment extends EditTextPreferenceDialogFragmen preference.setText(url); dismiss(); } else { final Context context = getContext(); if (context != null) { editText.setError(getContext().getString(R.string.provide_valid_url)); } } } }); // xml attribute inputType doesn't work in androidx EditText editText = dialog.findViewById(android.R.id.edit); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); // xml attribute hint doesn't work in androidx editText.setHint("https://www.example.com"); } } } } app/src/main/java/net/fabiszewski/ulogger/WebSyncService.java +7 −1 Original line number Diff line number Diff line Loading @@ -105,13 +105,17 @@ public class WebSyncService extends IntentService { /** * Get track id * If the track hasn't been registered on server yet, * get set up new track on the server and get new id * set up new track on the server and get new id * @return Track id */ private int getTrackId() { int trackId = db.getTrackId(); if (trackId == 0) { String trackName = db.getTrackName(); if (trackName == null) { handleError(new IllegalStateException("no track")); return trackId; } try { trackId = web.startTrack(trackName); db.setTrackId(trackId); Loading Loading @@ -193,6 +197,8 @@ public class WebSyncService extends IntentService { message = getString(R.string.e_bad_url, e.getMessage()); } else if (e instanceof ConnectException || e instanceof NoRouteToHostException) { message = getString(R.string.e_connect, e.getMessage()); } else if (e instanceof IllegalStateException) { message = getString(R.string.e_illegal_state, e.getMessage()); } else { message = e.getMessage(); } Loading app/src/main/res/values-pl/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -114,4 +114,5 @@ <string name="pref_cat_location">Śledzenie pozycji</string> <string name="pref_cat_server">Serwer</string> <string name="pref_cat_other">Inne</string> <string name="e_illegal_state">Błędny stan: %s</string> </resources> app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ <string name="unit_mile">mi.</string> <string name="provide_valid_url">Please provide valid server url</string> <string name="provide_user_pass_url">Please enter user, password and server url first</string> <string name="e_illegal_state">Illegal state error: %s</string> <string name="e_illegal_redirect">Illegal redirect: %d</string> <string name="e_auth_failure">Authorization failure: %d</string> <string name="e_http_code">HTTP error code: %d</string> Loading Loading
app/src/main/java/net/fabiszewski/ulogger/ProviderPreferenceDialogFragment.java +14 −7 Original line number Diff line number Diff line Loading @@ -66,13 +66,17 @@ public class ProviderPreferenceDialogFragment extends ListPreferenceDialogWithMe protected void onPrepareDialogBuilder(@NonNull AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); preference = (ListPreference) getPreference(); final Context context = getContext(); if (context == null) { return; } preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (Logger.DEBUG) { Log.d(TAG, "[preference changed: " + newValue + "]"); } int providersMask = Integer.valueOf((String) newValue); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(SettingsActivity.KEY_USE_GPS, (providersMask & VALUE_GPS) == VALUE_GPS); editor.putBoolean(SettingsActivity.KEY_USE_NET, (providersMask & VALUE_NET) == VALUE_NET); Loading @@ -84,7 +88,7 @@ public class ProviderPreferenceDialogFragment extends ListPreferenceDialogWithMe entries = preference.getEntries(); entryValues = preference.getEntryValues(); int defaultValue = VALUE_ALL; LocationManager locManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); LocationManager locManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); missingProviders = new ArrayList<>(); final boolean existsGPS = locManager != null && locManager.getAllProviders().contains(LocationManager.GPS_PROVIDER); final boolean existsNet = locManager != null && locManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER); Loading Loading @@ -130,12 +134,15 @@ public class ProviderPreferenceDialogFragment extends ListPreferenceDialogWithMe @SuppressLint("PrivateResource") private int getSingleChoiceLayoutResource() { int resId = android.R.layout.select_dialog_singlechoice; final TypedArray typedArray = getContext().obtainStyledAttributes(null, R.styleable.AlertDialog, final Context context = getContext(); if (context != null) { final TypedArray typedArray = context.obtainStyledAttributes(null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0); if (typedArray != null) { resId = typedArray.getResourceId(R.styleable.AlertDialog_singleChoiceItemLayout, resId); typedArray.recycle(); } } return resId; } Loading
app/src/main/java/net/fabiszewski/ulogger/UrlPreferenceDialogFragment.java +23 −20 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ package net.fabiszewski.ulogger; import android.app.Dialog; import android.content.Context; import android.os.Bundle; import android.text.InputType; import android.view.View; Loading @@ -35,11 +36,12 @@ public class UrlPreferenceDialogFragment extends EditTextPreferenceDialogFragmen super.onStart(); final AlertDialog dialog = (AlertDialog) getDialog(); if (dialog != null) { final EditText editText = dialog.findViewById(android.R.id.edit); Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE); if (editText != null && positiveButton != null) { positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText editText = dialog.findViewById(android.R.id.edit); final String url = editText.getText().toString().trim(); if (url.isEmpty() || WebHelper.isValidURL(url)) { editText.setError(null); Loading @@ -47,16 +49,17 @@ public class UrlPreferenceDialogFragment extends EditTextPreferenceDialogFragmen preference.setText(url); dismiss(); } else { final Context context = getContext(); if (context != null) { editText.setError(getContext().getString(R.string.provide_valid_url)); } } } }); // xml attribute inputType doesn't work in androidx EditText editText = dialog.findViewById(android.R.id.edit); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); // xml attribute hint doesn't work in androidx editText.setHint("https://www.example.com"); } } } }
app/src/main/java/net/fabiszewski/ulogger/WebSyncService.java +7 −1 Original line number Diff line number Diff line Loading @@ -105,13 +105,17 @@ public class WebSyncService extends IntentService { /** * Get track id * If the track hasn't been registered on server yet, * get set up new track on the server and get new id * set up new track on the server and get new id * @return Track id */ private int getTrackId() { int trackId = db.getTrackId(); if (trackId == 0) { String trackName = db.getTrackName(); if (trackName == null) { handleError(new IllegalStateException("no track")); return trackId; } try { trackId = web.startTrack(trackName); db.setTrackId(trackId); Loading Loading @@ -193,6 +197,8 @@ public class WebSyncService extends IntentService { message = getString(R.string.e_bad_url, e.getMessage()); } else if (e instanceof ConnectException || e instanceof NoRouteToHostException) { message = getString(R.string.e_connect, e.getMessage()); } else if (e instanceof IllegalStateException) { message = getString(R.string.e_illegal_state, e.getMessage()); } else { message = e.getMessage(); } Loading
app/src/main/res/values-pl/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -114,4 +114,5 @@ <string name="pref_cat_location">Śledzenie pozycji</string> <string name="pref_cat_server">Serwer</string> <string name="pref_cat_other">Inne</string> <string name="e_illegal_state">Błędny stan: %s</string> </resources>
app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ <string name="unit_mile">mi.</string> <string name="provide_valid_url">Please provide valid server url</string> <string name="provide_user_pass_url">Please enter user, password and server url first</string> <string name="e_illegal_state">Illegal state error: %s</string> <string name="e_illegal_redirect">Illegal redirect: %d</string> <string name="e_auth_failure">Authorization failure: %d</string> <string name="e_http_code">HTTP error code: %d</string> Loading