Implemented DownloadAuthenticationActivity
This commit is contained in:
parent
d8a9d68bf8
commit
0c2d78157c
|
@ -1,42 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.danoeh.antennapod"
|
||||
android:versionCode="35"
|
||||
android:versionName="0.9.8.2" >
|
||||
package="de.danoeh.antennapod"
|
||||
android:versionCode="35"
|
||||
android:versionName="0.9.8.2">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="10"
|
||||
android:targetSdkVersion="19" />
|
||||
android:targetSdkVersion="19"/>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:smallScreens="true"
|
||||
android:xlargeScreens="true" />
|
||||
android:xlargeScreens="true"/>
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.screen.portrait"
|
||||
android:required="false" />
|
||||
android:required="false"/>
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
android:required="false"/>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
|
||||
<application
|
||||
android:name="de.danoeh.antennapod.PodcastApp"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:logo="@drawable/ic_launcher"
|
||||
android:theme="@style/Theme.AntennaPod.Light" >
|
||||
android:theme="@style/Theme.AntennaPod.Light">
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
|
@ -60,7 +60,8 @@
|
|||
android:windowSoftInputMode="adjustResize">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
|
@ -114,7 +115,7 @@
|
|||
android:configChanges="orientation|screenSize">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
<meta-data
|
||||
android:name="android.app.default_searchable"
|
||||
android:value="de.danoeh.antennapod.activity.SearchActivity"/>
|
||||
|
@ -131,14 +132,14 @@
|
|||
android:exported="true">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
</activity>
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.AudioplayerActivity"
|
||||
android:launchMode="singleTop">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
|
@ -150,6 +151,10 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.DownloadAuthenticationActivity"
|
||||
android:launchMode="singleInstance"/>
|
||||
|
||||
<service
|
||||
android:name=".service.download.DownloadService"
|
||||
android:enabled="true"/>
|
||||
|
@ -170,14 +175,14 @@
|
|||
android:label="@string/settings_label">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.DownloadLogActivity"
|
||||
android:label="@string/download_log_label">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.DownloadActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.DownloadActivity"/>
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
|
@ -303,7 +308,7 @@
|
|||
android:label="@string/miro_guide_label">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.AddFeedActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.AddFeedActivity"/>
|
||||
<meta-data
|
||||
android:name="android.app.default_searchable"
|
||||
android:value="de.danoeh.antennapod.activity.MiroGuideSearchActivity"/>
|
||||
|
@ -328,7 +333,7 @@
|
|||
android:configChanges="keyboardHidden|orientation">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MiroGuideMainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MiroGuideMainActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.MiroGuideChannelViewActivity"
|
||||
|
@ -336,7 +341,7 @@
|
|||
android:label="@string/miro_guide_label">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MiroGuideCategoryActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MiroGuideCategoryActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.VideoplayerActivity"
|
||||
|
@ -344,7 +349,7 @@
|
|||
android:screenOrientation="landscape">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
|
@ -360,28 +365,30 @@
|
|||
android:label="@string/playback_history_label">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
</activity>
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActiviy" />
|
||||
android:value="de.danoeh.antennapod.activity.MainActiviy"/>
|
||||
<activity
|
||||
android:name=".activity.DirectoryChooserActivity"
|
||||
android:label="@string/choose_data_directory">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity" />
|
||||
</activity>
|
||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity"/>
|
||||
</activity>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activity.OrganizeQueueActivity"
|
||||
android:configChanges="orientation"
|
||||
android:label="@string/organize_queue_label">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.gpoddernet.GpodnetMainActivity"
|
||||
|
@ -396,7 +403,7 @@
|
|||
android:resource="@xml/gpodnet_searchable"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.AddFeedActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.AddFeedActivity"/>
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
|
@ -410,7 +417,7 @@
|
|||
android:resource="@xml/gpodnet_searchable"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.gpoddernet.GpodnetMainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.gpoddernet.GpodnetMainActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@ -421,12 +428,13 @@
|
|||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH"/>
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/gpodnet_searchable"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.gpoddernet.GpodnetMainActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.gpoddernet.GpodnetMainActivity"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@ -444,7 +452,7 @@
|
|||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity" />
|
||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity"/>
|
||||
</activity>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authentication_notification_title"
|
||||
android:layout_alignParentTop="true"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
android:layout_margin="16dp"
|
||||
android:textColor="@color/bright_blue"
|
||||
android:textStyle="italic"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authentication_notification_msg"
|
||||
android:layout_below="@id/txtvTitle"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:layout_margin="16dp"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:id="@+id/etxtUsername"
|
||||
android:hint="@string/username_label"
|
||||
android:layout_below="@id/txtvDescription"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:id="@+id/etxtPassword"
|
||||
android:hint="@string/password_label"
|
||||
android:inputType="textPassword"
|
||||
android:layout_below="@id/etxtUsername"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/footer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="48dp"
|
||||
android:focusableInTouchMode="true"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="?android:attr/dividerVertical"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/horizontal_divider"
|
||||
android:layout_width="1dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="?android:attr/dividerVertical"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/butCancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toLeftOf="@id/horizontal_divider"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="@string/cancel_label"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/butConfirm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toRightOf="@id/horizontal_divider"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="@string/confirm_label"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authentication_notification_title"
|
||||
android:layout_alignParentTop="true"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
android:layout_margin="16dp"
|
||||
android:textColor="@color/bright_blue"
|
||||
android:textStyle="italic"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authentication_notification_msg"
|
||||
android:layout_below="@id/txtvTitle"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:layout_margin="16dp"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:id="@+id/etxtUsername"
|
||||
android:hint="@string/username_label"
|
||||
android:layout_below="@id/txtvDescription"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:id="@+id/etxtPassword"
|
||||
android:hint="@string/password_label"
|
||||
android:inputType="textPassword"
|
||||
android:layout_below="@id/etxtUsername"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/footer"
|
||||
style="@android:style/ButtonBar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/butConfirm"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/confirm_label"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/butCancel"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/cancel_label"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,106 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
|
||||
/**
|
||||
* Shows a username and a password text field.
|
||||
* The activity MUST be started with the ARG_DOWNlOAD_REQUEST argument set to a non-null value.
|
||||
* Other arguments are optional.
|
||||
* The activity's result will be the same DownloadRequest with the entered username and password.
|
||||
*/
|
||||
public class DownloadAuthenticationActivity extends ActionBarActivity {
|
||||
private static final String TAG = "DownloadAuthenticationActivity";
|
||||
|
||||
/**
|
||||
* The download request object that contains information about the resource that requires a username and a password
|
||||
*/
|
||||
public static final String ARG_DOWNLOAD_REQUEST = "request";
|
||||
/**
|
||||
* True if the request should be sent to the DownloadRequester when this activity is finished, false otherwise.
|
||||
* The default value is false.
|
||||
*/
|
||||
public static final String ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL = "send_to_downloadrequester";
|
||||
|
||||
public static final String RESULT_REQUEST = "request";
|
||||
|
||||
private EditText etxtUsername;
|
||||
private EditText etxtPassword;
|
||||
private Button butConfirm;
|
||||
private Button butCancel;
|
||||
private TextView txtvDescription;
|
||||
|
||||
private DownloadRequest request;
|
||||
private boolean sendToDownloadRequester;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
getSupportActionBar().hide();
|
||||
setContentView(R.layout.download_authentication_activity);
|
||||
|
||||
etxtUsername = (EditText) findViewById(R.id.etxtUsername);
|
||||
etxtPassword = (EditText) findViewById(R.id.etxtPassword);
|
||||
butConfirm = (Button) findViewById(R.id.butConfirm);
|
||||
butCancel = (Button) findViewById(R.id.butCancel);
|
||||
txtvDescription = (TextView) findViewById(R.id.txtvDescription);
|
||||
|
||||
if (!getIntent().hasExtra(ARG_DOWNLOAD_REQUEST)) throw new IllegalArgumentException("Download request missing");
|
||||
request = getIntent().getParcelableExtra(ARG_DOWNLOAD_REQUEST);
|
||||
sendToDownloadRequester = getIntent().getBooleanExtra(ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, false);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
etxtUsername.setText(savedInstanceState.getString("username"));
|
||||
etxtPassword.setText(savedInstanceState.getString("password"));
|
||||
}
|
||||
|
||||
txtvDescription.setText(txtvDescription.getText() + ":\n\n" + request.getTitle());
|
||||
|
||||
butCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setResult(Activity.RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
butConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String username = etxtUsername.getText().toString();
|
||||
String password = etxtPassword.getText().toString();
|
||||
request.setUsername(username);
|
||||
request.setPassword(password);
|
||||
Intent result = new Intent();
|
||||
result.putExtra(RESULT_REQUEST, request);
|
||||
setResult(Activity.RESULT_OK, result);
|
||||
|
||||
if (sendToDownloadRequester) {
|
||||
if (AppConfig.DEBUG) Log.d(TAG, "Sending request to DownloadRequester");
|
||||
DownloadRequester.getInstance().download(DownloadAuthenticationActivity.this, request);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString("username", etxtUsername.getText().toString());
|
||||
outState.putString("password", etxtPassword.getText().toString());
|
||||
}
|
||||
}
|
|
@ -124,6 +124,15 @@ public class Feed extends FeedFile implements FlattrThing {
|
|||
this.flattrStatus = new FlattrStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used for requesting a feed download (it must not be used for anything else!). It should be
|
||||
* used if the title of the feed is already known.
|
||||
*/
|
||||
public Feed(String url, Date lastUpdate, String title, String username, String password) {
|
||||
this(url, lastUpdate, title);
|
||||
preferences = new FeedPreferences(0, true, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of FeedItems where 'read' is false. If the 'display
|
||||
* only episodes' - preference is set to true, this method will only count
|
||||
|
@ -413,4 +422,12 @@ public class Feed extends FeedFile implements FlattrThing {
|
|||
public void savePreferences(Context context) {
|
||||
DBWriter.setFeedPreferences(context, preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(long id) {
|
||||
super.setId(id);
|
||||
if (preferences != null) {
|
||||
preferences.setFeedID(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.feed;
|
|||
|
||||
import android.content.Context;
|
||||
import de.danoeh.antennapod.storage.DBWriter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Contains preferences for a single feed.
|
||||
|
@ -20,6 +21,36 @@ public class FeedPreferences {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compare another FeedPreferences with this one. The feedID and autoDownload attribute are excluded from the
|
||||
* comparison.
|
||||
*
|
||||
* @return True if the two objects are different.
|
||||
*/
|
||||
public boolean compareWithOther(FeedPreferences other) {
|
||||
if (other == null)
|
||||
return true;
|
||||
if (!StringUtils.equals(username, other.username)) {
|
||||
return true;
|
||||
}
|
||||
if (!StringUtils.equals(password, other.password)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update this FeedPreferences object from another one. The feedID and autoDownload attributes are excluded
|
||||
* from the update.
|
||||
*/
|
||||
public void updateFromOther(FeedPreferences other) {
|
||||
if (other == null)
|
||||
return;
|
||||
this.username = other.username;
|
||||
this.password = other.password;
|
||||
}
|
||||
|
||||
public long getFeedID() {
|
||||
return feedID;
|
||||
}
|
||||
|
|
|
@ -5,191 +5,200 @@ import android.os.Parcelable;
|
|||
|
||||
public class DownloadRequest implements Parcelable {
|
||||
|
||||
private final String destination;
|
||||
private final String source;
|
||||
private final String title;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final long feedfileId;
|
||||
private final int feedfileType;
|
||||
private final String destination;
|
||||
private final String source;
|
||||
private final String title;
|
||||
private String username;
|
||||
private String password;
|
||||
private final long feedfileId;
|
||||
private final int feedfileType;
|
||||
|
||||
protected int progressPercent;
|
||||
protected long soFar;
|
||||
protected long size;
|
||||
protected int statusMsg;
|
||||
protected int progressPercent;
|
||||
protected long soFar;
|
||||
protected long size;
|
||||
protected int statusMsg;
|
||||
|
||||
public DownloadRequest(String destination, String source, String title,
|
||||
long feedfileId, int feedfileType, String username, String password) {
|
||||
if (destination == null) {
|
||||
throw new IllegalArgumentException("Destination must not be null");
|
||||
}
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("Source must not be null");
|
||||
}
|
||||
if (title == null) {
|
||||
throw new IllegalArgumentException("Title must not be null");
|
||||
}
|
||||
public DownloadRequest(String destination, String source, String title,
|
||||
long feedfileId, int feedfileType, String username, String password) {
|
||||
if (destination == null) {
|
||||
throw new IllegalArgumentException("Destination must not be null");
|
||||
}
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("Source must not be null");
|
||||
}
|
||||
if (title == null) {
|
||||
throw new IllegalArgumentException("Title must not be null");
|
||||
}
|
||||
|
||||
this.destination = destination;
|
||||
this.source = source;
|
||||
this.title = title;
|
||||
this.feedfileId = feedfileId;
|
||||
this.feedfileType = feedfileType;
|
||||
this.destination = destination;
|
||||
this.source = source;
|
||||
this.title = title;
|
||||
this.feedfileId = feedfileId;
|
||||
this.feedfileType = feedfileType;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadRequest(String destination, String source, String title,
|
||||
long feedfileId, int feedfileType) {
|
||||
this(destination, source, title, feedfileId, feedfileType, null, null);
|
||||
}
|
||||
|
||||
private DownloadRequest(Parcel in) {
|
||||
destination = in.readString();
|
||||
source = in.readString();
|
||||
title = in.readString();
|
||||
feedfileId = in.readLong();
|
||||
feedfileType = in.readInt();
|
||||
private DownloadRequest(Parcel in) {
|
||||
destination = in.readString();
|
||||
source = in.readString();
|
||||
title = in.readString();
|
||||
feedfileId = in.readLong();
|
||||
feedfileType = in.readInt();
|
||||
if (in.dataAvail() > 0) {
|
||||
username = in.readString();
|
||||
password = in.readString();
|
||||
} else {
|
||||
username = null;
|
||||
}
|
||||
if (in.dataAvail() > 0) {
|
||||
password = in.readString();
|
||||
} else {
|
||||
password = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(destination);
|
||||
dest.writeString(source);
|
||||
dest.writeString(title);
|
||||
dest.writeLong(feedfileId);
|
||||
dest.writeInt(feedfileType);
|
||||
}
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(destination);
|
||||
dest.writeString(source);
|
||||
dest.writeString(title);
|
||||
dest.writeLong(feedfileId);
|
||||
dest.writeInt(feedfileType);
|
||||
if (username != null) {
|
||||
dest.writeString(username);
|
||||
}
|
||||
if (password != null) {
|
||||
dest.writeString(password);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<DownloadRequest> CREATOR = new Parcelable.Creator<DownloadRequest>() {
|
||||
public DownloadRequest createFromParcel(Parcel in) {
|
||||
return new DownloadRequest(in);
|
||||
}
|
||||
public static final Parcelable.Creator<DownloadRequest> CREATOR = new Parcelable.Creator<DownloadRequest>() {
|
||||
public DownloadRequest createFromParcel(Parcel in) {
|
||||
return new DownloadRequest(in);
|
||||
}
|
||||
|
||||
public DownloadRequest[] newArray(int size) {
|
||||
return new DownloadRequest[size];
|
||||
}
|
||||
};
|
||||
public DownloadRequest[] newArray(int size) {
|
||||
return new DownloadRequest[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((destination == null) ? 0 : destination.hashCode());
|
||||
result = prime * result + (int) (feedfileId ^ (feedfileId >>> 32));
|
||||
result = prime * result + feedfileType;
|
||||
result = prime * result + progressPercent;
|
||||
result = prime * result + (int) (size ^ (size >>> 32));
|
||||
result = prime * result + (int) (soFar ^ (soFar >>> 32));
|
||||
result = prime * result + ((source == null) ? 0 : source.hashCode());
|
||||
result = prime * result + statusMsg;
|
||||
result = prime * result + ((title == null) ? 0 : title.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((destination == null) ? 0 : destination.hashCode());
|
||||
result = prime * result + (int) (feedfileId ^ (feedfileId >>> 32));
|
||||
result = prime * result + feedfileType;
|
||||
result = prime * result + progressPercent;
|
||||
result = prime * result + (int) (size ^ (size >>> 32));
|
||||
result = prime * result + (int) (soFar ^ (soFar >>> 32));
|
||||
result = prime * result + ((source == null) ? 0 : source.hashCode());
|
||||
result = prime * result + statusMsg;
|
||||
result = prime * result + ((title == null) ? 0 : title.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DownloadRequest other = (DownloadRequest) obj;
|
||||
if (destination == null) {
|
||||
if (other.destination != null)
|
||||
return false;
|
||||
} else if (!destination.equals(other.destination))
|
||||
return false;
|
||||
if (feedfileId != other.feedfileId)
|
||||
return false;
|
||||
if (feedfileType != other.feedfileType)
|
||||
return false;
|
||||
if (progressPercent != other.progressPercent)
|
||||
return false;
|
||||
if (size != other.size)
|
||||
return false;
|
||||
if (soFar != other.soFar)
|
||||
return false;
|
||||
if (source == null) {
|
||||
if (other.source != null)
|
||||
return false;
|
||||
} else if (!source.equals(other.source))
|
||||
return false;
|
||||
if (statusMsg != other.statusMsg)
|
||||
return false;
|
||||
if (title == null) {
|
||||
if (other.title != null)
|
||||
return false;
|
||||
} else if (!title.equals(other.title))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DownloadRequest other = (DownloadRequest) obj;
|
||||
if (destination == null) {
|
||||
if (other.destination != null)
|
||||
return false;
|
||||
} else if (!destination.equals(other.destination))
|
||||
return false;
|
||||
if (feedfileId != other.feedfileId)
|
||||
return false;
|
||||
if (feedfileType != other.feedfileType)
|
||||
return false;
|
||||
if (progressPercent != other.progressPercent)
|
||||
return false;
|
||||
if (size != other.size)
|
||||
return false;
|
||||
if (soFar != other.soFar)
|
||||
return false;
|
||||
if (source == null) {
|
||||
if (other.source != null)
|
||||
return false;
|
||||
} else if (!source.equals(other.source))
|
||||
return false;
|
||||
if (statusMsg != other.statusMsg)
|
||||
return false;
|
||||
if (title == null) {
|
||||
if (other.title != null)
|
||||
return false;
|
||||
} else if (!title.equals(other.title))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public long getFeedfileId() {
|
||||
return feedfileId;
|
||||
}
|
||||
public long getFeedfileId() {
|
||||
return feedfileId;
|
||||
}
|
||||
|
||||
public int getFeedfileType() {
|
||||
return feedfileType;
|
||||
}
|
||||
public int getFeedfileType() {
|
||||
return feedfileType;
|
||||
}
|
||||
|
||||
public int getProgressPercent() {
|
||||
return progressPercent;
|
||||
}
|
||||
public int getProgressPercent() {
|
||||
return progressPercent;
|
||||
}
|
||||
|
||||
public void setProgressPercent(int progressPercent) {
|
||||
this.progressPercent = progressPercent;
|
||||
}
|
||||
public void setProgressPercent(int progressPercent) {
|
||||
this.progressPercent = progressPercent;
|
||||
}
|
||||
|
||||
public long getSoFar() {
|
||||
return soFar;
|
||||
}
|
||||
public long getSoFar() {
|
||||
return soFar;
|
||||
}
|
||||
|
||||
public void setSoFar(long soFar) {
|
||||
this.soFar = soFar;
|
||||
}
|
||||
public void setSoFar(long soFar) {
|
||||
this.soFar = soFar;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public int getStatusMsg() {
|
||||
return statusMsg;
|
||||
}
|
||||
public int getStatusMsg() {
|
||||
return statusMsg;
|
||||
}
|
||||
|
||||
public void setStatusMsg(int statusMsg) {
|
||||
this.statusMsg = statusMsg;
|
||||
}
|
||||
public void setStatusMsg(int statusMsg) {
|
||||
this.statusMsg = statusMsg;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
|
@ -198,4 +207,12 @@ public class DownloadRequest implements Parcelable {
|
|||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.webkit.URLUtil;
|
|||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.DownloadActivity;
|
||||
import de.danoeh.antennapod.activity.DownloadAuthenticationActivity;
|
||||
import de.danoeh.antennapod.activity.DownloadLogActivity;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.feed.*;
|
||||
|
@ -557,6 +558,11 @@ public class DownloadService extends Service {
|
|||
final String resourceTitle = (downloadRequest.getTitle() != null)
|
||||
? downloadRequest.getTitle() : downloadRequest.getSource();
|
||||
|
||||
final Intent activityIntent = new Intent(getApplicationContext(), DownloadAuthenticationActivity.class);
|
||||
activityIntent.putExtra(DownloadAuthenticationActivity.ARG_DOWNLOAD_REQUEST, downloadRequest);
|
||||
activityIntent.putExtra(DownloadAuthenticationActivity.ARG_SEND_TO_DOWNLOAD_REQUESTER_BOOL, true);
|
||||
final PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, activityIntent, PendingIntent.FLAG_ONE_SHOT);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(DownloadService.this);
|
||||
builder.setTicker(getText(R.string.authentication_notification_title))
|
||||
.setContentTitle(getText(R.string.authentication_notification_title))
|
||||
|
@ -566,7 +572,7 @@ public class DownloadService extends Service {
|
|||
.setSmallIcon(R.drawable.ic_stat_authentication)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_authentication))
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), MainActivity.class), 0));
|
||||
.setContentIntent(contentIntent);
|
||||
Notification n = builder.build();
|
||||
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.notify(downloadRequest.getSource().hashCode(), n);
|
||||
|
@ -628,6 +634,7 @@ public class DownloadService extends Service {
|
|||
Feed feed = new Feed(request.getSource(), new Date());
|
||||
feed.setFile_url(request.getDestination());
|
||||
feed.setDownloaded(true);
|
||||
feed.setPreferences(new FeedPreferences(0, true, request.getUsername(), request.getPassword()));
|
||||
|
||||
reason = null;
|
||||
String reasonDetailed = null;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class HttpDownloader extends Downloader {
|
|||
new UsernamePasswordCredentials(parts[0], parts[1]),
|
||||
"UTF-8", false));
|
||||
}
|
||||
} else if (StringUtils.isEmpty(request.getUsername()) && request.getPassword() != null) {
|
||||
} else if (!StringUtils.isEmpty(request.getUsername()) && request.getPassword() != null) {
|
||||
httpGet.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials(request.getUsername(),
|
||||
request.getPassword()), "UTF-8", false));
|
||||
}
|
||||
|
|
|
@ -242,8 +242,15 @@ public final class DBTasks {
|
|||
*/
|
||||
public static void refreshFeed(Context context, Feed feed)
|
||||
throws DownloadRequestException {
|
||||
DownloadRequester.getInstance().downloadFeed(context,
|
||||
new Feed(feed.getDownload_url(), new Date(), feed.getTitle()));
|
||||
Feed f;
|
||||
if (feed.getPreferences() == null) {
|
||||
f = new Feed(feed.getDownload_url(), new Date(), feed.getTitle());
|
||||
} else {
|
||||
f = new Feed(feed.getDownload_url(), new Date(), feed.getTitle(),
|
||||
feed.getPreferences().getUsername(), feed.getPreferences().getPassword());
|
||||
}
|
||||
|
||||
DownloadRequester.getInstance().downloadFeed(context, f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -654,6 +661,11 @@ public final class DBTasks {
|
|||
"Feed has updated attribute values. Updating old feed's attributes");
|
||||
savedFeed.updateFromOther(newFeed);
|
||||
}
|
||||
if (savedFeed.getPreferences().compareWithOther(newFeed.getPreferences())) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Feed has updated preferences. Updating old feed's preferences");
|
||||
savedFeed.getPreferences().updateFromOther(newFeed.getPreferences());
|
||||
}
|
||||
// Look for new or updated Items
|
||||
for (int idx = 0; idx < newFeed.getItems().size(); idx++) {
|
||||
final FeedItem item = newFeed.getItems().get(idx);
|
||||
|
|
|
@ -249,7 +249,6 @@ public class PodDBAdapter {
|
|||
public static final int IDX_FEED_SEL_PREFERENCES_PASSWORD = 17;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Select all columns from the feeditems-table except description and
|
||||
* content-encoded.
|
||||
|
@ -497,6 +496,9 @@ public class PodDBAdapter {
|
|||
setFeedItem(item, false);
|
||||
}
|
||||
}
|
||||
if (feed.getPreferences() != null) {
|
||||
setFeedPreferences(feed.getPreferences());
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
}
|
||||
|
@ -515,7 +517,7 @@ public class PodDBAdapter {
|
|||
*/
|
||||
public Cursor getFeedsInFlattrQueueCursor() {
|
||||
return db.query(TABLE_NAME_FEEDS, FEED_SEL_STD, KEY_FLATTR_STATUS + "=?",
|
||||
new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)},null, null, null);
|
||||
new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)}, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -523,7 +525,7 @@ public class PodDBAdapter {
|
|||
*/
|
||||
public Cursor getFeedItemsInFlattrQueueCursor() {
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_FLATTR_STATUS + "=?",
|
||||
new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)},null, null, null);
|
||||
new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)}, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -590,8 +592,7 @@ public class PodDBAdapter {
|
|||
* Update the flattr status of a feed or feed item specified by its payment link
|
||||
* and the new flattr status to use
|
||||
*/
|
||||
public void setItemFlattrStatus(String url, FlattrStatus status)
|
||||
{
|
||||
public void setItemFlattrStatus(String url, FlattrStatus status) {
|
||||
//Log.d(TAG, "setItemFlattrStatus(" + url + ") = " + status.toString());
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_FLATTR_STATUS, status.toLong());
|
||||
|
@ -606,19 +607,19 @@ public class PodDBAdapter {
|
|||
|
||||
if (db.update(TABLE_NAME_FEEDS, values,
|
||||
KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?", query_urls) > 0)
|
||||
{
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?", query_urls
|
||||
) > 0) {
|
||||
Log.i(TAG, "setItemFlattrStatus found match for " + url + " = " + status.toLong() + " in Feeds table");
|
||||
return;
|
||||
}
|
||||
if (db.update(TABLE_NAME_FEED_ITEMS, values,
|
||||
KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?", query_urls) > 0)
|
||||
{
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?"
|
||||
+ " OR " + KEY_PAYMENT_LINK + " GLOB ?", query_urls
|
||||
) > 0) {
|
||||
Log.i(TAG, "setItemFlattrStatus found match for " + url + " = " + status.toLong() + " in FeedsItems table");
|
||||
}
|
||||
}
|
||||
|
@ -626,8 +627,7 @@ public class PodDBAdapter {
|
|||
/**
|
||||
* Reset flattr status to unflattrd for all items
|
||||
*/
|
||||
public void clearAllFlattrStatus()
|
||||
{
|
||||
public void clearAllFlattrStatus() {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KEY_FLATTR_STATUS, 0);
|
||||
db.update(TABLE_NAME_FEEDS, values, null, null);
|
||||
|
@ -878,8 +878,9 @@ public class PodDBAdapter {
|
|||
|
||||
public final Cursor getAllItemsOfFeedCursor(final long feedId) {
|
||||
Cursor c = db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_FEED
|
||||
+ "=?", new String[]{String.valueOf(feedId)}, null, null,
|
||||
null);
|
||||
+ "=?", new String[]{String.valueOf(feedId)}, null, null,
|
||||
null
|
||||
);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -921,8 +922,9 @@ public class PodDBAdapter {
|
|||
|
||||
public final Cursor getSimpleChaptersOfFeedItemCursor(final FeedItem item) {
|
||||
Cursor c = db.query(TABLE_NAME_SIMPLECHAPTERS, null, KEY_FEEDITEM
|
||||
+ "=?", new String[]{String.valueOf(item.getId())}, null,
|
||||
null, null);
|
||||
+ "=?", new String[]{String.valueOf(item.getId())}, null,
|
||||
null, null
|
||||
);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -1069,7 +1071,8 @@ public class PodDBAdapter {
|
|||
if (ids.length > IN_OPERATOR_MAXIMUM) {
|
||||
throw new IllegalArgumentException(
|
||||
"number of IDs must not be larger than "
|
||||
+ IN_OPERATOR_MAXIMUM);
|
||||
+ IN_OPERATOR_MAXIMUM
|
||||
);
|
||||
}
|
||||
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_ID + " IN "
|
||||
|
@ -1124,15 +1127,17 @@ public class PodDBAdapter {
|
|||
if (feedID != 0) {
|
||||
// search items in specific feed
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_FEED
|
||||
+ "=? AND " + KEY_DESCRIPTION + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'",
|
||||
+ "=? AND " + KEY_DESCRIPTION + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'",
|
||||
new String[]{String.valueOf(feedID)}, null, null,
|
||||
null);
|
||||
null
|
||||
);
|
||||
} else {
|
||||
// search through all items
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL,
|
||||
KEY_DESCRIPTION + " LIKE '%" + prepareSearchQuery(query)
|
||||
+ "%'", null, null, null, null);
|
||||
+ "%'", null, null, null, null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1146,16 +1151,18 @@ public class PodDBAdapter {
|
|||
if (feedID != 0) {
|
||||
// search items in specific feed
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_FEED
|
||||
+ "=? AND " + KEY_CONTENT_ENCODED + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'",
|
||||
+ "=? AND " + KEY_CONTENT_ENCODED + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'",
|
||||
new String[]{String.valueOf(feedID)}, null, null,
|
||||
null);
|
||||
null
|
||||
);
|
||||
} else {
|
||||
// search through all items
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL,
|
||||
KEY_CONTENT_ENCODED + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'", null, null,
|
||||
null, null);
|
||||
null, null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1163,16 +1170,18 @@ public class PodDBAdapter {
|
|||
if (feedID != 0) {
|
||||
// search items in specific feed
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL, KEY_FEED
|
||||
+ "=? AND " + KEY_TITLE + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'",
|
||||
+ "=? AND " + KEY_TITLE + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'",
|
||||
new String[]{String.valueOf(feedID)}, null, null,
|
||||
null);
|
||||
null
|
||||
);
|
||||
} else {
|
||||
// search through all items
|
||||
return db.query(TABLE_NAME_FEED_ITEMS, FEEDITEM_SEL_FI_SMALL,
|
||||
KEY_TITLE + " LIKE '%"
|
||||
+ prepareSearchQuery(query) + "%'", null, null,
|
||||
null, null);
|
||||
null, null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue