Skip to content

Commit

Permalink
Merge pull request #102 from wallabag/someupdate
Browse files Browse the repository at this point in the history
Someupdate
  • Loading branch information
tcitworld committed Nov 12, 2015
2 parents 4535c1a + 9be50b6 commit ddef71d
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 54 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "fr.gaulupeau.apps.InThePoche"
minSdkVersion 8
targetSdkVersion 22
versionCode 11
versionName "1.8"
versionCode 12
versionName "1.9"
}

buildTypes {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="fr.gaulupeau.apps.Poche.ui.ReadArticleActivity" />
<activity
android:name="fr.gaulupeau.apps.Poche.ui.ReadArticleActivity"
android:hardwareAccelerated="true" />
<activity
android:name="fr.gaulupeau.apps.Poche.ui.PocheActivity"
android:theme="@style/mainActivity_theme" />
Expand Down
21 changes: 20 additions & 1 deletion app/src/main/java/fr/gaulupeau/apps/Poche/data/ListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.view.ViewGroup;
import android.widget.TextView;

import java.net.URL;
import java.util.List;

import fr.gaulupeau.apps.InThePoche.R;
Expand All @@ -19,6 +20,7 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ViewHolder> {

private List<Article> articles;
private OnItemClickListener listener;
private String originalUrlHost;

public ListAdapter(List<Article> articles, OnItemClickListener listener) {
this.articles = articles;
Expand All @@ -45,18 +47,35 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
OnItemClickListener listener;
TextView title;
TextView url;
TextView favourite;
TextView read;

public ViewHolder(View itemView, OnItemClickListener listener) {
super(itemView);
this.listener = listener;
title = (TextView) itemView.findViewById(R.id.title);
url = (TextView) itemView.findViewById(R.id.url);
favourite = (TextView) itemView.findViewById(R.id.favourite);
read = (TextView) itemView.findViewById(R.id.read);
itemView.setOnClickListener(this);
}

public void bind(Article article) {
String originalUrlText = new String(article.getUrl());
try {
URL originalUrl = new URL(originalUrlText);
originalUrlHost = originalUrl.getHost();
} catch (Exception e) {
//
}
title.setText(article.getTitle());
url.setText(article.getUrl());
url.setText(originalUrlHost);
if (article.getFavorite()){
favourite.setText("★");
}
if (article.getArchive()){
read.setText("☑");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;

import java.util.ArrayList;
Expand Down Expand Up @@ -80,6 +82,7 @@ public void onRefresh() {
readList.setAdapter(mAdapter);

checkAndHandleAfterUpdate();

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import java.net.URL;

import fr.gaulupeau.apps.InThePoche.R;
import fr.gaulupeau.apps.Poche.App;
import fr.gaulupeau.apps.Poche.network.tasks.AddLinkTask;
Expand All @@ -41,8 +42,10 @@ public class ReadArticleActivity extends BaseActionBarActivity {

private ScrollView scrollView;
private WebView webViewContent;
private Button btnMarkRead;
private TextView loadingPlaceholder;
private Button btnMarkRead;
private LinearLayout bottomTools;
private View hrBar;

private Article mArticle;
private ArticleDao mArticleDao;
Expand All @@ -66,19 +69,11 @@ public void onCreate(Bundle savedInstanceState) {

titleText = mArticle.getTitle();
originalUrlText = mArticle.getUrl();
String originalUrlDesc = originalUrlText;
String htmlContent = mArticle.getContent();
positionToRestore = mArticle.getArticleProgress();

setTitle(titleText);

try {
URL originalUrl = new URL(originalUrlText);
originalUrlDesc = originalUrl.getHost();
} catch (Exception e) {
//
}

boolean highContrast = App.getInstance().getSettings().getBoolean(Settings.HIGH_CONTRAST, false);

String htmlHeader = "<html>\n" +
Expand All @@ -94,7 +89,6 @@ public void onCreate(Bundle savedInstanceState) {
"\t\t\t\t\t<div id=\"article\">\n" +
"\t\t\t\t\t\t<header class=\"mbm\">\n" +
"\t\t\t\t\t\t\t<h1>" + titleText + "</h1>\n" +
"\t\t\t\t\t\t\t<p>" + getString(R.string.open_original) + "<a href=\"" + originalUrlText + "\">" + originalUrlDesc + "</a></p>\n" +
"\t\t\t\t\t\t</header>\n" +
"\t\t\t\t\t\t<article>";

Expand All @@ -106,9 +100,11 @@ public void onCreate(Bundle savedInstanceState) {
"</html>";

scrollView = (ScrollView) findViewById(R.id.scroll);

webViewContent = (WebView) findViewById(R.id.webViewContent);
webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null);
webViewContent.getSettings().setJavaScriptEnabled(true);
webViewContent.setWebChromeClient(new WebChromeClient() {
});
webViewContent.loadDataWithBaseURL("file:///android_asset/", htmlHeader + htmlContent + htmlFooter, "text/html", "utf-8", null);

webViewContent.setWebViewClient(new WebViewClient() {
@Override
Expand All @@ -117,7 +113,7 @@ public void onPageFinished(WebView view, String url) {
view.postDelayed(new Runnable() {
@Override
public void run() {
if(webViewContent.getHeight() == 0) {
if (webViewContent.getHeight() == 0) {
webViewContent.postDelayed(this, 10);
} else {
loadingFinished();
Expand All @@ -135,6 +131,10 @@ public boolean shouldOverrideUrlLoading(WebView webView, String url) {
});

loadingPlaceholder = (TextView) findViewById(R.id.tv_loading_article);
MenuItem menuNext;
MenuItem menuPrevious;
ImageButton btnGoPrevious;
ImageButton btnGoNext;

btnMarkRead = (Button) findViewById(R.id.btnMarkRead);
btnMarkRead.setOnClickListener(new OnClickListener() {
Expand All @@ -144,13 +144,39 @@ public void onClick(View v) {
markAsReadAndClose();
}
});
btnGoPrevious = (ImageButton) findViewById(R.id.btnGoPrevious);
if (mArticle.getId()-1 == 0) {
btnGoPrevious.setVisibility(View.GONE);
}
btnGoNext = (ImageButton) findViewById(R.id.btnGoNext);
btnGoPrevious.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),ReadArticleActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(ReadArticleActivity.EXTRA_ID, mArticle.getId()-1);
startActivity(intent);
}
});
btnGoNext.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),ReadArticleActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(ReadArticleActivity.EXTRA_ID, mArticle.getId()+1);
startActivity(intent);
}
});
}

private void loadingFinished() {
loadingFinished = true;
bottomTools = (LinearLayout) findViewById(R.id.bottomTools);
hrBar = (View) findViewById(R.id.view1);

loadingPlaceholder.setVisibility(View.GONE);
btnMarkRead.setVisibility(View.VISIBLE);
bottomTools.setVisibility(View.VISIBLE);
hrBar.setVisibility(View.VISIBLE);

restoreReadingPosition();
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_action_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 29 additions & 7 deletions app/src/main/res/layout/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
android:layout_height="1dip"
android:layout_marginBottom="5sp"
android:layout_marginTop="5sp"
android:background="#000000" />
android:background="#000000"
android:visibility="gone" />

<TextView
android:id="@+id/tv_loading_article"
Expand All @@ -41,13 +42,34 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/loading_article_text" />

<Button
android:id="@+id/btnMarkRead"
<LinearLayout
android:id="@+id/bottomTools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/btnMarkRead"
android:visibility="gone" />
android:layout_height="fill_parent"
android:orientation="horizontal"
android:visibility="gone">
<ImageButton
android:id="@+id/btnGoPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Previous"
android:src="@drawable/ic_action_previous_item"
android:layout_weight="1" />
<Button
android:id="@+id/btnMarkRead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/btnMarkRead"
android:layout_weight="6" />
<ImageButton
android:id="@+id/btnGoNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Next"
android:src="@drawable/ic_action_next_item"
android:layout_weight="1" />
</LinearLayout>

</LinearLayout>

Expand Down
36 changes: 31 additions & 5 deletions app/src/main/res/layout/list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,35 @@
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" >
<TextView
android:id="@+id/favourite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:text="" />
<TextView
android:id="@+id/read"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:layout_alignParentRight="true"
android:text="" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
38 changes: 28 additions & 10 deletions app/src/main/res/menu/option_list.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menuFastSync" android:title="@string/btnFastSync" android:icon="@drawable/ic_action_refresh" />
<item android:id="@+id/menuSync" android:title="@string/btnSync" android:icon="@drawable/ic_action_refresh" />
<item android:id="@+id/menuBagPage" android:title="@string/bag_page" />
<item android:id="@+id/menuShowArchived" android:title="@string/menu_show_archived" />
<item android:id="@+id/menuPrioritizeFavorites" android:title="@string/menu_prioritize_favorites" />
<item android:id="@+id/menuOpenRandomArticle" android:title="@string/menu_open_random_article" />
<item android:id="@+id/menuUploadOfflineURLs" android:title="@string/menuUploadOfflineURLs" />
<item android:id="@+id/menuWipeDb" android:title="@string/menuWipeDb" />
<item android:id="@+id/menuSettings" android:title="@string/btnSettings" />
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menuFastSync"
android:title="@string/btnFastSync"
android:icon="@drawable/ic_action_refresh" />
<item
android:id="@+id/menuBagPage"
android:title="@string/bag_page"
android:icon="@drawable/ic_action_new"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menuSync"
android:title="@string/btnSync"
android:icon="@drawable/ic_action_refresh"
app:showAsAction="ifRoom" />
<item android:id="@+id/menuShowArchived"
android:title="@string/menu_show_archived" />
<item android:id="@+id/menuPrioritizeFavorites"
android:title="@string/menu_prioritize_favorites" />
<item android:id="@+id/menuOpenRandomArticle"
android:title="@string/menu_open_random_article" />
<item android:id="@+id/menuUploadOfflineURLs"
android:title="@string/menuUploadOfflineURLs" />
<item android:id="@+id/menuWipeDb"
android:title="@string/menuWipeDb" />
<item android:id="@+id/menuSettings"
android:title="@string/btnSettings" />
</menu>
Loading

0 comments on commit ddef71d

Please sign in to comment.