News download finished, but multilanguage news still pending.

This commit is contained in:
jens 2021-02-21 19:21:40 +01:00
parent fecfc9c810
commit d1ab6c660a
6 changed files with 20 additions and 5 deletions

View File

@ -71,7 +71,6 @@ dependencies {
apkFlavorImplementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'

View File

@ -196,6 +196,10 @@
<activity android:name=".ActivityPermissions"></activity>
<!-- https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p-->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<service android:name=".location.GeofenceIntentService"/>
</application>

View File

@ -182,6 +182,8 @@
<activity android:name=".ActivityPermissions"></activity>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
</manifest>

View File

@ -198,6 +198,8 @@
<service android:name=".location.GeofenceIntentService"/>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
</manifest>

View File

@ -187,6 +187,9 @@
<activity android:name=".ActivityPermissions"></activity>
<!-- https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p-->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
</manifest>

View File

@ -10,6 +10,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import java.io.File;
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -28,13 +29,15 @@ public class News
Calendar now = Calendar.getInstance();
String newsContent;
if (Settings.lastNewsPolltime == -1 || now.getTimeInMillis() >= Settings.lastNewsPolltime + (long)(Settings.pollNewsEveryXDays * 24 * 60 * 60 * 1000))
String filePath = context.getFilesDir() + "/appNews.xml";
if (!(new File(filePath)).exists() || Settings.lastNewsPolltime == -1 || now.getTimeInMillis() >= Settings.lastNewsPolltime + (long)(Settings.pollNewsEveryXDays * 24 * 60 * 60 * 1000))
{
String newsUrl = "https://server47.de/automation/appNews.php";
newsContent = Miscellaneous.downloadURL(newsUrl, null, null);
// Cache content to local storage
if(Miscellaneous.writeStringToFile(context.getFilesDir() + "/appNews.xml", newsContent))
if(Miscellaneous.writeStringToFile(filePath, newsContent))
{
Settings.lastNewsPolltime = now.getTimeInMillis();
Settings.writeSettings(context);
@ -43,7 +46,7 @@ public class News
else
{
// Just read local cache file
newsContent = Miscellaneous.readFileToString(context.getFilesDir() + "/appNews.xml");
newsContent = Miscellaneous.readFileToString(filePath);
}
ArrayList<News> returnList = new ArrayList<>();
@ -164,7 +167,9 @@ public class News
@Override
protected ArrayList doInBackground(Context... contexts)
{
return downloadNews(contexts[0]);
Calendar limit = Calendar.getInstance();
limit.add(Calendar.DAY_OF_MONTH, -Settings.pollNewsEveryXDays);
return downloadNews(contexts[0], limit);
}
@Override