style issues fixed

This commit is contained in:
simon 2020-10-05 09:54:25 +03:00
parent dba64d6317
commit 0948476bf8
8 changed files with 33 additions and 28 deletions

View file

@ -82,9 +82,9 @@ public class NetworkUtils {
}
return null;
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e);
} catch (ExecutionException e) {
e.printStackTrace();
log.error(e);
}
return null;
}
@ -166,7 +166,7 @@ public class NetworkUtils {
Algorithms.closeStream(ous);
return ous.toByteArray();
} catch (IOException e) {
e.printStackTrace();
log.error(e);
}
return new byte[0];
}

View file

@ -6,6 +6,8 @@ import com.github.scribejava.core.builder.api.DefaultApi10a;
import com.github.scribejava.core.builder.api.OAuth1SignatureType;
import com.github.scribejava.core.model.*;
import com.github.scribejava.core.oauth.OAuth10aService;
import net.osmand.PlatformUtil;
import org.apache.commons.logging.Log;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
@ -16,9 +18,10 @@ import java.util.concurrent.ExecutionException;
* @since 2746
*/
public class OsmOAuthAuthorizationClient {
OAuth10aService service;
OAuth1RequestToken requestToken;
OAuth1AccessToken accessToken;
private OAuth1RequestToken requestToken;
private OAuth1AccessToken accessToken;
private final OAuth10aService service;
public final static Log log = PlatformUtil.getLog(OsmOAuthAuthorizationClient.class);
public OsmOAuthAuthorizationClient(String key, String secret) {
service = new ServiceBuilder(key)
@ -58,7 +61,7 @@ public class OsmOAuthAuthorizationClient {
}
public OAuth1AccessToken getAccessToken() {
return this.accessToken;
return accessToken;
}
public Response performRequestWithoutAuth(String url, String requestMethod, String requestBody)
@ -96,11 +99,11 @@ public class OsmOAuthAuthorizationClient {
try {
requestToken = service.getRequestToken();
} catch (IOException e) {
e.printStackTrace();
log.error(e);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e);
} catch (ExecutionException e) {
e.printStackTrace();
log.error(e);
}
return requestToken;
}
@ -109,11 +112,11 @@ public class OsmOAuthAuthorizationClient {
try {
setAccessToken(service.getAccessToken(requestToken, oauthVerifier));
} catch (IOException e) {
e.printStackTrace();
log.error(e);
} catch (InterruptedException e) {
e.printStackTrace();
log.error(e);
} catch (ExecutionException e) {
e.printStackTrace();
log.error(e);
}
return accessToken;
}

View file

@ -59,8 +59,8 @@ public class DownloadIndexesThread {
private ConcurrentLinkedQueue<IndexItem> indexItemDownloading = new ConcurrentLinkedQueue<IndexItem>();
private IndexItem currentDownloadingItem = null;
private int currentDownloadingItemProgress = 0;
private DownloadResources indexes;
private static final int THREAD_ID = 10103;
public interface DownloadEvents {
@ -337,7 +337,6 @@ public class DownloadIndexesThread {
@Override
protected DownloadResources doInBackground(Void... params) {
final int THREAD_ID = 10103;
TrafficStats.setThreadStatsTag(THREAD_ID);
DownloadResources result = null;
DownloadOsmandIndexesHelper.IndexFileList indexFileList = DownloadOsmandIndexesHelper.getIndexesList(ctx);

View file

@ -180,7 +180,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
id = Long.parseLong(response);
}
} catch (Exception e) {
e.printStackTrace();
log.error(e);
}
return id;
}

View file

@ -109,7 +109,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
private OsmBugResult editingPOI(String url, String requestMethod, String userOperation,
boolean anonymous) {
OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(this.app);
OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(app);
OsmBugResult r = new OsmBugResult();
try {
HttpURLConnection connection = NetworkUtils.getHttpURLConnection(url);

View file

@ -19,17 +19,20 @@ import android.widget.TextView;
import android.widget.Toast;
import com.github.scribejava.core.model.OAuthAsyncRequestCallback;
import com.github.scribejava.core.model.Response;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
import org.apache.commons.logging.Log;
import java.io.IOException;
public class SettingsOsmEditingActivity extends SettingsBaseActivity {
OsmOAuthAuthorizationAdapter client;
private OsmOAuthAuthorizationAdapter client;
private static final Log log = PlatformUtil.getLog(SettingsOsmEditingActivity.class);
@Override
public void onCreate(Bundle savedInstanceState) {
@ -43,7 +46,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
client = new OsmOAuthAuthorizationAdapter(this.getMyApplication());
client = new OsmOAuthAuthorizationAdapter(getMyApplication());
getToolbar().setTitle(R.string.osm_settings);
@SuppressWarnings("deprecation")
@ -78,12 +81,12 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
if (client.isValidToken()){
prefOAuth.setTitle(R.string.osm_authorization_success);
prefOAuth.setSummary(R.string.osm_authorization_success);
prefOAuth.setKey("local_openstreetmap_token");
prefOAuth.setKey("local_openstreetmap_oauth_success");
final Preference prefTestUser = new Preference(this);
prefTestUser.setTitle(R.string.test_user_request);
prefTestUser.setSummary(R.string.test_user_request_description);
prefTestUser.setKey("local_openstreetmap_token");
prefTestUser.setKey("local_openstreetmap_oauth_user");
prefTestUser.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
@ -94,7 +97,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
try {
Toast.makeText(SettingsOsmEditingActivity.this,response.getBody(),Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
log.error(e);
}
}
@ -110,7 +113,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
final Preference prefClearToken = new Preference(this);
prefClearToken.setTitle(R.string.shared_string_logoff);
prefClearToken.setSummary(R.string.clear_osm_token);
prefClearToken.setKey("local_openstreetmap_token");
prefClearToken.setKey("local_openstreetmap_oauth_clear");
prefClearToken.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
@ -128,7 +131,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
else {
prefOAuth.setTitle(R.string.perform_oauth_authorization);
prefOAuth.setSummary(R.string.perform_oauth_authorization_description);
prefOAuth.setKey("local_openstreetmap_token");
prefOAuth.setKey("local_openstreetmap_oauth_login");
prefOAuth.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {

View file

@ -25,6 +25,7 @@ public class UploadOpenstreetmapPointAsyncTask
private OsmEditingPlugin plugin;
private final boolean closeChangeSet;
private final boolean loadAnonymous;
private static final int THREAD_ID = 10102;
public UploadOpenstreetmapPointAsyncTask(ProgressDialogFragment progress,
OsmEditsUploadListener listener,
@ -44,7 +45,6 @@ public class UploadOpenstreetmapPointAsyncTask
@Override
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
final int THREAD_ID = 10102;
TrafficStats.setThreadStatsTag(THREAD_ID);
Map<OsmPoint, String> loadErrorsMap = new HashMap<>();

View file

@ -16,11 +16,11 @@ import java.io.IOException;
import java.util.concurrent.ExecutionException;
public class OsmOAuthAuthorizationAdapter {
OsmandApplication application;
OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET);
private OsmandApplication application;
private OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET);
private static final int THREAD_ID = 10101;
public OsmOAuthAuthorizationAdapter(OsmandApplication application) {
final int THREAD_ID = 10101;
TrafficStats.setThreadStatsTag(THREAD_ID);
this.application = application;
restoreToken();