diff --git a/app/build.gradle b/app/build.gradle index e36929b8d..71d48a067 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,51 +12,6 @@ def getVersionName = { -> return stdout.toString().trim() } -dependencies { - implementation 'com.android.support:support-v4:27.1.1' - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support:gridlayout-v7:27.1.1' - implementation 'com.android.support:support-annotations:27.1.1' - implementation 'com.android.support:recyclerview-v7:27.1.1' - implementation 'com.android.support:cardview-v7:27.1.1' - implementation 'com.android.support:design:27.1.1' - implementation 'com.android.support:support-vector-drawable:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.0' - implementation 'com.android.support:palette-v7:27.1.1' - implementation 'com.android.support:preference-v14:27.1.1' - - implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' - implementation 'com.google.zxing:core:3.3.2' - implementation 'eu.chainfire:libsuperuser:1.0.0.201602271131' - implementation 'cc.mvdan.accesspoint:library:0.2.0' - implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1' - implementation 'info.guardianproject.panic:panic:0.5' - implementation 'commons-io:commons-io:2.5' - implementation 'commons-net:commons-net:3.5' - implementation 'org.jmdns:jmdns:3.5.3' - implementation 'org.nanohttpd:nanohttpd:2.3.1' - implementation 'ch.acra:acra:4.9.1' - implementation 'io.reactivex:rxjava:1.1.0' - implementation 'io.reactivex:rxandroid:0.23.0' - implementation 'com.hannesdorfmann:adapterdelegates3:3.0.1' - implementation 'com.ashokvarma.android:bottom-navigation-bar:2.0.4' - - implementation 'com.fasterxml.jackson.core:jackson-core:2.8.7' - implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.7' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.7' - - implementation 'org.bouncycastle:bcpkix-jdk15on:1.59' - implementation 'org.bouncycastle:bcprov-jdk15on:1.59' - - testImplementation 'org.robolectric:robolectric:3.8' - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.7.22' - - androidTestImplementation 'com.android.support:support-annotations:25.3.1' - androidTestImplementation 'com.android.support.test:runner:0.5' - androidTestImplementation 'com.android.support.test:rules:0.5' -} - def isCi = "true".equals(System.getenv("CI")) def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true")) @@ -179,6 +134,51 @@ android { } } +dependencies { + implementation 'com.android.support:support-v4:27.1.1' + implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:gridlayout-v7:27.1.1' + implementation 'com.android.support:support-annotations:27.1.1' + implementation 'com.android.support:recyclerview-v7:27.1.1' + implementation 'com.android.support:cardview-v7:27.1.1' + implementation 'com.android.support:design:27.1.1' + implementation 'com.android.support:support-vector-drawable:27.1.1' + implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation 'com.android.support:palette-v7:27.1.1' + implementation 'com.android.support:preference-v14:27.1.1' + + implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' + implementation 'com.google.zxing:core:3.3.2' + implementation 'eu.chainfire:libsuperuser:1.0.0.201602271131' + implementation 'cc.mvdan.accesspoint:library:0.2.0' + implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1' + implementation 'info.guardianproject.panic:panic:0.5' + implementation 'commons-io:commons-io:2.5' + implementation 'commons-net:commons-net:3.5' + implementation 'org.jmdns:jmdns:3.5.3' + implementation 'org.nanohttpd:nanohttpd:2.3.1' + implementation 'ch.acra:acra:4.9.1' + implementation 'io.reactivex:rxjava:1.1.0' + implementation 'io.reactivex:rxandroid:0.23.0' + implementation 'com.hannesdorfmann:adapterdelegates3:3.0.1' + implementation 'com.ashokvarma.android:bottom-navigation-bar:2.0.4' + + implementation 'com.fasterxml.jackson.core:jackson-core:2.8.7' + implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.7' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.7' + + implementation 'org.bouncycastle:bcpkix-jdk15on:1.59' + implementation 'org.bouncycastle:bcprov-jdk15on:1.59' + + testImplementation 'org.robolectric:robolectric:3.8' + testImplementation 'junit:junit:4.12' + testImplementation 'org.mockito:mockito-core:2.7.22' + + androidTestImplementation 'com.android.support:support-annotations:25.3.1' + androidTestImplementation 'com.android.support.test:runner:0.5' + androidTestImplementation 'com.android.support.test:rules:0.5' +} + checkstyle { toolVersion = '7.2' } diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java index 0f5c938f4..612313bab 100644 --- a/app/src/main/java/org/fdroid/fdroid/Utils.java +++ b/app/src/main/java/org/fdroid/fdroid/Utils.java @@ -59,7 +59,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.math.BigInteger; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -528,12 +527,20 @@ public final class Utils { * * @param bytes an array of bytes. * @return the bytes represented as a string of hexadecimal digits. + * @see source */ - private static String toHexString(byte[] bytes) { - BigInteger bi = new BigInteger(1, bytes); - return String.format("%0" + (bytes.length << 1) + "X", bi); + public static String toHexString(byte[] bytes) { + char[] hexChars = new char[bytes.length * 2]; + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = HEX_LOOKUP_ARRAY[v >>> 4]; + hexChars[j * 2 + 1] = HEX_LOOKUP_ARRAY[v & 0x0F]; + } + return new String(hexChars); } + private static final char[] HEX_LOOKUP_ARRAY = "0123456789ABCDEF".toCharArray(); + public static int parseInt(String str, int fallback) { if (str == null || str.length() == 0) { return fallback; diff --git a/app/src/main/java/org/fdroid/fdroid/installer/ApkSignatureVerifier.java b/app/src/main/java/org/fdroid/fdroid/installer/ApkSignatureVerifier.java index c200efba9..dc0c27485 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/ApkSignatureVerifier.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/ApkSignatureVerifier.java @@ -26,7 +26,6 @@ import android.content.pm.PackageManager; import android.content.pm.Signature; import org.acra.ACRA; import org.fdroid.fdroid.Utils; -import org.bouncycastle.util.encoders.Hex; import java.io.ByteArrayOutputStream; import java.io.File; @@ -69,8 +68,8 @@ class ApkSignatureVerifier { } Utils.debugLog(TAG, "Signature mismatch!"); - Utils.debugLog(TAG, "APK sig: " + Hex.toHexString(getApkSignature(apkFile))); - Utils.debugLog(TAG, "F-Droid sig: " + Hex.toHexString(getFDroidSignature())); + Utils.debugLog(TAG, "APK sig: " + Utils.toHexString(getApkSignature(apkFile))); + Utils.debugLog(TAG, "F-Droid sig: " + Utils.toHexString(getFDroidSignature())); return false; } diff --git a/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java b/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java index b8d9e66e6..218dd71a7 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java +++ b/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java @@ -4,12 +4,12 @@ import android.annotation.TargetApi; import android.net.Uri; import android.os.Build; import android.text.TextUtils; +import android.util.Base64; import info.guardianproject.netcipher.NetCipher; import org.apache.commons.io.FileUtils; import org.fdroid.fdroid.BuildConfig; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Utils; -import org.bouncycastle.util.encoders.Base64; import java.io.BufferedInputStream; import java.io.File; @@ -151,7 +151,8 @@ public class HttpDownloader extends Downloader { if (username != null && password != null) { // add authorization header from username / password if set String authString = username + ":" + password; - connection.setRequestProperty("Authorization", "Basic " + Base64.toBase64String(authString.getBytes())); + connection.setRequestProperty("Authorization", "Basic " + + Base64.encodeToString(authString.getBytes(), Base64.NO_WRAP)); } return connection; } diff --git a/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java b/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java index b8d5df5c8..ab2dc6936 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java +++ b/app/src/main/java/org/fdroid/fdroid/views/fragments/PreferencesFragment.java @@ -1,3 +1,28 @@ +/* + * Copyright (C) 2014-2018 Hans-Christoph Steiner + * Copyright (C) 2014-2017 Peter Serwylo + * Copyright (C) 2015-2016 Daniel Martí + * Copyright (C) 2015 Dominik Schürmann + * Copyright (C) 2018 Torsten Grote + * Copyright (C) 2018 dkanada + * Copyright (C) 2018 Senecto Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + package org.fdroid.fdroid.views.fragments; import android.app.Activity; @@ -24,6 +49,7 @@ import org.fdroid.fdroid.Languages; import org.fdroid.fdroid.Preferences; import org.fdroid.fdroid.R; import org.fdroid.fdroid.UpdateService; +import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.RepoProvider; import org.fdroid.fdroid.installer.InstallHistoryService; import org.fdroid.fdroid.installer.PrivilegedInstaller; @@ -120,7 +146,11 @@ public class PreferencesFragment extends PreferenceFragment private void textSummary(String key, int resId) { EditTextPreference pref = (EditTextPreference) findPreference(key); - pref.setSummary(getString(resId, pref.getText())); + if (pref == null) { + Utils.debugLog(TAG, "null preference found for " + key); + } else { + pref.setSummary(getString(resId, pref.getText())); + } } private void setNetworkSeekBarSummary(SeekBarPreference seekBarPreference) { 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 bcf7813f0..185a1e364 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 @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2016-2017 Peter Serwylo + * Copyright (C) 2017 Christine Emrich + * Copyright (C) 2017 Hans-Christoph Steiner + * Copyright (C) 2018 Senecto Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + package org.fdroid.fdroid.views.main; import android.app.SearchManager; @@ -65,7 +87,7 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB private RecyclerView pager; private MainViewAdapter adapter; private BottomNavigationBar bottomNavigation; - private int selectedMenuId = R.id.whats_new; + private int selectedMenuId; private TextBadgeItem updatesBadge; @Override @@ -110,7 +132,9 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB LocalBroadcastManager.getInstance(this).registerReceiver(onUpdateableAppsChanged, updateableAppsFilter); if (savedInstanceState != null) { - selectedMenuId = savedInstanceState.getInt(STATE_SELECTED_MENU_ID, R.id.whats_new); + selectedMenuId = savedInstanceState.getInt(STATE_SELECTED_MENU_ID, (int) adapter.getItemId(0)); + } else { + selectedMenuId = (int) adapter.getItemId(0); } setSelectedMenuInNav(); diff --git a/app/src/main/res/values-v16/styles.xml b/app/src/main/res/values-v16/styles.xml index 8d3cbd992..8ed5bae82 100644 --- a/app/src/main/res/values-v16/styles.xml +++ b/app/src/main/res/values-v16/styles.xml @@ -4,7 +4,7 @@ - - - - - - - @@ -122,7 +122,7 @@ @style/TextAppearance.AppCompat.Caption ?android:attr/textColorSecondary - - - - - - - - - - qgi + -