Merge branch 'bottom-bar-overhaul' into 'master'

remove text animation from BottomBar so more text fits in the labels

Closes #1569

See merge request fdroid/fdroidclient!772
This commit is contained in:
Hans-Christoph Steiner 2018-12-21 21:57:06 +00:00
commit 30c4a26145
4 changed files with 42 additions and 6 deletions

View File

@ -23,6 +23,7 @@ package org.fdroid.fdroid.installer;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
@ -78,11 +79,11 @@ public class DefaultInstallerActivity extends FragmentActivity {
} }
// https://code.google.com/p/android/issues/detail?id=205827 // https://code.google.com/p/android/issues/detail?id=205827
if ((Build.VERSION.SDK_INT < 24) 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!"); throw new RuntimeException("PackageInstaller < Android N only supports file scheme!");
} }
if ((Build.VERSION.SDK_INT >= 24) 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!"); throw new RuntimeException("PackageInstaller >= Android N only supports content scheme!");
} }

View File

@ -1,5 +1,6 @@
package org.fdroid.fdroid.net; package org.fdroid.fdroid.net;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import org.fdroid.fdroid.data.Repo; import org.fdroid.fdroid.data.Repo;
@ -29,11 +30,11 @@ public class DownloaderFactory {
Downloader downloader; Downloader downloader;
String scheme = uri.getScheme(); String scheme = uri.getScheme();
if ("bluetooth".equals(scheme)) { if (BluetoothDownloader.SCHEME.equals(scheme)) {
downloader = new BluetoothDownloader(uri, destFile); downloader = new BluetoothDownloader(uri, destFile);
} else if ("content".equals(scheme)) { } else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) {
downloader = new TreeUriDownloader(uri, destFile); downloader = new TreeUriDownloader(uri, destFile);
} else if ("file".equals(scheme)) { } else if (ContentResolver.SCHEME_FILE.equals(scheme)) {
downloader = new LocalFileDownloader(uri, destFile); downloader = new LocalFileDownloader(uri, destFile);
} else { } else {
final String[] projection = {Schema.RepoTable.Cols.USERNAME, Schema.RepoTable.Cols.PASSWORD}; final String[] projection = {Schema.RepoTable.Cols.USERNAME, Schema.RepoTable.Cols.PASSWORD};

View File

@ -37,7 +37,11 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.ashokvarma.bottomnavigation.BottomNavigationBar; import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem; 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.apps.AppListActivity;
import org.fdroid.fdroid.views.swap.SwapWorkflowActivity; import org.fdroid.fdroid.views.swap.SwapWorkflowActivity;
import java.lang.reflect.Field;
/** /**
* Main view shown to users upon starting F-Droid. * Main view shown to users upon starting F-Droid.
* <p> * <p>
@ -133,8 +139,35 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
.setMode(BottomNavigationBar.MODE_FIXED) .setMode(BottomNavigationBar.MODE_FIXED)
.addItem(new BottomNavigationItem(R.drawable.ic_updates, R.string.updates).setBadgeItem(updatesBadge)) .addItem(new BottomNavigationItem(R.drawable.ic_updates, R.string.updates).setBadgeItem(updatesBadge))
.addItem(new BottomNavigationItem(R.drawable.ic_settings, R.string.menu_settings)) .addItem(new BottomNavigationItem(R.drawable.ic_settings, R.string.menu_settings))
.setAnimationDuration(0)
.initialise(); .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); IntentFilter updateableAppsFilter = new IntentFilter(AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED);
updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED); updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED); updateableAppsFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);

View File

@ -120,9 +120,10 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
assertEquals("repo.icon should be set", "fdroid-icon.png", repoFromDb.icon); 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 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.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 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 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. // Make sure the per-apk anti features which are new in index v1 get added correctly.
assertEquals(0, AppProvider.Helper.findInstalledAppsWithKnownVulns(context).size()); assertEquals(0, AppProvider.Helper.findInstalledAppsWithKnownVulns(context).size());