implement publish with note
This commit is contained in:
parent
b4b781209f
commit
f532761611
@ -1,39 +1,39 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/selection_toggle_unread"
|
android:id="@+id/selection_toggle_unread"
|
||||||
android:showAsAction=""
|
android:showAsAction=""
|
||||||
android:title="@string/context_selection_toggle_unread"/>
|
android:title="@string/context_selection_toggle_unread"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/selection_toggle_marked"
|
android:id="@+id/selection_toggle_marked"
|
||||||
android:showAsAction=""
|
android:showAsAction=""
|
||||||
android:title="@string/context_selection_toggle_marked"/>
|
android:title="@string/context_selection_toggle_marked"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/selection_toggle_published"
|
android:id="@+id/selection_toggle_published"
|
||||||
android:showAsAction=""
|
android:showAsAction=""
|
||||||
android:title="@string/context_selection_toggle_published"/>
|
android:title="@string/context_selection_toggle_published"/>
|
||||||
|
|
||||||
<group android:id="@+id/menu_group_single_article">
|
<group android:id="@+id/menu_group_single_article" >
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/share_article"
|
android:id="@+id/share_article"
|
||||||
android:showAsAction=""
|
android:showAsAction=""
|
||||||
android:title="@string/share_article"/>
|
android:title="@string/share_article"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/article_link_copy"
|
android:id="@+id/article_link_copy"
|
||||||
android:showAsAction=""
|
android:showAsAction=""
|
||||||
android:title="@string/article_link_copy"/>
|
android:title="@string/article_link_copy"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/catchup_above"
|
android:id="@+id/catchup_above"
|
||||||
android:showAsAction=""
|
android:showAsAction=""
|
||||||
android:title="@string/article_mark_read_above"/>
|
android:title="@string/article_mark_read_above"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/set_labels"
|
||||||
|
android:icon="@drawable/ic_menu_marked"
|
||||||
|
android:title="@string/article_set_labels"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/article_set_note"
|
||||||
|
android:showAsAction=""
|
||||||
|
android:title="@string/article_set_note"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -127,6 +127,11 @@
|
|||||||
android:id="@+id/set_labels"
|
android:id="@+id/set_labels"
|
||||||
android:icon="@drawable/ic_menu_marked"
|
android:icon="@drawable/ic_menu_marked"
|
||||||
android:title="@string/article_set_labels"/>
|
android:title="@string/article_set_labels"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/article_set_note"
|
||||||
|
android:showAsAction=""
|
||||||
|
android:title="@string/article_set_note"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
@ -118,4 +118,5 @@
|
|||||||
<string name="dialog_offline_sync_in_progress">Offline sync in progress</string>
|
<string name="dialog_offline_sync_in_progress">Offline sync in progress</string>
|
||||||
<string name="dialog_offline_sync_stop">Stop syncing</string>
|
<string name="dialog_offline_sync_stop">Stop syncing</string>
|
||||||
<string name="dialog_offline_sync_continue">Continue</string>
|
<string name="dialog_offline_sync_continue">Continue</string>
|
||||||
|
<string name="article_set_note">Publish with note</string>
|
||||||
</resources>
|
</resources>
|
@ -116,6 +116,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
menu.setGroupVisible(R.id.menu_group_single_article, true);
|
menu.setGroupVisible(R.id.menu_group_single_article, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu.findItem(R.id.set_labels).setEnabled(m_onlineServices.getApiLevel() >= 1);
|
||||||
|
menu.findItem(R.id.article_set_note).setEnabled(m_onlineServices.getApiLevel() >= 1);
|
||||||
|
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -247,6 +247,24 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
req.execute(map);
|
req.execute(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
|
public void saveArticleNote(final Article article, final String note) {
|
||||||
|
ApiRequest req = new ApiRequest(getApplicationContext());
|
||||||
|
|
||||||
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
|
{
|
||||||
|
put("sid", m_sessionId);
|
||||||
|
put("op", "updateArticle");
|
||||||
|
put("article_ids", String.valueOf(article.id));
|
||||||
|
put("mode", "1");
|
||||||
|
put("data", note);
|
||||||
|
put("field", "3");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
req.execute(map);
|
||||||
|
}
|
||||||
|
|
||||||
public static String articlesToIdString(ArticleList articles) {
|
public static String articlesToIdString(ArticleList articles) {
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
|
|
||||||
@ -936,6 +954,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
case R.id.go_offline:
|
case R.id.go_offline:
|
||||||
switchOffline();
|
switchOffline();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.article_set_note:
|
||||||
|
if (m_selectedArticle != null) {
|
||||||
|
editArticleNote(m_selectedArticle);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case R.id.headlines_select:
|
case R.id.headlines_select:
|
||||||
if (hf != null) {
|
if (hf != null) {
|
||||||
Dialog dialog = new Dialog(this);
|
Dialog dialog = new Dialog(this);
|
||||||
@ -1095,6 +1118,46 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.set_labels:
|
case R.id.set_labels:
|
||||||
if (m_selectedArticle != null) {
|
if (m_selectedArticle != null) {
|
||||||
|
editArticleLabels(m_selectedArticle);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
Log.d(TAG,
|
||||||
|
"onOptionsItemSelected, unhandled id=" + item.getItemId());
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editArticleNote(final Article article) {
|
||||||
|
String note = "";
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(article.title);
|
||||||
|
final EditText topicEdit = new EditText(this);
|
||||||
|
topicEdit.setText(note);
|
||||||
|
builder.setView(topicEdit);
|
||||||
|
|
||||||
|
builder.setPositiveButton(R.string.article_set_note, new Dialog.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
saveArticleNote(article, topicEdit.getText().toString().trim());
|
||||||
|
article.published = true;
|
||||||
|
saveArticlePublished(article);
|
||||||
|
updateHeadlines();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNegativeButton(R.string.dialog_cancel, new Dialog.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editArticleLabels(Article article) {
|
||||||
|
final int articleId = article.id;
|
||||||
|
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
||||||
@Override
|
@Override
|
||||||
@ -1128,7 +1191,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
put("sid", m_sessionId);
|
put("sid", m_sessionId);
|
||||||
put("op", "setArticleLabel");
|
put("op", "setArticleLabel");
|
||||||
put("label_id", String.valueOf(labelId));
|
put("label_id", String.valueOf(labelId));
|
||||||
put("article_ids", String.valueOf(m_selectedArticle.id));
|
put("article_ids", String.valueOf(articleId));
|
||||||
if (isChecked) put("assign", "true");
|
if (isChecked) put("assign", "true");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1157,19 +1220,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", m_sessionId);
|
||||||
put("op", "getLabels");
|
put("op", "getLabels");
|
||||||
put("article_id", String.valueOf(m_selectedArticle.id));
|
put("article_id", String.valueOf(articleId));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
req.execute(map);
|
req.execute(map);
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
Log.d(TAG,
|
|
||||||
"onOptionsItemSelected, unhandled id=" + item.getItemId());
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent getShareIntent(Article article) {
|
private Intent getShareIntent(Article article) {
|
||||||
@ -1317,6 +1372,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1);
|
m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1);
|
||||||
|
m_menu.findItem(R.id.article_set_note).setEnabled(m_apiLevel >= 1);
|
||||||
|
|
||||||
m_menu.findItem(R.id.donate).setVisible(BillingHelper.isBillingSupported());
|
m_menu.findItem(R.id.donate).setVisible(BillingHelper.isBillingSupported());
|
||||||
|
|
||||||
@ -1745,6 +1801,36 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
shareArticle(m_selectedArticle);
|
shareArticle(m_selectedArticle);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.set_labels:
|
||||||
|
if (true) {
|
||||||
|
Article article = null;
|
||||||
|
|
||||||
|
if (m_selectedArticle != null) {
|
||||||
|
article = m_selectedArticle;
|
||||||
|
} else if (info != null) {
|
||||||
|
article = hf.getArticleAtPosition(info.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (article != null) {
|
||||||
|
editArticleLabels(article);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case R.id.article_set_note:
|
||||||
|
if (true) {
|
||||||
|
Article article = null;
|
||||||
|
|
||||||
|
if (m_selectedArticle != null) {
|
||||||
|
article = m_selectedArticle;
|
||||||
|
} else if (info != null) {
|
||||||
|
article = hf.getArticleAtPosition(info.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (article != null) {
|
||||||
|
editArticleNote(article);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case R.id.browse_articles:
|
case R.id.browse_articles:
|
||||||
if (cf != null) {
|
if (cf != null) {
|
||||||
FeedCategory cat = cf.getCategoryAtPosition(info.position);
|
FeedCategory cat = cf.getCategoryAtPosition(info.position);
|
||||||
|
Loading…
Reference in New Issue
Block a user