style issues fixed
This commit is contained in:
parent
dba64d6317
commit
0948476bf8
8 changed files with 33 additions and 28 deletions
|
@ -82,9 +82,9 @@ public class NetworkUtils {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ public class NetworkUtils {
|
||||||
Algorithms.closeStream(ous);
|
Algorithms.closeStream(ous);
|
||||||
return ous.toByteArray();
|
return ous.toByteArray();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
}
|
}
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.builder.api.OAuth1SignatureType;
|
||||||
import com.github.scribejava.core.model.*;
|
import com.github.scribejava.core.model.*;
|
||||||
import com.github.scribejava.core.oauth.OAuth10aService;
|
import com.github.scribejava.core.oauth.OAuth10aService;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -16,9 +18,10 @@ import java.util.concurrent.ExecutionException;
|
||||||
* @since 2746
|
* @since 2746
|
||||||
*/
|
*/
|
||||||
public class OsmOAuthAuthorizationClient {
|
public class OsmOAuthAuthorizationClient {
|
||||||
OAuth10aService service;
|
private OAuth1RequestToken requestToken;
|
||||||
OAuth1RequestToken requestToken;
|
private OAuth1AccessToken accessToken;
|
||||||
OAuth1AccessToken accessToken;
|
private final OAuth10aService service;
|
||||||
|
public final static Log log = PlatformUtil.getLog(OsmOAuthAuthorizationClient.class);
|
||||||
|
|
||||||
public OsmOAuthAuthorizationClient(String key, String secret) {
|
public OsmOAuthAuthorizationClient(String key, String secret) {
|
||||||
service = new ServiceBuilder(key)
|
service = new ServiceBuilder(key)
|
||||||
|
@ -58,7 +61,7 @@ public class OsmOAuthAuthorizationClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth1AccessToken getAccessToken() {
|
public OAuth1AccessToken getAccessToken() {
|
||||||
return this.accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response performRequestWithoutAuth(String url, String requestMethod, String requestBody)
|
public Response performRequestWithoutAuth(String url, String requestMethod, String requestBody)
|
||||||
|
@ -96,11 +99,11 @@ public class OsmOAuthAuthorizationClient {
|
||||||
try {
|
try {
|
||||||
requestToken = service.getRequestToken();
|
requestToken = service.getRequestToken();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
}
|
}
|
||||||
return requestToken;
|
return requestToken;
|
||||||
}
|
}
|
||||||
|
@ -109,11 +112,11 @@ public class OsmOAuthAuthorizationClient {
|
||||||
try {
|
try {
|
||||||
setAccessToken(service.getAccessToken(requestToken, oauthVerifier));
|
setAccessToken(service.getAccessToken(requestToken, oauthVerifier));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
}
|
}
|
||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ public class DownloadIndexesThread {
|
||||||
private ConcurrentLinkedQueue<IndexItem> indexItemDownloading = new ConcurrentLinkedQueue<IndexItem>();
|
private ConcurrentLinkedQueue<IndexItem> indexItemDownloading = new ConcurrentLinkedQueue<IndexItem>();
|
||||||
private IndexItem currentDownloadingItem = null;
|
private IndexItem currentDownloadingItem = null;
|
||||||
private int currentDownloadingItemProgress = 0;
|
private int currentDownloadingItemProgress = 0;
|
||||||
|
|
||||||
private DownloadResources indexes;
|
private DownloadResources indexes;
|
||||||
|
private static final int THREAD_ID = 10103;
|
||||||
|
|
||||||
public interface DownloadEvents {
|
public interface DownloadEvents {
|
||||||
|
|
||||||
|
@ -337,7 +337,6 @@ public class DownloadIndexesThread {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DownloadResources doInBackground(Void... params) {
|
protected DownloadResources doInBackground(Void... params) {
|
||||||
final int THREAD_ID = 10103;
|
|
||||||
TrafficStats.setThreadStatsTag(THREAD_ID);
|
TrafficStats.setThreadStatsTag(THREAD_ID);
|
||||||
DownloadResources result = null;
|
DownloadResources result = null;
|
||||||
DownloadOsmandIndexesHelper.IndexFileList indexFileList = DownloadOsmandIndexesHelper.getIndexesList(ctx);
|
DownloadOsmandIndexesHelper.IndexFileList indexFileList = DownloadOsmandIndexesHelper.getIndexesList(ctx);
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
id = Long.parseLong(response);
|
id = Long.parseLong(response);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
||||||
|
|
||||||
private OsmBugResult editingPOI(String url, String requestMethod, String userOperation,
|
private OsmBugResult editingPOI(String url, String requestMethod, String userOperation,
|
||||||
boolean anonymous) {
|
boolean anonymous) {
|
||||||
OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(this.app);
|
OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(app);
|
||||||
OsmBugResult r = new OsmBugResult();
|
OsmBugResult r = new OsmBugResult();
|
||||||
try {
|
try {
|
||||||
HttpURLConnection connection = NetworkUtils.getHttpURLConnection(url);
|
HttpURLConnection connection = NetworkUtils.getHttpURLConnection(url);
|
||||||
|
|
|
@ -19,17 +19,20 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.github.scribejava.core.model.OAuthAsyncRequestCallback;
|
import com.github.scribejava.core.model.OAuthAsyncRequestCallback;
|
||||||
import com.github.scribejava.core.model.Response;
|
import com.github.scribejava.core.model.Response;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||||
import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
|
import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter;
|
||||||
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class SettingsOsmEditingActivity extends SettingsBaseActivity {
|
public class SettingsOsmEditingActivity extends SettingsBaseActivity {
|
||||||
OsmOAuthAuthorizationAdapter client;
|
private OsmOAuthAuthorizationAdapter client;
|
||||||
|
private static final Log log = PlatformUtil.getLog(SettingsOsmEditingActivity.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -43,7 +46,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
|
||||||
((OsmandApplication) getApplication()).applyTheme(this);
|
((OsmandApplication) getApplication()).applyTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
client = new OsmOAuthAuthorizationAdapter(this.getMyApplication());
|
client = new OsmOAuthAuthorizationAdapter(getMyApplication());
|
||||||
|
|
||||||
getToolbar().setTitle(R.string.osm_settings);
|
getToolbar().setTitle(R.string.osm_settings);
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -78,12 +81,12 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
|
||||||
if (client.isValidToken()){
|
if (client.isValidToken()){
|
||||||
prefOAuth.setTitle(R.string.osm_authorization_success);
|
prefOAuth.setTitle(R.string.osm_authorization_success);
|
||||||
prefOAuth.setSummary(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);
|
final Preference prefTestUser = new Preference(this);
|
||||||
prefTestUser.setTitle(R.string.test_user_request);
|
prefTestUser.setTitle(R.string.test_user_request);
|
||||||
prefTestUser.setSummary(R.string.test_user_request_description);
|
prefTestUser.setSummary(R.string.test_user_request_description);
|
||||||
prefTestUser.setKey("local_openstreetmap_token");
|
prefTestUser.setKey("local_openstreetmap_oauth_user");
|
||||||
prefTestUser.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
prefTestUser.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
@ -94,7 +97,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
|
||||||
try {
|
try {
|
||||||
Toast.makeText(SettingsOsmEditingActivity.this,response.getBody(),Toast.LENGTH_SHORT).show();
|
Toast.makeText(SettingsOsmEditingActivity.this,response.getBody(),Toast.LENGTH_SHORT).show();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +113,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
|
||||||
final Preference prefClearToken = new Preference(this);
|
final Preference prefClearToken = new Preference(this);
|
||||||
prefClearToken.setTitle(R.string.shared_string_logoff);
|
prefClearToken.setTitle(R.string.shared_string_logoff);
|
||||||
prefClearToken.setSummary(R.string.clear_osm_token);
|
prefClearToken.setSummary(R.string.clear_osm_token);
|
||||||
prefClearToken.setKey("local_openstreetmap_token");
|
prefClearToken.setKey("local_openstreetmap_oauth_clear");
|
||||||
prefClearToken.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
prefClearToken.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
@ -128,7 +131,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
|
||||||
else {
|
else {
|
||||||
prefOAuth.setTitle(R.string.perform_oauth_authorization);
|
prefOAuth.setTitle(R.string.perform_oauth_authorization);
|
||||||
prefOAuth.setSummary(R.string.perform_oauth_authorization_description);
|
prefOAuth.setSummary(R.string.perform_oauth_authorization_description);
|
||||||
prefOAuth.setKey("local_openstreetmap_token");
|
prefOAuth.setKey("local_openstreetmap_oauth_login");
|
||||||
prefOAuth.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
prefOAuth.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class UploadOpenstreetmapPointAsyncTask
|
||||||
private OsmEditingPlugin plugin;
|
private OsmEditingPlugin plugin;
|
||||||
private final boolean closeChangeSet;
|
private final boolean closeChangeSet;
|
||||||
private final boolean loadAnonymous;
|
private final boolean loadAnonymous;
|
||||||
|
private static final int THREAD_ID = 10102;
|
||||||
|
|
||||||
public UploadOpenstreetmapPointAsyncTask(ProgressDialogFragment progress,
|
public UploadOpenstreetmapPointAsyncTask(ProgressDialogFragment progress,
|
||||||
OsmEditsUploadListener listener,
|
OsmEditsUploadListener listener,
|
||||||
|
@ -44,7 +45,6 @@ public class UploadOpenstreetmapPointAsyncTask
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
|
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
|
||||||
final int THREAD_ID = 10102;
|
|
||||||
TrafficStats.setThreadStatsTag(THREAD_ID);
|
TrafficStats.setThreadStatsTag(THREAD_ID);
|
||||||
|
|
||||||
Map<OsmPoint, String> loadErrorsMap = new HashMap<>();
|
Map<OsmPoint, String> loadErrorsMap = new HashMap<>();
|
||||||
|
|
|
@ -16,11 +16,11 @@ import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
public class OsmOAuthAuthorizationAdapter {
|
public class OsmOAuthAuthorizationAdapter {
|
||||||
OsmandApplication application;
|
private OsmandApplication application;
|
||||||
OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET);
|
private OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET);
|
||||||
|
private static final int THREAD_ID = 10101;
|
||||||
|
|
||||||
public OsmOAuthAuthorizationAdapter(OsmandApplication application) {
|
public OsmOAuthAuthorizationAdapter(OsmandApplication application) {
|
||||||
final int THREAD_ID = 10101;
|
|
||||||
TrafficStats.setThreadStatsTag(THREAD_ID);
|
TrafficStats.setThreadStatsTag(THREAD_ID);
|
||||||
this.application = application;
|
this.application = application;
|
||||||
restoreToken();
|
restoreToken();
|
||||||
|
|
Loading…
Reference in a new issue