Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d4991d0
add github-action
Zusel May 17, 2024
453b70e
add github-action
Zusel May 17, 2024
b33f279
add github-action
Zusel May 17, 2024
f7499e0
fix action
Zusel May 17, 2024
0791a62
fix action
Zusel May 17, 2024
09cead8
fix action
Zusel May 17, 2024
772d24d
fix action
Zusel May 17, 2024
aa5e7c0
fix action
Zusel May 17, 2024
643ed7d
fix action
Zusel May 17, 2024
30c1f53
fix action
Zusel May 17, 2024
c2dfe96
fix action
Zusel May 18, 2024
4cfe8d2
fix action
Zusel May 18, 2024
922c5ac
fix action
Zusel May 18, 2024
350c375
fix action
Zusel May 18, 2024
988e748
fix action
Zusel May 18, 2024
2e49126
fix action
Zusel May 18, 2024
a30dc3e
fix action
Zusel May 18, 2024
42fe0bc
fix action
Zusel May 18, 2024
914dfaa
fix action
Zusel May 18, 2024
716c950
fix action
Zusel May 18, 2024
112c643
fix action
Zusel May 18, 2024
7ee8e7d
fix action
Zusel May 18, 2024
218fe52
fix action
Zusel May 18, 2024
7d53fdb
fix action
Zusel May 18, 2024
1bb8030
fix action
Zusel May 18, 2024
ce6f90a
fix action
Zusel May 28, 2024
3d27f44
cleanup code and add already read feature
Zusel Nov 26, 2023
7968b2f
add application to Manifest
Zusel Nov 26, 2023
9ea778e
add application to Manifest
Zusel Nov 26, 2023
7bcbc8b
change text-color if the article was already read
Zusel Nov 29, 2023
e5ca20d
safe
Zusel Feb 19, 2024
b7f363a
erster Umbau
Zusel Feb 22, 2024
8176ec8
Fix timestamp problem
Zusel Feb 24, 2024
86d2177
replace deprecated stuff
Zusel May 30, 2024
4cfb984
fucking bug
Zusel May 30, 2024
034d8f5
add migration
Zusel Jun 2, 2024
f47e70e
fix migration
Zusel Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build_and_push_apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Push Android-APK

on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Version
run: echo "RELEASE_NUMBER=$(cat app/build.gradle | grep versionName | grep -o -P '".*"' | tr -d '"')" >> $GITHUB_ENV
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: "21"
- name: Change Permissions
run: chmod +x ./gradlew
- name: Build APK
run: ./gradlew assemble
- name: Create Release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_NUMBER }}
release_name: Release ${{ env.RELEASE_NUMBER }}
- name: Upload Release APK
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/apk/release/app-release.apk
asset_name: app-release.apk
asset_content_type: application/zip
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ android {
}

