diff --git a/.travis.yml b/.travis.yml index dba292114..d5f87d331 100644 --- a/.travis.yml +++ b/.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 diff --git a/app/src/main/java/org/kiwix/kiwixmobile/data/ZimContentProvider.java b/app/src/main/java/org/kiwix/kiwixmobile/data/ZimContentProvider.java index 167afbea9..01e305b3f 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/data/ZimContentProvider.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/data/ZimContentProvider.java @@ -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; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java index 542ab28fc..f0c8b4ce6 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/NetworkModule.java @@ -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(); } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/AddNoteDialog.java b/app/src/main/java/org/kiwix/kiwixmobile/main/AddNoteDialog.java index 9faafd946..dfd9fde0c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/main/AddNoteDialog.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/main/AddNoteDialog.java @@ -52,28 +52,32 @@ 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; @BindView(R.id.add_note_toolbar) - Toolbar toolbar; // Displays options for the note dialog + Toolbar toolbar; // Displays options for the note dialog @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 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()) { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java index a618bd884..ab66be396 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/main/MainActivity.java @@ -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); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/AnimationUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/AnimationUtils.java index ad0cab05e..54e3e4c0b 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/AnimationUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/AnimationUtils.java @@ -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)); } }); } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModel.kt b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModel.kt index ccbffdbf3..e4ed2c862 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModel.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModel.kt @@ -144,7 +144,7 @@ class ZimManageViewModel @Inject constructor( .subscribe( { kiwixService.library - .timeout(10, SECONDS) + .timeout(60, SECONDS) .retry(5) .subscribe( { library.onNext(it) }, diff --git a/app/src/main/res/drawable/ic_close_black_24dp.xml b/app/src/main/res/drawable/ic_close_black_24dp.xml new file mode 100644 index 000000000..e5085c6ef --- /dev/null +++ b/app/src/main/res/drawable/ic_close_black_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/tab_switcher.xml b/app/src/main/res/layout/tab_switcher.xml index fc51c5089..ba1307ad4 100644 --- a/app/src/main/res/layout/tab_switcher.xml +++ b/app/src/main/res/layout/tab_switcher.xml @@ -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" /> diff --git a/secrets.tar.enc b/secrets.tar.enc index 05e3c25c9..84725abc8 100644 Binary files a/secrets.tar.enc and b/secrets.tar.enc differ