Skip to content

Commit

Permalink
Merge pull request #4 from foobnix/master
Browse files Browse the repository at this point in the history
обновление
  • Loading branch information
venoom90 authored Oct 17, 2019
2 parents b3393d2 + 5fadd87 commit 0555f5a
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 241 deletions.
6 changes: 3 additions & 3 deletions app/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Wed Oct 16 11:37:02 EEST 2019
appCodeNumber=3292
#Wed Oct 16 15:51:30 EEST 2019
appCodeNumber=3296
appVersionNumberBase=8.1
appVersionNumberIndex=308
appDB=8
appVersionNumberIndex=309
27 changes: 9 additions & 18 deletions app/src/main/java/com/foobnix/model/AppTemp.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
public class AppTemp {

private static AppTemp instance = new AppTemp();

public static AppTemp get() {
return instance;
}

public String lastBookPath;
public String lastClosedActivity;
public String lastMode;
Expand All @@ -25,41 +20,37 @@ public static AppTemp get() {
public int lastBookHeight = 0;
public int lastFontSize = 0;
public String lastBookLang = "";

public boolean isLocked = false;

public boolean isFirstTimeVertical = true;
public boolean isFirstTimeHorizontal = true;

public int readingMode = AppState.READING_MODE_BOOK;

public long syncTime;
public int syncTimeStatus;

public String hypenLang;

public boolean isCut = false;
public boolean isDouble = false;
public boolean isDoubleCoverAlone = false;
public boolean isCrop = false;
public boolean isCropSymetry = false;

public boolean isEnableSync;
public String syncRootID;
transient SharedPreferences sp;

transient SharedPreferences sp;
public static AppTemp get() {
return instance;
}

public void init(Context c){
sp = c.getSharedPreferences("AppTemp", Context.MODE_PRIVATE);
load();
public void init(Context c) {
sp = c.getSharedPreferences("AppTemp", Context.MODE_PRIVATE);
load();
}

public void load(){
public void load() {
Objects.loadFromSp(instance, sp);

}

public void save(){
public void save() {
Objects.saveToSP(instance, sp);

}
Expand Down
21 changes: 15 additions & 6 deletions app/src/main/java/com/foobnix/opds/Link.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.foobnix.android.utils.TxtUtils;
import com.foobnix.pdf.info.ExtUtils;

import org.ebookdroid.BookType;
import org.xmlpull.v1.XmlPullParser;

import java.util.HashMap;
Expand All @@ -11,23 +12,22 @@
public class Link {

public static final String APPLICATION_ATOM_XML = "application/atom+xml";
public static final String APPLICATION_ATOM_XML2 = "atom/atom+xml";
public static final String APPLICATION_ATOM_XML_PROFILE = "application/atom+xml;profile";
public static final String APPLICATION_ATOM_XML_SUBLINE = "application/atom+xml;subline";
public static final String WEB_LINK = "text/html";
public static final String DISABLED = "disabled/";
public static final String TYPE_LOGO = "MY_LOGO";
public static final String REL_THUMBNAIL1 = "http://opds-spec.org/image/thumbnail";
public static final String REL_THUMBNAIL2 = "http://opds-spec.org/thumbnail";

static Map<String, String> map = new HashMap<String, String>();
public String href;
public String type = "";
public String rel;
public String title;

public String parentTitle;
public String filePath;

static Map<String, String> map = new HashMap<String, String>();
{
map.put("text/html", "web");
map.put("text/download", "txt");
Expand Down Expand Up @@ -77,10 +77,11 @@ public boolean isThumbnail() {

public boolean isSearchLink() {
return "search".equals(rel) && APPLICATION_ATOM_XML.equals(type);

}

public boolean isOpdsLink() {
return type != null && type.startsWith(APPLICATION_ATOM_XML);
return type != null && (type.startsWith(APPLICATION_ATOM_XML) || type.startsWith(APPLICATION_ATOM_XML2));
}

public boolean isDisabled() {
Expand All @@ -104,13 +105,21 @@ public String getDownloadDisplayFormat() {
return map.get(item);
}
}

if (type.contains("+zip") || type.contains("+rar")) {
String ext = ExtUtils.getFileExtension(href);
if (BookType.isSupportedExtByPath(ext)) {
return ext.replace(".", "");
}
ext = ExtUtils.getExtByMimeType(type);
if (TxtUtils.isNotEmpty(ext)) {
return ext;
}
if (type.contains("application/")) {
return type.replace("application/", "").replace("+", ".");
}

return null;


}

public String getDownloadName() {
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/foobnix/pdf/info/ExtUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ public class ExtUtils {
mimeCache.put(".mp4", "video/mp4");
mimeCache.put(".webm", "video/webm");
}
public static String getExtByMimeType(String mime){
if(TxtUtils.isEmpty(mime)){
return mime;
}
for(String key:mimeCache.keySet()){
if(mime.equals(mimeCache.get(key))){
return key.replace(".","");
}
}
String ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(mime);
return ext;
}

public static void updateSearchExts() {
List<String> result = new ArrayList<String>();
Expand Down
Loading

0 comments on commit 0555f5a

Please sign in to comment.