dependencies {
implementation "androidx.room:room-runtime:2.6.1"
annotationProcessor "androidx.room:room-compiler:2.6.1"

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.preference:preference:1.1.1'
Expand Down
29 changes: 15 additions & 14 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:logo="@drawable/golem_eye"
android:resizeableActivity="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="n">
android:name="de.eknoes.inofficialgolem.MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:logo="@drawable/golem_eye"
android:resizeableActivity="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="n">
<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
android:name="org.apache.http.legacy"
android:required="false" />

<activity
android:name=".ArticleView"
android:configChanges="orientation|screenSize"
android:parentActivityName=".MainActivity"
android:exported="true">
android:name=".ArticleView"
android:configChanges="orientation|screenSize"
android:exported="true"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/java/de/eknoes/inofficialgolem/Article.kt

This file was deleted.

80 changes: 28 additions & 52 deletions app/src/main/java/de/eknoes/inofficialgolem/ArticleFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
Expand All @@ -27,10 +25,17 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.room.Room;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import org.jetbrains.annotations.NotNull;

import de.eknoes.inofficialgolem.entities.Article;
import de.eknoes.inofficialgolem.entities.DATABASES;
import de.eknoes.inofficialgolem.utils.ArticleDao;
import de.eknoes.inofficialgolem.utils.ArticleDatabase;
import de.eknoes.inofficialgolem.utils.DBHelper;

public class ArticleFragment extends Fragment {
static final String ARTICLE_URL = "de.eknoes.inofficialgolem.ARTICLE_URL";
static final String FORCE_WEBVIEW = "de.eknoes.inofficialgolem.FORCE_WEBVIEW";
Expand Down Expand Up @@ -114,7 +119,7 @@ public void onSaveInstanceState(@NotNull Bundle outState) {
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

if(webView != null) {
if (webView != null) {
webView.setWebViewClient(new GolemWebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Expand All @@ -139,8 +144,8 @@ public void onPageFinished(WebView view, String url) {
webView.getSettings().setJavaScriptEnabled(true);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setAcceptThirdPartyCookies(webView,true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setAcceptThirdPartyCookies(webView, true);
}
}

Expand Down Expand Up @@ -170,7 +175,7 @@ public void onResume() {
@Override
public void onDetach() {
super.onDetach();
if(mTask != null) {
if (mTask != null) {
mTask.cancel(false);
}
}
Expand All @@ -180,9 +185,9 @@ public void onCreateOptionsMenu(@NotNull Menu menu, @NotNull MenuInflater inflat
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_webview, menu);

if(article == null || article.getCommentUrl() == null) {
if (article == null || article.getCommentUrl() == null) {
MenuItem item = menu.findItem(R.id.action_comments);
if(item != null) {
if (item != null) {
item.setVisible(false);
}
}
Expand All @@ -208,14 +213,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
String link = null;
if (article != null && article.getUrl() != null) {
link = article.getUrl();
if (article != null && article.getArticleUrl() != null) {
link = article.getArticleUrl();
} else if (url != null) {
link = url;
}

if (link != null && article != null) {
shareIntent.putExtra(Intent.EXTRA_TEXT, article.getSubheadline() + ": " + article.getTitle() + " - " + link);
shareIntent.putExtra(Intent.EXTRA_TEXT, article.getSubHeadline() + ": " + article.getTitle() + " - " + link);
} else {
shareIntent.putExtra(Intent.EXTRA_TEXT, link);
}
Expand Down Expand Up @@ -264,44 +269,11 @@ private class loadArticleTask extends AsyncTask<Void, Void, Void> {

@Override
protected Void doInBackground(Void... params) {
FeedReaderDbHelper dbHelper = FeedReaderDbHelper.getInstance(requireContext().getApplicationContext());

SQLiteDatabase db = dbHelper.getReadableDatabase();

if (url != null) {
String[] columns = {
FeedReaderContract.Article.COLUMN_NAME_ID,
FeedReaderContract.Article.COLUMN_NAME_TITLE,
FeedReaderContract.Article.COLUMN_NAME_SUBHEADING,
FeedReaderContract.Article.COLUMN_NAME_URL,
FeedReaderContract.Article.COLUMN_NAME_COMMENTNR,
FeedReaderContract.Article.COLUMN_NAME_COMMENTURL,
FeedReaderContract.Article.COLUMN_NAME_OFFLINE,
FeedReaderContract.Article.COLUMN_NAME_FULLTEXT,
};
Cursor cursor = db.query(
FeedReaderContract.Article.TABLE_NAME,
columns,
"url=\"" + url + "\"",
null,
null,
null,
null);
if (cursor.moveToFirst()) {
article = new Article();
article.setId(cursor.getInt(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_ID)));
article.setTitle(cursor.getString(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_TITLE)));
article.setSubheadline(cursor.getString(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_SUBHEADING)));
article.setUrl(cursor.getString(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_URL)));
article.setCommentUrl(cursor.getString(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_COMMENTURL)));
article.setCommentNr(cursor.getString(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_COMMENTNR)));
article.setOffline(cursor.getInt(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_OFFLINE)) == 1);
article.setFulltext(cursor.getString(cursor.getColumnIndexOrThrow(FeedReaderContract.Article.COLUMN_NAME_FULLTEXT)));
}


cursor.close();
}
if (url != null) {
ArticleDatabase db = Room.databaseBuilder(getContext(), ArticleDatabase.class, DATABASES.ARTICLE.name()).build();
ArticleDao dao = db.articleDao();
article = dao.getArticleByUrl(url);
}
return null;
}

Expand All @@ -320,19 +292,23 @@ protected void onPostExecute(Void vVoid) {
networkInfo = connMgr.getActiveNetworkInfo();
}
if (networkInfo != null && networkInfo.isConnected()) {
article.setAlreadyRead(true);
DBHelper.updateArticle(getContext(), article);
webView.loadUrl(url);
} else {
webView.loadData(getResources().getString(R.string.err_no_network), "text/html; charset=utf-8", "UTF-8");
}
} else {
article.setAlreadyRead(true);
DBHelper.updateArticle(getContext(),article);
webView.loadUrl(url);
}
} else {
Log.d(TAG, "onPostExecute: Fill Webview");
String fulltext = article.getFulltext();
String fulltext = article.getFullText();

// Change CSS for Dark Mode
if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES) {
if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES) {
if (fulltext != null) {
fulltext = fulltext.replace("</head>", """
<style type="text/css">#screen, body, html {
Expand All @@ -353,7 +329,7 @@ protected void onPostExecute(Void vVoid) {
color: black !important;
}</style></head>""");
}
webView.loadDataWithBaseURL(article.getUrl(), fulltext, "text/html", "UTF-8", null);
webView.loadDataWithBaseURL(article.getArticleUrl(), fulltext, "text/html", "UTF-8", null);
Log.d(TAG, "onPostExecute: Filled Webview");

}
Expand Down
Loading