From 3bead53f134ef3167015e55ce6a3cd5bbc39ef1d Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Sun, 20 May 2018 15:32:05 +0100 Subject: [PATCH 01/53] Remove download notificaiton channel sound --- .../java/org/kiwix/kiwixmobile/downloader/DownloadService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java index 521facf90..35d1e425d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java @@ -572,6 +572,7 @@ public class DownloadService extends Service { NotificationChannel ongoingDownloadsChannel = new NotificationChannel( Constants.ONGOING_DOWNLOAD_CHANNEL_ID, name, importance); ongoingDownloadsChannel.setDescription(description); + ongoingDownloadsChannel.setSound(null, null); NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE); notificationManager.createNotificationChannel(ongoingDownloadsChannel); From 308a7e5f672bfd39316694f5eccd942a9c398596 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Sun, 20 May 2018 15:49:54 +0100 Subject: [PATCH 02/53] Update error activity create to use application context --- .../kiwixmobile/utils/SplashActivity.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java index 196fb4d5d..cd1c259c5 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java @@ -34,24 +34,21 @@ public class SplashActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Context appContext = this; - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread paramThread, Throwable paramThrowable) { + Context appContext = getApplicationContext(); + Thread.setDefaultUncaughtExceptionHandler((paramThread, paramThrowable) -> { - final Intent intent = new Intent(appContext, KiwixErrorActivity.class); + final Intent intent = new Intent(appContext, KiwixErrorActivity.class); - Bundle extras = new Bundle(); - extras.putSerializable("exception", (Serializable) paramThrowable); + Bundle extras = new Bundle(); + extras.putSerializable("exception", paramThrowable); - intent.putExtras(extras); + intent.putExtras(extras); - appContext.startActivity(intent); + appContext.startActivity(intent); - finish(); - android.os.Process.killProcess(android.os.Process.myPid()); - System.exit(10); - } + finish(); + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(10); }); Intent intent = new Intent(this, KiwixMobileActivity.class); From 5d375bf4a4da0151bf45c7f0ef177dafd1a149a3 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Sun, 20 May 2018 17:39:34 +0100 Subject: [PATCH 03/53] Add dummy webview creation before setting locale --- .../main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java | 3 +++ .../main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index d7c51f1b4..97b277387 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -352,6 +352,9 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); super.onCreate(savedInstanceState); + + new WebView(this).destroy(); // Workaround for buggy webviews see #710 + wifiOnly = sharedPreferenceUtil.getPrefWifiOnly(); nightMode = KiwixSettingsActivity.nightMode(sharedPreferenceUtil); if (nightMode) { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java index 3ad6c06cc..85b2f4cf3 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java @@ -79,9 +79,11 @@ public class LanguageUtils { Locale locale = new Locale(language); Locale.setDefault(locale); Configuration config = new Configuration(); - config.locale = locale; if (Build.VERSION.SDK_INT >= 17) { + config.setLocale(locale); config.setLayoutDirection(locale); + } else { + config.locale = locale; } context.getResources() .updateConfiguration(config, context.getResources().getDisplayMetrics()); @@ -108,7 +110,6 @@ public class LanguageUtils { return mLocaleMap.get(iso3.toUpperCase()); } - @TargetApi(Build.VERSION_CODES.N) public static Locale getCurrentLocale(Context context){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){ return context.getResources().getConfiguration().getLocales().get(0); From f7ab93153c544d15ac9fc32215e61b71b658ad6f Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Sun, 20 May 2018 19:18:21 +0100 Subject: [PATCH 04/53] Reset locale to selected on each activity creation --- .../kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java | 3 +++ .../org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java | 1 + .../org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java | 3 +++ 3 files changed, 7 insertions(+) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java index 081e087ea..72454a33a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/bookmarks_view/BookmarksActivity.java @@ -47,6 +47,7 @@ import org.kiwix.kiwixmobile.KiwixMobileActivity; import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.base.BaseActivity; import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity; +import org.kiwix.kiwixmobile.utils.LanguageUtils; import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import java.util.ArrayList; @@ -84,6 +85,8 @@ public class BookmarksActivity extends BaseActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + LanguageUtils.handleLocaleChange(this, sharedPreferenceUtil); + if (KiwixSettingsActivity.nightMode(sharedPreferenceUtil)) { setTheme(R.style.AppTheme_Night); } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java index 952d1c674..3c2d04dc6 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/settings/KiwixSettingsActivity.java @@ -88,6 +88,7 @@ public class KiwixSettingsActivity extends BaseActivity { public void onCreate(Bundle savedInstanceState) { getWindow().setWindowAnimations(R.style.WindowAnimationTransition); super.onCreate(savedInstanceState); + LanguageUtils.handleLocaleChange(this, sharedPreferenceUtil); if (nightMode(sharedPreferenceUtil)) { setTheme(R.style.AppTheme_Night); } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java index 01759b484..e7ae0a6a5 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimManageActivity.java @@ -39,6 +39,7 @@ import org.kiwix.kiwixmobile.KiwixMobileActivity; import org.kiwix.kiwixmobile.R; import org.kiwix.kiwixmobile.base.BaseActivity; import org.kiwix.kiwixmobile.settings.KiwixSettingsActivity; +import org.kiwix.kiwixmobile.utils.LanguageUtils; import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil; import org.kiwix.kiwixmobile.views.LanguageSelectDialog; @@ -87,6 +88,8 @@ public class ZimManageActivity extends BaseActivity implements ZimManageViewCall @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + LanguageUtils.handleLocaleChange(this, sharedPreferenceUtil); + if (KiwixSettingsActivity.nightMode(sharedPreferenceUtil)) { setTheme(R.style.AppTheme_Night); } From 4c6bff34cb2ea23a18d6ab0c32ed513046f9c021 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Mon, 21 May 2018 11:08:40 +0100 Subject: [PATCH 05/53] Use page title as toc header if h1 is not used --- .../java/org/kiwix/kiwixmobile/tests/BasicTest.java | 2 +- .../main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java index b1a83156c..4a60ad432 100644 --- a/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java +++ b/app/src/androidTestKiwix/java/org/kiwix/kiwixmobile/tests/BasicTest.java @@ -73,7 +73,7 @@ public class BasicTest { openDrawerWithGravity(R.id.drawer_layout, Gravity.RIGHT); assertDrawerIsOpenWithGravity(R.id.drawer_layout, Gravity.RIGHT); - assertDisplayed(R.string.no_section_info); + assertDisplayed(R.string.menu_help); closeDrawerWithGravity(R.id.drawer_layout, Gravity.RIGHT); assertDrawerIsClosedWithGravity(R.id.drawer_layout, Gravity.RIGHT); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java index 87ff92e76..9d69a2172 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/TableDrawerAdapter.java @@ -83,6 +83,9 @@ public class TableDrawerAdapter extends RecyclerView.Adapter { From f37cf860c2d8b97a6d6032d67e5b5b805a6063d9 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 30 May 2018 01:17:57 +0100 Subject: [PATCH 06/53] Fix provider domain when updating from 2.2 --- .../kiwixmobile/KiwixMobileActivity.java | 5 ++-- .../kiwixmobile/database/BookmarksDao.java | 23 +++++++++++++++++++ .../kiwixmobile/database/KiwixDatabase.java | 12 +++++++++- .../kiwix/kiwixmobile/utils/Constants.java | 6 +++++ .../kiwix/kiwixmobile/utils/UpdateUtils.java | 10 ++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/org/kiwix/kiwixmobile/utils/UpdateUtils.java diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index 97b277387..d0e2a0de7 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -146,6 +146,7 @@ import static org.kiwix.kiwixmobile.utils.Constants.TAG_CURRENT_TAB; import static org.kiwix.kiwixmobile.utils.Constants.TAG_FILE_SEARCHED; import static org.kiwix.kiwixmobile.utils.Constants.TAG_KIWIX; import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; +import static org.kiwix.kiwixmobile.utils.UpdateUtils.reformatProviderUrl; public class KiwixMobileActivity extends BaseActivity implements WebViewCallback { @@ -1726,11 +1727,11 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback JSONArray urls = new JSONArray(zimArticles); JSONArray positions = new JSONArray(zimPositions); int i = 0; - getCurrentWebView().loadUrl(urls.getString(i)); + getCurrentWebView().loadUrl(reformatProviderUrl(urls.getString(i))); getCurrentWebView().setScrollY(positions.getInt(i)); i++; for (; i < urls.length(); i++) { - newTab(urls.getString(i)); + newTab(reformatProviderUrl(urls.getString(i))); getCurrentWebView().setScrollY(positions.getInt(i)); } selectTab(currentTab); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java b/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java index a9bc46af8..bcf92009a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/BookmarksDao.java @@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.database; import com.yahoo.squidb.data.SquidCursor; import com.yahoo.squidb.sql.Query; +import com.yahoo.squidb.sql.Update; import org.kiwix.kiwixmobile.database.entity.Bookmarks; @@ -96,4 +97,26 @@ public class BookmarksDao { mDb.deleteWhere(Bookmarks.class, Bookmarks.BOOKMARK_URL.eq(favArticle).and(Bookmarks.ZIM_ID.eq(ZimId).or(Bookmarks.ZIM_NAME.eq(ZimName))) ); } + public void processBookmark(StringOperation operation) { + SquidCursor bookmarkCursor = mDb.query( + Bookmarks.class, + Query.select(Bookmarks.ID, Bookmarks.BOOKMARK_URL)); + try { + while (bookmarkCursor.moveToNext()) { + String url = bookmarkCursor.get(Bookmarks.BOOKMARK_URL); + url = operation.apply(url); + if (url != null) { + mDb.update(Update.table(Bookmarks.TABLE) + .where(Bookmarks.ID.eq(bookmarkCursor.get(Bookmarks.ID))) + .set(Bookmarks.BOOKMARK_URL, url)); + } + } + } finally { + bookmarkCursor.close(); + } + } + + public interface StringOperation { + String apply(String string); + } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/KiwixDatabase.java b/app/src/main/java/org/kiwix/kiwixmobile/database/KiwixDatabase.java index 55bd19c7c..e8be001e8 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/KiwixDatabase.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/KiwixDatabase.java @@ -32,6 +32,7 @@ import org.kiwix.kiwixmobile.database.entity.Bookmarks; import org.kiwix.kiwixmobile.database.entity.LibraryDatabaseEntity; import org.kiwix.kiwixmobile.database.entity.NetworkLanguageDatabaseEntity; import org.kiwix.kiwixmobile.database.entity.RecentSearch; +import org.kiwix.kiwixmobile.utils.UpdateUtils; import java.io.BufferedReader; import java.io.FileNotFoundException; @@ -47,7 +48,7 @@ import static org.kiwix.kiwixmobile.utils.Constants.TAG_KIWIX; @Singleton public class KiwixDatabase extends SquidDatabase { - private static final int VERSION = 14; + private static final int VERSION = 15; private Context context; @Inject @@ -129,6 +130,9 @@ public class KiwixDatabase extends SquidDatabase { tryDropTable(BookDatabaseEntity.TABLE); tryCreateTable(BookDatabaseEntity.TABLE); } + if (newVersion >= 15 && oldVersion < 15) { + reformatBookmarks(); + } return true; } @@ -165,6 +169,12 @@ public class KiwixDatabase extends SquidDatabase { } } } + + // Reformat bookmark urls to use correct provider + private void reformatBookmarks() { + BookmarksDao bookmarksDao = new BookmarksDao(this); + bookmarksDao.processBookmark(UpdateUtils::reformatProviderUrl); + } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java index 169fbda14..66e959537 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/Constants.java @@ -17,6 +17,8 @@ */ package org.kiwix.kiwixmobile.utils; +import org.kiwix.kiwixmobile.BuildConfig; + public final class Constants { public static final String TAG_KIWIX = "kiwix"; @@ -127,4 +129,8 @@ public final class Constants { // Notification Channel Constants public static final String ONGOING_DOWNLOAD_CHANNEL_ID = "ongoing_downloads_channel_id"; + public static final String OLD_PROVIDER_DOMAIN = "org.kiwix.zim.base"; + + public static final String NEW_PROVIDER_DOMAIN = BuildConfig.APPLICATION_ID + ".zim.base"; + } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/UpdateUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/UpdateUtils.java new file mode 100644 index 000000000..1201d96eb --- /dev/null +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/UpdateUtils.java @@ -0,0 +1,10 @@ +package org.kiwix.kiwixmobile.utils; + +import static org.kiwix.kiwixmobile.utils.Constants.NEW_PROVIDER_DOMAIN; +import static org.kiwix.kiwixmobile.utils.Constants.OLD_PROVIDER_DOMAIN; + +public class UpdateUtils { + public static String reformatProviderUrl(String url) { + return url.replace(OLD_PROVIDER_DOMAIN, NEW_PROVIDER_DOMAIN); + } +} From 60c159ad916f98a2adcc9cee41282b8a5bc61d4a Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 31 May 2018 00:15:24 +0100 Subject: [PATCH 07/53] Fix opening ZIM files from file system searching --- .../main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index d0e2a0de7..a2e45bde8 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -1280,7 +1280,8 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback } else if (intent.getAction().equals(KiwixSearchWidget.MIC_CLICKED)) { intent.setAction(""); goToSearch(true); - } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { + } else if (intent.getAction().equals(Intent.ACTION_VIEW) + && (intent.getType() == null || !intent.getType().equals("application/octet-stream"))) { final String zimFile = ZimContentProvider.getZimFile(); saveTabStates(); Intent i = new Intent(KiwixMobileActivity.this, SearchActivity.class); From 0346422cc70fdd5e1bd5d1f5acab0746f15f7678 Mon Sep 17 00:00:00 2001 From: Joe Reeve Date: Mon, 4 Jun 2018 19:22:23 +0100 Subject: [PATCH 08/53] Modified help page drawer behaviour (#719) * Fixed drawer tests in other languages * Restructured getResourceString --- app/src/main/assets/help.html | 12 +++++++++--- .../kiwix/kiwixmobile/KiwixMobileActivity.java | 14 ++++++++++++-- .../org/kiwix/kiwixmobile/TabDrawerAdapter.java | 12 ++++++++++-- .../kiwix/kiwixmobile/utils/LanguageUtils.java | 17 +++++++++++++++++ 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/app/src/main/assets/help.html b/app/src/main/assets/help.html index dd5d406b3..f79b4dede 100644 --- a/app/src/main/assets/help.html +++ b/app/src/main/assets/help.html @@ -1,7 +1,13 @@ + - - Help + + REPLACE_menu_help - + + +

REPLACE_menu_help

+ + + \ No newline at end of file diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index a2e45bde8..fa6c397d5 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -145,6 +145,7 @@ import static org.kiwix.kiwixmobile.utils.Constants.TAG_CURRENT_POSITIONS; import static org.kiwix.kiwixmobile.utils.Constants.TAG_CURRENT_TAB; import static org.kiwix.kiwixmobile.utils.Constants.TAG_FILE_SEARCHED; import static org.kiwix.kiwixmobile.utils.Constants.TAG_KIWIX; +import static org.kiwix.kiwixmobile.utils.LanguageUtils.getResourceString; import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; import static org.kiwix.kiwixmobile.utils.UpdateUtils.reformatProviderUrl; @@ -394,7 +395,7 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback }); documentSections = new ArrayList<>(); - tabDrawerAdapter = new TabDrawerAdapter(mWebViews); + tabDrawerAdapter = new TabDrawerAdapter(mWebViews, getApplicationContext()); tabDrawerLeft.setLayoutManager(new LinearLayoutManager(this)); tabDrawerLeft.setAdapter(tabDrawerAdapter); tableDrawerRight.setLayoutManager(new LinearLayoutManager(this)); @@ -447,8 +448,17 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback documentParser = new DocumentParser(new DocumentParser.SectionsListener() { @Override public void sectionsLoaded(String title, List sections) { + for (DocumentSection section : sections) { + if(section.title.contains("REPLACE_")) { + section.title = getResourceString(getApplicationContext(), section.title); + } + } documentSections.addAll(sections); - tableDrawerAdapter.setTitle(title); + if(title.contains("REPLACE_")) { + tableDrawerAdapter.setTitle(getResourceString(getApplicationContext(), title)); + } else { + tableDrawerAdapter.setTitle(title); + } tableDrawerAdapter.setSections(documentSections); tableDrawerAdapter.notifyDataSetChanged(); } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java index 546357c03..439558318 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java @@ -17,6 +17,7 @@ */ package org.kiwix.kiwixmobile; +import android.content.Context; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; @@ -34,15 +35,18 @@ import butterknife.ButterKnife; import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.N; +import static org.kiwix.kiwixmobile.utils.LanguageUtils.getResourceString; public class TabDrawerAdapter extends RecyclerView.Adapter { private TabClickListener listener; private List webViews; + private Context appContext; private int selectedPosition = 0; - public TabDrawerAdapter(List webViews) { + public TabDrawerAdapter(List webViews, Context appContext) { this.webViews = webViews; + this.appContext = appContext; } @Override @@ -54,7 +58,11 @@ public class TabDrawerAdapter extends RecyclerView.Adapter listener.onCloseTab(v, position)); holder.itemView.setOnClickListener(v -> { listener.onSelectTab(v, position); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java index 85b2f4cf3..f603402fb 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/LanguageUtils.java @@ -341,4 +341,21 @@ public class LanguageUtils { return mLanguageName; } } + + + + public static String getResourceString(Context appContext, String str){ + String resourceName = str; + if(resourceName.contains("REPLACE_")) { + resourceName = resourceName.replace("REPLACE_", ""); + } + int resourceId = appContext.getResources() + .getIdentifier( + resourceName, + "string", + appContext.getPackageName() + ); + String resourceString = appContext.getResources().getString(resourceId); + return resourceString != null ? resourceString : str; + } } From 0549624c44045e0251ad1293e1985b67cccfb643 Mon Sep 17 00:00:00 2001 From: Sakchham Sharma Date: Tue, 5 Jun 2018 17:39:32 +0530 Subject: [PATCH 09/53] changed chunk download logic. --- .../kiwixmobile/downloader/ChunkUtils.java | 2 +- .../downloader/DownloadService.java | 44 ++++++++++++++++--- .../kiwixmobile/utils/files/FileUtils.java | 13 ++++-- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java index 2731e2897..802b0be5a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java @@ -26,7 +26,7 @@ public class ChunkUtils { public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz"; public static final String ZIM_EXTENSION = ".zim"; - public static final String PART = ".part"; + public static final String PART = ".part.part"; public static final long CHUNK_SIZE = 1024L * 1024L * 1024L * 2L; public static List getChunks(String url, long contentLength, int notificationID) { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java index 35d1e425d..59464f199 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java @@ -68,6 +68,9 @@ import okhttp3.Request; import okhttp3.Response; import okio.BufferedSource; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.ALPHABET; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.PART; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.ZIM_EXTENSION; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_BOOK; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_LIBRARY; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_NOTIFICATION_ID; @@ -310,6 +313,35 @@ public class DownloadService extends Service { notification.get(notificationID).setContentText(getString(R.string.zim_file_downloaded)); final Intent target = new Intent(this, KiwixMobileActivity.class); target.putExtra(EXTRA_ZIM_FILE, KIWIX_ROOT + StorageUtils.getFileNameFromUrl(book.getUrl())); + //Remove the extra ".part" from files + String filename = book.file.getPath(); + if(filename.endsWith(ZIM_EXTENSION)) { + filename = filename + PART; + File partFile = new File(filename); + if(partFile.exists()) { + partFile.renameTo(new File(partFile.getPath().replaceAll(".part", ""))); + } + } else { + for (int i = 0; true; i++) { + char first = ALPHABET.charAt(i / 26); + char second = ALPHABET.charAt(i % 26); + String chunkExtension = String.valueOf(first) + second; + filename = book.file.getPath(); + filename = filename.replaceAll(".zim([a-z][a-z]){0,1}$", ".zim"); + filename = filename + chunkExtension + ".part"; + File partFile = new File(filename); + if(partFile.exists()) { + partFile.renameTo(new File(partFile.getPath().replaceAll(".part$", ""))); + } else { + File lastChunkFile = new File(filename + ".part"); + if(lastChunkFile.exists()) { + lastChunkFile.renameTo(new File(partFile.getPath().replaceAll(".part", ""))); + } else { + break; + } + } + } + } target.putExtra(EXTRA_NOTIFICATION_ID, notificationID); PendingIntent pendingIntent = PendingIntent.getActivity (getBaseContext(), 0, @@ -414,7 +446,7 @@ public class DownloadService extends Service { // Create chunk file File file = new File(KIWIX_ROOT, chunk.getFileName()); file.getParentFile().mkdirs(); - File fullFile = new File(file.getPath().substring(0, file.getPath().length() - 5)); + File fullFile = new File(file.getPath().substring(0, file.getPath().length() - PART.length())); long downloaded = Long.parseLong(chunk.getRangeHeader().split("-")[0]); if (fullFile.exists() && fullFile.length() == chunk.getSize()) { @@ -539,16 +571,16 @@ public class DownloadService extends Service { if (downloadStatus.get(chunk.getNotificationID()) == CANCEL) { String path = file.getPath(); Log.i(KIWIX_TAG, "Download Cancelled, deleting file: " + path); - if (path.substring(path.length() - 8).equals("zim.part")) { - path = path.substring(0, path.length() - 5); + if (path.substring(path.length() - (ZIM_EXTENSION + PART).length()).equals(ZIM_EXTENSION + PART)) { + path = path.substring(0, path.length() - PART.length() + 1); FileUtils.deleteZimFile(path); } else { - path = path.substring(0, path.length() - 7) + "aa"; + path = path.substring(0, path.length() - (ZIM_EXTENSION + PART).length() + 2) + "aa"; FileUtils.deleteZimFile(path); } } else { - Log.i(KIWIX_TAG, "Download completed, renaming file ([" + file.getPath() + "] -> .zim)"); - file.renameTo(new File(file.getPath().replace(".part", ""))); + Log.i(KIWIX_TAG, "Download completed, renaming file ([" + file.getPath() + "] -> .zim.part)"); + file.renameTo(new File(file.getPath().replaceAll(".part$", ""))); } // Mark chunk status as downloaded chunk.isDownloaded = true; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java index 69e07aafe..3538f761a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java @@ -27,6 +27,7 @@ import android.provider.DocumentsContract; import android.util.Log; import org.kiwix.kiwixmobile.BuildConfig; +import org.kiwix.kiwixmobile.downloader.ChunkUtils; import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.Book; import java.io.File; @@ -61,8 +62,8 @@ public class FileUtils { } public static synchronized void deleteZimFile(String path) { - if (path.substring(path.length() - 5).equals(".part")) { - path = path.substring(0, path.length() - 5); + if (path.substring(path.length() - ChunkUtils.PART.length()).equals(ChunkUtils.PART)) { + path = path.substring(0, path.length() - ChunkUtils.PART.length()); } Log.i("kiwix", "Deleting file: " + path); File file = new File(path); @@ -86,10 +87,16 @@ public class FileUtils { } private static synchronized boolean deleteZimFileParts(String path) { - File file = new File(path + ".part"); + File file = new File(path + ChunkUtils.PART); if (file.exists()) { file.delete(); return true; + } else { + File singlePart = new File(path + ".part"); + if (singlePart.exists()) { + singlePart.delete(); + return true; + } } return false; } From 2759a0be7bc6ef60c7801fa7cc20a70060f00e77 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 20 Jun 2018 19:45:55 +0100 Subject: [PATCH 10/53] Remove crash activity from debug builds --- app/build.gradle | 2 ++ .../kiwixmobile/utils/SplashActivity.java | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b704756bd..168da4fac 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -199,6 +199,7 @@ android { // Main build type for debugging debug { buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://download.kiwix.org/\"" + buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false" // True breaks local variables being shown in breakpoints testCoverageEnabled false // Needed for instrumentation tests on Pre 5.0 @@ -227,6 +228,7 @@ android { // Release Type release { buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://download.kiwix.org/\"" + buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "true" } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java index cd1c259c5..53cfc7b1e 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/SplashActivity.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import org.kiwix.kiwixmobile.BuildConfig; import org.kiwix.kiwixmobile.KiwixErrorActivity; import org.kiwix.kiwixmobile.KiwixMobileActivity; @@ -35,21 +36,23 @@ public class SplashActivity extends AppCompatActivity { super.onCreate(savedInstanceState); Context appContext = getApplicationContext(); - Thread.setDefaultUncaughtExceptionHandler((paramThread, paramThrowable) -> { + if (BuildConfig.KIWIX_ERROR_ACTIVITY) { + Thread.setDefaultUncaughtExceptionHandler((paramThread, paramThrowable) -> { - final Intent intent = new Intent(appContext, KiwixErrorActivity.class); + final Intent intent = new Intent(appContext, KiwixErrorActivity.class); - Bundle extras = new Bundle(); - extras.putSerializable("exception", paramThrowable); + Bundle extras = new Bundle(); + extras.putSerializable("exception", paramThrowable); - intent.putExtras(extras); + intent.putExtras(extras); - appContext.startActivity(intent); + appContext.startActivity(intent); - finish(); - android.os.Process.killProcess(android.os.Process.myPid()); - System.exit(10); - }); + finish(); + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(10); + }); + } Intent intent = new Intent(this, KiwixMobileActivity.class); startActivity(intent); From 064de2338c1b891e565433cdf132e8afb02a169f Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Wed, 20 Jun 2018 20:54:22 +0100 Subject: [PATCH 11/53] Fix search for titles with special characters --- .../kiwixmobile/search/SearchActivity.java | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java index ef55aa235..bdfe144ba 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/search/SearchActivity.java @@ -29,7 +29,6 @@ import android.support.v7.app.AlertDialog; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.text.Html; -import android.text.Spanned; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -65,9 +64,10 @@ public class SearchActivity extends BaseActivity public static final String EXTRA_SEARCH_IN_TEXT = "bool_searchintext"; private final int REQ_CODE_SPEECH_INPUT = 100; - private ListView mListView; - private AutoCompleteAdapter mAutoAdapter; - private ArrayAdapter mDefaultAdapter; + private ListView listView; + private ArrayAdapter currentAdapter; + private AutoCompleteAdapter autoAdapter; + private ArrayAdapter defaultAdapter; private SearchView searchView; private String searchText; @@ -92,14 +92,14 @@ public class SearchActivity extends BaseActivity getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_action_back); getSupportActionBar().setHomeButtonEnabled(true); searchPresenter.attachView(this); - mListView = findViewById(R.id.search_list); - mDefaultAdapter = getDefaultAdapter(); + listView = findViewById(R.id.search_list); + defaultAdapter = getDefaultAdapter(); searchPresenter.getRecentSearches(); - mListView.setAdapter(mDefaultAdapter); + activateDefaultAdapter(); - mAutoAdapter = new AutoCompleteAdapter(this); - mListView.setOnItemClickListener(this); - mListView.setOnItemLongClickListener(this); + autoAdapter = new AutoCompleteAdapter(this); + listView.setOnItemClickListener(this); + listView.setOnItemLongClickListener(this); boolean IS_VOICE_SEARCH_INTENT = getIntent().getBooleanExtra(EXTRA_IS_WIDGET_VOICE, false); if (IS_VOICE_SEARCH_INTENT) { @@ -107,10 +107,20 @@ public class SearchActivity extends BaseActivity } } + public void activateDefaultAdapter() { + currentAdapter = defaultAdapter; + listView.setAdapter(currentAdapter); + } + + public void activateAutoAdapter() { + currentAdapter = autoAdapter; + listView.setAdapter(currentAdapter); + } + @Override public void addRecentSearches(List recentSearches) { - mDefaultAdapter.addAll(recentSearches); - mDefaultAdapter.notifyDataSetChanged(); + defaultAdapter.addAll(recentSearches); + defaultAdapter.notifyDataSetChanged(); } @Override @@ -135,8 +145,8 @@ public class SearchActivity extends BaseActivity searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); if (searchText != null) { searchView.setQuery(searchText, false); - mListView.setAdapter(mAutoAdapter); - mAutoAdapter.getFilter().filter(searchText.toLowerCase()); + activateAutoAdapter(); + autoAdapter.getFilter().filter(searchText.toLowerCase()); } searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override @@ -147,10 +157,10 @@ public class SearchActivity extends BaseActivity @Override public boolean onQueryTextChange(String s) { if (s.equals("")) { - mListView.setAdapter(mDefaultAdapter); + activateDefaultAdapter(); } else { - mListView.setAdapter(mAutoAdapter); - mAutoAdapter.getFilter().filter(s.toLowerCase()); + activateAutoAdapter(); + autoAdapter.getFilter().filter(s.toLowerCase()); } return true; @@ -205,15 +215,7 @@ public class SearchActivity extends BaseActivity @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - CharSequence text = ((TextView) view).getText(); - String title; - if (text instanceof Spanned) { - title = Html.toHtml((Spanned) text); - // To remove the "ltr style information" from spanned text - title = title.substring(title.indexOf(">") + 1, title.lastIndexOf("<")); - } else { - title = text.toString(); - } + String title = currentAdapter.getItem(position); searchPresenter.saveSearch(title); sendMessage(title); } @@ -249,8 +251,8 @@ public class SearchActivity extends BaseActivity @Override public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { - if (parent.getAdapter() == mDefaultAdapter) { - String searched = mListView.getItemAtPosition(position).toString(); + if (parent.getAdapter() == defaultAdapter) { + String searched = listView.getItemAtPosition(position).toString(); deleteSpecificSearchDialog(searched); } return true; @@ -275,8 +277,8 @@ public class SearchActivity extends BaseActivity } private void resetAdapter() { - mDefaultAdapter = getDefaultAdapter(); - mListView.setAdapter(mDefaultAdapter); + defaultAdapter = getDefaultAdapter(); + activateDefaultAdapter(); searchPresenter.getRecentSearches(); } From a1038a5b91d35ce768f246ba0896f8e719ea999c Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Mon, 25 Jun 2018 19:43:03 +0100 Subject: [PATCH 12/53] Request write permission instead of read --- .../zim_manager/fileselect_view/ZimFileSelectFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java index 86dd56e7f..b025e6d9c 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java @@ -168,11 +168,11 @@ public class ZimFileSelectFragment extends BaseFragment public void checkPermissions(){ if (ContextCompat.checkSelfPermission(super.getActivity(), - Manifest.permission.READ_EXTERNAL_STORAGE) + Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && Build.VERSION.SDK_INT > 18) { Toast.makeText(super.getActivity(), getResources().getString(R.string.request_storage), Toast.LENGTH_LONG) .show(); - requestPermissions( new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + requestPermissions( new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_STORAGE_PERMISSION); } else { getFiles(); From a8858292a472d5f9b6575e9aa3a813d1e9b145c6 Mon Sep 17 00:00:00 2001 From: Qin Yin Date: Fri, 29 Jun 2018 12:17:45 +0200 Subject: [PATCH 13/53] Add setupTableDrawerAdapter() function to simply KiwixMobileActivity.onCreate(). BUG: #565 --- .../kiwixmobile/KiwixMobileActivity.java | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index fa6c397d5..5883466f5 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -400,24 +400,8 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback tabDrawerLeft.setAdapter(tabDrawerAdapter); tableDrawerRight.setLayoutManager(new LinearLayoutManager(this)); - TableDrawerAdapter tableDrawerAdapter = new TableDrawerAdapter(); + TableDrawerAdapter tableDrawerAdapter = setupTableDrawerAdapter(); tableDrawerRight.setAdapter(tableDrawerAdapter); - tableDrawerAdapter.setTableClickListener(new TableClickListener() { - @Override public void onHeaderClick(View view) { - getCurrentWebView().setScrollY(0); - drawerLayout.closeDrawer(GravityCompat.END); - } - - @Override public void onSectionClick(View view, int position) { - getCurrentWebView().loadUrl("javascript:document.getElementById('" - + documentSections.get(position).id - + "').scrollIntoView();"); - - drawerLayout.closeDrawers(); - } - }); - - tableDrawerAdapter.notifyDataSetChanged(); tabDrawerAdapter.setTabClickListener(new TabDrawerAdapter.TabClickListener() { @Override public void onSelectTab(View view, int position) { @@ -522,6 +506,29 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback } } + private TableDrawerAdapter setupTableDrawerAdapter() { + TableDrawerAdapter tableDrawerAdapter = new TableDrawerAdapter(); + + tableDrawerAdapter.setTableClickListener(new TableClickListener() { + @Override public void onHeaderClick(View view) { + getCurrentWebView().setScrollY(0); + drawerLayout.closeDrawer(GravityCompat.END); + } + + @Override public void onSectionClick(View view, int position) { + getCurrentWebView().loadUrl("javascript:document.getElementById('" + + documentSections.get(position).id + + "').scrollIntoView();"); + + drawerLayout.closeDrawers(); + } + }); + + tableDrawerAdapter.notifyDataSetChanged(); + + return tableDrawerAdapter; + } + private void backToTopAppearDaily() { backToTopButton.setAlpha(0.6f); backToTopButton.setBackgroundColor(getResources().getColor(R.color.back_to_top_background)); From 0d4af4e918abb15d55c7ffbc61281292385264e1 Mon Sep 17 00:00:00 2001 From: Qin Yin Date: Fri, 29 Jun 2018 13:56:25 +0200 Subject: [PATCH 14/53] Add setupTableDrawerAdapter() to simplify KiwixMobileActivity onCreate. --- .../main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index 5883466f5..af8e9c7f2 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -402,6 +402,7 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback TableDrawerAdapter tableDrawerAdapter = setupTableDrawerAdapter(); tableDrawerRight.setAdapter(tableDrawerAdapter); + tableDrawerAdapter.notifyDataSetChanged(); tabDrawerAdapter.setTabClickListener(new TabDrawerAdapter.TabClickListener() { @Override public void onSelectTab(View view, int position) { @@ -524,8 +525,6 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback } }); - tableDrawerAdapter.notifyDataSetChanged(); - return tableDrawerAdapter; } From 873218352f083c9d5dd2eff2f8cb597b52c33dbc Mon Sep 17 00:00:00 2001 From: qinyin Date: Sun, 1 Jul 2018 20:44:02 +0200 Subject: [PATCH 15/53] Pause download service if no network (#783) * Add setupTableDrawerAdapter() function to simply KiwixMobileActivity.onCreate(). BUG: #565 * Pause DownloadService if network is not available * Revert changes to KiwixMobileActivity.java * Negation on the network availability condition. --- .../org/kiwix/kiwixmobile/downloader/DownloadService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java index 59464f199..eb7bb2565 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java @@ -137,8 +137,7 @@ public class DownloadService extends Service { if (intent == null) { return START_NOT_STICKY; } - String log = intent.getAction(); - log += " : "; + String log = intent.getAction() + " : "; if (intent.hasExtra(NOTIFICATION_ID)) { log += intent.getIntExtra(NOTIFICATION_ID, -3); } @@ -202,7 +201,7 @@ public class DownloadService extends Service { .addAction(pause) .addAction(stop) .setOngoing(true)); - + notificationManager.notify(notificationID, notification.get(notificationID).build()); downloadStatus.put(notificationID, PLAY); LibraryFragment.downloadingBooks.remove(book); @@ -512,7 +511,8 @@ public class DownloadService extends Service { break; } - if (KiwixMobileActivity.wifiOnly && !NetworkUtils.isWiFi(getApplicationContext())) { + if (KiwixMobileActivity.wifiOnly && !NetworkUtils.isWiFi(getApplicationContext()) || + !NetworkUtils.isNetworkAvailable(getApplicationContext())) { pauseDownload(chunk.getNotificationID()); } From 5db00e6dde2a86ed18564804d4ed74f5067edf64 Mon Sep 17 00:00:00 2001 From: Abdul Wadood Date: Sat, 30 Jun 2018 23:22:03 +0530 Subject: [PATCH 16/53] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 35 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 23 +++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..ab387b716 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + + + +**Describe the bug** + + +**Expected behavior** + + +**Steps to reproduce the behavior:** +1. + + +**Screenshots** + + +**Environment** +- Version of Kiwix Android : +- Device : +- OS version : + +**Logs** + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..7ab2f9dbb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + + +**Is your feature request related to a problem? Please describe.** + + +**Describe the solution you'd like** + + +**Describe alternatives you've considered** + + +**Additional context** + From d808ade453fb411546ed1820b41e95a826437cdc Mon Sep 17 00:00:00 2001 From: Abdul Wadood Date: Sat, 30 Jun 2018 23:41:47 +0530 Subject: [PATCH 17/53] Delete ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 45 --------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 2d5b808bc..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,45 +0,0 @@ -# Fill out this template with your issue then delete these lines only leaving the titles and your responses. - -# For a Bug Report: - -## Bug Report - -### Are you ready to report? - - Your issue may already be reported! Please search on the [issue track](../) before creating one. - - Ensure you have tested with the last (dev) version of the software. (If not, and if possible, run your test again with the most recent version available.) - -### Environment - * version of the software you use : _____ - * device / operating system : _____ - -### The Bug: - - * What do you obtain? A copy of the error message or a screenshot is always useful. - - * When does this occur? - -#### Steps to reproduce: - - 1. _____ - 2. _____ - 3. _____ - ... - - * What should be the behaviour from your point of view? How do you expect the service to work? - - -### Other Comments: - * What is the context of this ticket? If not obvious, explain why you need to do this. - - * If you have an idea about the technical background of the ticket, please share it. - - -# For a Feature Request: - -## Feature Request - -#### Feature Description - -Please describe the feature you want to add to the project. - - From 1499919247ef9786a8b61721309fe846f8d4905d Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Sun, 8 Jul 2018 12:36:48 +0100 Subject: [PATCH 18/53] Fix crash when attempting to bookmark help --- .../org/kiwix/kiwixmobile/KiwixMobileActivity.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index af8e9c7f2..4c41def69 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -191,6 +191,8 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback private ArrayList bookmarks; + private boolean bookmarkTabEnabled; + private List mWebViews = new ArrayList<>(); private KiwixTextToSpeech tts; @@ -340,7 +342,9 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback @Override public void onBookmarkTabSelected() { - toggleBookmark(); + if (bookmarkTabEnabled) { + toggleBookmark(); + } } @Override @@ -1627,13 +1631,15 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback .getIcon().setAlpha(255); bookmarkTab.getCustomView().findViewById(R.id.bookmark_tab_icon).setBackgroundResource(icon); + bookmarkTabEnabled = true; } else { menu.findItem(R.id.menu_bookmarks) - .setEnabled(false) - .setIcon(R.drawable.action_bookmark) - .getIcon().setAlpha(130); + .setEnabled(false) + .setIcon(R.drawable.action_bookmark) + .getIcon().setAlpha(130); bookmarkTab.getCustomView().findViewById(R.id.bookmark_tab_icon).setBackgroundResource(R.drawable.action_bookmark); + bookmarkTabEnabled = false; } } From 3295bed1db8f35779bddd1f633d2d8139da24df3 Mon Sep 17 00:00:00 2001 From: gevic Date: Fri, 16 Mar 2018 11:45:13 +0530 Subject: [PATCH 19/53] Styles storage night mode --- app/src/main/res/values/styles.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f035e57fa..676751ae5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -78,10 +78,12 @@ + From d16217e2db1d0a2a79543d5b0916a462c35975b2 Mon Sep 17 00:00:00 2001 From: gevic Date: Sat, 17 Mar 2018 12:40:34 +0530 Subject: [PATCH 20/53] LanguageDialog perfectly styled --- app/src/main/res/values/styles.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 676751ae5..ec235f576 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -43,6 +43,7 @@ @color/primary_light @color/primary_light @color/primary_light + @style/AppTheme.Dialog.Night @color/accent @@ -80,6 +81,7 @@ @color/white @style/NegativeButtonStyle @style/PositiveButtonStyle + @color/white @color/cardview_dark_background @color/primary_light From f7fe922fd498eb837e7a36569d7481fe68d38c94 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Tue, 10 Jul 2018 23:52:48 +0100 Subject: [PATCH 21/53] Improve download stablity and rename partial download fragments --- .../kiwixmobile/KiwixMobileActivity.java | 3 +- .../kiwix/kiwixmobile/database/BookDao.java | 8 +- .../kiwixmobile/downloader/ChunkUtils.java | 81 +++++++++- .../downloader/DownloadFragment.java | 3 +- .../downloader/DownloadService.java | 149 ++++++++---------- .../kiwixmobile/utils/files/FileUtils.java | 111 +------------ .../ZimFileSelectFragment.java | 2 +- 7 files changed, 156 insertions(+), 201 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java index 4c41def69..a542609dc 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -116,6 +116,7 @@ import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES; import static org.kiwix.kiwixmobile.TableDrawerAdapter.DocumentSection; import static org.kiwix.kiwixmobile.TableDrawerAdapter.TableClickListener; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.getFileName; import static org.kiwix.kiwixmobile.search.SearchActivity.EXTRA_SEARCH_IN_TEXT; import static org.kiwix.kiwixmobile.utils.Constants.BOOKMARK_CHOSEN_REQUEST; import static org.kiwix.kiwixmobile.utils.Constants.CONTACT_EMAIL_ADDRESS; @@ -480,7 +481,7 @@ public class KiwixMobileActivity extends BaseActivity implements WebViewCallback getCurrentWebView().loadUrl(i.getStringExtra(EXTRA_CHOSE_X_TITLE)); } if (i.hasExtra(EXTRA_ZIM_FILE)) { - File file = new File(FileUtils.getFileName(i.getStringExtra(EXTRA_ZIM_FILE))); + File file = new File(getFileName(i.getStringExtra(EXTRA_ZIM_FILE))); LibraryFragment.mService.cancelNotification(i.getIntExtra(EXTRA_NOTIFICATION_ID, 0)); Uri uri = Uri.fromFile(file); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java b/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java index 00a915ab2..82b973dd0 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/database/BookDao.java @@ -30,6 +30,8 @@ import java.util.ArrayList; import javax.inject.Inject; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.hasParts; + /** * Dao class for books */ @@ -86,11 +88,11 @@ public class BookDao { while (bookCursor.moveToNext()) { Book book = new Book(); setBookDetails(book, bookCursor); - if (!FileUtils.hasPart(book.file)) { + if (!hasParts(book.file)) { if (book.file.exists()) { books.add(book); } else { - mDb.deleteWhere(BookDatabaseEntity.class, BookDatabaseEntity.URL.eq(book.file.getPath())); + mDb.deleteWhere(BookDatabaseEntity.class, BookDatabaseEntity.URL.eq(book.file)); } } } @@ -107,7 +109,7 @@ public class BookDao { Book book = new Book(); setBookDetails(book, bookCursor); book.remoteUrl = bookCursor.get(BookDatabaseEntity.REMOTE_URL); - if (FileUtils.hasPart(book.file)) { + if (hasParts(book.file)) { books.add(book); } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java index 802b0be5a..dfac9317e 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java @@ -17,8 +17,11 @@ */ package org.kiwix.kiwixmobile.downloader; +import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity; import org.kiwix.kiwixmobile.utils.StorageUtils; +import java.io.File; +import java.io.FilenameFilter; import java.util.ArrayList; import java.util.List; @@ -26,9 +29,81 @@ public class ChunkUtils { public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz"; public static final String ZIM_EXTENSION = ".zim"; - public static final String PART = ".part.part"; + // Chuck Part + private static final String CPART = ".cpart"; + // Total Part + private static final String TPART = ".tpart"; public static final long CHUNK_SIZE = 1024L * 1024L * 1024L * 2L; + public static String baseNameFromParts(File file) { + return file.getName().replace(CPART, "").replace(TPART, "") + .replaceAll("\\.zim..", ".zim"); + } + + public static File completedChunk(String name) { + return new File(name + TPART); + } + + public static boolean isPresent(String name) { + return new File(name).exists() || new File(name + TPART).exists() + || new File(name + CPART + TPART).exists(); + } + + public static boolean hasParts(File file) { + return file.getParentFile().listFiles((file1, s) -> + s.startsWith(baseNameFromParts(file)) && s.endsWith(TPART)).length > 0; + } + + public static String getFileName(String fileName) { + if (isPresent(fileName)) { + return fileName; + } else { + return fileName + "aa"; + } + } + + public static File initialChunk(String name) { + return new File(name + CPART + TPART); + } + + public static void completeChunk(File chunk) { + chunk.renameTo(new File(chunk.getPath().replace(CPART, ""))); + } + + public static void completeDownload(File file) { + final String baseName = baseNameFromParts(file); + File directory =file.getParentFile(); + File[] parts = directory.listFiles((file1, s) -> s.startsWith(baseName) && s.endsWith(TPART)); + for (File part : parts) { + part.renameTo(new File(part.getPath().replace(TPART, ""))); + } + } + + public static long getCurrentSize(LibraryNetworkEntity.Book book) { + long size = 0; + File[] files = getAllZimParts(book.file); + for (File file : files) { + size += file.length(); + } + return size; + } + + private static File[] getAllZimParts(File file) { + final String baseName = baseNameFromParts(file); + File directory = new File(file.getPath()).getParentFile(); + File[] parts = directory.listFiles((file1, s) -> s.matches(baseName + ".*")); + return parts; + } + + public static void deleteAllParts(File file) { + final String baseName = baseNameFromParts(file); + File directory = file.getParentFile(); + File[] parts = directory.listFiles((file1, s) -> s.matches(baseName + ".*")); + for (File part : parts) { + part.delete(); + } + } + public static List getChunks(String url, long contentLength, int notificationID) { int fileCount = getZimChunkFileCount(contentLength); String filename = StorageUtils.getFileNameFromUrl(url); @@ -63,7 +138,7 @@ public class ChunkUtils { private static String[] getZimChunkFileNames(String fileName, int count) { if (count == 1) { - return new String[] { fileName + PART}; + return new String[] { fileName }; } int position = fileName.lastIndexOf("."); String baseName = position > 0 ? fileName.substring(0, position) : fileName; @@ -73,7 +148,7 @@ public class ChunkUtils { char first = ALPHABET.charAt(i / 26); char second = ALPHABET.charAt(i % 26); String chunkExtension = String.valueOf(first) + second; - fileNames[i] = baseName + ZIM_EXTENSION + chunkExtension + PART; + fileNames[i] = baseName + ZIM_EXTENSION + chunkExtension; } return fileNames; } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java index b4d924b29..db3594d1a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadFragment.java @@ -58,6 +58,7 @@ import java.util.Locale; import javax.inject.Inject; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.getFileName; import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; public class DownloadFragment extends BaseFragment { @@ -189,7 +190,7 @@ public class DownloadFragment extends BaseFragment { } ImageView pause = viewGroup.findViewById(R.id.pause); pause.setEnabled(false); - String fileName = FileUtils.getFileName(mDownloadFiles.get(mKeys[position])); + String fileName = getFileName(mDownloadFiles.get(mKeys[position])); { Snackbar completeSnack = Snackbar.make(mainLayout, getResources().getString(R.string.download_complete_snackbar), Snackbar.LENGTH_LONG); completeSnack.setAction(getResources().getString(R.string.open), v -> zimManageActivity.finishResult(fileName)).setActionTextColor(getResources().getColor(R.color.white)).show(); diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java index eb7bb2565..d600fec5d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/DownloadService.java @@ -63,20 +63,26 @@ import javax.inject.Inject; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.functions.Action; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okio.BufferedSource; import static org.kiwix.kiwixmobile.downloader.ChunkUtils.ALPHABET; -import static org.kiwix.kiwixmobile.downloader.ChunkUtils.PART; import static org.kiwix.kiwixmobile.downloader.ChunkUtils.ZIM_EXTENSION; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.completeChunk; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.completeDownload; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.completedChunk; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.deleteAllParts; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.getCurrentSize; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.initialChunk; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.isPresent; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_BOOK; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_LIBRARY; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_NOTIFICATION_ID; import static org.kiwix.kiwixmobile.utils.Constants.EXTRA_ZIM_FILE; import static org.kiwix.kiwixmobile.utils.Constants.ONGOING_DOWNLOAD_CHANNEL_ID; -import static org.kiwix.kiwixmobile.utils.files.FileUtils.getCurrentSize; public class DownloadService extends Service { @@ -291,11 +297,11 @@ public class DownloadService extends Service { KIWIX_ROOT + StorageUtils.getFileNameFromUrl(book.getUrl())); } TestingUtils.bindResource(DownloadService.class); - if (book.file != null && (book.file.exists() || new File(book.file.getPath() + ".part").exists())) { + if (book.file != null && isPresent(book.file.getPath())) { // Calculate initial download progress int initial = (int) (getCurrentSize(book) / (Long.valueOf(book.getSize()) * BOOK_SIZE_OFFSET)); notification.get(notificationID).setProgress(100, initial, false); - updateDownloadFragmentProgress(initial, notificationID); + updateDownloadFragmentProgress(initial, notificationID, book); notificationManager.notify(notificationID, notification.get(notificationID).build()); } kiwixService.getMetaLinks(url) @@ -304,53 +310,29 @@ public class DownloadService extends Service { .flatMap(metaLink -> getMetaLinkContentLength(metaLink.getRelevantUrl().getValue())) .flatMap(pair -> Observable.fromIterable(ChunkUtils.getChunks(pair.first, pair.second, notificationID))) .concatMap(this::downloadChunk) - .distinctUntilChanged().doOnComplete(() -> updateDownloadFragmentComplete(notificationID)) - .subscribe(progress -> { - if (progress == 100) { - notification.get(notificationID).setOngoing(false); - notification.get(notificationID).setContentTitle(notificationTitle + " " + getResources().getString(R.string.zim_file_downloaded)); - notification.get(notificationID).setContentText(getString(R.string.zim_file_downloaded)); - final Intent target = new Intent(this, KiwixMobileActivity.class); - target.putExtra(EXTRA_ZIM_FILE, KIWIX_ROOT + StorageUtils.getFileNameFromUrl(book.getUrl())); - //Remove the extra ".part" from files - String filename = book.file.getPath(); - if(filename.endsWith(ZIM_EXTENSION)) { - filename = filename + PART; - File partFile = new File(filename); - if(partFile.exists()) { - partFile.renameTo(new File(partFile.getPath().replaceAll(".part", ""))); - } - } else { - for (int i = 0; true; i++) { - char first = ALPHABET.charAt(i / 26); - char second = ALPHABET.charAt(i % 26); - String chunkExtension = String.valueOf(first) + second; - filename = book.file.getPath(); - filename = filename.replaceAll(".zim([a-z][a-z]){0,1}$", ".zim"); - filename = filename + chunkExtension + ".part"; - File partFile = new File(filename); - if(partFile.exists()) { - partFile.renameTo(new File(partFile.getPath().replaceAll(".part$", ""))); - } else { - File lastChunkFile = new File(filename + ".part"); - if(lastChunkFile.exists()) { - lastChunkFile.renameTo(new File(partFile.getPath().replaceAll(".part", ""))); - } else { - break; - } - } - } - } - target.putExtra(EXTRA_NOTIFICATION_ID, notificationID); - PendingIntent pendingIntent = PendingIntent.getActivity - (getBaseContext(), 0, - target, PendingIntent.FLAG_CANCEL_CURRENT); - book.downloaded = true; - bookDao.deleteBook(book.id); - notification.get(notificationID).setContentIntent(pendingIntent); - notification.get(notificationID).mActions.clear(); - TestingUtils.unbindResource(DownloadService.class); - } + .distinctUntilChanged().doOnComplete(() -> updateDownloadFragmentComplete(notificationID, book)).doOnComplete(() -> { + notification.get(notificationID).setOngoing(false); + notification.get(notificationID).setContentTitle(notificationTitle + " " + getResources().getString(R.string.zim_file_downloaded)); + notification.get(notificationID).setContentText(getString(R.string.zim_file_downloaded)); + final Intent target = new Intent(this, KiwixMobileActivity.class); + target.putExtra(EXTRA_ZIM_FILE, KIWIX_ROOT + StorageUtils.getFileNameFromUrl(book.getUrl())); + File filec = book.file; + completeDownload(filec); + target.putExtra(EXTRA_NOTIFICATION_ID, notificationID); + PendingIntent pendingIntent = PendingIntent.getActivity + (getBaseContext(), 0, + target, PendingIntent.FLAG_CANCEL_CURRENT); + book.downloaded = true; + bookDao.deleteBook(book.id); + notification.get(notificationID).setContentIntent(pendingIntent); + notification.get(notificationID).mActions.clear(); + TestingUtils.unbindResource(DownloadService.class); + notification.get(notificationID).setProgress(100, 100, false); + notificationManager.notify(notificationID, notification.get(notificationID).build()); + updateForeground(); + updateDownloadFragmentProgress(100, notificationID, book); + stopSelf(); + }).subscribe(progress -> { notification.get(notificationID).setProgress(100, progress, false); if (progress != 100 && timeRemaining.get(notificationID) != -1) notification.get(notificationID).setContentText(DownloadFragment.toHumanReadableTime(timeRemaining.get(notificationID))); @@ -359,30 +341,35 @@ public class DownloadService extends Service { // Tells android to not kill the service updateForeground(); } - updateDownloadFragmentProgress(progress, notificationID); - if (progress == 100) { - stopSelf(); - } + updateDownloadFragmentProgress(progress, notificationID, book); }, Throwable::printStackTrace); } - private void updateDownloadFragmentProgress(int progress, int notificationID) { - if (DownloadFragment.mDownloads != null && DownloadFragment.mDownloads.get(notificationID) != null) { - handler.post(() -> { - if (DownloadFragment.mDownloads.get(notificationID) != null) { - DownloadFragment.downloadAdapter.updateProgress(progress, notificationID); - } - }); + private void updateDownloadFragmentProgress(int progress, int notificationID, LibraryNetworkEntity.Book book) { + if (DownloadFragment.mDownloads != null) { + if (DownloadFragment.mDownloads.get(notificationID) != null) { + handler.post(() -> { + if (DownloadFragment.mDownloads.get(notificationID) != null) { + DownloadFragment.downloadAdapter.updateProgress(progress, notificationID); + } + }); + } else { + DownloadFragment.mDownloads.put(notificationID, book); + } } } - private void updateDownloadFragmentComplete(int notificationID) { - if (DownloadFragment.mDownloads != null && DownloadFragment.mDownloads.get(notificationID) != null) { - handler.post(() -> { - if (DownloadFragment.mDownloads.get(notificationID) != null) { - DownloadFragment.downloadAdapter.complete(notificationID); - } - }); + private void updateDownloadFragmentComplete(int notificationID, LibraryNetworkEntity.Book book) { + if (DownloadFragment.mDownloads != null) { + if (DownloadFragment.mDownloads.get(notificationID) != null) { + handler.post(() -> { + if (DownloadFragment.mDownloads.get(notificationID) != null) { + DownloadFragment.downloadAdapter.complete(notificationID); + } + }); + } else { + DownloadFragment.mDownloads.put(notificationID, book); + } } } @@ -443,9 +430,9 @@ public class DownloadService extends Service { } // Create chunk file - File file = new File(KIWIX_ROOT, chunk.getFileName()); - file.getParentFile().mkdirs(); - File fullFile = new File(file.getPath().substring(0, file.getPath().length() - PART.length())); + File fullFile = new File(KIWIX_ROOT, chunk.getFileName()); + fullFile.getParentFile().mkdirs(); + File file = initialChunk(fullFile.getPath()); long downloaded = Long.parseLong(chunk.getRangeHeader().split("-")[0]); if (fullFile.exists() && fullFile.length() == chunk.getSize()) { @@ -540,7 +527,6 @@ public class DownloadService extends Service { double speed = (downloaded - lastSize) / (timeDiff / 1000.0); lastSize = downloaded; int secondsLeft = (int) ((chunk.getContentLength() - downloaded) / speed); - timeRemaining.put(chunk.getNotificationID(), secondsLeft); } @@ -567,20 +553,13 @@ public class DownloadService extends Service { if (input != null) { input.close(); } - // If download is canceled clean up else remove .part from file name if (downloadStatus.get(chunk.getNotificationID()) == CANCEL) { - String path = file.getPath(); - Log.i(KIWIX_TAG, "Download Cancelled, deleting file: " + path); - if (path.substring(path.length() - (ZIM_EXTENSION + PART).length()).equals(ZIM_EXTENSION + PART)) { - path = path.substring(0, path.length() - PART.length() + 1); - FileUtils.deleteZimFile(path); - } else { - path = path.substring(0, path.length() - (ZIM_EXTENSION + PART).length() + 2) + "aa"; - FileUtils.deleteZimFile(path); - } + File path = file; + Log.i(KIWIX_TAG, "Download Cancelled, deleting file: " + file.getPath()); + deleteAllParts(path); } else { - Log.i(KIWIX_TAG, "Download completed, renaming file ([" + file.getPath() + "] -> .zim.part)"); - file.renameTo(new File(file.getPath().replaceAll(".part$", ""))); + Log.i(KIWIX_TAG, "Chunk download completed, competing chunk rename"); + completeChunk(file); } // Mark chunk status as downloaded chunk.isDownloaded = true; diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java index 3538f761a..2db9a12b4 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileUtils.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static org.kiwix.kiwixmobile.downloader.ChunkUtils.deleteAllParts; import static org.kiwix.kiwixmobile.utils.Constants.TAG_KIWIX; public class FileUtils { @@ -61,44 +62,8 @@ public class FileUtils { } } - public static synchronized void deleteZimFile(String path) { - if (path.substring(path.length() - ChunkUtils.PART.length()).equals(ChunkUtils.PART)) { - path = path.substring(0, path.length() - ChunkUtils.PART.length()); - } - Log.i("kiwix", "Deleting file: " + path); - File file = new File(path); - if (!file.getPath().substring(file.getPath().length() - 3).equals("zim")) { - fileloop: - for (char alphabetFirst = 'a'; alphabetFirst <= 'z'; alphabetFirst++) { - for (char alphabetSecond = 'a'; alphabetSecond <= 'z'; alphabetSecond++) { - String chunkPath = path.substring(0, path.length() - 2) + alphabetFirst + alphabetSecond; - File fileChunk = new File(chunkPath); - if (fileChunk.exists()) { - fileChunk.delete(); - } else if (!deleteZimFileParts(chunkPath)) { - break fileloop; - } - } - } - } else { - file.delete(); - deleteZimFileParts(path); - } - } - - private static synchronized boolean deleteZimFileParts(String path) { - File file = new File(path + ChunkUtils.PART); - if (file.exists()) { - file.delete(); - return true; - } else { - File singlePart = new File(path + ".part"); - if (singlePart.exists()) { - singlePart.delete(); - return true; - } - } - return false; + public static synchronized void deleteZimFile(File file) { + deleteAllParts(file); } /** @@ -218,79 +183,11 @@ public class FileUtils { return readCsv(content); } - private static List getAllZimParts(Book book) { - List files = new ArrayList<>(); - if(book.file.getPath().endsWith(".zim") || book.file.getPath().endsWith(".zim.part")) { - if(book.file.exists()) { - files.add(book.file); - } else { - files.add(new File(book.file + ".part")); - } - return files; - } - String path = book.file.getPath(); - for(char alphabetFirst = 'a'; alphabetFirst <= 'z'; alphabetFirst++) { - for(char alphabetSecond = 'a'; alphabetSecond <= 'z'; alphabetSecond++) { - path = path.substring(0, path.length() - 2) + alphabetFirst + alphabetSecond; - if(new File(path).exists()) { - files.add(new File(path)); - } else if(new File(path + ".part").exists()) { - files.add(new File(path + ".part")); - } else { - return files; - } - } - } - return files; - } + private static ArrayList readCsv(String csv) { String[] csvArray = csv.split(","); return new ArrayList<>(Arrays.asList(csvArray)); } - - public static boolean hasPart(File file) { - file = new File(getFileName(file.getPath())); - if (file.getPath().endsWith(".zim")) { - return false; - } - if (file.getPath().endsWith(".part")) { - return true; - } - String path = file.getPath(); - - for (char alphabetFirst = 'a'; alphabetFirst <= 'z'; alphabetFirst++) { - for (char alphabetSecond = 'a'; alphabetSecond <= 'z'; alphabetSecond++) { - String chunkPath = path.substring(0, path.length() - 2) + alphabetFirst + alphabetSecond; - File fileChunk = new File(chunkPath + ".part"); - if (fileChunk.exists()) { - return true; - } else if (!new File(chunkPath).exists()) { - return false; - } - } - } - return false; - } - - public static String getFileName (String fileName) { - if (new File(fileName).exists()) { - return fileName; - } else if (new File(fileName + ".part").exists()) { - return fileName + ".part"; - } else { - return fileName + "aa"; - } - } - - public static long getCurrentSize(Book book) { - long size = 0; - List files = getAllZimParts(book); - for (File file : files) { - size += file.length(); - } - return size; - } - } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java index b025e6d9c..23f4dc597 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/ZimFileSelectFragment.java @@ -294,7 +294,7 @@ public class ZimFileSelectFragment extends BaseFragment public boolean deleteSpecificZimFile(int position) { File file = mFiles.get(position).file; - FileUtils.deleteZimFile(file.getPath()); + FileUtils.deleteZimFile(file); if (file.exists()) { return false; } From 23ec9ff92f749a06bfe32359c82b72741f97ba4a Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Tue, 17 Jul 2018 22:13:39 +0100 Subject: [PATCH 22/53] Disable custom error reporting for inital 2.4 so nothing slips through cracks --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 168da4fac..e4a568027 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -228,7 +228,7 @@ android { // Release Type release { buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://download.kiwix.org/\"" - buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "true" + buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false" } } From a4cc58c3bd3b9e5c7aee619fee2519f390387083 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Tue, 17 Jul 2018 22:30:46 +0100 Subject: [PATCH 23/53] Bump kiwixlib dependency version --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index e4a568027..6fc2b8a85 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,7 +33,7 @@ dependencies { // Get kiwixlib online if it is not populated locally if (file("../kiwixlib/src/main").list().length == 1) { - implementation 'org.kiwix.kiwixlib:kiwixlib:1.0.8' + implementation 'org.kiwix.kiwixlib:kiwixlib:1.0.9' } else { implementation project(':kiwixlib') archs = file("../kiwixlib/src/main/jniLibs").list() From 5e7c7560906a57157d98179989c8cabd65d39d52 Mon Sep 17 00:00:00 2001 From: siddharth2010 Date: Sun, 22 Jul 2018 08:20:04 +0530 Subject: [PATCH 24/53] add test_request template --- .github/ISSUE_TEMPLATE/test_request.md | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/test_request.md diff --git a/.github/ISSUE_TEMPLATE/test_request.md b/.github/ISSUE_TEMPLATE/test_request.md new file mode 100644 index 000000000..2bfa78222 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/test_request.md @@ -0,0 +1,31 @@ +--- +name: Request Tests +about: Identify code liable to break and create tests to prevent software regression due to code changes + +--- + + + +**Type of Test** + +[ ] Unit Test +[ ] UI Test + +**Particular area and files to be tested** + + +**Current Status of the tests** + + +**Particular Behaviour to be tested** + \ No newline at end of file From 2411b841417c97d4afd9118d944437ed1ffbad25 Mon Sep 17 00:00:00 2001 From: siddharth2010 Date: Sun, 22 Jul 2018 08:21:22 +0530 Subject: [PATCH 25/53] update feature_request.md and bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ab387b716..5bc91e633 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -5,7 +5,7 @@ about: Create a report to help us improve --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 7ab2f9dbb..e3fae4acf 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -5,7 +5,7 @@ about: Suggest an idea for this project --- **Is your feature request related to a problem? Please describe.** From 968dfd26901df2c8354ab52b16af3eff79dbea38 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Thu, 26 Jul 2018 00:57:33 +0100 Subject: [PATCH 26/53] Fix null pointer crash --- .../java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java index dfac9317e..106fc4d0e 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/downloader/ChunkUtils.java @@ -50,8 +50,9 @@ public class ChunkUtils { } public static boolean hasParts(File file) { - return file.getParentFile().listFiles((file1, s) -> - s.startsWith(baseNameFromParts(file)) && s.endsWith(TPART)).length > 0; + File[] files = file.getParentFile().listFiles((file1, s) -> + s.startsWith(baseNameFromParts(file)) && s.endsWith(TPART)); + return files != null && files.length > 0; } public static String getFileName(String fileName) { From 1779b64f25023f5c93e378da8ed3500bdcf7f9a4 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Fri, 3 Aug 2018 00:06:14 +0100 Subject: [PATCH 27/53] Bump kiwix-lib version --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 6fc2b8a85..f35ff9850 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,7 +33,7 @@ dependencies { // Get kiwixlib online if it is not populated locally if (file("../kiwixlib/src/main").list().length == 1) { - implementation 'org.kiwix.kiwixlib:kiwixlib:1.0.9' + implementation 'org.kiwix.kiwixlib:kiwixlib:1.0.11' } else { implementation project(':kiwixlib') archs = file("../kiwixlib/src/main/jniLibs").list() From 670a985d8de2731d6a4dd8da7cab6e99e9e9e218 Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Fri, 3 Aug 2018 00:10:14 +0100 Subject: [PATCH 28/53] Null pointer fix --- .../java/org/kiwix/kiwixmobile/TabDrawerAdapter.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java b/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java index 439558318..a32089e93 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/TabDrawerAdapter.java @@ -58,11 +58,13 @@ public class TabDrawerAdapter extends RecyclerView.Adapter listener.onCloseTab(v, position)); holder.itemView.setOnClickListener(v -> { listener.onSelectTab(v, position); From 77607b814234604380d24083eb3bccbade2b412c Mon Sep 17 00:00:00 2001 From: Isaac Hutt Date: Sun, 12 Aug 2018 19:00:08 +0100 Subject: [PATCH 29/53] Update Changelog for version 2.4 --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c45c86e1f..901aff1f3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -2.3 +2.4 FIX: External SD card problems FIX: Some UI translation FIX: Download manager process sporadic problems From c6dfed6a3e08338bde07a6fefc06a59da856302d Mon Sep 17 00:00:00 2001 From: Isaac Hutt Date: Thu, 16 Aug 2018 23:22:02 +0100 Subject: [PATCH 30/53] Increase testdroid timeout limit --- testdroid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdroid.py b/testdroid.py index 478e6fdcc..ac27c0375 100755 --- a/testdroid.py +++ b/testdroid.py @@ -16,7 +16,7 @@ runID = os.environ['TRAVIS_BUILD_NUMBER'] apiKey = os.environ['BITBAR_API_KEY'] testName = "Auto Test {}".format(runID) -for x in range(0, 50): +for x in range(0, 200): r = requests.get('https://cloud.testdroid.com/api/me/projects/{}/runs'.format(PROJECT_ID), auth=(apiKey, ''), headers={"Accept" : "application/json"}) result = list(filter(lambda run: run.get("displayName") == testName, r.json().get("data"))) if len(result) > 0 and result[0].get("state") == "FINISHED": From f3a7b9df21e5142cfba5fc3975ace01098740e34 Mon Sep 17 00:00:00 2001 From: siddharth2010 Date: Mon, 20 Aug 2018 19:54:36 +0530 Subject: [PATCH 31/53] fix checkbox in issue template for tests --- .github/ISSUE_TEMPLATE/test_request.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/test_request.md b/.github/ISSUE_TEMPLATE/test_request.md index 2bfa78222..6ddbaedc1 100644 --- a/.github/ISSUE_TEMPLATE/test_request.md +++ b/.github/ISSUE_TEMPLATE/test_request.md @@ -13,8 +13,8 @@ about: Identify code liable to break and create tests to prevent software regres **Type of Test** -[ ] Unit Test -[ ] UI Test +* [ ] Unit Test +* [ ] UI Test **Particular area and files to be tested** + +**Describe the bug** + + +**Expected behavior** + + +**Steps to reproduce the behavior:** +1. + + +**Screenshots** + + +**Environment** +- Version of Kiwix Android : +- Device : +- OS version : + +**Logs** + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..7ab2f9dbb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + + +**Is your feature request related to a problem? Please describe.** + + +**Describe the solution you'd like** + + +**Describe alternatives you've considered** + + +**Additional context** + From ce4b2392b959eaadef4989c3d6115d53fefbdc65 Mon Sep 17 00:00:00 2001 From: Abdul Wadood Date: Sat, 30 Jun 2018 23:41:47 +0530 Subject: [PATCH 46/53] Delete ISSUE_TEMPLATE.md (cherry picked from commit d808ade453fb411546ed1820b41e95a826437cdc) --- .github/ISSUE_TEMPLATE.md | 45 --------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 2d5b808bc..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,45 +0,0 @@ -# Fill out this template with your issue then delete these lines only leaving the titles and your responses. - -# For a Bug Report: - -## Bug Report - -### Are you ready to report? - - Your issue may already be reported! Please search on the [issue track](../) before creating one. - - Ensure you have tested with the last (dev) version of the software. (If not, and if possible, run your test again with the most recent version available.) - -### Environment - * version of the software you use : _____ - * device / operating system : _____ - -### The Bug: - - * What do you obtain? A copy of the error message or a screenshot is always useful. - - * When does this occur? - -#### Steps to reproduce: - - 1. _____ - 2. _____ - 3. _____ - ... - - * What should be the behaviour from your point of view? How do you expect the service to work? - - -### Other Comments: - * What is the context of this ticket? If not obvious, explain why you need to do this. - - * If you have an idea about the technical background of the ticket, please share it. - - -# For a Feature Request: - -## Feature Request - -#### Feature Description - -Please describe the feature you want to add to the project. - - From aa7427d60859cf88502dc79331313e74fcb03f82 Mon Sep 17 00:00:00 2001 From: gevic Date: Fri, 16 Mar 2018 11:45:13 +0530 Subject: [PATCH 47/53] Styles storage night mode (cherry picked from commit 3295bed1db8f35779bddd1f633d2d8139da24df3) --- app/src/main/res/values/styles.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f3038bc07..dbbe037f9 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -79,10 +79,11 @@ @@ -82,6 +83,7 @@ @style/NegativeButtonStyle @style/PositiveButtonStyle @style/NeutralButtonStyle + @color/white @color/cardview_dark_background @color/primary_light From 039d91a534a2d786eceb7bed59c30ee89e4b80b8 Mon Sep 17 00:00:00 2001 From: siddharth2010 Date: Sun, 22 Jul 2018 08:20:04 +0530 Subject: [PATCH 49/53] add test_request template (cherry picked from commit 5e7c7560906a57157d98179989c8cabd65d39d52) --- .github/ISSUE_TEMPLATE/test_request.md | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/test_request.md diff --git a/.github/ISSUE_TEMPLATE/test_request.md b/.github/ISSUE_TEMPLATE/test_request.md new file mode 100644 index 000000000..2bfa78222 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/test_request.md @@ -0,0 +1,31 @@ +--- +name: Request Tests +about: Identify code liable to break and create tests to prevent software regression due to code changes + +--- + + + +**Type of Test** + +[ ] Unit Test +[ ] UI Test + +**Particular area and files to be tested** + + +**Current Status of the tests** + + +**Particular Behaviour to be tested** + \ No newline at end of file From 346215383e29ca22fb3e1d53e6dbcfe23d1a5335 Mon Sep 17 00:00:00 2001 From: siddharth2010 Date: Sun, 22 Jul 2018 08:21:22 +0530 Subject: [PATCH 50/53] update feature_request.md and bug_report.md (cherry picked from commit 2411b841417c97d4afd9118d944437ed1ffbad25) --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ab387b716..5bc91e633 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -5,7 +5,7 @@ about: Create a report to help us improve --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 7ab2f9dbb..e3fae4acf 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -5,7 +5,7 @@ about: Suggest an idea for this project --- **Is your feature request related to a problem? Please describe.** From 49727a2dcb9762e2d8a98d32ab262e5be678e372 Mon Sep 17 00:00:00 2001 From: Isaac Hutt Date: Thu, 16 Aug 2018 23:22:02 +0100 Subject: [PATCH 51/53] Increase testdroid timeout limit --- testdroid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdroid.py b/testdroid.py index 478e6fdcc..ac27c0375 100755 --- a/testdroid.py +++ b/testdroid.py @@ -16,7 +16,7 @@ runID = os.environ['TRAVIS_BUILD_NUMBER'] apiKey = os.environ['BITBAR_API_KEY'] testName = "Auto Test {}".format(runID) -for x in range(0, 50): +for x in range(0, 200): r = requests.get('https://cloud.testdroid.com/api/me/projects/{}/runs'.format(PROJECT_ID), auth=(apiKey, ''), headers={"Accept" : "application/json"}) result = list(filter(lambda run: run.get("displayName") == testName, r.json().get("data"))) if len(result) > 0 and result[0].get("state") == "FINISHED": From d29de7eae0db87043cee7ee8fc23ee18012a8802 Mon Sep 17 00:00:00 2001 From: siddharth2010 Date: Mon, 20 Aug 2018 19:54:36 +0530 Subject: [PATCH 52/53] fix checkbox in issue template for tests --- .github/ISSUE_TEMPLATE/test_request.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/test_request.md b/.github/ISSUE_TEMPLATE/test_request.md index 2bfa78222..6ddbaedc1 100644 --- a/.github/ISSUE_TEMPLATE/test_request.md +++ b/.github/ISSUE_TEMPLATE/test_request.md @@ -13,8 +13,8 @@ about: Identify code liable to break and create tests to prevent software regres **Type of Test** -[ ] Unit Test -[ ] UI Test +* [ ] Unit Test +* [ ] UI Test **Particular area and files to be tested**