Merge branch 'develop' into feature/macgills/#692-build-all-variants

# Conflicts:
#	.travis.yml
This commit is contained in:
Sean Mac Gillicuddy 2019-07-02 09:53:27 +01:00
commit f2b4806d14
10 changed files with 86 additions and 16 deletions

View File

@ -60,7 +60,7 @@ script:
after_success: after_success:
- bash <(curl -s https://codecov.io/bash) - bash <(curl -s https://codecov.io/bash)
- ./gradlew kiwixtestUploadKiwix - ./gradlew kiwixtestUploadKiwix assembleKiwixRelease
after_failure: after_failure:
- export LOG_DIR = ${TRAVIS_HOME}/build/kiwix/kiwix-android/app/build/outputs/reports/androidTests/connected/flavors/KIWIX/ - 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: before_deploy:
# - export APP_CHANGELOG=$(cat app/src/kiwix/play/release-notes/en-US/default.txt) # - 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: deploy:
#publish on github releases #publish on github releases
- provider: releases - provider: releases
api_key: "$GITHUB_TOKEN" api_key: "$GITHUB_TOKEN"
file: app/build/outputs/apk/kiwix/release/* file: $UNIVERSAL_APK
file_glob: true file_glob: true
skip_cleanup: true skip_cleanup: true
overwrite: true overwrite: true
@ -92,3 +95,10 @@ deploy:
script: ./gradlew publishKiwixRelease script: ./gradlew publishKiwixRelease
on: on:
tags: true 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

View File

@ -115,10 +115,17 @@ public class ZimContentProvider extends ContentProvider {
return zimFileName; return zimFileName;
} }
/** Returns path to the current ZIM file */
public static String getZimFile() { public static String getZimFile() {
return zimFileName; 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() { public static String getZimFileTitle() {
if (currentJNIReader == null || zimFileName == null) { if (currentJNIReader == null || zimFileName == null) {
return null; return null;

View File

@ -40,7 +40,7 @@ import org.kiwix.kiwixmobile.data.remote.UserAgentInterceptor;
return new OkHttpClient().newBuilder().followRedirects(true).followSslRedirects(true) return new OkHttpClient().newBuilder().followRedirects(true).followSslRedirects(true)
.connectTimeout(10, TimeUnit.SECONDS) .connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(20, TimeUnit.SECONDS) .readTimeout(60, TimeUnit.SECONDS)
.addNetworkInterceptor(logging) .addNetworkInterceptor(logging)
.addNetworkInterceptor(new UserAgentInterceptor(userAgent)).build(); .addNetworkInterceptor(new UserAgentInterceptor(userAgent)).build();
} }

View File

@ -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 * 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. * 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 class AddNoteDialog extends DialogFragment implements ConfirmationAlertDialogFragment.UserClickListener {
public static String TAG = "AddNoteDialog"; public static final String TAG = "AddNoteDialog";
private SharedPreferenceUtil sharedPreferenceUtil; private SharedPreferenceUtil sharedPreferenceUtil;
@ -66,15 +66,19 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
@BindView(R.id.add_note_text_view) @BindView(R.id.add_note_text_view)
TextView addNoteTextView; // Displays article title TextView addNoteTextView; // Displays article title
@BindView(R.id.add_note_edit_text) @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 Unbinder unbinder;
private String zimFileTitle; private String zimFileTitle;
private String articleTitle; 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 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) { public AddNoteDialog(SharedPreferenceUtil sharedPreferenceUtil) {
this.sharedPreferenceUtil = sharedPreferenceUtil; this.sharedPreferenceUtil = sharedPreferenceUtil;
} }
@ -87,6 +91,11 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
zimFileTitle = ZimContentProvider.getZimFileTitle(); zimFileTitle = ZimContentProvider.getZimFileTitle();
articleTitle = ((MainActivity)getActivity()).getCurrentWebView().getTitle(); articleTitle = ((MainActivity)getActivity()).getCurrentWebView().getTitle();
zimNoteDirectoryName = getZimNoteDirectoryName();
articleNotefileName = getArticleNotefileName();
ZIM_NOTES_DIRECTORY = NOTES_DIRECTORY + zimNoteDirectoryName + "/";
} }
@Override @Override
@ -149,6 +158,40 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
return view; 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 // Override onBackPressed() to respond to user pressing 'Back' button on navigation bar
@NonNull @NonNull
@Override @Override
@ -248,7 +291,7 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
return; return;
} }
File notesFolder = new File(NOTES_DIRECTORY + zimFileTitle); File notesFolder = new File(ZIM_NOTES_DIRECTORY);
boolean folderExists = true; boolean folderExists = true;
if(!notesFolder.exists()) { if(!notesFolder.exists()) {
@ -257,7 +300,7 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
} }
if(folderExists) { if(folderExists) {
File noteFile = new File(notesFolder.getAbsolutePath(), articleTitle + ".txt"); File noteFile = new File(notesFolder.getAbsolutePath(), articleNotefileName + ".txt");
// Save note text-file code: // Save note text-file code:
try { try {
@ -290,7 +333,7 @@ public class AddNoteDialog extends DialogFragment implements ConfirmationAlertDi
* is displayed in the EditText field (note content area) * 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()) { if(noteFile.exists()) {
noteFileExists = true; 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 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; Uri noteFileUri = null;
if(noteFile.exists()) { if(noteFile.exists()) {

View File

@ -529,7 +529,7 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
closeAllTabsButton.setImageDrawable( closeAllTabsButton.setImageDrawable(
ContextCompat.getDrawable(this, R.drawable.ic_close_white_24dp)); ContextCompat.getDrawable(this, R.drawable.ic_close_black_24dp));
tabSwitcherRoot.setVisibility(View.GONE); tabSwitcherRoot.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
contentFrame.setVisibility(View.VISIBLE); contentFrame.setVisibility(View.VISIBLE);

View File

@ -86,7 +86,7 @@ public class AnimationUtils {
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
v.setImageDrawable( v.setImageDrawable(
ContextCompat.getDrawable(v.getContext(), R.drawable.ic_close_white_24dp)); ContextCompat.getDrawable(v.getContext(), R.drawable.ic_close_black_24dp));
} }
}); });
} }

View File

@ -144,7 +144,7 @@ class ZimManageViewModel @Inject constructor(
.subscribe( .subscribe(
{ {
kiwixService.library kiwixService.library
.timeout(10, SECONDS) .timeout(60, SECONDS)
.retry(5) .retry(5)
.subscribe( .subscribe(
{ library.onNext(it) }, { library.onNext(it) },

View 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>

View File

@ -25,6 +25,6 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/ic_close_white_24dp" app:srcCompat="@drawable/ic_close_black_24dp"
/> />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.