Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RunKeeper remove feed #608

Merged
merged 18 commits into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a5cc120
Whitespace changes for insert accounts
gerhardol Jul 28, 2017
215263d
Hardcode used of "name" instead of Constants.DB.ACCOUNT.NAME
gerhardol Jul 28, 2017
55d45ec
Move PUBLIC_URL to Synchronizer modules (from dbhelper)
gerhardol Jul 28, 2017
4a0713c
Move use DB.ACCOUNT.ICON from database to code
gerhardol Jul 28, 2017
b579280
Remove use of DB.ACCOUNT FORMAT, AUTH_METHOD
gerhardol Jul 28, 2017
4bed7fc
Remove AUTH_NOTICE column from db, use resource in synchronizer
gerhardol Jul 29, 2017
597d45d
Hide unusable synchers (Garmin etc) in the account list
gerhardol Jul 29, 2017
45216a6
AccountList: Long press to toggle enabled
gerhardol Jul 29, 2017
e88d1b8
DB Account: Remove use of column DESCRIPTION
gerhardol Jul 30, 2017
63b7343
DB Account: Get URL for presentation from synchronizer instead of DB.…
gerhardol Jul 30, 2017
38829c6
typo in recreateAccount (from 2015, affecting updating from 2013)
gerhardol Jul 30, 2017
ee72627
DB Account: Prepare for moving FORMAT to AUTH_CONFIG for FileSynchron…
gerhardol Jul 30, 2017
aeec23d
Runalyze: Decrease verbisity
gerhardol Jul 31, 2017
321af18
ExternalId handling for uploaded activities
gerhardol Aug 5, 2017
03ce75a
If an account have external ids configured, show them as clickable li…
gerhardol Aug 5, 2017
c6ac6de
Strava: Get Strava ID (external id) for uploaded activities
gerhardol Aug 5, 2017
553cc8d
Disable RunKeeper Feed (not working for some years)
gerhardol Aug 9, 2017
3cf9975
Remove RunKeeper feed implementation
gerhardol Aug 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 1 addition & 31 deletions app/latest/java/org/runnerup/feedwidget/FeedWidgetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,35 +135,6 @@ private RemoteViews getViewFactorizedAt(int position) {
} else {
rv.setViewVisibility(R.id.feed_widget_item_notes, View.GONE);
}

// c.put(FEED.FEED_TYPE, FEED.FEED_TYPE_ACTIVITY);
// c.put(FEED.FEED_SUBTYPE,
// getTrainingType(o.getInt("TrainingTypeID"),
// o.getString("TrainingTypeName")));
// c.put(FEED.FEED_TYPE_STRING,
// o.getString("TrainingTypeName"));
// c.put(FEED.START_TIME,
// parseDateTime(o.getString("DateTime")));
// if (!o.isNull("Distance"))
// c.put(FEED.DISTANCE, 1000 * o.getDouble("Distance"));
// if (!o.isNull("Duration"))
// c.put(FEED.DURATION,
// getDuration(o.getJSONObject("Duration")));
// if (!o.isNull("PersonID"))
// c.put(FEED.USER_ID, o.getInt("PersonID"));
// if (!o.isNull("Firstname"))
// c.put(FEED.USER_FIRST_NAME, o.getString("Firstname"));
// if (!o.isNull("Lastname"))
// c.put(FEED.USER_LAST_NAME, o.getString("Lastname"));
// if (!o.isNull("PictureURL"))
// c.put(FEED.USER_IMAGE_URL,
// o.getString("PictureURL").replace("~/",
// "http://www.funbeat.se/"));
// if (!o.isNull("Description"))
// c.put(FEED.NOTES, o.getString("Description"));
// c.put(FEED.URL,
// "http://www.funbeat.se/training/show.aspx?TrainingID="
// + Long.toString(o.getLong("ID")));
} else {
Log.e(getClass().getSimpleName(), "Unexpected feed type");
}
Expand All @@ -178,10 +149,9 @@ private String getSynchronizerName(long id) {
};
Cursor c = mDB.query(Constants.DB.ACCOUNT.TABLE, from, "_id = ?",
args, null, null, null, null);
String name = "?";
c.moveToFirst();
ContentValues config = DBHelper.get(c);
name = config.getAsString("name");
String name = config.getAsString(Constants.DB.ACCOUNT.NAME);
c.close();
return name;
}
Expand Down
1 change: 1 addition & 0 deletions app/res/layout/account_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<TableRow
android:id="@+id/table_row1"
android:longClickable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
Expand Down
5 changes: 4 additions & 1 deletion app/res/layout/reportlist_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
android:id="@+id/account_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
android:layout_weight="1"
android:onClick="onClickAccountName"
android:clickable="true"
android:focusable="true"/>

