mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Merge branch 'develop' into feature/macgills/#692-build-all-variants
# Conflicts: # .travis.yml
This commit is contained in:
commit
f2b4806d14
14
.travis.yml
14
.travis.yml
@ -60,7 +60,7 @@ script:
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
- ./gradlew kiwixtestUploadKiwix
|
||||
- ./gradlew kiwixtestUploadKiwix assembleKiwixRelease
|
||||
|
||||
after_failure:
|
||||
- export LOG_DIR = ${TRAVIS_HOME}/build/kiwix/kiwix-android/app/build/outputs/reports/androidTests/connected/flavors/KIWIX/
|
||||
@ -71,13 +71,16 @@ after_failure:
|
||||
|
||||
before_deploy:
|
||||
# - export APP_CHANGELOG=$(cat app/src/kiwix/play/release-notes/en-US/default.txt)
|
||||
- export DATE = `date +%Y-%m-%d`
|
||||
- export UNIVERSAL_APK = app/build/outputs/apk/kiwix/release/*universal*.apk
|
||||
- export SSH_KEY = travis_ci_builder_id_key
|
||||
|
||||
deploy:
|
||||
|
||||
#publish on github releases
|
||||
- provider: releases
|
||||
api_key: "$GITHUB_TOKEN"
|
||||
file: app/build/outputs/apk/kiwix/release/*
|
||||
file: $UNIVERSAL_APK
|
||||
file_glob: true
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
@ -92,3 +95,10 @@ deploy:
|
||||
script: ./gradlew publishKiwixRelease
|
||||
on:
|
||||
tags: true
|
||||
|
||||
#publish on download.kiwix.org
|
||||
- provider: script
|
||||
skip_cleanup: true
|
||||
script: scp -vrp -i ${SSH_KEY} -o StrictHostKeyChecking=no $UNIVERSAL_APK ci@download.kiwix.org:/data/download/nightly/$DATE
|
||||
on:
|
||||
branch: develop
|
||||
|
@ -115,10 +115,17 @@ public class ZimContentProvider extends ContentProvider {
|
||||
return zimFileName;
|
||||
}
|
||||
|
||||
/** Returns path to the current ZIM file */
|
||||
public static String getZimFile() {
|
||||
return zimFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns title associated with the current ZIM file.
|
||||
*
|
||||
* Note that the value returned is NOT unique for each zim file. Versions of the same wiki
|
||||
* (complete, nopic, novid, etc) may return the same title.
|
||||
* */
|
||||
public static String getZimFileTitle() {
|
||||
if (currentJNIReader == null || zimFileName == null) {
|
||||
return null;
|
||||
|
@ -40,7 +40,7 @@ import org.kiwix.kiwixmobile.data.remote.UserAgentInterceptor;
|
||||
|
||||
return new OkHttpClient().newBuilder().followRedirects(true).followSslRedirects(true)
|
||||
.connectTimeout(10, TimeUnit.SECONDS)
|
||||
.readTimeout(20, TimeUnit.SECONDS)
|
||||
.readTimeout(60, TimeUnit.SECONDS)
|
||||
.addNetworkInterceptor(logging)
|
||||
.addNetworkInterceptor(new UserAgentInterceptor(userAgent)).build();
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ import static org.kiwix.kiwixmobile.utils.Constants.NOTES_DIRECTORY;
|
||||
* AddNoteDialog extends DialogFragment and is used to display the note corresponding to a particular
|
||||
* article (of a particular zim file/wiki/book) as a full-screen dialog fragment.
|
||||
*
|
||||
* Notes are saved as text files at location: "{External Storage}/Kiwix/Notes/ZimFileTitle/ArticleTitle.txt"
|
||||
* Notes are saved as text files at location: "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
||||
* */
|
||||
|
||||
public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDialogFragment.UserClickListener {
|
||||
|
||||
public static String TAG = "AddNoteDialog";
|
||||
public static final String TAG = "AddNoteDialog";
|
||||
|
||||
private SharedPreferenceUtil sharedPreferenceUtil;
|
||||
|
||||
@ -66,15 +66,19 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
|
||||
@BindView(R.id.add_note_text_view)
|
||||
TextView addNoteTextView; // Displays article title
|
||||
@BindView(R.id.add_note_edit_text)
|
||||
EditText addNoteEditText; // Displays zim file title (wiki name)
|
||||
EditText addNoteEditText; // Displays the note text
|
||||
|
||||
private Unbinder unbinder;
|
||||
|
||||
private String zimFileTitle;
|
||||
private String articleTitle;
|
||||
private String zimNoteDirectoryName; // Corresponds to "ZimFileName" of "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
||||
private String articleNotefileName; // Corresponds to "ArticleUrl" of "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
||||
private boolean noteFileExists = false;
|
||||
private boolean noteEdited = false; // Keeps track of state of the note (whether edited since last save)
|
||||
|
||||
private String ZIM_NOTES_DIRECTORY; // Stores path to directory for the currently open zim's notes
|
||||
|
||||
public AddNoteDialog(SharedPreferenceUtil sharedPreferenceUtil) {
|
||||
this.sharedPreferenceUtil = sharedPreferenceUtil;
|
||||
}
|
||||
@ -87,6 +91,11 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
|
||||
|
||||
zimFileTitle = ZimContentProvider.getZimFileTitle();
|
||||
articleTitle = ((MainActivity)getActivity()).getCurrentWebView().getTitle();
|
||||
|
||||
zimNoteDirectoryName = getZimNoteDirectoryName();
|
||||
articleNotefileName = getArticleNotefileName();
|
||||
|
||||
ZIM_NOTES_DIRECTORY = NOTES_DIRECTORY + zimNoteDirectoryName + "/";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,6 +158,40 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
|
||||
return view;
|
||||
}
|
||||
|
||||
private @NonNull String getZimNoteDirectoryName() {
|
||||
String zimFileName = ZimContentProvider.getZimFile(); // Returns name of the form ".../Kiwix/granbluefantasy_en_all_all_nopic_2018-10.zim"
|
||||
|
||||
String noteDirectoryName = getTextAfterLastSlashWithoutExtension(zimFileName);
|
||||
|
||||
return (!noteDirectoryName.isEmpty()) ? noteDirectoryName : zimFileTitle; // Incase the required ZIM file name couldn't be extracted
|
||||
}
|
||||
|
||||
private @NonNull String getArticleNotefileName() {
|
||||
String articleUrl = ((MainActivity) getActivity()).getCurrentWebView().getUrl(); // Returns url of the form: "content://org.kiwix.kiwixmobile.zim.base/A/Main_Page.html"
|
||||
|
||||
String notefileName = getTextAfterLastSlashWithoutExtension(articleUrl);
|
||||
|
||||
return (!notefileName.isEmpty()) ? notefileName : articleTitle; // Incase the required html file name couldn't be extracted
|
||||
}
|
||||
|
||||
private @NonNull String getTextAfterLastSlashWithoutExtension(@NonNull String path) {
|
||||
/* That's about exactly what it does.
|
||||
*
|
||||
* From ".../Kiwix/granbluefantasy_en_all_all_nopic_2018-10.zim", returns "granbluefantasy_en_all_all_nopic_2018-10"
|
||||
* From "content://org.kiwix.kiwixmobile.zim.base/A/Main_Page.html", returns "Main_Page"
|
||||
* For null input or on being unable to find required text, returns null
|
||||
* */
|
||||
|
||||
int rightmostSlash = path.lastIndexOf('/');
|
||||
int rightmostDot = path.lastIndexOf('.');
|
||||
|
||||
if(rightmostSlash > -1 && rightmostDot > -1) {
|
||||
return (path.substring(rightmostSlash+1, rightmostDot));
|
||||
}
|
||||
|
||||
return ""; // If couldn't find the dot and/or slash
|
||||
}
|
||||
|
||||
// Override onBackPressed() to respond to user pressing 'Back' button on navigation bar
|
||||
@NonNull
|
||||
@Override
|
||||
@ -248,7 +291,7 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
|
||||
return;
|
||||
}
|
||||
|
||||
File notesFolder = new File(NOTES_DIRECTORY + zimFileTitle);
|
||||
File notesFolder = new File(ZIM_NOTES_DIRECTORY);
|
||||
boolean folderExists = true;
|
||||
|
||||
if(!notesFolder.exists()) {
|
||||
@ -257,7 +300,7 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
|
||||
}
|
||||
|
||||
if(folderExists) {
|
||||
File noteFile = new File(notesFolder.getAbsolutePath(), articleTitle + ".txt");
|
||||
File noteFile = new File(notesFolder.getAbsolutePath(), articleNotefileName + ".txt");
|
||||
|
||||
// Save note text-file code:
|
||||
try {
|
||||
@ -290,7 +333,7 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
|
||||
* is displayed in the EditText field (note content area)
|
||||
* */
|
||||
|
||||
File noteFile = new File(NOTES_DIRECTORY + zimFileTitle + "/" + articleTitle + ".txt");
|
||||
File noteFile = new File(ZIM_NOTES_DIRECTORY + articleNotefileName + ".txt");
|
||||
|
||||
if(noteFile.exists()) {
|
||||
noteFileExists = true;
|
||||
@ -337,7 +380,7 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
|
||||
saveNote(addNoteEditText.getText().toString()); // Save edited note before sharing the text file
|
||||
}
|
||||
|
||||
File noteFile = new File(NOTES_DIRECTORY + zimFileTitle + "/" + articleTitle + ".txt");
|
||||
File noteFile = new File(ZIM_NOTES_DIRECTORY + articleNotefileName + ".txt");
|
||||
|
||||
Uri noteFileUri = null;
|
||||
if(noteFile.exists()) {
|
||||
|
@ -529,7 +529,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
||||
|
||||
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
|
||||
closeAllTabsButton.setImageDrawable(
|
||||
ContextCompat.getDrawable(this, R.drawable.ic_close_white_24dp));
|
||||
ContextCompat.getDrawable(this, R.drawable.ic_close_black_24dp));
|
||||
tabSwitcherRoot.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
contentFrame.setVisibility(View.VISIBLE);
|
||||
|
@ -86,7 +86,7 @@ public class AnimationUtils {
|
||||
|
||||
public void onAnimationStart(Animation animation) {
|
||||
v.setImageDrawable(
|
||||
ContextCompat.getDrawable(v.getContext(), R.drawable.ic_close_white_24dp));
|
||||
ContextCompat.getDrawable(v.getContext(), R.drawable.ic_close_black_24dp));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ class ZimManageViewModel @Inject constructor(
|
||||
.subscribe(
|
||||
{
|
||||
kiwixService.library
|
||||
.timeout(10, SECONDS)
|
||||
.timeout(60, SECONDS)
|
||||
.retry(5)
|
||||
.subscribe(
|
||||
{ library.onNext(it) },
|
||||
|
10
app/src/main/res/drawable/ic_close_black_24dp.xml
Normal file
10
app/src/main/res/drawable/ic_close_black_24dp.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:tint="#000000"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0"
|
||||
android:width="24dp">
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
|
||||
</vector>
|
@ -25,6 +25,6 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:srcCompat="@drawable/ic_close_white_24dp"
|
||||
app:srcCompat="@drawable/ic_close_black_24dp"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
BIN
secrets.tar.enc
BIN
secrets.tar.enc
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user