mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Merge branch 'master' of https://github.com/ojiikun/NewsBlur into pr/130-test
This commit is contained in:
commit
45e342a1b8
8 changed files with 68 additions and 103 deletions
2
media/android/NewsBlur/.gitignore
vendored
Normal file
2
media/android/NewsBlur/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
build.xml
|
||||
libs/ActionBarSherlock/build.xml
|
12
media/android/NewsBlur/HOWTO-shellbuild.md
Normal file
12
media/android/NewsBlur/HOWTO-shellbuild.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
## How To Build from the Command Line
|
||||
|
||||
*an abridged version of the official guide found [here](https://developer.android.com/tools/building/building-cmdline.html)*
|
||||
|
||||
1. install java and ant
|
||||
2. download the Android SDK from [android.com](https://developer.android.com/sdk/index.html) (the full ADT bundle in fine, too)
|
||||
3. get the `tools/` and/or `platform-tools/` directories on your path
|
||||
4. `android update sdk --no-ui` (this could take a while)
|
||||
5. go to both of the following NewsBlur directories and run `android update project --path .`:
|
||||
* `NewsBlur/media/android/NewsBlur/`
|
||||
* `NewsBlur/media/android/NewsBlur/libs/ActionBarSherlock/`
|
||||
6. build a test APK with `ant clean && ant debug` from `NewsBlur/media/android/NewsBlur/` (.apk will be in `NewsBlur/media/android/NewsBlur/bin/`)
|
|
@ -124,7 +124,7 @@ public class Main extends SherlockFragmentActivity implements StateChangedListen
|
|||
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Log.d(TAG, "Has returned");
|
||||
Log.d(this.getClass().getName(), "onActivityResult:RESULT_OK" );
|
||||
folderFeedList.hasUpdated();
|
||||
}
|
||||
}
|
||||
|
@ -153,4 +153,4 @@ public class Main extends SherlockFragmentActivity implements StateChangedListen
|
|||
public void closeAfterUpdate() {
|
||||
updateAfterSync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.database.Cursor;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.Display;
|
||||
|
@ -64,6 +65,8 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
|||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Log.d( this.getClass().getName(), "Fragment Create start" );
|
||||
|
||||
Cursor folderCursor = resolver.query(FeedProvider.FOLDERS_URI, null, null, new String[] { DatabaseConstants.FOLDER_INTELLIGENCE_SOME }, null);
|
||||
Cursor socialFeedCursor = resolver.query(FeedProvider.SOCIAL_FEEDS_URI, null, DatabaseConstants.SOCIAL_INTELLIGENCE_SOME, null, null);
|
||||
Cursor countCursor = resolver.query(FeedProvider.FEED_COUNT_URI, null, DatabaseConstants.SOCIAL_INTELLIGENCE_SOME, null, null);
|
||||
|
@ -85,6 +88,9 @@ public class FolderListFragment extends Fragment implements OnGroupClickListener
|
|||
|
||||
folderAdapter = new MixedExpandableListAdapter(getActivity(), folderCursor, socialFeedCursor, countCursor, sharedCountCursor, R.layout.row_folder_collapsed, R.layout.row_folder_collapsed, R.layout.row_socialfeed, groupFrom, groupTo, R.layout.row_feed, childFrom, childTo, blogFrom, blogTo);
|
||||
folderAdapter.setViewBinders(groupViewBinder, blogViewBinder);
|
||||
|
||||
Log.d( this.getClass().getName(), "Fragment Create end" );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,14 +27,11 @@ import com.newsblur.service.SyncService;
|
|||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
||||
public class LoginProgressFragment extends Fragment implements Receiver {
|
||||
public class LoginProgressFragment extends Fragment {
|
||||
|
||||
private APIManager apiManager;
|
||||
private DetachableResultReceiver receiver;
|
||||
private String TAG = "LoginProgress";
|
||||
private TextView updateStatus, retrievingFeeds, letsGo;
|
||||
private ImageView loginProfilePicture;
|
||||
private int CURRENT_STATUS = -1;
|
||||
private ProgressBar feedProgress, loggingInProgress;
|
||||
private LoginTask loginTask;
|
||||
private String username;
|
||||
|
@ -54,8 +51,6 @@ public class LoginProgressFragment extends Fragment implements Receiver {
|
|||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
apiManager = new APIManager(getActivity());
|
||||
receiver = new DetachableResultReceiver(new Handler());
|
||||
receiver.setReceiver(this);
|
||||
|
||||
username = getArguments().getString("username");
|
||||
password = getArguments().getString("password");
|
||||
|
@ -71,14 +66,9 @@ public class LoginProgressFragment extends Fragment implements Receiver {
|
|||
feedProgress = (ProgressBar) v.findViewById(R.id.login_feed_progress);
|
||||
loggingInProgress = (ProgressBar) v.findViewById(R.id.login_logging_in_progress);
|
||||
loginProfilePicture = (ImageView) v.findViewById(R.id.login_profile_picture);
|
||||
// password.setOnEditorActionListener(this);
|
||||
|
||||
if (loginTask != null) {
|
||||
refreshUI();
|
||||
} else {
|
||||
loginTask = new LoginTask();
|
||||
loginTask.execute();
|
||||
}
|
||||
loginTask = new LoginTask();
|
||||
loginTask.execute();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -98,10 +88,10 @@ public class LoginProgressFragment extends Fragment implements Receiver {
|
|||
LoginResponse response = apiManager.login(username, password);
|
||||
apiManager.updateUserProfile();
|
||||
try {
|
||||
// We include this wait simply as a small UX convenience. Otherwise the user could be met with a disconcerting flicker when attempting to log in and failing.
|
||||
Thread.sleep(700);
|
||||
// TODO: get rid of this and use proper UI transactions
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "Error sleeping during login.");
|
||||
Log.e(this.getClass().getName(), "Error sleeping during login.");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
@ -122,10 +112,9 @@ public class LoginProgressFragment extends Fragment implements Receiver {
|
|||
retrievingFeeds.setText(R.string.login_retrieving_feeds);
|
||||
retrievingFeeds.startAnimation(b);
|
||||
|
||||
final Intent intent = new Intent(Intent.ACTION_SYNC, null, getActivity(), SyncService.class);
|
||||
intent.putExtra(SyncService.EXTRA_STATUS_RECEIVER, receiver);
|
||||
intent.putExtra(SyncService.SYNCSERVICE_TASK, SyncService.EXTRA_TASK_FOLDER_UPDATE);
|
||||
getActivity().startService(intent);
|
||||
Intent startMain = new Intent(getActivity(), Main.class);
|
||||
getActivity().startActivity(startMain);
|
||||
|
||||
} else {
|
||||
if (result.errors != null && result.errors.message != null) {
|
||||
Toast.makeText(getActivity(), result.errors.message[0], Toast.LENGTH_LONG).show();
|
||||
|
@ -137,55 +126,4 @@ public class LoginProgressFragment extends Fragment implements Receiver {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void refreshUI() {
|
||||
switch (CURRENT_STATUS) {
|
||||
case SyncService.NOT_RUNNING:
|
||||
break;
|
||||
case SyncService.STATUS_NO_MORE_UPDATES:
|
||||
break;
|
||||
case SyncService.STATUS_FINISHED:
|
||||
final Animation b = AnimationUtils.loadAnimation(getActivity(), R.anim.text_down);
|
||||
retrievingFeeds.setText(R.string.login_retrieved_feeds);
|
||||
retrievingFeeds.startAnimation(b);
|
||||
|
||||
final Animation c = AnimationUtils.loadAnimation(getActivity(), R.anim.text_up);
|
||||
letsGo.setText(R.string.login_lets_go);
|
||||
c.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
Intent startMain = new Intent(getActivity(), Main.class);
|
||||
getActivity().startActivity(startMain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) { }
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) { }
|
||||
});
|
||||
letsGo.startAnimation(c);
|
||||
break;
|
||||
case SyncService.STATUS_RUNNING:
|
||||
break;
|
||||
case SyncService.STATUS_ERROR:
|
||||
updateStatus.setText("Error synchronising.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Interface for Host
|
||||
public interface LoginFragmentInterface {
|
||||
public void loginSuccessful();
|
||||
public void loginUnsuccessful();
|
||||
public void syncSuccessful();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiverResult(int resultCode, Bundle resultData) {
|
||||
CURRENT_STATUS = resultCode;
|
||||
refreshUI();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.newsblur.util.PrefConstants;
|
|||
|
||||
public class APIClient {
|
||||
|
||||
private static final String TAG = "APIClient";
|
||||
private Context context;
|
||||
|
||||
public APIClient(final Context context) {
|
||||
|
@ -38,16 +37,17 @@ public class APIClient {
|
|||
return response;
|
||||
}
|
||||
try {
|
||||
final URL urlFeeds = new URL(urlString);
|
||||
connection = (HttpURLConnection) urlFeeds.openConnection();
|
||||
final URL url = new URL(urlString);
|
||||
Log.d(this.getClass().getName(), "API GET " + url );
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
final SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
final String cookie = preferences.getString(PrefConstants.PREF_COOKIE, null);
|
||||
if (cookie != null) {
|
||||
connection.setRequestProperty("Cookie", cookie);
|
||||
}
|
||||
return extractResponse(urlFeeds, connection);
|
||||
return extractResponse(url, connection);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error opening GET connection to " + urlString, e.getCause());
|
||||
Log.e(this.getClass().getName(), "Error opening GET connection to " + urlString, e.getCause());
|
||||
return new APIResponse();
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
|
@ -72,16 +72,17 @@ public class APIClient {
|
|||
}
|
||||
final String parameterString = TextUtils.join("&", parameters);
|
||||
|
||||
final URL urlFeeds = new URL(urlString + "?" + parameterString);
|
||||
connection = (HttpURLConnection) urlFeeds.openConnection();
|
||||
final URL url = new URL(urlString + "?" + parameterString);
|
||||
Log.d(this.getClass().getName(), "API GET " + url );
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
final SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
final String cookie = preferences.getString(PrefConstants.PREF_COOKIE, null);
|
||||
if (cookie != null) {
|
||||
connection.setRequestProperty("Cookie", cookie);
|
||||
}
|
||||
return extractResponse(urlFeeds, connection);
|
||||
return extractResponse(url, connection);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error opening GET connection to " + urlString, e.getCause());
|
||||
Log.e(this.getClass().getName(), "Error opening GET connection to " + urlString, e.getCause());
|
||||
return new APIResponse();
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
|
@ -100,17 +101,18 @@ public class APIClient {
|
|||
try {
|
||||
String parameterString = valueMap.getParameterString();
|
||||
|
||||
final URL urlFeeds = new URL(urlString + "?" + parameterString);
|
||||
connection = (HttpURLConnection) urlFeeds.openConnection();
|
||||
final URL url = new URL(urlString + "?" + parameterString);
|
||||
Log.d(this.getClass().getName(), "API GET " + url );
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
final SharedPreferences preferences = context.getSharedPreferences(PrefConstants.PREFERENCES, 0);
|
||||
final String cookie = preferences.getString(PrefConstants.PREF_COOKIE, null);
|
||||
if (cookie != null) {
|
||||
connection.setRequestProperty("Cookie", cookie);
|
||||
}
|
||||
return extractResponse(urlFeeds, connection);
|
||||
return extractResponse(url, connection);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error opening GET connection to " + urlString, e.getCause());
|
||||
Log.e(this.getClass().getName(), "Error opening GET connection to " + urlString, e.getCause());
|
||||
return new APIResponse();
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
|
@ -149,7 +151,7 @@ public class APIClient {
|
|||
try {
|
||||
builder.append(URLEncoder.encode((String) entry.getValue(), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e(TAG, e.getLocalizedMessage());
|
||||
Log.e(this.getClass().getName(), e.getLocalizedMessage());
|
||||
return new APIResponse();
|
||||
}
|
||||
parameters.add(builder.toString());
|
||||
|
@ -157,6 +159,7 @@ public class APIClient {
|
|||
final String parameterString = TextUtils.join("&", parameters);
|
||||
try {
|
||||
final URL url = new URL(urlString);
|
||||
Log.d(this.getClass().getName(), "API POST " + url );
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
|
@ -175,7 +178,7 @@ public class APIClient {
|
|||
|
||||
return extractResponse(url, connection);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error opening POST connection to " + urlString + ": " + e.getCause(), e.getCause());
|
||||
Log.e(this.getClass().getName(), "Error opening POST connection to " + urlString + ": " + e.getCause(), e.getCause());
|
||||
return new APIResponse();
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
|
@ -198,6 +201,7 @@ public class APIClient {
|
|||
|
||||
try {
|
||||
final URL url = new URL(urlString);
|
||||
Log.d(this.getClass().getName(), "API POST " + url );
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
|
@ -217,7 +221,7 @@ public class APIClient {
|
|||
|
||||
return extractResponse(url, connection);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error opening POST connection to " + urlString + ": " + e.getCause(), e.getCause());
|
||||
Log.e(this.getClass().getName(), "Error opening POST connection to " + urlString + ": " + e.getCause(), e.getCause());
|
||||
return new APIResponse();
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
|
|
|
@ -519,7 +519,6 @@ public class APIManager {
|
|||
if (!existingFolders.contains(folderName) && !TextUtils.isEmpty(folderName)) {
|
||||
final ContentValues folderValues = new ContentValues();
|
||||
folderValues.put(DatabaseConstants.FOLDER_NAME, folderName);
|
||||
Log.d("Folder", "Inserting folder: " + folderName);
|
||||
contentResolver.insert(FeedProvider.FOLDERS_URI, folderValues);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import com.newsblur.network.domain.StoriesResponse;
|
|||
*/
|
||||
public class SyncService extends IntentService {
|
||||
|
||||
private static final String TAG = "SyncService";
|
||||
public static final String EXTRA_STATUS_RECEIVER = "resultReceiverExtra";
|
||||
public static final String EXTRA_TASK_FEED_ID = "taskFeedId";
|
||||
public static final String EXTRA_TASK_FOLDER_NAME = "taskFoldername";
|
||||
|
@ -74,7 +73,7 @@ public class SyncService extends IntentService {
|
|||
|
||||
|
||||
public SyncService() {
|
||||
super(TAG);
|
||||
super(SyncService.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,6 +91,8 @@ public class SyncService extends IntentService {
|
|||
receiver.send(STATUS_RUNNING, Bundle.EMPTY);
|
||||
}
|
||||
|
||||
Log.d( this.getClass().getName(), "Sync Intent: " + intent.getIntExtra(SYNCSERVICE_TASK , -1) );
|
||||
|
||||
switch (intent.getIntExtra(SYNCSERVICE_TASK , -1)) {
|
||||
case EXTRA_TASK_FOLDER_UPDATE:
|
||||
if (!apiManager.getFolderFeedMapping()) {
|
||||
|
@ -131,7 +132,7 @@ public class SyncService extends IntentService {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "No feed/stories to mark as read included in SyncRequest");
|
||||
Log.e(this.getClass().getName(), "No feed/stories to mark as read included in SyncRequest");
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
break;
|
||||
|
@ -157,7 +158,7 @@ public class SyncService extends IntentService {
|
|||
if (!TextUtils.isEmpty(markSocialJson)) {
|
||||
apiManager.markSocialStoryAsRead(markSocialJson);
|
||||
} else {
|
||||
Log.e(TAG, "No feed/story to mark as read included in SyncRequest");
|
||||
Log.e(this.getClass().getName(), "No feed/story to mark as read included in SyncRequest");
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
break;
|
||||
|
@ -171,7 +172,7 @@ public class SyncService extends IntentService {
|
|||
receiver.send(STATUS_NO_MORE_UPDATES, Bundle.EMPTY);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "No feed to refresh included in SyncRequest");
|
||||
Log.e(this.getClass().getName(), "No feed to refresh included in SyncRequest");
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
break;
|
||||
|
@ -186,7 +187,7 @@ public class SyncService extends IntentService {
|
|||
receiver.send(STATUS_NO_MORE_UPDATES, Bundle.EMPTY);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "No feed ids to refresh included in SyncRequest");
|
||||
Log.e(this.getClass().getName(), "No feed ids to refresh included in SyncRequest");
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
break;
|
||||
|
@ -200,7 +201,7 @@ public class SyncService extends IntentService {
|
|||
receiver.send(STATUS_NO_MORE_UPDATES, Bundle.EMPTY);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "No socialfeed ids to refresh included in SyncRequest");
|
||||
Log.e(this.getClass().getName(), "No socialfeed ids to refresh included in SyncRequest");
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
break;
|
||||
|
@ -214,12 +215,12 @@ public class SyncService extends IntentService {
|
|||
receiver.send(STATUS_FINISHED_CLOSE, Bundle.EMPTY);
|
||||
return;
|
||||
} else {
|
||||
Log.e(TAG, "Error deleting feed");
|
||||
Log.e(this.getClass().getName(), "Error deleting feed");
|
||||
Toast.makeText(this, getResources().getString(R.string.error_deleting_feed), Toast.LENGTH_LONG).show();
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "No feed id to delete include in SyncRequest");
|
||||
Log.e(this.getClass().getName(), "No feed id to delete include in SyncRequest");
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
break;
|
||||
|
@ -233,18 +234,21 @@ public class SyncService extends IntentService {
|
|||
receiver.send(STATUS_NO_MORE_UPDATES, Bundle.EMPTY);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Missing parameters forsocialfeed SyncRequest");
|
||||
Log.e(this.getClass().getName(), "Missing parameters for socialfeed SyncRequest");
|
||||
receiver.send(STATUS_ERROR, Bundle.EMPTY);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.e(TAG, "SyncService called without relevant task assignment");
|
||||
Log.e(this.getClass().getName(), "SyncService called without relevant task assignment");
|
||||
break;
|
||||
}
|
||||
|
||||
Log.d( this.getClass().getName(), "Sync Intent complete");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Couldn't synchronise with Newsblur servers: " + e.getMessage(), e.getCause());
|
||||
Log.e(this.getClass().getName(), "Couldn't synchronise with Newsblur servers: " + e.getMessage(), e.getCause());
|
||||
if (receiver != null) {
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(Intent.EXTRA_TEXT, e.toString());
|
||||
|
@ -255,7 +259,7 @@ public class SyncService extends IntentService {
|
|||
if (receiver != null) {
|
||||
receiver.send(STATUS_FINISHED, Bundle.EMPTY);
|
||||
} else {
|
||||
Log.e(TAG, "No receiver attached to Sync?");
|
||||
Log.e(this.getClass().getName(), "No receiver attached to Sync?");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue