From 59befbd355866f9417d84f5a2181b3e5317971f3 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 10 Aug 2018 11:58:09 +0200 Subject: [PATCH 1/3] use Android constants for common URI schemes This makes the code easier to trace. --- .../fdroid/fdroid/installer/DefaultInstallerActivity.java | 5 +++-- .../main/java/org/fdroid/fdroid/net/DownloaderFactory.java | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/installer/DefaultInstallerActivity.java b/app/src/main/java/org/fdroid/fdroid/installer/DefaultInstallerActivity.java index ba20934df..322350c29 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/DefaultInstallerActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/DefaultInstallerActivity.java @@ -23,6 +23,7 @@ package org.fdroid.fdroid.installer; import android.annotation.SuppressLint; import android.app.Activity; import android.content.ActivityNotFoundException; +import android.content.ContentResolver; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; @@ -78,11 +79,11 @@ public class DefaultInstallerActivity extends FragmentActivity { } // https://code.google.com/p/android/issues/detail?id=205827 if ((Build.VERSION.SDK_INT < 24) - && (!uri.getScheme().equals("file"))) { + && (!ContentResolver.SCHEME_FILE.equals(uri.getScheme()))) { throw new RuntimeException("PackageInstaller < Android N only supports file scheme!"); } if ((Build.VERSION.SDK_INT >= 24) - && (!uri.getScheme().equals("content"))) { + && (!ContentResolver.SCHEME_CONTENT.equals(uri.getScheme()))) { throw new RuntimeException("PackageInstaller >= Android N only supports content scheme!"); } diff --git a/app/src/main/java/org/fdroid/fdroid/net/DownloaderFactory.java b/app/src/main/java/org/fdroid/fdroid/net/DownloaderFactory.java index 2a13e947a..1ef905b62 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/DownloaderFactory.java +++ b/app/src/main/java/org/fdroid/fdroid/net/DownloaderFactory.java @@ -1,5 +1,6 @@ package org.fdroid.fdroid.net; +import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import org.fdroid.fdroid.data.Repo; @@ -29,11 +30,11 @@ public class DownloaderFactory { Downloader downloader; String scheme = uri.getScheme(); - if ("bluetooth".equals(scheme)) { + if (BluetoothDownloader.SCHEME.equals(scheme)) { downloader = new BluetoothDownloader(uri, destFile); - } else if ("content".equals(scheme)) { + } else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) { downloader = new TreeUriDownloader(uri, destFile); - } else if ("file".equals(scheme)) { + } else if (ContentResolver.SCHEME_FILE.equals(scheme)) { downloader = new LocalFileDownloader(uri, destFile); } else { final String[] projection = {Schema.RepoTable.Cols.USERNAME, Schema.RepoTable.Cols.PASSWORD}; From ae0c712a3e1f68682752c58bf00d1cbfa29c7083 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 21 Dec 2018 14:11:39 +0100 Subject: [PATCH 2/3] remove animation from BottomBar to make more text fit into labels For many languages, there are unavoidable long words needed for the labels on the button bar, for example, the standard word for Settings can be up to 15 characters long: https://gitlab.com/fdroid/fdroidclient/issues/1569#note_126469088 The BottomBar was scaling the active one up, and sizing all the fields based on that size. This removes that animation, and sets all tabs to always have the same text size. That makes it possible to make the spacing tighter. This also sets the text truncating mode to "middle" which sticks an elipsis in the middle of the truncated word and shows the start and end. closes #1569 closes !756 --- .../fdroid/views/main/MainActivity.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java b/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java index 50b47cdfb..444765855 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/main/MainActivity.java @@ -37,7 +37,11 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; +import android.util.TypedValue; +import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; import android.widget.Toast; import com.ashokvarma.bottomnavigation.BottomNavigationBar; import com.ashokvarma.bottomnavigation.BottomNavigationItem; @@ -57,6 +61,8 @@ import org.fdroid.fdroid.views.ManageReposActivity; import org.fdroid.fdroid.views.apps.AppListActivity; import org.fdroid.fdroid.views.swap.SwapWorkflowActivity; +import java.lang.reflect.Field; + /** * Main view shown to users upon starting F-Droid. *

@@ -133,8 +139,35 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB .setMode(BottomNavigationBar.MODE_FIXED) .addItem(new BottomNavigationItem(R.drawable.ic_updates, R.string.updates).setBadgeItem(updatesBadge)) .addItem(new BottomNavigationItem(R.drawable.ic_settings, R.string.menu_settings)) + .setAnimationDuration(0) .initialise(); + // turn off animation, scaling, and truncate labels in the middle + final LinearLayout linearLayout = bottomNavigation.findViewById(R.id.bottom_navigation_bar_item_container); + final int childCount = linearLayout.getChildCount(); + for (int i = 0; i < childCount; i++) { + final View fixedBottomNavigationTab = linearLayout.getChildAt(i); + try { + Field labelScale = fixedBottomNavigationTab.getClass().getDeclaredField("labelScale"); + labelScale.setAccessible(true); + labelScale.set(fixedBottomNavigationTab, 1.0f); + } catch (IllegalAccessException | NoSuchFieldException | IllegalArgumentException e) { + e.printStackTrace(); + } + + final View container = fixedBottomNavigationTab.findViewById(R.id.fixed_bottom_navigation_container); + container.setPadding( + 2, + container.getPaddingTop(), + 2, + container.getPaddingBottom() + ); + + final TextView title = fixedBottomNavigationTab.findViewById(R.id.fixed_bottom_navigation_title); + title.setEllipsize(TextUtils.TruncateAt.MIDDLE); + title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); + } + IntentFilter updateableAppsFilter = new IntentFilter(AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED); updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED); updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED); From e0f346d4b4b012009e1d04b8a9105a69de4dd24b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 21 Dec 2018 15:26:02 +0100 Subject: [PATCH 3/3] fix repo tests after change in mirror list logic Why didn't these tests fail earlier? this should have been included in ac1a5e0ad8bed1c658885c8f6142367a3812815d fdroid/fdroidclient!769 --- .../java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java b/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java index 83e1880d4..3ea37db40 100644 --- a/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java +++ b/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java @@ -120,9 +120,10 @@ public class IndexV1UpdaterTest extends FDroidProviderTest { assertEquals("repo.icon should be set", "fdroid-icon.png", repoFromDb.icon); String description = "This is a repository of apps to be used with F-Droid. Applications in this repository are either official binaries built by the original application developers, or are binaries built from source by the admin of f-droid.org using the tools on https://gitlab.com/u/fdroid. "; // NOCHECKSTYLE LineLength assertEquals("repo.description should be set", description, repoFromDb.description); - assertEquals("repo.mirrors should have items", 2, repo.mirrors.length); + assertEquals("repo.mirrors should have items", 3, repo.mirrors.length); assertEquals("repo.mirrors first URL", "http://frkcchxlcvnb4m5a.onion/fdroid/repo", repo.mirrors[0]); assertEquals("repo.mirrors second URL", "http://testy.at.or.at/fdroid/repo", repo.mirrors[1]); + assertEquals("repo.mirrors third URL", "testy.at.or.at_index-v1.jar", repo.mirrors[2]); // Make sure the per-apk anti features which are new in index v1 get added correctly. assertEquals(0, AppProvider.Helper.findInstalledAppsWithKnownVulns(context).size());