<CheckBox
android:id="@+id/report_sent"
Expand Down
4 changes: 4 additions & 0 deletions app/res/menu/account_list_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
android:id="@+id/menu_tab_format"
android:orderInCategory="100"
android:title="@string/Table_format" />
<item
android:id="@+id/menu_show_disabled"
android:title="@string/Show_disabled_accounts"
android:checkable="true" />
</menu>
235 changes: 117 additions & 118 deletions app/src/org/runnerup/db/DBHelper.java

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions app/src/org/runnerup/export/DefaultSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public abstract class DefaultSynchronizer implements Synchronizer {
protected final Set<String> cookies = new HashSet<String>();
protected final FormValues formValues = new FormValues();

private Integer authNotice;

public DefaultSynchronizer() {
super();
logout();
Expand All @@ -70,6 +68,12 @@ public String getName() {
return null;
}

@Override
public int getIconId() {
//0 is used if the resource id cannot be found
return 0;
}

@Override
public void init(ContentValues config) {
//Note that only auth_config can be expected here
Expand Down Expand Up @@ -111,6 +115,10 @@ public Status upload(SQLiteDatabase db, long mID) {
return s;
}

public Status getExternalId(SQLiteDatabase db, Status uploadStatus) {
return Status.ERROR;
}

public boolean checkSupport(Synchronizer.Feature f) {
return false;
}
Expand Down Expand Up @@ -237,11 +245,14 @@ protected String getFormValues(HttpURLConnection conn) throws IOException {

@Override
public Integer getAuthNotice() {
return authNotice;
return 0;
}

@Override
public void setAuthNotice(Integer authNotice) {
this.authNotice = authNotice;
public String getUrl() {
return PUBLIC_URL;
}

@Override
public String getActivityUrl(String extId) { return null; }
}
5 changes: 5 additions & 0 deletions app/src/org/runnerup/export/DigifitSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.runnerup.R;
import org.runnerup.common.util.Constants.DB;
import org.runnerup.export.format.TCX;
import org.runnerup.export.util.Part;
Expand Down Expand Up @@ -68,6 +69,7 @@ public class DigifitSynchronizer extends DefaultSynchronizer {
public static final String DIGIFIT_URL = "http://my.digifit.com";

public static final String NAME = "Digifit";
public static final String PUBLIC_URL = "http://www.digifit.com";

public static void main(String args[]) throws Exception {
if (args.length < 2) {
Expand Down Expand Up @@ -309,6 +311,9 @@ public String getName() {
return NAME;
}

@Override
public int getIconId() {return R.drawable.a9_digifit;}

private String getUploadUrl() throws IOException, MalformedURLException, ProtocolException,
JSONException {
String getUploadUrl = DIGIFIT_URL + "/rpc/json/workout/import_workouts_url";
Expand Down
11 changes: 8 additions & 3 deletions app/src/org/runnerup/export/EndomondoSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.runnerup.R;
import org.runnerup.common.util.Constants.DB;
import org.runnerup.common.util.Constants.DB.FEED;
import org.runnerup.export.format.EndomondoTrack;
Expand Down Expand Up @@ -63,9 +64,10 @@
public class EndomondoSynchronizer extends DefaultSynchronizer {

public static final String NAME = "Endomondo";
public static final String AUTH_URL = "https://api.mobile.endomondo.com/mobile/auth";
public static final String UPLOAD_URL = "http://api.mobile.endomondo.com/mobile/track";
public static final String FEED_URL = "http://api.mobile.endomondo.com/mobile/api/feed";
public static final String PUBLIC_URL = "http://www.endomondo.com";
private static final String AUTH_URL = "https://api.mobile.endomondo.com/mobile/auth";
private static final String UPLOAD_URL = "http://api.mobile.endomondo.com/mobile/track";
private static final String FEED_URL = "http://api.mobile.endomondo.com/mobile/api/feed";

long id = 0;
private String username = null;
Expand Down Expand Up @@ -101,6 +103,9 @@ public String getName() {
return NAME;
}

@Override
public int getIconId() {return R.drawable.a6_endomondo;}

@Override
public void init(ContentValues config) {
id = config.getAsLong("_id");
Expand Down
5 changes: 5 additions & 0 deletions app/src/org/runnerup/export/FacebookSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.json.JSONException;
import org.json.JSONObject;
import org.runnerup.R;
import org.runnerup.common.util.Constants.DB;
import org.runnerup.export.format.FacebookCourse;
import org.runnerup.export.oauth2client.OAuth2Activity;
Expand All @@ -54,6 +55,7 @@
public class FacebookSynchronizer extends DefaultSynchronizer implements OAuth2Server {

public static final String NAME = "Facebook";
public static final String PUBLIC_URL = "http://www.facebook.com";

/**
* @todo register OAuth2Server
Expand Down Expand Up @@ -141,6 +143,9 @@ public String getName() {
return NAME;
}

@Override
public int getIconId() {return R.drawable.a11_facebook;}

@Override
public void init(ContentValues config) {
String authConfig = config.getAsString(DB.ACCOUNT.AUTH_CONFIG);
Expand Down
36 changes: 27 additions & 9 deletions app/src/org/runnerup/export/FileSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import android.annotation.TargetApi;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;

import org.runnerup.R;
import org.runnerup.common.util.Constants.DB;
import org.runnerup.export.format.GPX;
import org.runnerup.export.format.TCX;
Expand All @@ -41,7 +43,8 @@ public class FileSynchronizer extends DefaultSynchronizer {
public static final String NAME = "File";

private long id = 0;
private String mPath = null;
private String mPath;
private String mFormat;

FileSynchronizer() {
}
Expand All @@ -56,12 +59,27 @@ public String getName() {
return NAME;
}

@Override
public int getIconId() {return R.drawable.a16_localfile;}

@Override
public String getUrl() {
return mPath;
}

static public String contentValuesToAuthConfig(ContentValues config) {
FileSynchronizer f = new FileSynchronizer();
f.mPath = config.getAsString(DB.ACCOUNT.URL);
f.mFormat = config.getAsString(DB.ACCOUNT.FORMAT);

return f.getAuthConfig();
}

@Override
public void init(ContentValues config) {
//Note: config contains a subset of account, primarily AUTH_CONFIG
//Reuse AUTH_CONFIG to communicate with SyncManager to not change structure too much
//path is also in URL (used for display), path is needed in connect()
//Temporary format until database is updated, URL is in AUTH_CONFIG
mPath = config.getAsString(DB.ACCOUNT.AUTH_CONFIG);
mFormat = config.getAsString(DB.ACCOUNT.FORMAT);
id = config.getAsLong("_id");
}

Expand All @@ -72,7 +90,7 @@ public String getAuthConfig() {

@Override
public boolean isConfigured() {
return !TextUtils.isEmpty(mPath);
return !TextUtils.isEmpty(mPath) && !TextUtils.isEmpty(mFormat);
}

@Override
Expand Down Expand Up @@ -106,19 +124,19 @@ public Status upload(SQLiteDatabase db, final long mID) {
if ((s = connect()) != Status.OK) {
return s;
}
ContentValues config = SyncManager.loadConfig(db, this.getName());
String format = config.getAsString(DB.ACCOUNT.FORMAT);

try {
String fileBase = new File(mPath).getAbsolutePath() + File.separator +
String.format(Locale.getDefault(), "RunnerUp_%04d.", mID);
if (format.contains("tcx")) {
if (mFormat.contains("tcx")) {
TCX tcx = new TCX(db);
File file = new File(fileBase + "tcx");
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
tcx.export(mID, new OutputStreamWriter(out));
s.externalId = Uri.fromFile(file).toString();
s.externalIdStatus = ExternalIdStatus.NONE; //Not working yet
}
if (format.contains("gpx")) {
if (mFormat.contains("gpx")) {
GPX gpx = new GPX(db, true, true);
File file = new File(fileBase + "gpx");
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
Expand Down
13 changes: 9 additions & 4 deletions app/src/org/runnerup/export/FunBeatSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.runnerup.R;
import org.runnerup.common.util.Constants.DB;
import org.runnerup.common.util.Constants.DB.FEED;
import org.runnerup.export.format.TCX;
Expand Down Expand Up @@ -61,10 +62,11 @@
public class FunBeatSynchronizer extends DefaultSynchronizer {

public static final String NAME = "FunBeat";
public static final String BASE_URL = "http://www.funbeat.se";
public static final String START_URL = BASE_URL + "/index.aspx";
public static final String LOGIN_URL = BASE_URL + "/index.aspx";
public static final String UPLOAD_URL = BASE_URL
public static final String PUBLIC_URL = "http://www.funbeat.se";
private static final String BASE_URL = PUBLIC_URL;
private static final String START_URL = BASE_URL + "/index.aspx";
private static final String LOGIN_URL = BASE_URL + "/index.aspx";
private static final String UPLOAD_URL = BASE_URL
+ "/importexport/upload.aspx";

public static final String API_URL = "http://1.0.0.android.api.funbeat.se/json/Default.asmx/";
Expand Down Expand Up @@ -118,6 +120,9 @@ public String getName() {
return NAME;
}

@Override
public int getIconId() {return R.drawable.a2_funbeatlogo;}

@Override
public void init(ContentValues config) {
id = config.getAsLong("_id");
Expand Down
7 changes: 6 additions & 1 deletion app/src/org/runnerup/export/GarminSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.runnerup.R;
import org.runnerup.common.util.Constants.DB;
import org.runnerup.export.format.TCX;
import org.runnerup.export.util.FormValues;
Expand Down Expand Up @@ -57,8 +58,9 @@
public class GarminSynchronizer extends DefaultSynchronizer {

public static final String NAME = "Garmin";
public static final String PUBLIC_URL = "http://connect.garmin.com";

public static final String CHOOSE_URL = "http://connect.garmin.com/";
private static final String CHOOSE_URL = PUBLIC_URL + "/";

public static final String START_URL = "https://connect.garmin.com/signin";
public static final String LOGIN_URL = "https://connect.garmin.com/signin";
Expand Down Expand Up @@ -96,6 +98,9 @@ public String getName() {
return NAME;
}

@Override
public int getIconId() {return R.drawable.a0_garminlogo;}

@Override
public void init(ContentValues config) {
id = config.getAsLong("_id");
Expand Down
9 changes: 7 additions & 2 deletions app/src/org/runnerup/export/GoogleFitSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.runnerup.R;
import org.runnerup.export.format.GoogleFitData;
import org.runnerup.export.util.SyncHelper;

Expand All @@ -42,7 +43,8 @@
public class GoogleFitSynchronizer extends GooglePlusSynchronizer {

public static final String NAME = "GoogleFit";
public static final String REST_URL = "https://www.googleapis.com/fitness/v1/users/me/";
public static final String PUBLIC_URL = "https://fit.google.com";
private static final String REST_URL = "https://www.googleapis.com/fitness/v1/users/me/";
public static final String REST_DATASOURCE = "dataSources";
public static final String REST_DATASETS = "datasets";
public static final String REST_SESSIONS = "sessions";
Expand Down Expand Up @@ -72,7 +74,10 @@ public String getName() {
return NAME;
}

public Context getContext() {
@Override
public int getIconId() {return R.drawable.a14_googlefit;}

private Context getContext() {
return context;
}

Expand Down